@coinflowlabs/vue 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/coinflow-vue.js +16805 -0
- package/dist/coinflow-vue.umd.cjs +23 -0
- package/dist/components/CoinflowPurchase.vue.d.ts +164 -0
- package/dist/components/CoinflowWithdraw.vue.d.ts +148 -0
- package/dist/components/card-form/CoinflowCardNumberInput.vue.d.ts +47 -0
- package/dist/components/card-form/CoinflowCvvInput.vue.d.ts +4 -0
- package/dist/components/card-form/useCardformIframe.d.ts +30 -0
- package/dist/index.d.ts +7 -0
- package/dist/lib/common/CoinflowLibMessageHandlers.d.ts +31 -0
- package/dist/lib/common/CoinflowTypes.d.ts +309 -0
- package/dist/lib/common/CoinflowUtils.d.ts +21 -0
- package/dist/lib/common/SolanaPeerDeps.d.ts +5 -0
- package/dist/lib/common/card-form/TokenEx.d.ts +106 -0
- package/dist/lib/common/card-form/cardFormTypes.d.ts +44 -0
- package/dist/lib/common/card-form/tokenexHelpers.d.ts +43 -0
- package/dist/lib/common/index.d.ts +6 -0
- package/package.json +60 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(function(Lt,Et){typeof exports=="object"&&typeof module<"u"?Et(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],Et):(Lt=typeof globalThis<"u"?globalThis:Lt||self,Et(Lt.VueTypeWriter={},Lt.Vue))})(this,function(Lt,Et){"use strict";var Jd=Object.defineProperty;var Xd=(Lt,Et,wr)=>Et in Lt?Jd(Lt,Et,{enumerable:!0,configurable:!0,writable:!0,value:wr}):Lt[Et]=wr;var we=(Lt,Et,wr)=>(Xd(Lt,typeof Et!="symbol"?Et+"":Et,wr),wr);var wr=(o=>(o.Credits="Credits",o.USDC="USDC",o.Bank="Bank",o))(wr||{}),rs=(o=>(o.Rounded="rounded",o.Sharp="sharp",o.Pill="pill",o))(rs||{}),qr=(o=>(o.VISA="VISA",o.MASTERCARD="MSTR",o.AMEX="AMEX",o.DISCOVER="DISC",o))(qr||{}),Ve=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ln(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function li(o){if(o.__esModule)return o;var t=o.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(o).forEach(function(n){var s=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:function(){return o[n]}})}),e}var lt={},Hr={};Hr.byteLength=Nc,Hr.toByteArray=Dc,Hr.fromByteArray=Kc;for(var Je=[],We=[],Fc=typeof Uint8Array<"u"?Uint8Array:Array,di="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vr=0,Oc=di.length;Vr<Oc;++Vr)Je[Vr]=di[Vr],We[di.charCodeAt(Vr)]=Vr;We["-".charCodeAt(0)]=62,We["_".charCodeAt(0)]=63;function ns(o){var t=o.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Nc(o){var t=ns(o),e=t[0],n=t[1];return(e+n)*3/4-n}function zc(o,t,e){return(t+e)*3/4-e}function Dc(o){var t,e=ns(o),n=e[0],s=e[1],a=new Fc(zc(o,n,s)),f=0,u=s>0?n-4:n,p;for(p=0;p<u;p+=4)t=We[o.charCodeAt(p)]<<18|We[o.charCodeAt(p+1)]<<12|We[o.charCodeAt(p+2)]<<6|We[o.charCodeAt(p+3)],a[f++]=t>>16&255,a[f++]=t>>8&255,a[f++]=t&255;return s===2&&(t=We[o.charCodeAt(p)]<<2|We[o.charCodeAt(p+1)]>>4,a[f++]=t&255),s===1&&(t=We[o.charCodeAt(p)]<<10|We[o.charCodeAt(p+1)]<<4|We[o.charCodeAt(p+2)]>>2,a[f++]=t>>8&255,a[f++]=t&255),a}function $c(o){return Je[o>>18&63]+Je[o>>12&63]+Je[o>>6&63]+Je[o&63]}function Wc(o,t,e){for(var n,s=[],a=t;a<e;a+=3)n=(o[a]<<16&16711680)+(o[a+1]<<8&65280)+(o[a+2]&255),s.push($c(n));return s.join("")}function Kc(o){for(var t,e=o.length,n=e%3,s=[],a=16383,f=0,u=e-n;f<u;f+=a)s.push(Wc(o,f,f+a>u?u:f+a));return n===1?(t=o[e-1],s.push(Je[t>>2]+Je[t<<4&63]+"==")):n===2&&(t=(o[e-2]<<8)+o[e-1],s.push(Je[t>>10]+Je[t>>4&63]+Je[t<<2&63]+"=")),s.join("")}var dn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */dn.read=function(o,t,e,n,s){var a,f,u=s*8-n-1,p=(1<<u)-1,b=p>>1,E=-7,I=e?s-1:0,M=e?-1:1,T=o[t+I];for(I+=M,a=T&(1<<-E)-1,T>>=-E,E+=u;E>0;a=a*256+o[t+I],I+=M,E-=8);for(f=a&(1<<-E)-1,a>>=-E,E+=n;E>0;f=f*256+o[t+I],I+=M,E-=8);if(a===0)a=1-b;else{if(a===p)return f?NaN:(T?-1:1)*(1/0);f=f+Math.pow(2,n),a=a-b}return(T?-1:1)*f*Math.pow(2,a-n)},dn.write=function(o,t,e,n,s,a){var f,u,p,b=a*8-s-1,E=(1<<b)-1,I=E>>1,M=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=n?0:a-1,U=n?1:-1,_=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,f=E):(f=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-f))<1&&(f--,p*=2),f+I>=1?t+=M/p:t+=M*Math.pow(2,1-I),t*p>=2&&(f++,p/=2),f+I>=E?(u=0,f=E):f+I>=1?(u=(t*p-1)*Math.pow(2,s),f=f+I):(u=t*Math.pow(2,I-1)*Math.pow(2,s),f=0));s>=8;o[e+T]=u&255,T+=U,u/=256,s-=8);for(f=f<<s|u,b+=s;b>0;o[e+T]=f&255,T+=U,f/=256,b-=8);o[e+T-U]|=_*128};/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/(function(o){const t=Hr,e=dn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=$,o.INSPECT_MAX_BYTES=50;const s=2147483647;o.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=a(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>s)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(c)}return p(c,r,i)}u.poolSize=8192;function p(c,r,i){if(typeof c=="string")return M(c,r);if(ArrayBuffer.isView(c))return U(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(It(c,ArrayBuffer)||c&&It(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(It(c,SharedArrayBuffer)||c&&It(c.buffer,SharedArrayBuffer)))return _(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=L(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return p(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function b(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function E(c,r,i){return b(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return E(c,r,i)};function I(c){return b(c),f(c<0?0:C(c)|0)}u.allocUnsafe=function(c){return I(c)},u.allocUnsafeSlow=function(c){return I(c)};function M(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=N(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function T(c){const r=c.length<0?0:C(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function U(c){if(It(c,Uint8Array)){const r=new Uint8Array(c);return _(r.buffer,r.byteOffset,r.byteLength)}return T(c)}function _(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function L(c){if(u.isBuffer(c)){const r=C(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||Rt(c.length)?f(0):T(c);if(c.type==="Buffer"&&Array.isArray(c.data))return T(c.data)}function C(c){if(c>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return c|0}function $(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(It(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),It(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let m=0,x=Math.min(h,g);m<x;++m)if(r[m]!==i[m]){h=r[m],g=i[m];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let m=0;for(h=0;h<r.length;++h){let x=r[h];if(It(x,Uint8Array))m+x.length>g.length?(u.isBuffer(x)||(x=u.from(x)),x.copy(g,m)):Uint8Array.prototype.set.call(g,x,m);else if(u.isBuffer(x))x.copy(g,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=x.length}return g};function N(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||It(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return _t(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return Nt(c).length;default:if(g)return h?-1:_t(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=N;function H(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return B(this,r,i);case"utf8":case"utf-8":return l(this,r,i);case"ascii":return A(this,r,i);case"latin1":case"binary":return S(this,r,i);case"base64":return R(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function D(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)D(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)D(this,i,i+3),D(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)D(this,i,i+7),D(this,i+1,i+6),D(this,i+2,i+5),D(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?l(this,0,r):H.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,m){if(It(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),m===void 0&&(m=this.length),i<0||h>r.length||g<0||m>this.length)throw new RangeError("out of range index");if(g>=m&&i>=h)return 0;if(g>=m)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,m>>>=0,this===r)return 0;let x=m-g,K=h-i;const Z=Math.min(x,K),G=this.slice(g,m),it=r.slice(i,h);for(let V=0;V<Z;++V)if(G[V]!==it[V]){x=G[V],K=it[V];break}return x<K?-1:K<x?1:0};function F(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,Rt(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:W(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):W(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function W(c,r,i,h,g){let m=1,x=c.length,K=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;m=2,x/=2,K/=2,i/=2}function Z(it,V){return m===1?it[V]:it.readUInt16BE(V*m)}let G;if(g){let it=-1;for(G=i;G<x;G++)if(Z(c,G)===Z(r,it===-1?0:G-it)){if(it===-1&&(it=G),G-it+1===K)return it*m}else it!==-1&&(G-=G-it),it=-1}else for(i+K>x&&(i=x-K),G=i;G>=0;G--){let it=!0;for(let V=0;V<K;V++)if(Z(c,G+V)!==Z(r,V)){it=!1;break}if(it)return G}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return F(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return F(this,r,i,h,!1)};function q(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const m=r.length;h>m/2&&(h=m/2);let x;for(x=0;x<h;++x){const K=parseInt(r.substr(x*2,2),16);if(Rt(K))return x;c[i+x]=K}return x}function Bt(c,r,i,h){return vt(_t(r,c.length-i),c,i,h)}function gt(c,r,i,h){return vt(qt(r),c,i,h)}function ot(c,r,i,h){return vt(Nt(r),c,i,h)}function At(c,r,i,h){return vt(ur(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const m=this.length-i;if((h===void 0||h>m)&&(h=m),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let x=!1;for(;;)switch(g){case"hex":return q(this,r,i,h);case"utf8":case"utf-8":return Bt(this,r,i,h);case"ascii":case"latin1":case"binary":return gt(this,r,i,h);case"base64":return ot(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return At(this,r,i,h);default:if(x)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),x=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function R(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function l(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const m=c[g];let x=null,K=m>239?4:m>223?3:m>191?2:1;if(g+K<=i){let Z,G,it,V;switch(K){case 1:m<128&&(x=m);break;case 2:Z=c[g+1],(Z&192)===128&&(V=(m&31)<<6|Z&63,V>127&&(x=V));break;case 3:Z=c[g+1],G=c[g+2],(Z&192)===128&&(G&192)===128&&(V=(m&15)<<12|(Z&63)<<6|G&63,V>2047&&(V<55296||V>57343)&&(x=V));break;case 4:Z=c[g+1],G=c[g+2],it=c[g+3],(Z&192)===128&&(G&192)===128&&(it&192)===128&&(V=(m&15)<<18|(Z&63)<<12|(G&63)<<6|it&63,V>65535&&V<1114112&&(x=V))}}x===null?(x=65533,K=1):x>65535&&(x-=65536,h.push(x>>>10&1023|55296),x=56320|x&1023),h.push(x),g+=K}return k(h)}const y=4096;function k(c){const r=c.length;if(r<=y)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=y));return i}function A(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function S(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function B(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let m=r;m<i;++m)g+=Dt[c[m]];return g}function P(c,r,i){const h=c.slice(r,i);let g="";for(let m=0;m<h.length-1;m+=2)g+=String.fromCharCode(h[m]+h[m+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function w(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r],m=1,x=0;for(;++x<i&&(m*=256);)g+=this[r+x]*m;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r+--i],m=1;for(;i>0&&(m*=256);)g+=this[r+--i]*m;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||w(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||w(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||w(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||w(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,m=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(m)<<BigInt(32))}),u.prototype.readBigUInt64BE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],m=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(m)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r],m=1,x=0;for(;++x<i&&(m*=256);)g+=this[r+x]*m;return m*=128,g>=m&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=i,m=1,x=this[r+--g];for(;g>0&&(m*=256);)x+=this[r+--g]*m;return m*=128,x>=m&&(x-=Math.pow(2,8*i)),x},u.prototype.readInt8=function(r,i){return r=r>>>0,i||w(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||w(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||w(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||w(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||w(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||w(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||w(r,8,this.length),e.read(this,r,!1,52,8)};function d(c,r,i,h,g,m){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<m)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const K=Math.pow(2,8*h)-1;d(this,r,i,h,K,0)}let m=1,x=0;for(this[i]=r&255;++x<h&&(m*=256);)this[i+x]=r/m&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const K=Math.pow(2,8*h)-1;d(this,r,i,h,K,0)}let m=h-1,x=1;for(this[i+m]=r&255;--m>=0&&(x*=256);)this[i+m]=r/x&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function v(c,r,i,h,g){yt(r,h,g,c,i,7);let m=Number(r&BigInt(4294967295));c[i++]=m,m=m>>8,c[i++]=m,m=m>>8,c[i++]=m,m=m>>8,c[i++]=m;let x=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=x,x=x>>8,c[i++]=x,x=x>>8,c[i++]=x,x=x>>8,c[i++]=x,i}function Y(c,r,i,h,g){yt(r,h,g,c,i,7);let m=Number(r&BigInt(4294967295));c[i+7]=m,m=m>>8,c[i+6]=m,m=m>>8,c[i+5]=m,m=m>>8,c[i+4]=m;let x=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=x,x=x>>8,c[i+2]=x,x=x>>8,c[i+1]=x,x=x>>8,c[i]=x,i+8}u.prototype.writeBigUInt64LE=Ft(function(r,i=0){return v(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Ft(function(r,i=0){return Y(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const Z=Math.pow(2,8*h-1);d(this,r,i,h,Z-1,-Z)}let m=0,x=1,K=0;for(this[i]=r&255;++m<h&&(x*=256);)r<0&&K===0&&this[i+m-1]!==0&&(K=1),this[i+m]=(r/x>>0)-K&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const Z=Math.pow(2,8*h-1);d(this,r,i,h,Z-1,-Z)}let m=h-1,x=1,K=0;for(this[i+m]=r&255;--m>=0&&(x*=256);)r<0&&K===0&&this[i+m+1]!==0&&(K=1),this[i+m]=(r/x>>0)-K&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=Ft(function(r,i=0){return v(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Ft(function(r,i=0){return Y(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function J(c,r,i,h,g,m){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function X(c,r,i,h,g){return r=+r,i=i>>>0,g||J(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return X(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return X(this,r,i,!1,h)};function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||J(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return ft(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const m=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),m},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const x=r.charCodeAt(0);(g==="utf8"&&x<128||g==="latin1")&&(r=x)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let m;if(typeof r=="number")for(m=i;m<h;++m)this[m]=r;else{const x=u.isBuffer(r)?r:u.from(r,g),K=x.length;if(K===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(m=0;m<h-i;++m)this[m+i]=x[m%K]}return this};const st={};function ht(c,r,i){st[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ht("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),ht("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Wt(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Wt(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Wt(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function wt(c,r,i){mt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&dt(r,c.length-(i+1))}function yt(c,r,i,h,g,m){if(c>i||c<r){const x=typeof r=="bigint"?"n":"";let K;throw m>3?r===0||r===BigInt(0)?K=`>= 0${x} and < 2${x} ** ${(m+1)*8}${x}`:K=`>= -(2${x} ** ${(m+1)*8-1}${x}) and < 2 ** ${(m+1)*8-1}${x}`:K=`>= ${r}${x} and <= ${i}${x}`,new st.ERR_OUT_OF_RANGE("value",K,c)}wt(h,g,m)}function mt(c,r){if(typeof c!="number")throw new st.ERR_INVALID_ARG_TYPE(r,"number",c)}function dt(c,r,i){throw Math.floor(c)!==c?(mt(c,i),new st.ERR_OUT_OF_RANGE(i||"offset","an integer",c)):r<0?new st.ERR_BUFFER_OUT_OF_BOUNDS:new st.ERR_OUT_OF_RANGE(i||"offset",`>= ${i?1:0} and <= ${r}`,c)}const Mt=/[^+/0-9A-Za-z-_]/g;function Oe(c){if(c=c.split("=")[0],c=c.trim().replace(Mt,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function _t(c,r){r=r||1/0;let i;const h=c.length;let g=null;const m=[];for(let x=0;x<h;++x){if(i=c.charCodeAt(x),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&m.push(239,191,189);continue}else if(x+1===h){(r-=3)>-1&&m.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&m.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&m.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;m.push(i)}else if(i<2048){if((r-=2)<0)break;m.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;m.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;m.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return m}function qt(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function ur(c,r){let i,h,g;const m=[];for(let x=0;x<c.length&&!((r-=2)<0);++x)i=c.charCodeAt(x),h=i>>8,g=i%256,m.push(g),m.push(h);return m}function Nt(c){return t.toByteArray(Oe(c))}function vt(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function It(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function Rt(c){return c!==c}const Dt=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function Ft(c){return typeof BigInt>"u"?Kt:c}function Kt(){throw new Error("BigInt not supported")}})(lt);function Pn(o){if(!Number.isSafeInteger(o)||o<0)throw new Error(`positive integer expected, not ${o}`)}function qc(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function pn(o,...t){if(!qc(o))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(o.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${o.length}`)}function Hc(o){if(typeof o!="function"||typeof o.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Pn(o.outputLen),Pn(o.blockLen)}function jr(o,t=!0){if(o.destroyed)throw new Error("Hash instance has been destroyed");if(t&&o.finished)throw new Error("Hash#digest() has already been called")}function is(o,t){pn(o);const e=t.outputLen;if(o.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const pi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vc=o=>new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)),gi=o=>new DataView(o.buffer,o.byteOffset,o.byteLength),Xe=(o,t)=>o<<32-t|o>>>t,os=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,jc=o=>o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255;function ss(o){for(let t=0;t<o.length;t++)o[t]=jc(o[t])}function as(o){if(typeof o!="string")throw new Error(`utf8ToBytes expected string, got ${typeof o}`);return new Uint8Array(new TextEncoder().encode(o))}function Ln(o){return typeof o=="string"&&(o=as(o)),pn(o),o}function cs(...o){let t=0;for(let n=0;n<o.length;n++){const s=o[n];pn(s),t+=s.length}const e=new Uint8Array(t);for(let n=0,s=0;n<o.length;n++){const a=o[n];e.set(a,s),s+=a.length}return e}class yi{clone(){return this._cloneInto()}}function mi(o){const t=n=>o().update(Ln(n)).digest(),e=o();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>o(),t}function us(o=32){if(pi&&typeof pi.getRandomValues=="function")return pi.getRandomValues(new Uint8Array(o));throw new Error("crypto.getRandomValues must be defined")}function Gc(o,t,e,n){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,e,n);const s=BigInt(32),a=BigInt(4294967295),f=Number(e>>s&a),u=Number(e&a),p=n?4:0,b=n?0:4;o.setUint32(t+p,f,n),o.setUint32(t+b,u,n)}const Yc=(o,t,e)=>o&t^~o&e,Zc=(o,t,e)=>o&t^o&e^t&e;class fs extends yi{constructor(t,e,n,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=gi(this.buffer)}update(t){jr(this);const{view:e,buffer:n,blockLen:s}=this;t=Ln(t);const a=t.length;for(let f=0;f<a;){const u=Math.min(s-this.pos,a-f);if(u===s){const p=gi(t);for(;s<=a-f;f+=s)this.process(p,f);continue}n.set(t.subarray(f,f+u),this.pos),this.pos+=u,f+=u,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){jr(this),is(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:s,isLE:a}=this;let{pos:f}=this;e[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>s-f&&(this.process(n,0),f=0);for(let I=f;I<s;I++)e[I]=0;Gc(n,s-8,BigInt(this.length*8),a),this.process(n,0);const u=gi(t),p=this.outputLen;if(p%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const b=p/4,E=this.get();if(b>E.length)throw new Error("_sha2: outputLen bigger than state");for(let I=0;I<b;I++)u.setUint32(4*I,E[I],a)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:s,finished:a,destroyed:f,pos:u}=this;return t.length=s,t.pos=u,t.finished=a,t.destroyed=f,s%e&&t.buffer.set(n),t}}const Un=BigInt(2**32-1),wi=BigInt(32);function hs(o,t=!1){return t?{h:Number(o&Un),l:Number(o>>wi&Un)}:{h:Number(o>>wi&Un)|0,l:Number(o&Un)|0}}function ls(o,t=!1){let e=new Uint32Array(o.length),n=new Uint32Array(o.length);for(let s=0;s<o.length;s++){const{h:a,l:f}=hs(o[s],t);[e[s],n[s]]=[a,f]}return[e,n]}const Jc=(o,t)=>BigInt(o>>>0)<<wi|BigInt(t>>>0),Xc=(o,t,e)=>o>>>e,Qc=(o,t,e)=>o<<32-e|t>>>e,tu=(o,t,e)=>o>>>e|t<<32-e,eu=(o,t,e)=>o<<32-e|t>>>e,ru=(o,t,e)=>o<<64-e|t>>>e-32,nu=(o,t,e)=>o>>>e-32|t<<64-e,iu=(o,t)=>t,ou=(o,t)=>o,ds=(o,t,e)=>o<<e|t>>>32-e,ps=(o,t,e)=>t<<e|o>>>32-e,gs=(o,t,e)=>t<<e-32|o>>>64-e,ys=(o,t,e)=>o<<e-32|t>>>64-e;function su(o,t,e,n){const s=(t>>>0)+(n>>>0);return{h:o+e+(s/2**32|0)|0,l:s|0}}const bt={fromBig:hs,split:ls,toBig:Jc,shrSH:Xc,shrSL:Qc,rotrSH:tu,rotrSL:eu,rotrBH:ru,rotrBL:nu,rotr32H:iu,rotr32L:ou,rotlSH:ds,rotlSL:ps,rotlBH:gs,rotlBL:ys,add:su,add3L:(o,t,e)=>(o>>>0)+(t>>>0)+(e>>>0),add3H:(o,t,e,n)=>t+e+n+(o/2**32|0)|0,add4L:(o,t,e,n)=>(o>>>0)+(t>>>0)+(e>>>0)+(n>>>0),add4H:(o,t,e,n,s)=>t+e+n+s+(o/2**32|0)|0,add5H:(o,t,e,n,s,a)=>t+e+n+s+a+(o/2**32|0)|0,add5L:(o,t,e,n,s)=>(o>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0)},[au,cu]=(()=>bt.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(o=>BigInt(o))))(),br=new Uint32Array(80),xr=new Uint32Array(80);class uu extends fs{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:n,Bl:s,Ch:a,Cl:f,Dh:u,Dl:p,Eh:b,El:E,Fh:I,Fl:M,Gh:T,Gl:U,Hh:_,Hl:L}=this;return[t,e,n,s,a,f,u,p,b,E,I,M,T,U,_,L]}set(t,e,n,s,a,f,u,p,b,E,I,M,T,U,_,L){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=s|0,this.Ch=a|0,this.Cl=f|0,this.Dh=u|0,this.Dl=p|0,this.Eh=b|0,this.El=E|0,this.Fh=I|0,this.Fl=M|0,this.Gh=T|0,this.Gl=U|0,this.Hh=_|0,this.Hl=L|0}process(t,e){for(let N=0;N<16;N++,e+=4)br[N]=t.getUint32(e),xr[N]=t.getUint32(e+=4);for(let N=16;N<80;N++){const H=br[N-15]|0,D=xr[N-15]|0,F=bt.rotrSH(H,D,1)^bt.rotrSH(H,D,8)^bt.shrSH(H,D,7),W=bt.rotrSL(H,D,1)^bt.rotrSL(H,D,8)^bt.shrSL(H,D,7),q=br[N-2]|0,Bt=xr[N-2]|0,gt=bt.rotrSH(q,Bt,19)^bt.rotrBH(q,Bt,61)^bt.shrSH(q,Bt,6),ot=bt.rotrSL(q,Bt,19)^bt.rotrBL(q,Bt,61)^bt.shrSL(q,Bt,6),At=bt.add4L(W,ot,xr[N-7],xr[N-16]),R=bt.add4H(At,F,gt,br[N-7],br[N-16]);br[N]=R|0,xr[N]=At|0}let{Ah:n,Al:s,Bh:a,Bl:f,Ch:u,Cl:p,Dh:b,Dl:E,Eh:I,El:M,Fh:T,Fl:U,Gh:_,Gl:L,Hh:C,Hl:$}=this;for(let N=0;N<80;N++){const H=bt.rotrSH(I,M,14)^bt.rotrSH(I,M,18)^bt.rotrBH(I,M,41),D=bt.rotrSL(I,M,14)^bt.rotrSL(I,M,18)^bt.rotrBL(I,M,41),F=I&T^~I&_,W=M&U^~M&L,q=bt.add5L($,D,W,cu[N],xr[N]),Bt=bt.add5H(q,C,H,F,au[N],br[N]),gt=q|0,ot=bt.rotrSH(n,s,28)^bt.rotrBH(n,s,34)^bt.rotrBH(n,s,39),At=bt.rotrSL(n,s,28)^bt.rotrBL(n,s,34)^bt.rotrBL(n,s,39),R=n&a^n&u^a&u,l=s&f^s&p^f&p;C=_|0,$=L|0,_=T|0,L=U|0,T=I|0,U=M|0,{h:I,l:M}=bt.add(b|0,E|0,Bt|0,gt|0),b=u|0,E=p|0,u=a|0,p=f|0,a=n|0,f=s|0;const y=bt.add3L(gt,At,l);n=bt.add3H(y,Bt,ot,R),s=y|0}({h:n,l:s}=bt.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:a,l:f}=bt.add(this.Bh|0,this.Bl|0,a|0,f|0),{h:u,l:p}=bt.add(this.Ch|0,this.Cl|0,u|0,p|0),{h:b,l:E}=bt.add(this.Dh|0,this.Dl|0,b|0,E|0),{h:I,l:M}=bt.add(this.Eh|0,this.El|0,I|0,M|0),{h:T,l:U}=bt.add(this.Fh|0,this.Fl|0,T|0,U|0),{h:_,l:L}=bt.add(this.Gh|0,this.Gl|0,_|0,L|0),{h:C,l:$}=bt.add(this.Hh|0,this.Hl|0,C|0,$|0),this.set(n,s,a,f,u,p,b,E,I,M,T,U,_,L,C,$)}roundClean(){br.fill(0),xr.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 ms=mi(()=>new uu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ws=BigInt(0),Cn=BigInt(1),fu=BigInt(2);function _r(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function gn(o){if(!_r(o))throw new Error("Uint8Array expected")}const hu=Array.from({length:256},(o,t)=>t.toString(16).padStart(2,"0"));function Rr(o){gn(o);let t="";for(let e=0;e<o.length;e++)t+=hu[o[e]];return t}function bs(o){const t=o.toString(16);return t.length&1?`0${t}`:t}function bi(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);return BigInt(o===""?"0":`0x${o}`)}const fr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function xs(o){if(o>=fr._0&&o<=fr._9)return o-fr._0;if(o>=fr._A&&o<=fr._F)return o-(fr._A-10);if(o>=fr._a&&o<=fr._f)return o-(fr._a-10)}function Gr(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);const t=o.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(e);for(let s=0,a=0;s<e;s++,a+=2){const f=xs(o.charCodeAt(a)),u=xs(o.charCodeAt(a+1));if(f===void 0||u===void 0){const p=o[a]+o[a+1];throw new Error('hex string expected, got non-hex character "'+p+'" at index '+a)}n[s]=f*16+u}return n}function Tr(o){return bi(Rr(o))}function Yr(o){return gn(o),bi(Rr(Uint8Array.from(o).reverse()))}function Zr(o,t){return Gr(o.toString(16).padStart(t*2,"0"))}function yn(o,t){return Zr(o,t).reverse()}function lu(o){return Gr(bs(o))}function be(o,t,e){let n;if(typeof t=="string")try{n=Gr(t)}catch(a){throw new Error(`${o} must be valid hex string, got "${t}". Cause: ${a}`)}else if(_r(t))n=Uint8Array.from(t);else throw new Error(`${o} must be hex string or Uint8Array`);const s=n.length;if(typeof e=="number"&&s!==e)throw new Error(`${o} expected ${e} bytes, got ${s}`);return n}function Mr(...o){let t=0;for(let n=0;n<o.length;n++){const s=o[n];gn(s),t+=s.length}const e=new Uint8Array(t);for(let n=0,s=0;n<o.length;n++){const a=o[n];e.set(a,s),s+=a.length}return e}function du(o,t){if(o.length!==t.length)return!1;let e=0;for(let n=0;n<o.length;n++)e|=o[n]^t[n];return e===0}function pu(o){if(typeof o!="string")throw new Error(`utf8ToBytes expected string, got ${typeof o}`);return new Uint8Array(new TextEncoder().encode(o))}function gu(o){let t;for(t=0;o>ws;o>>=Cn,t+=1);return t}function yu(o,t){return o>>BigInt(t)&Cn}function mu(o,t,e){return o|(e?Cn:ws)<<BigInt(t)}const xi=o=>(fu<<BigInt(o-1))-Cn,ki=o=>new Uint8Array(o),ks=o=>Uint8Array.from(o);function Es(o,t,e){if(typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=ki(o),s=ki(o),a=0;const f=()=>{n.fill(1),s.fill(0),a=0},u=(...I)=>e(s,n,...I),p=(I=ki())=>{s=u(ks([0]),I),n=u(),I.length!==0&&(s=u(ks([1]),I),n=u())},b=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let I=0;const M=[];for(;I<t;){n=u();const T=n.slice();M.push(T),I+=n.length}return Mr(...M)};return(I,M)=>{f(),p(I);let T;for(;!(T=M(b()));)p();return f(),T}}const wu={bigint:o=>typeof o=="bigint",function:o=>typeof o=="function",boolean:o=>typeof o=="boolean",string:o=>typeof o=="string",stringOrUint8Array:o=>typeof o=="string"||_r(o),isSafeInteger:o=>Number.isSafeInteger(o),array:o=>Array.isArray(o),field:(o,t)=>t.Fp.isValid(o),hash:o=>typeof o=="function"&&Number.isSafeInteger(o.outputLen)};function Jr(o,t,e={}){const n=(s,a,f)=>{const u=wu[a];if(typeof u!="function")throw new Error(`Invalid validator "${a}", expected function`);const p=o[s];if(!(f&&p===void 0)&&!u(p,o))throw new Error(`Invalid param ${String(s)}=${p} (${typeof p}), expected ${a}`)};for(const[s,a]of Object.entries(t))n(s,a,!1);for(const[s,a]of Object.entries(e))n(s,a,!0);return o}const bu=Object.freeze(Object.defineProperty({__proto__:null,abytes:gn,bitGet:yu,bitLen:gu,bitMask:xi,bitSet:mu,bytesToHex:Rr,bytesToNumberBE:Tr,bytesToNumberLE:Yr,concatBytes:Mr,createHmacDrbg:Es,ensureBytes:be,equalBytes:du,hexToBytes:Gr,hexToNumber:bi,isBytes:_r,numberToBytesBE:Zr,numberToBytesLE:yn,numberToHexUnpadded:bs,numberToVarBytesBE:lu,utf8ToBytes:pu,validateObject:Jr},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xe=BigInt(0),Zt=BigInt(1),Pr=BigInt(2),xu=BigInt(3),Ei=BigInt(4),Is=BigInt(5),Ss=BigInt(8);BigInt(9),BigInt(16);function Gt(o,t){const e=o%t;return e>=xe?e:t+e}function ku(o,t,e){if(e<=xe||t<xe)throw new Error("Expected power/modulo > 0");if(e===Zt)return xe;let n=Zt;for(;t>xe;)t&Zt&&(n=n*o%e),o=o*o%e,t>>=Zt;return n}function Xt(o,t,e){let n=o;for(;t-- >xe;)n*=n,n%=e;return n}function Ii(o,t){if(o===xe||t<=xe)throw new Error(`invert: expected positive integers, got n=${o} mod=${t}`);let e=Gt(o,t),n=t,s=xe,a=Zt;for(;e!==xe;){const u=n/e,p=n%e,b=s-a*u;n=e,e=p,s=a,a=b}if(n!==Zt)throw new Error("invert: does not exist");return Gt(s,t)}function Eu(o){const t=(o-Zt)/Pr;let e,n,s;for(e=o-Zt,n=0;e%Pr===xe;e/=Pr,n++);for(s=Pr;s<o&&ku(s,t,o)!==o-Zt;s++);if(n===1){const f=(o+Zt)/Ei;return function(p,b){const E=p.pow(b,f);if(!p.eql(p.sqr(E),b))throw new Error("Cannot find square root");return E}}const a=(e+Zt)/Pr;return function(u,p){if(u.pow(p,t)===u.neg(u.ONE))throw new Error("Cannot find square root");let b=n,E=u.pow(u.mul(u.ONE,s),e),I=u.pow(p,a),M=u.pow(p,e);for(;!u.eql(M,u.ONE);){if(u.eql(M,u.ZERO))return u.ZERO;let T=1;for(let _=u.sqr(M);T<b&&!u.eql(_,u.ONE);T++)_=u.sqr(_);const U=u.pow(E,Zt<<BigInt(b-T-1));E=u.sqr(U),I=u.mul(I,U),M=u.mul(M,E),b=T}return I}}function Iu(o){if(o%Ei===xu){const t=(o+Zt)/Ei;return function(n,s){const a=n.pow(s,t);if(!n.eql(n.sqr(a),s))throw new Error("Cannot find square root");return a}}if(o%Ss===Is){const t=(o-Is)/Ss;return function(n,s){const a=n.mul(s,Pr),f=n.pow(a,t),u=n.mul(s,f),p=n.mul(n.mul(u,Pr),f),b=n.mul(u,n.sub(p,n.ONE));if(!n.eql(n.sqr(b),s))throw new Error("Cannot find square root");return b}}return Eu(o)}const Su=(o,t)=>(Gt(o,t)&Zt)===Zt,Bu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Au(o){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Bu.reduce((n,s)=>(n[s]="function",n),t);return Jr(o,e)}function vu(o,t,e){if(e<xe)throw new Error("Expected power > 0");if(e===xe)return o.ONE;if(e===Zt)return t;let n=o.ONE,s=t;for(;e>xe;)e&Zt&&(n=o.mul(n,s)),s=o.sqr(s),e>>=Zt;return n}function _u(o,t){const e=new Array(t.length),n=t.reduce((a,f,u)=>o.is0(f)?a:(e[u]=a,o.mul(a,f)),o.ONE),s=o.inv(n);return t.reduceRight((a,f,u)=>o.is0(f)?a:(e[u]=o.mul(a,e[u]),o.mul(a,f)),s),e}function Bs(o,t){const e=t!==void 0?t:o.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function As(o,t,e=!1,n={}){if(o<=xe)throw new Error(`Expected Field ORDER > 0, got ${o}`);const{nBitLength:s,nByteLength:a}=Bs(o,t);if(a>2048)throw new Error("Field lengths over 2048 bytes are not supported");const f=Iu(o),u=Object.freeze({ORDER:o,BITS:s,BYTES:a,MASK:xi(s),ZERO:xe,ONE:Zt,create:p=>Gt(p,o),isValid:p=>{if(typeof p!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof p}`);return xe<=p&&p<o},is0:p=>p===xe,isOdd:p=>(p&Zt)===Zt,neg:p=>Gt(-p,o),eql:(p,b)=>p===b,sqr:p=>Gt(p*p,o),add:(p,b)=>Gt(p+b,o),sub:(p,b)=>Gt(p-b,o),mul:(p,b)=>Gt(p*b,o),pow:(p,b)=>vu(u,p,b),div:(p,b)=>Gt(p*Ii(b,o),o),sqrN:p=>p*p,addN:(p,b)=>p+b,subN:(p,b)=>p-b,mulN:(p,b)=>p*b,inv:p=>Ii(p,o),sqrt:n.sqrt||(p=>f(u,p)),invertBatch:p=>_u(u,p),cmov:(p,b,E)=>E?b:p,toBytes:p=>e?yn(p,a):Zr(p,a),fromBytes:p=>{if(p.length!==a)throw new Error(`Fp.fromBytes: expected ${a}, got ${p.length}`);return e?Yr(p):Tr(p)}});return Object.freeze(u)}function Ru(o,t){if(!o.isOdd)throw new Error("Field doesn't have isOdd");const e=o.sqrt(t);return o.isOdd(e)?o.neg(e):e}function vs(o){if(typeof o!="bigint")throw new Error("field order must be bigint");const t=o.toString(2).length;return Math.ceil(t/8)}function _s(o){const t=vs(o);return t+Math.ceil(t/2)}function Tu(o,t,e=!1){const n=o.length,s=vs(t),a=_s(t);if(n<16||n<a||n>1024)throw new Error(`expected ${a}-1024 bytes of input, got ${n}`);const f=e?Tr(o):Yr(o),u=Gt(f,t-Zt)+Zt;return e?yn(u,s):Zr(u,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Mu=BigInt(0),Si=BigInt(1);function Rs(o,t){const e=(s,a)=>{const f=a.negate();return s?f:a},n=s=>{const a=Math.ceil(t/s)+1,f=2**(s-1);return{windows:a,windowSize:f}};return{constTimeNegate:e,unsafeLadder(s,a){let f=o.ZERO,u=s;for(;a>Mu;)a&Si&&(f=f.add(u)),u=u.double(),a>>=Si;return f},precomputeWindow(s,a){const{windows:f,windowSize:u}=n(a),p=[];let b=s,E=b;for(let I=0;I<f;I++){E=b,p.push(E);for(let M=1;M<u;M++)E=E.add(b),p.push(E);b=E.double()}return p},wNAF(s,a,f){const{windows:u,windowSize:p}=n(s);let b=o.ZERO,E=o.BASE;const I=BigInt(2**s-1),M=2**s,T=BigInt(s);for(let U=0;U<u;U++){const _=U*p;let L=Number(f&I);f>>=T,L>p&&(L-=M,f+=Si);const C=_,$=_+Math.abs(L)-1,N=U%2!==0,H=L<0;L===0?E=E.add(e(N,a[C])):b=b.add(e(H,a[$]))}return{p:b,f:E}},wNAFCached(s,a,f,u){const p=s._WINDOW_SIZE||1;let b=a.get(s);return b||(b=this.precomputeWindow(s,p),p!==1&&a.set(s,u(b))),this.wNAF(p,b,f)}}}function Bi(o){return Au(o.Fp),Jr(o,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Bs(o.n,o.nBitLength),...o,p:o.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const je=BigInt(0),Ne=BigInt(1),Fn=BigInt(2),Pu=BigInt(8),Lu={zip215:!0};function Uu(o){const t=Bi(o);return Jr(o,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Ai(o){const t=Uu(o),{Fp:e,n,prehash:s,hash:a,randomBytes:f,nByteLength:u,h:p}=t,b=Fn<<BigInt(u*8)-Ne,E=e.create,I=t.uvRatio||((S,B)=>{try{return{isValid:!0,value:e.sqrt(S*e.inv(B))}}catch{return{isValid:!1,value:je}}}),M=t.adjustScalarBytes||(S=>S),T=t.domain||((S,B,P)=>{if(B.length||P)throw new Error("Contexts/pre-hash are not supported");return S}),U=S=>typeof S=="bigint"&&je<S,_=(S,B)=>U(S)&&U(B)&&S<B,L=S=>S===je||_(S,b);function C(S,B){if(_(S,B))return S;throw new Error(`Expected valid scalar < ${B}, got ${typeof S} ${S}`)}function $(S){return S===je?S:C(S,n)}const N=new Map;function H(S){if(!(S instanceof D))throw new Error("ExtendedPoint expected")}class D{constructor(B,P,w,d){if(this.ex=B,this.ey=P,this.ez=w,this.et=d,!L(B))throw new Error("x required");if(!L(P))throw new Error("y required");if(!L(w))throw new Error("z required");if(!L(d))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(B){if(B instanceof D)throw new Error("extended point not allowed");const{x:P,y:w}=B||{};if(!L(P)||!L(w))throw new Error("invalid affine point");return new D(P,w,Ne,E(P*w))}static normalizeZ(B){const P=e.invertBatch(B.map(w=>w.ez));return B.map((w,d)=>w.toAffine(P[d])).map(D.fromAffine)}_setWindowSize(B){this._WINDOW_SIZE=B,N.delete(this)}assertValidity(){const{a:B,d:P}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:w,ey:d,ez:v,et:Y}=this,J=E(w*w),X=E(d*d),ft=E(v*v),st=E(ft*ft),ht=E(J*B),Wt=E(ft*E(ht+X)),wt=E(st+E(P*E(J*X)));if(Wt!==wt)throw new Error("bad point: equation left != right (1)");const yt=E(w*d),mt=E(v*Y);if(yt!==mt)throw new Error("bad point: equation left != right (2)")}equals(B){H(B);const{ex:P,ey:w,ez:d}=this,{ex:v,ey:Y,ez:J}=B,X=E(P*J),ft=E(v*d),st=E(w*J),ht=E(Y*d);return X===ft&&st===ht}is0(){return this.equals(D.ZERO)}negate(){return new D(E(-this.ex),this.ey,this.ez,E(-this.et))}double(){const{a:B}=t,{ex:P,ey:w,ez:d}=this,v=E(P*P),Y=E(w*w),J=E(Fn*E(d*d)),X=E(B*v),ft=P+w,st=E(E(ft*ft)-v-Y),ht=X+Y,Wt=ht-J,wt=X-Y,yt=E(st*Wt),mt=E(ht*wt),dt=E(st*wt),Mt=E(Wt*ht);return new D(yt,mt,Mt,dt)}add(B){H(B);const{a:P,d:w}=t,{ex:d,ey:v,ez:Y,et:J}=this,{ex:X,ey:ft,ez:st,et:ht}=B;if(P===BigInt(-1)){const It=E((v-d)*(ft+X)),Rt=E((v+d)*(ft-X)),Dt=E(Rt-It);if(Dt===je)return this.double();const Ft=E(Y*Fn*ht),Kt=E(J*Fn*st),c=Kt+Ft,r=Rt+It,i=Kt-Ft,h=E(c*Dt),g=E(r*i),m=E(c*i),x=E(Dt*r);return new D(h,g,x,m)}const Wt=E(d*X),wt=E(v*ft),yt=E(J*w*ht),mt=E(Y*st),dt=E((d+v)*(X+ft)-Wt-wt),Mt=mt-yt,Oe=mt+yt,_t=E(wt-P*Wt),qt=E(dt*Mt),ur=E(Oe*_t),Nt=E(dt*_t),vt=E(Mt*Oe);return new D(qt,ur,vt,Nt)}subtract(B){return this.add(B.negate())}wNAF(B){return q.wNAFCached(this,N,B,D.normalizeZ)}multiply(B){const{p:P,f:w}=this.wNAF(C(B,n));return D.normalizeZ([P,w])[0]}multiplyUnsafe(B){let P=$(B);return P===je?W:this.equals(W)||P===Ne?this:this.equals(F)?this.wNAF(P).p:q.unsafeLadder(this,P)}isSmallOrder(){return this.multiplyUnsafe(p).is0()}isTorsionFree(){return q.unsafeLadder(this,n).is0()}toAffine(B){const{ex:P,ey:w,ez:d}=this,v=this.is0();B==null&&(B=v?Pu:e.inv(d));const Y=E(P*B),J=E(w*B),X=E(d*B);if(v)return{x:je,y:Ne};if(X!==Ne)throw new Error("invZ was invalid");return{x:Y,y:J}}clearCofactor(){const{h:B}=t;return B===Ne?this:this.multiplyUnsafe(B)}static fromHex(B,P=!1){const{d:w,a:d}=t,v=e.BYTES;B=be("pointHex",B,v);const Y=B.slice(),J=B[v-1];Y[v-1]=J&-129;const X=Yr(Y);X===je||(P?C(X,b):C(X,e.ORDER));const ft=E(X*X),st=E(ft-Ne),ht=E(w*ft-d);let{isValid:Wt,value:wt}=I(st,ht);if(!Wt)throw new Error("Point.fromHex: invalid y coordinate");const yt=(wt&Ne)===Ne,mt=(J&128)!==0;if(!P&&wt===je&&mt)throw new Error("Point.fromHex: x=0 and x_0=1");return mt!==yt&&(wt=E(-wt)),D.fromAffine({x:wt,y:X})}static fromPrivateKey(B){return ot(B).point}toRawBytes(){const{x:B,y:P}=this.toAffine(),w=yn(P,e.BYTES);return w[w.length-1]|=B&Ne?128:0,w}toHex(){return Rr(this.toRawBytes())}}D.BASE=new D(t.Gx,t.Gy,Ne,E(t.Gx*t.Gy)),D.ZERO=new D(je,Ne,Ne,je);const{BASE:F,ZERO:W}=D,q=Rs(D,u*8);function Bt(S){return Gt(S,n)}function gt(S){return Bt(Yr(S))}function ot(S){const B=u;S=be("private key",S,B);const P=be("hashed private key",a(S),2*B),w=M(P.slice(0,B)),d=P.slice(B,2*B),v=gt(w),Y=F.multiply(v),J=Y.toRawBytes();return{head:w,prefix:d,scalar:v,point:Y,pointBytes:J}}function At(S){return ot(S).pointBytes}function R(S=new Uint8Array,...B){const P=Mr(...B);return gt(a(T(P,be("context",S),!!s)))}function l(S,B,P={}){S=be("message",S),s&&(S=s(S));const{prefix:w,scalar:d,pointBytes:v}=ot(B),Y=R(P.context,w,S),J=F.multiply(Y).toRawBytes(),X=R(P.context,J,v,S),ft=Bt(Y+X*d);$(ft);const st=Mr(J,yn(ft,e.BYTES));return be("result",st,u*2)}const y=Lu;function k(S,B,P,w=y){const{context:d,zip215:v}=w,Y=e.BYTES;S=be("signature",S,2*Y),B=be("message",B),s&&(B=s(B));const J=Yr(S.slice(Y,2*Y));let X,ft,st;try{X=D.fromHex(P,v),ft=D.fromHex(S.slice(0,Y),v),st=F.multiplyUnsafe(J)}catch{return!1}if(!v&&X.isSmallOrder())return!1;const ht=R(d,ft.toRawBytes(),X.toRawBytes(),B);return ft.add(X.multiplyUnsafe(ht)).subtract(st).clearCofactor().equals(D.ZERO)}return F._setWindowSize(8),{CURVE:t,getPublicKey:At,sign:l,verify:k,ExtendedPoint:D,utils:{getExtendedPublicKey:ot,randomPrivateKey:()=>f(e.BYTES),precompute(S=8,B=D.BASE){return B._setWindowSize(S),B.multiply(BigInt(3)),B}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ts=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Cu=BigInt(1),_i=BigInt(2),Fu=BigInt(5),Ms=BigInt(10),Ou=BigInt(20),Nu=BigInt(40),Ps=BigInt(80);function zu(o){const t=vi,n=o*o%t*o%t,s=Xt(n,_i,t)*n%t,a=Xt(s,Cu,t)*o%t,f=Xt(a,Fu,t)*a%t,u=Xt(f,Ms,t)*f%t,p=Xt(u,Ou,t)*u%t,b=Xt(p,Nu,t)*p%t,E=Xt(b,Ps,t)*b%t,I=Xt(E,Ps,t)*b%t,M=Xt(I,Ms,t)*f%t;return{pow_p_5_8:Xt(M,_i,t)*o%t,b2:n}}function Du(o){return o[0]&=248,o[31]&=127,o[31]|=64,o}function $u(o,t){const e=vi,n=Gt(t*t*t,e),s=Gt(n*n*t,e),a=zu(o*s).pow_p_5_8;let f=Gt(o*n*a,e);const u=Gt(t*f*f,e),p=f,b=Gt(f*Ts,e),E=u===o,I=u===Gt(-o,e),M=u===Gt(-o*Ts,e);return E&&(f=p),(I||M)&&(f=b),Su(f,e)&&(f=Gt(-f,e)),{isValid:E||I,value:f}}const hr=As(vi,void 0,!0),Ri={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:hr,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ms,randomBytes:us,adjustScalarBytes:Du,uvRatio:$u},Xr=Ai(Ri);function Ls(o,t,e){if(t.length>255)throw new Error("Context is too big");return cs(as("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,o)}({...Ri},{...Ri});const Wu=(hr.ORDER+BigInt(3))/BigInt(8);hr.pow(_i,Wu),hr.sqrt(hr.neg(hr.ONE)),(hr.ORDER-BigInt(5))/BigInt(8),BigInt(486662),Ru(hr,hr.neg(BigInt(486664))),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Ti={exports:{}};const Ku=li(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));Ti.exports,function(o){(function(t,e){function n(R,l){if(!R)throw new Error(l||"Assertion failed")}function s(R,l){R.super_=l;var y=function(){};y.prototype=l.prototype,R.prototype=new y,R.prototype.constructor=R}function a(R,l,y){if(a.isBN(R))return R;this.negative=0,this.words=null,this.length=0,this.red=null,R!==null&&((l==="le"||l==="be")&&(y=l,l=10),this._init(R||0,l||10,y||"be"))}typeof t=="object"?t.exports=a:e.BN=a,a.BN=a,a.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=Ku.Buffer}catch{}a.isBN=function(l){return l instanceof a?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===a.wordSize&&Array.isArray(l.words)},a.max=function(l,y){return l.cmp(y)>0?l:y},a.min=function(l,y){return l.cmp(y)<0?l:y},a.prototype._init=function(l,y,k){if(typeof l=="number")return this._initNumber(l,y,k);if(typeof l=="object")return this._initArray(l,y,k);y==="hex"&&(y=16),n(y===(y|0)&&y>=2&&y<=36),l=l.toString().replace(/\s+/g,"");var A=0;l[0]==="-"&&(A++,this.negative=1),A<l.length&&(y===16?this._parseHex(l,A,k):(this._parseBase(l,y,A),k==="le"&&this._initArray(this.toArray(),y,k)))},a.prototype._initNumber=function(l,y,k){l<0&&(this.negative=1,l=-l),l<67108864?(this.words=[l&67108863],this.length=1):l<4503599627370496?(this.words=[l&67108863,l/67108864&67108863],this.length=2):(n(l<9007199254740992),this.words=[l&67108863,l/67108864&67108863,1],this.length=3),k==="le"&&this._initArray(this.toArray(),y,k)},a.prototype._initArray=function(l,y,k){if(n(typeof l.length=="number"),l.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(l.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var S,B,P=0;if(k==="be")for(A=l.length-1,S=0;A>=0;A-=3)B=l[A]|l[A-1]<<8|l[A-2]<<16,this.words[S]|=B<<P&67108863,this.words[S+1]=B>>>26-P&67108863,P+=24,P>=26&&(P-=26,S++);else if(k==="le")for(A=0,S=0;A<l.length;A+=3)B=l[A]|l[A+1]<<8|l[A+2]<<16,this.words[S]|=B<<P&67108863,this.words[S+1]=B>>>26-P&67108863,P+=24,P>=26&&(P-=26,S++);return this._strip()};function u(R,l){var y=R.charCodeAt(l);if(y>=48&&y<=57)return y-48;if(y>=65&&y<=70)return y-55;if(y>=97&&y<=102)return y-87;n(!1,"Invalid character in "+R)}function p(R,l,y){var k=u(R,y);return y-1>=l&&(k|=u(R,y-1)<<4),k}a.prototype._parseHex=function(l,y,k){this.length=Math.ceil((l.length-y)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var S=0,B=0,P;if(k==="be")for(A=l.length-1;A>=y;A-=2)P=p(l,y,A)<<S,this.words[B]|=P&67108863,S>=18?(S-=18,B+=1,this.words[B]|=P>>>26):S+=8;else{var w=l.length-y;for(A=w%2===0?y+1:y;A<l.length;A+=2)P=p(l,y,A)<<S,this.words[B]|=P&67108863,S>=18?(S-=18,B+=1,this.words[B]|=P>>>26):S+=8}this._strip()};function b(R,l,y,k){for(var A=0,S=0,B=Math.min(R.length,y),P=l;P<B;P++){var w=R.charCodeAt(P)-48;A*=k,w>=49?S=w-49+10:w>=17?S=w-17+10:S=w,n(w>=0&&S<k,"Invalid character"),A+=S}return A}a.prototype._parseBase=function(l,y,k){this.words=[0],this.length=1;for(var A=0,S=1;S<=67108863;S*=y)A++;A--,S=S/y|0;for(var B=l.length-k,P=B%A,w=Math.min(B,B-P)+k,d=0,v=k;v<w;v+=A)d=b(l,v,v+A,y),this.imuln(S),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(P!==0){var Y=1;for(d=b(l,v,l.length,y),v=0;v<P;v++)Y*=y;this.imuln(Y),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this._strip()},a.prototype.copy=function(l){l.words=new Array(this.length);for(var y=0;y<this.length;y++)l.words[y]=this.words[y];l.length=this.length,l.negative=this.negative,l.red=this.red};function E(R,l){R.words=l.words,R.length=l.length,R.negative=l.negative,R.red=l.red}if(a.prototype._move=function(l){E(l,this)},a.prototype.clone=function(){var l=new a(null);return this.copy(l),l},a.prototype._expand=function(l){for(;this.length<l;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=I}catch{a.prototype.inspect=I}else a.prototype.inspect=I;function I(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var M=["","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"],T=[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],U=[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];a.prototype.toString=function(l,y){l=l||10,y=y|0||1;var k;if(l===16||l==="hex"){k="";for(var A=0,S=0,B=0;B<this.length;B++){var P=this.words[B],w=((P<<A|S)&16777215).toString(16);S=P>>>24-A&16777215,A+=2,A>=26&&(A-=26,B--),S!==0||B!==this.length-1?k=M[6-w.length]+w+k:k=w+k}for(S!==0&&(k=S.toString(16)+k);k.length%y!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(l===(l|0)&&l>=2&&l<=36){var d=T[l],v=U[l];k="";var Y=this.clone();for(Y.negative=0;!Y.isZero();){var J=Y.modrn(v).toString(l);Y=Y.idivn(v),Y.isZero()?k=J+k:k=M[d-J.length]+J+k}for(this.isZero()&&(k="0"+k);k.length%y!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},a.prototype.toJSON=function(){return this.toString(16,2)},f&&(a.prototype.toBuffer=function(l,y){return this.toArrayLike(f,l,y)}),a.prototype.toArray=function(l,y){return this.toArrayLike(Array,l,y)};var _=function(l,y){return l.allocUnsafe?l.allocUnsafe(y):new l(y)};a.prototype.toArrayLike=function(l,y,k){this._strip();var A=this.byteLength(),S=k||Math.max(1,A);n(A<=S,"byte array longer than desired length"),n(S>0,"Requested array length <= 0");var B=_(l,S),P=y==="le"?"LE":"BE";return this["_toArrayLike"+P](B,A),B},a.prototype._toArrayLikeLE=function(l,y){for(var k=0,A=0,S=0,B=0;S<this.length;S++){var P=this.words[S]<<B|A;l[k++]=P&255,k<l.length&&(l[k++]=P>>8&255),k<l.length&&(l[k++]=P>>16&255),B===6?(k<l.length&&(l[k++]=P>>24&255),A=0,B=0):(A=P>>>24,B+=2)}if(k<l.length)for(l[k++]=A;k<l.length;)l[k++]=0},a.prototype._toArrayLikeBE=function(l,y){for(var k=l.length-1,A=0,S=0,B=0;S<this.length;S++){var P=this.words[S]<<B|A;l[k--]=P&255,k>=0&&(l[k--]=P>>8&255),k>=0&&(l[k--]=P>>16&255),B===6?(k>=0&&(l[k--]=P>>24&255),A=0,B=0):(A=P>>>24,B+=2)}if(k>=0)for(l[k--]=A;k>=0;)l[k--]=0},Math.clz32?a.prototype._countBits=function(l){return 32-Math.clz32(l)}:a.prototype._countBits=function(l){var y=l,k=0;return y>=4096&&(k+=13,y>>>=13),y>=64&&(k+=7,y>>>=7),y>=8&&(k+=4,y>>>=4),y>=2&&(k+=2,y>>>=2),k+y},a.prototype._zeroBits=function(l){if(l===0)return 26;var y=l,k=0;return y&8191||(k+=13,y>>>=13),y&127||(k+=7,y>>>=7),y&15||(k+=4,y>>>=4),y&3||(k+=2,y>>>=2),y&1||k++,k},a.prototype.bitLength=function(){var l=this.words[this.length-1],y=this._countBits(l);return(this.length-1)*26+y};function L(R){for(var l=new Array(R.bitLength()),y=0;y<l.length;y++){var k=y/26|0,A=y%26;l[y]=R.words[k]>>>A&1}return l}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,y=0;y<this.length;y++){var k=this._zeroBits(this.words[y]);if(l+=k,k!==26)break}return l},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(l){return this.negative!==0?this.abs().inotn(l).iaddn(1):this.clone()},a.prototype.fromTwos=function(l){return this.testn(l-1)?this.notn(l).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(l){for(;this.length<l.length;)this.words[this.length++]=0;for(var y=0;y<l.length;y++)this.words[y]=this.words[y]|l.words[y];return this._strip()},a.prototype.ior=function(l){return n((this.negative|l.negative)===0),this.iuor(l)},a.prototype.or=function(l){return this.length>l.length?this.clone().ior(l):l.clone().ior(this)},a.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},a.prototype.iuand=function(l){var y;this.length>l.length?y=l:y=this;for(var k=0;k<y.length;k++)this.words[k]=this.words[k]&l.words[k];return this.length=y.length,this._strip()},a.prototype.iand=function(l){return n((this.negative|l.negative)===0),this.iuand(l)},a.prototype.and=function(l){return this.length>l.length?this.clone().iand(l):l.clone().iand(this)},a.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},a.prototype.iuxor=function(l){var y,k;this.length>l.length?(y=this,k=l):(y=l,k=this);for(var A=0;A<k.length;A++)this.words[A]=y.words[A]^k.words[A];if(this!==y)for(;A<y.length;A++)this.words[A]=y.words[A];return this.length=y.length,this._strip()},a.prototype.ixor=function(l){return n((this.negative|l.negative)===0),this.iuxor(l)},a.prototype.xor=function(l){return this.length>l.length?this.clone().ixor(l):l.clone().ixor(this)},a.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},a.prototype.inotn=function(l){n(typeof l=="number"&&l>=0);var y=Math.ceil(l/26)|0,k=l%26;this._expand(y),k>0&&y--;for(var A=0;A<y;A++)this.words[A]=~this.words[A]&67108863;return k>0&&(this.words[A]=~this.words[A]&67108863>>26-k),this._strip()},a.prototype.notn=function(l){return this.clone().inotn(l)},a.prototype.setn=function(l,y){n(typeof l=="number"&&l>=0);var k=l/26|0,A=l%26;return this._expand(k+1),y?this.words[k]=this.words[k]|1<<A:this.words[k]=this.words[k]&~(1<<A),this._strip()},a.prototype.iadd=function(l){var y;if(this.negative!==0&&l.negative===0)return this.negative=0,y=this.isub(l),this.negative^=1,this._normSign();if(this.negative===0&&l.negative!==0)return l.negative=0,y=this.isub(l),l.negative=1,y._normSign();var k,A;this.length>l.length?(k=this,A=l):(k=l,A=this);for(var S=0,B=0;B<A.length;B++)y=(k.words[B]|0)+(A.words[B]|0)+S,this.words[B]=y&67108863,S=y>>>26;for(;S!==0&&B<k.length;B++)y=(k.words[B]|0)+S,this.words[B]=y&67108863,S=y>>>26;if(this.length=k.length,S!==0)this.words[this.length]=S,this.length++;else if(k!==this)for(;B<k.length;B++)this.words[B]=k.words[B];return this},a.prototype.add=function(l){var y;return l.negative!==0&&this.negative===0?(l.negative=0,y=this.sub(l),l.negative^=1,y):l.negative===0&&this.negative!==0?(this.negative=0,y=l.sub(this),this.negative=1,y):this.length>l.length?this.clone().iadd(l):l.clone().iadd(this)},a.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var y=this.iadd(l);return l.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var k=this.cmp(l);if(k===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,S;k>0?(A=this,S=l):(A=l,S=this);for(var B=0,P=0;P<S.length;P++)y=(A.words[P]|0)-(S.words[P]|0)+B,B=y>>26,this.words[P]=y&67108863;for(;B!==0&&P<A.length;P++)y=(A.words[P]|0)+B,B=y>>26,this.words[P]=y&67108863;if(B===0&&P<A.length&&A!==this)for(;P<A.length;P++)this.words[P]=A.words[P];return this.length=Math.max(this.length,P),A!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(l){return this.clone().isub(l)};function C(R,l,y){y.negative=l.negative^R.negative;var k=R.length+l.length|0;y.length=k,k=k-1|0;var A=R.words[0]|0,S=l.words[0]|0,B=A*S,P=B&67108863,w=B/67108864|0;y.words[0]=P;for(var d=1;d<k;d++){for(var v=w>>>26,Y=w&67108863,J=Math.min(d,l.length-1),X=Math.max(0,d-R.length+1);X<=J;X++){var ft=d-X|0;A=R.words[ft]|0,S=l.words[X]|0,B=A*S+Y,v+=B/67108864|0,Y=B&67108863}y.words[d]=Y|0,w=v|0}return w!==0?y.words[d]=w|0:y.length--,y._strip()}var $=function(l,y,k){var A=l.words,S=y.words,B=k.words,P=0,w,d,v,Y=A[0]|0,J=Y&8191,X=Y>>>13,ft=A[1]|0,st=ft&8191,ht=ft>>>13,Wt=A[2]|0,wt=Wt&8191,yt=Wt>>>13,mt=A[3]|0,dt=mt&8191,Mt=mt>>>13,Oe=A[4]|0,_t=Oe&8191,qt=Oe>>>13,ur=A[5]|0,Nt=ur&8191,vt=ur>>>13,It=A[6]|0,Rt=It&8191,Dt=It>>>13,Ft=A[7]|0,Kt=Ft&8191,c=Ft>>>13,r=A[8]|0,i=r&8191,h=r>>>13,g=A[9]|0,m=g&8191,x=g>>>13,K=S[0]|0,Z=K&8191,G=K>>>13,it=S[1]|0,V=it&8191,ee=it>>>13,_c=S[2]|0,re=_c&8191,ne=_c>>>13,Rc=S[3]|0,ie=Rc&8191,oe=Rc>>>13,Tc=S[4]|0,se=Tc&8191,ae=Tc>>>13,Mc=S[5]|0,ce=Mc&8191,ue=Mc>>>13,Pc=S[6]|0,fe=Pc&8191,he=Pc>>>13,Lc=S[7]|0,le=Lc&8191,de=Lc>>>13,Uc=S[8]|0,pe=Uc&8191,ge=Uc>>>13,Cc=S[9]|0,ye=Cc&8191,me=Cc>>>13;k.negative=l.negative^y.negative,k.length=19,w=Math.imul(J,Z),d=Math.imul(J,G),d=d+Math.imul(X,Z)|0,v=Math.imul(X,G);var Oo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Oo>>>26)|0,Oo&=67108863,w=Math.imul(st,Z),d=Math.imul(st,G),d=d+Math.imul(ht,Z)|0,v=Math.imul(ht,G),w=w+Math.imul(J,V)|0,d=d+Math.imul(J,ee)|0,d=d+Math.imul(X,V)|0,v=v+Math.imul(X,ee)|0;var No=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(No>>>26)|0,No&=67108863,w=Math.imul(wt,Z),d=Math.imul(wt,G),d=d+Math.imul(yt,Z)|0,v=Math.imul(yt,G),w=w+Math.imul(st,V)|0,d=d+Math.imul(st,ee)|0,d=d+Math.imul(ht,V)|0,v=v+Math.imul(ht,ee)|0,w=w+Math.imul(J,re)|0,d=d+Math.imul(J,ne)|0,d=d+Math.imul(X,re)|0,v=v+Math.imul(X,ne)|0;var zo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(zo>>>26)|0,zo&=67108863,w=Math.imul(dt,Z),d=Math.imul(dt,G),d=d+Math.imul(Mt,Z)|0,v=Math.imul(Mt,G),w=w+Math.imul(wt,V)|0,d=d+Math.imul(wt,ee)|0,d=d+Math.imul(yt,V)|0,v=v+Math.imul(yt,ee)|0,w=w+Math.imul(st,re)|0,d=d+Math.imul(st,ne)|0,d=d+Math.imul(ht,re)|0,v=v+Math.imul(ht,ne)|0,w=w+Math.imul(J,ie)|0,d=d+Math.imul(J,oe)|0,d=d+Math.imul(X,ie)|0,v=v+Math.imul(X,oe)|0;var Do=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Do>>>26)|0,Do&=67108863,w=Math.imul(_t,Z),d=Math.imul(_t,G),d=d+Math.imul(qt,Z)|0,v=Math.imul(qt,G),w=w+Math.imul(dt,V)|0,d=d+Math.imul(dt,ee)|0,d=d+Math.imul(Mt,V)|0,v=v+Math.imul(Mt,ee)|0,w=w+Math.imul(wt,re)|0,d=d+Math.imul(wt,ne)|0,d=d+Math.imul(yt,re)|0,v=v+Math.imul(yt,ne)|0,w=w+Math.imul(st,ie)|0,d=d+Math.imul(st,oe)|0,d=d+Math.imul(ht,ie)|0,v=v+Math.imul(ht,oe)|0,w=w+Math.imul(J,se)|0,d=d+Math.imul(J,ae)|0,d=d+Math.imul(X,se)|0,v=v+Math.imul(X,ae)|0;var $o=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+($o>>>26)|0,$o&=67108863,w=Math.imul(Nt,Z),d=Math.imul(Nt,G),d=d+Math.imul(vt,Z)|0,v=Math.imul(vt,G),w=w+Math.imul(_t,V)|0,d=d+Math.imul(_t,ee)|0,d=d+Math.imul(qt,V)|0,v=v+Math.imul(qt,ee)|0,w=w+Math.imul(dt,re)|0,d=d+Math.imul(dt,ne)|0,d=d+Math.imul(Mt,re)|0,v=v+Math.imul(Mt,ne)|0,w=w+Math.imul(wt,ie)|0,d=d+Math.imul(wt,oe)|0,d=d+Math.imul(yt,ie)|0,v=v+Math.imul(yt,oe)|0,w=w+Math.imul(st,se)|0,d=d+Math.imul(st,ae)|0,d=d+Math.imul(ht,se)|0,v=v+Math.imul(ht,ae)|0,w=w+Math.imul(J,ce)|0,d=d+Math.imul(J,ue)|0,d=d+Math.imul(X,ce)|0,v=v+Math.imul(X,ue)|0;var Wo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Wo>>>26)|0,Wo&=67108863,w=Math.imul(Rt,Z),d=Math.imul(Rt,G),d=d+Math.imul(Dt,Z)|0,v=Math.imul(Dt,G),w=w+Math.imul(Nt,V)|0,d=d+Math.imul(Nt,ee)|0,d=d+Math.imul(vt,V)|0,v=v+Math.imul(vt,ee)|0,w=w+Math.imul(_t,re)|0,d=d+Math.imul(_t,ne)|0,d=d+Math.imul(qt,re)|0,v=v+Math.imul(qt,ne)|0,w=w+Math.imul(dt,ie)|0,d=d+Math.imul(dt,oe)|0,d=d+Math.imul(Mt,ie)|0,v=v+Math.imul(Mt,oe)|0,w=w+Math.imul(wt,se)|0,d=d+Math.imul(wt,ae)|0,d=d+Math.imul(yt,se)|0,v=v+Math.imul(yt,ae)|0,w=w+Math.imul(st,ce)|0,d=d+Math.imul(st,ue)|0,d=d+Math.imul(ht,ce)|0,v=v+Math.imul(ht,ue)|0,w=w+Math.imul(J,fe)|0,d=d+Math.imul(J,he)|0,d=d+Math.imul(X,fe)|0,v=v+Math.imul(X,he)|0;var Ko=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Ko>>>26)|0,Ko&=67108863,w=Math.imul(Kt,Z),d=Math.imul(Kt,G),d=d+Math.imul(c,Z)|0,v=Math.imul(c,G),w=w+Math.imul(Rt,V)|0,d=d+Math.imul(Rt,ee)|0,d=d+Math.imul(Dt,V)|0,v=v+Math.imul(Dt,ee)|0,w=w+Math.imul(Nt,re)|0,d=d+Math.imul(Nt,ne)|0,d=d+Math.imul(vt,re)|0,v=v+Math.imul(vt,ne)|0,w=w+Math.imul(_t,ie)|0,d=d+Math.imul(_t,oe)|0,d=d+Math.imul(qt,ie)|0,v=v+Math.imul(qt,oe)|0,w=w+Math.imul(dt,se)|0,d=d+Math.imul(dt,ae)|0,d=d+Math.imul(Mt,se)|0,v=v+Math.imul(Mt,ae)|0,w=w+Math.imul(wt,ce)|0,d=d+Math.imul(wt,ue)|0,d=d+Math.imul(yt,ce)|0,v=v+Math.imul(yt,ue)|0,w=w+Math.imul(st,fe)|0,d=d+Math.imul(st,he)|0,d=d+Math.imul(ht,fe)|0,v=v+Math.imul(ht,he)|0,w=w+Math.imul(J,le)|0,d=d+Math.imul(J,de)|0,d=d+Math.imul(X,le)|0,v=v+Math.imul(X,de)|0;var qo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(qo>>>26)|0,qo&=67108863,w=Math.imul(i,Z),d=Math.imul(i,G),d=d+Math.imul(h,Z)|0,v=Math.imul(h,G),w=w+Math.imul(Kt,V)|0,d=d+Math.imul(Kt,ee)|0,d=d+Math.imul(c,V)|0,v=v+Math.imul(c,ee)|0,w=w+Math.imul(Rt,re)|0,d=d+Math.imul(Rt,ne)|0,d=d+Math.imul(Dt,re)|0,v=v+Math.imul(Dt,ne)|0,w=w+Math.imul(Nt,ie)|0,d=d+Math.imul(Nt,oe)|0,d=d+Math.imul(vt,ie)|0,v=v+Math.imul(vt,oe)|0,w=w+Math.imul(_t,se)|0,d=d+Math.imul(_t,ae)|0,d=d+Math.imul(qt,se)|0,v=v+Math.imul(qt,ae)|0,w=w+Math.imul(dt,ce)|0,d=d+Math.imul(dt,ue)|0,d=d+Math.imul(Mt,ce)|0,v=v+Math.imul(Mt,ue)|0,w=w+Math.imul(wt,fe)|0,d=d+Math.imul(wt,he)|0,d=d+Math.imul(yt,fe)|0,v=v+Math.imul(yt,he)|0,w=w+Math.imul(st,le)|0,d=d+Math.imul(st,de)|0,d=d+Math.imul(ht,le)|0,v=v+Math.imul(ht,de)|0,w=w+Math.imul(J,pe)|0,d=d+Math.imul(J,ge)|0,d=d+Math.imul(X,pe)|0,v=v+Math.imul(X,ge)|0;var Ho=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Ho>>>26)|0,Ho&=67108863,w=Math.imul(m,Z),d=Math.imul(m,G),d=d+Math.imul(x,Z)|0,v=Math.imul(x,G),w=w+Math.imul(i,V)|0,d=d+Math.imul(i,ee)|0,d=d+Math.imul(h,V)|0,v=v+Math.imul(h,ee)|0,w=w+Math.imul(Kt,re)|0,d=d+Math.imul(Kt,ne)|0,d=d+Math.imul(c,re)|0,v=v+Math.imul(c,ne)|0,w=w+Math.imul(Rt,ie)|0,d=d+Math.imul(Rt,oe)|0,d=d+Math.imul(Dt,ie)|0,v=v+Math.imul(Dt,oe)|0,w=w+Math.imul(Nt,se)|0,d=d+Math.imul(Nt,ae)|0,d=d+Math.imul(vt,se)|0,v=v+Math.imul(vt,ae)|0,w=w+Math.imul(_t,ce)|0,d=d+Math.imul(_t,ue)|0,d=d+Math.imul(qt,ce)|0,v=v+Math.imul(qt,ue)|0,w=w+Math.imul(dt,fe)|0,d=d+Math.imul(dt,he)|0,d=d+Math.imul(Mt,fe)|0,v=v+Math.imul(Mt,he)|0,w=w+Math.imul(wt,le)|0,d=d+Math.imul(wt,de)|0,d=d+Math.imul(yt,le)|0,v=v+Math.imul(yt,de)|0,w=w+Math.imul(st,pe)|0,d=d+Math.imul(st,ge)|0,d=d+Math.imul(ht,pe)|0,v=v+Math.imul(ht,ge)|0,w=w+Math.imul(J,ye)|0,d=d+Math.imul(J,me)|0,d=d+Math.imul(X,ye)|0,v=v+Math.imul(X,me)|0;var Vo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Vo>>>26)|0,Vo&=67108863,w=Math.imul(m,V),d=Math.imul(m,ee),d=d+Math.imul(x,V)|0,v=Math.imul(x,ee),w=w+Math.imul(i,re)|0,d=d+Math.imul(i,ne)|0,d=d+Math.imul(h,re)|0,v=v+Math.imul(h,ne)|0,w=w+Math.imul(Kt,ie)|0,d=d+Math.imul(Kt,oe)|0,d=d+Math.imul(c,ie)|0,v=v+Math.imul(c,oe)|0,w=w+Math.imul(Rt,se)|0,d=d+Math.imul(Rt,ae)|0,d=d+Math.imul(Dt,se)|0,v=v+Math.imul(Dt,ae)|0,w=w+Math.imul(Nt,ce)|0,d=d+Math.imul(Nt,ue)|0,d=d+Math.imul(vt,ce)|0,v=v+Math.imul(vt,ue)|0,w=w+Math.imul(_t,fe)|0,d=d+Math.imul(_t,he)|0,d=d+Math.imul(qt,fe)|0,v=v+Math.imul(qt,he)|0,w=w+Math.imul(dt,le)|0,d=d+Math.imul(dt,de)|0,d=d+Math.imul(Mt,le)|0,v=v+Math.imul(Mt,de)|0,w=w+Math.imul(wt,pe)|0,d=d+Math.imul(wt,ge)|0,d=d+Math.imul(yt,pe)|0,v=v+Math.imul(yt,ge)|0,w=w+Math.imul(st,ye)|0,d=d+Math.imul(st,me)|0,d=d+Math.imul(ht,ye)|0,v=v+Math.imul(ht,me)|0;var jo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(jo>>>26)|0,jo&=67108863,w=Math.imul(m,re),d=Math.imul(m,ne),d=d+Math.imul(x,re)|0,v=Math.imul(x,ne),w=w+Math.imul(i,ie)|0,d=d+Math.imul(i,oe)|0,d=d+Math.imul(h,ie)|0,v=v+Math.imul(h,oe)|0,w=w+Math.imul(Kt,se)|0,d=d+Math.imul(Kt,ae)|0,d=d+Math.imul(c,se)|0,v=v+Math.imul(c,ae)|0,w=w+Math.imul(Rt,ce)|0,d=d+Math.imul(Rt,ue)|0,d=d+Math.imul(Dt,ce)|0,v=v+Math.imul(Dt,ue)|0,w=w+Math.imul(Nt,fe)|0,d=d+Math.imul(Nt,he)|0,d=d+Math.imul(vt,fe)|0,v=v+Math.imul(vt,he)|0,w=w+Math.imul(_t,le)|0,d=d+Math.imul(_t,de)|0,d=d+Math.imul(qt,le)|0,v=v+Math.imul(qt,de)|0,w=w+Math.imul(dt,pe)|0,d=d+Math.imul(dt,ge)|0,d=d+Math.imul(Mt,pe)|0,v=v+Math.imul(Mt,ge)|0,w=w+Math.imul(wt,ye)|0,d=d+Math.imul(wt,me)|0,d=d+Math.imul(yt,ye)|0,v=v+Math.imul(yt,me)|0;var Go=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Go>>>26)|0,Go&=67108863,w=Math.imul(m,ie),d=Math.imul(m,oe),d=d+Math.imul(x,ie)|0,v=Math.imul(x,oe),w=w+Math.imul(i,se)|0,d=d+Math.imul(i,ae)|0,d=d+Math.imul(h,se)|0,v=v+Math.imul(h,ae)|0,w=w+Math.imul(Kt,ce)|0,d=d+Math.imul(Kt,ue)|0,d=d+Math.imul(c,ce)|0,v=v+Math.imul(c,ue)|0,w=w+Math.imul(Rt,fe)|0,d=d+Math.imul(Rt,he)|0,d=d+Math.imul(Dt,fe)|0,v=v+Math.imul(Dt,he)|0,w=w+Math.imul(Nt,le)|0,d=d+Math.imul(Nt,de)|0,d=d+Math.imul(vt,le)|0,v=v+Math.imul(vt,de)|0,w=w+Math.imul(_t,pe)|0,d=d+Math.imul(_t,ge)|0,d=d+Math.imul(qt,pe)|0,v=v+Math.imul(qt,ge)|0,w=w+Math.imul(dt,ye)|0,d=d+Math.imul(dt,me)|0,d=d+Math.imul(Mt,ye)|0,v=v+Math.imul(Mt,me)|0;var Yo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Yo>>>26)|0,Yo&=67108863,w=Math.imul(m,se),d=Math.imul(m,ae),d=d+Math.imul(x,se)|0,v=Math.imul(x,ae),w=w+Math.imul(i,ce)|0,d=d+Math.imul(i,ue)|0,d=d+Math.imul(h,ce)|0,v=v+Math.imul(h,ue)|0,w=w+Math.imul(Kt,fe)|0,d=d+Math.imul(Kt,he)|0,d=d+Math.imul(c,fe)|0,v=v+Math.imul(c,he)|0,w=w+Math.imul(Rt,le)|0,d=d+Math.imul(Rt,de)|0,d=d+Math.imul(Dt,le)|0,v=v+Math.imul(Dt,de)|0,w=w+Math.imul(Nt,pe)|0,d=d+Math.imul(Nt,ge)|0,d=d+Math.imul(vt,pe)|0,v=v+Math.imul(vt,ge)|0,w=w+Math.imul(_t,ye)|0,d=d+Math.imul(_t,me)|0,d=d+Math.imul(qt,ye)|0,v=v+Math.imul(qt,me)|0;var Zo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Zo>>>26)|0,Zo&=67108863,w=Math.imul(m,ce),d=Math.imul(m,ue),d=d+Math.imul(x,ce)|0,v=Math.imul(x,ue),w=w+Math.imul(i,fe)|0,d=d+Math.imul(i,he)|0,d=d+Math.imul(h,fe)|0,v=v+Math.imul(h,he)|0,w=w+Math.imul(Kt,le)|0,d=d+Math.imul(Kt,de)|0,d=d+Math.imul(c,le)|0,v=v+Math.imul(c,de)|0,w=w+Math.imul(Rt,pe)|0,d=d+Math.imul(Rt,ge)|0,d=d+Math.imul(Dt,pe)|0,v=v+Math.imul(Dt,ge)|0,w=w+Math.imul(Nt,ye)|0,d=d+Math.imul(Nt,me)|0,d=d+Math.imul(vt,ye)|0,v=v+Math.imul(vt,me)|0;var Jo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Jo>>>26)|0,Jo&=67108863,w=Math.imul(m,fe),d=Math.imul(m,he),d=d+Math.imul(x,fe)|0,v=Math.imul(x,he),w=w+Math.imul(i,le)|0,d=d+Math.imul(i,de)|0,d=d+Math.imul(h,le)|0,v=v+Math.imul(h,de)|0,w=w+Math.imul(Kt,pe)|0,d=d+Math.imul(Kt,ge)|0,d=d+Math.imul(c,pe)|0,v=v+Math.imul(c,ge)|0,w=w+Math.imul(Rt,ye)|0,d=d+Math.imul(Rt,me)|0,d=d+Math.imul(Dt,ye)|0,v=v+Math.imul(Dt,me)|0;var Xo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Xo>>>26)|0,Xo&=67108863,w=Math.imul(m,le),d=Math.imul(m,de),d=d+Math.imul(x,le)|0,v=Math.imul(x,de),w=w+Math.imul(i,pe)|0,d=d+Math.imul(i,ge)|0,d=d+Math.imul(h,pe)|0,v=v+Math.imul(h,ge)|0,w=w+Math.imul(Kt,ye)|0,d=d+Math.imul(Kt,me)|0,d=d+Math.imul(c,ye)|0,v=v+Math.imul(c,me)|0;var Qo=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(Qo>>>26)|0,Qo&=67108863,w=Math.imul(m,pe),d=Math.imul(m,ge),d=d+Math.imul(x,pe)|0,v=Math.imul(x,ge),w=w+Math.imul(i,ye)|0,d=d+Math.imul(i,me)|0,d=d+Math.imul(h,ye)|0,v=v+Math.imul(h,me)|0;var ts=(P+w|0)+((d&8191)<<13)|0;P=(v+(d>>>13)|0)+(ts>>>26)|0,ts&=67108863,w=Math.imul(m,ye),d=Math.imul(m,me),d=d+Math.imul(x,ye)|0,v=Math.imul(x,me);var es=(P+w|0)+((d&8191)<<13)|0;return P=(v+(d>>>13)|0)+(es>>>26)|0,es&=67108863,B[0]=Oo,B[1]=No,B[2]=zo,B[3]=Do,B[4]=$o,B[5]=Wo,B[6]=Ko,B[7]=qo,B[8]=Ho,B[9]=Vo,B[10]=jo,B[11]=Go,B[12]=Yo,B[13]=Zo,B[14]=Jo,B[15]=Xo,B[16]=Qo,B[17]=ts,B[18]=es,P!==0&&(B[19]=P,k.length++),k};Math.imul||($=C);function N(R,l,y){y.negative=l.negative^R.negative,y.length=R.length+l.length;for(var k=0,A=0,S=0;S<y.length-1;S++){var B=A;A=0;for(var P=k&67108863,w=Math.min(S,l.length-1),d=Math.max(0,S-R.length+1);d<=w;d++){var v=S-d,Y=R.words[v]|0,J=l.words[d]|0,X=Y*J,ft=X&67108863;B=B+(X/67108864|0)|0,ft=ft+P|0,P=ft&67108863,B=B+(ft>>>26)|0,A+=B>>>26,B&=67108863}y.words[S]=P,k=B,B=A}return k!==0?y.words[S]=k:y.length--,y._strip()}function H(R,l,y){return N(R,l,y)}a.prototype.mulTo=function(l,y){var k,A=this.length+l.length;return this.length===10&&l.length===10?k=$(this,l,y):A<63?k=C(this,l,y):A<1024?k=N(this,l,y):k=H(this,l,y),k},a.prototype.mul=function(l){var y=new a(null);return y.words=new Array(this.length+l.length),this.mulTo(l,y)},a.prototype.mulf=function(l){var y=new a(null);return y.words=new Array(this.length+l.length),H(this,l,y)},a.prototype.imul=function(l){return this.clone().mulTo(l,this)},a.prototype.imuln=function(l){var y=l<0;y&&(l=-l),n(typeof l=="number"),n(l<67108864);for(var k=0,A=0;A<this.length;A++){var S=(this.words[A]|0)*l,B=(S&67108863)+(k&67108863);k>>=26,k+=S/67108864|0,k+=B>>>26,this.words[A]=B&67108863}return k!==0&&(this.words[A]=k,this.length++),y?this.ineg():this},a.prototype.muln=function(l){return this.clone().imuln(l)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(l){var y=L(l);if(y.length===0)return new a(1);for(var k=this,A=0;A<y.length&&y[A]===0;A++,k=k.sqr());if(++A<y.length)for(var S=k.sqr();A<y.length;A++,S=S.sqr())y[A]!==0&&(k=k.mul(S));return k},a.prototype.iushln=function(l){n(typeof l=="number"&&l>=0);var y=l%26,k=(l-y)/26,A=67108863>>>26-y<<26-y,S;if(y!==0){var B=0;for(S=0;S<this.length;S++){var P=this.words[S]&A,w=(this.words[S]|0)-P<<y;this.words[S]=w|B,B=P>>>26-y}B&&(this.words[S]=B,this.length++)}if(k!==0){for(S=this.length-1;S>=0;S--)this.words[S+k]=this.words[S];for(S=0;S<k;S++)this.words[S]=0;this.length+=k}return this._strip()},a.prototype.ishln=function(l){return n(this.negative===0),this.iushln(l)},a.prototype.iushrn=function(l,y,k){n(typeof l=="number"&&l>=0);var A;y?A=(y-y%26)/26:A=0;var S=l%26,B=Math.min((l-S)/26,this.length),P=67108863^67108863>>>S<<S,w=k;if(A-=B,A=Math.max(0,A),w){for(var d=0;d<B;d++)w.words[d]=this.words[d];w.length=B}if(B!==0)if(this.length>B)for(this.length-=B,d=0;d<this.length;d++)this.words[d]=this.words[d+B];else this.words[0]=0,this.length=1;var v=0;for(d=this.length-1;d>=0&&(v!==0||d>=A);d--){var Y=this.words[d]|0;this.words[d]=v<<26-S|Y>>>S,v=Y&P}return w&&v!==0&&(w.words[w.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(l,y,k){return n(this.negative===0),this.iushrn(l,y,k)},a.prototype.shln=function(l){return this.clone().ishln(l)},a.prototype.ushln=function(l){return this.clone().iushln(l)},a.prototype.shrn=function(l){return this.clone().ishrn(l)},a.prototype.ushrn=function(l){return this.clone().iushrn(l)},a.prototype.testn=function(l){n(typeof l=="number"&&l>=0);var y=l%26,k=(l-y)/26,A=1<<y;if(this.length<=k)return!1;var S=this.words[k];return!!(S&A)},a.prototype.imaskn=function(l){n(typeof l=="number"&&l>=0);var y=l%26,k=(l-y)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(y!==0&&k++,this.length=Math.min(k,this.length),y!==0){var A=67108863^67108863>>>y<<y;this.words[this.length-1]&=A}return this._strip()},a.prototype.maskn=function(l){return this.clone().imaskn(l)},a.prototype.iaddn=function(l){return n(typeof l=="number"),n(l<67108864),l<0?this.isubn(-l):this.negative!==0?this.length===1&&(this.words[0]|0)<=l?(this.words[0]=l-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(l),this.negative=1,this):this._iaddn(l)},a.prototype._iaddn=function(l){this.words[0]+=l;for(var y=0;y<this.length&&this.words[y]>=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},a.prototype.isubn=function(l){if(n(typeof l=="number"),n(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},a.prototype.addn=function(l){return this.clone().iaddn(l)},a.prototype.subn=function(l){return this.clone().isubn(l)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(l,y,k){var A=l.length+k,S;this._expand(A);var B,P=0;for(S=0;S<l.length;S++){B=(this.words[S+k]|0)+P;var w=(l.words[S]|0)*y;B-=w&67108863,P=(B>>26)-(w/67108864|0),this.words[S+k]=B&67108863}for(;S<this.length-k;S++)B=(this.words[S+k]|0)+P,P=B>>26,this.words[S+k]=B&67108863;if(P===0)return this._strip();for(n(P===-1),P=0,S=0;S<this.length;S++)B=-(this.words[S]|0)+P,P=B>>26,this.words[S]=B&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(l,y){var k=this.length-l.length,A=this.clone(),S=l,B=S.words[S.length-1]|0,P=this._countBits(B);k=26-P,k!==0&&(S=S.ushln(k),A.iushln(k),B=S.words[S.length-1]|0);var w=A.length-S.length,d;if(y!=="mod"){d=new a(null),d.length=w+1,d.words=new Array(d.length);for(var v=0;v<d.length;v++)d.words[v]=0}var Y=A.clone()._ishlnsubmul(S,1,w);Y.negative===0&&(A=Y,d&&(d.words[w]=1));for(var J=w-1;J>=0;J--){var X=(A.words[S.length+J]|0)*67108864+(A.words[S.length+J-1]|0);for(X=Math.min(X/B|0,67108863),A._ishlnsubmul(S,X,J);A.negative!==0;)X--,A.negative=0,A._ishlnsubmul(S,1,J),A.isZero()||(A.negative^=1);d&&(d.words[J]=X)}return d&&d._strip(),A._strip(),y!=="div"&&k!==0&&A.iushrn(k),{div:d||null,mod:A}},a.prototype.divmod=function(l,y,k){if(n(!l.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var A,S,B;return this.negative!==0&&l.negative===0?(B=this.neg().divmod(l,y),y!=="mod"&&(A=B.div.neg()),y!=="div"&&(S=B.mod.neg(),k&&S.negative!==0&&S.iadd(l)),{div:A,mod:S}):this.negative===0&&l.negative!==0?(B=this.divmod(l.neg(),y),y!=="mod"&&(A=B.div.neg()),{div:A,mod:B.mod}):this.negative&l.negative?(B=this.neg().divmod(l.neg(),y),y!=="div"&&(S=B.mod.neg(),k&&S.negative!==0&&S.isub(l)),{div:B.div,mod:S}):l.length>this.length||this.cmp(l)<0?{div:new a(0),mod:this}:l.length===1?y==="div"?{div:this.divn(l.words[0]),mod:null}:y==="mod"?{div:null,mod:new a(this.modrn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new a(this.modrn(l.words[0]))}:this._wordDiv(l,y)},a.prototype.div=function(l){return this.divmod(l,"div",!1).div},a.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},a.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},a.prototype.divRound=function(l){var y=this.divmod(l);if(y.mod.isZero())return y.div;var k=y.div.negative!==0?y.mod.isub(l):y.mod,A=l.ushrn(1),S=l.andln(1),B=k.cmp(A);return B<0||S===1&&B===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},a.prototype.modrn=function(l){var y=l<0;y&&(l=-l),n(l<=67108863);for(var k=(1<<26)%l,A=0,S=this.length-1;S>=0;S--)A=(k*A+(this.words[S]|0))%l;return y?-A:A},a.prototype.modn=function(l){return this.modrn(l)},a.prototype.idivn=function(l){var y=l<0;y&&(l=-l),n(l<=67108863);for(var k=0,A=this.length-1;A>=0;A--){var S=(this.words[A]|0)+k*67108864;this.words[A]=S/l|0,k=S%l}return this._strip(),y?this.ineg():this},a.prototype.divn=function(l){return this.clone().idivn(l)},a.prototype.egcd=function(l){n(l.negative===0),n(!l.isZero());var y=this,k=l.clone();y.negative!==0?y=y.umod(l):y=y.clone();for(var A=new a(1),S=new a(0),B=new a(0),P=new a(1),w=0;y.isEven()&&k.isEven();)y.iushrn(1),k.iushrn(1),++w;for(var d=k.clone(),v=y.clone();!y.isZero();){for(var Y=0,J=1;!(y.words[0]&J)&&Y<26;++Y,J<<=1);if(Y>0)for(y.iushrn(Y);Y-- >0;)(A.isOdd()||S.isOdd())&&(A.iadd(d),S.isub(v)),A.iushrn(1),S.iushrn(1);for(var X=0,ft=1;!(k.words[0]&ft)&&X<26;++X,ft<<=1);if(X>0)for(k.iushrn(X);X-- >0;)(B.isOdd()||P.isOdd())&&(B.iadd(d),P.isub(v)),B.iushrn(1),P.iushrn(1);y.cmp(k)>=0?(y.isub(k),A.isub(B),S.isub(P)):(k.isub(y),B.isub(A),P.isub(S))}return{a:B,b:P,gcd:k.iushln(w)}},a.prototype._invmp=function(l){n(l.negative===0),n(!l.isZero());var y=this,k=l.clone();y.negative!==0?y=y.umod(l):y=y.clone();for(var A=new a(1),S=new a(0),B=k.clone();y.cmpn(1)>0&&k.cmpn(1)>0;){for(var P=0,w=1;!(y.words[0]&w)&&P<26;++P,w<<=1);if(P>0)for(y.iushrn(P);P-- >0;)A.isOdd()&&A.iadd(B),A.iushrn(1);for(var d=0,v=1;!(k.words[0]&v)&&d<26;++d,v<<=1);if(d>0)for(k.iushrn(d);d-- >0;)S.isOdd()&&S.iadd(B),S.iushrn(1);y.cmp(k)>=0?(y.isub(k),A.isub(S)):(k.isub(y),S.isub(A))}var Y;return y.cmpn(1)===0?Y=A:Y=S,Y.cmpn(0)<0&&Y.iadd(l),Y},a.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var y=this.clone(),k=l.clone();y.negative=0,k.negative=0;for(var A=0;y.isEven()&&k.isEven();A++)y.iushrn(1),k.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;k.isEven();)k.iushrn(1);var S=y.cmp(k);if(S<0){var B=y;y=k,k=B}else if(S===0||k.cmpn(1)===0)break;y.isub(k)}while(!0);return k.iushln(A)},a.prototype.invm=function(l){return this.egcd(l).a.umod(l)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(l){return this.words[0]&l},a.prototype.bincn=function(l){n(typeof l=="number");var y=l%26,k=(l-y)/26,A=1<<y;if(this.length<=k)return this._expand(k+1),this.words[k]|=A,this;for(var S=A,B=k;S!==0&&B<this.length;B++){var P=this.words[B]|0;P+=S,S=P>>>26,P&=67108863,this.words[B]=P}return S!==0&&(this.words[B]=S,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(l){var y=l<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var k;if(this.length>1)k=1;else{y&&(l=-l),n(l<=67108863,"Number is too big");var A=this.words[0]|0;k=A===l?0:A<l?-1:1}return this.negative!==0?-k|0:k},a.prototype.cmp=function(l){if(this.negative!==0&&l.negative===0)return-1;if(this.negative===0&&l.negative!==0)return 1;var y=this.ucmp(l);return this.negative!==0?-y|0:y},a.prototype.ucmp=function(l){if(this.length>l.length)return 1;if(this.length<l.length)return-1;for(var y=0,k=this.length-1;k>=0;k--){var A=this.words[k]|0,S=l.words[k]|0;if(A!==S){A<S?y=-1:A>S&&(y=1);break}}return y},a.prototype.gtn=function(l){return this.cmpn(l)===1},a.prototype.gt=function(l){return this.cmp(l)===1},a.prototype.gten=function(l){return this.cmpn(l)>=0},a.prototype.gte=function(l){return this.cmp(l)>=0},a.prototype.ltn=function(l){return this.cmpn(l)===-1},a.prototype.lt=function(l){return this.cmp(l)===-1},a.prototype.lten=function(l){return this.cmpn(l)<=0},a.prototype.lte=function(l){return this.cmp(l)<=0},a.prototype.eqn=function(l){return this.cmpn(l)===0},a.prototype.eq=function(l){return this.cmp(l)===0},a.red=function(l){return new ot(l)},a.prototype.toRed=function(l){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},a.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(l){return this.red=l,this},a.prototype.forceRed=function(l){return n(!this.red,"Already a number in reduction context"),this._forceRed(l)},a.prototype.redAdd=function(l){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},a.prototype.redIAdd=function(l){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},a.prototype.redSub=function(l){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},a.prototype.redISub=function(l){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},a.prototype.redShl=function(l){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},a.prototype.redMul=function(l){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},a.prototype.redIMul=function(l){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},a.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(l){return n(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var D={k256:null,p224:null,p192:null,p25519:null};function F(R,l){this.name=R,this.p=new a(l,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F.prototype._tmp=function(){var l=new a(null);return l.words=new Array(Math.ceil(this.n/13)),l},F.prototype.ireduce=function(l){var y=l,k;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),k=y.bitLength();while(k>this.n);var A=k<this.n?-1:y.ucmp(this.p);return A===0?(y.words[0]=0,y.length=1):A>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},F.prototype.split=function(l,y){l.iushrn(this.n,0,y)},F.prototype.imulK=function(l){return l.imul(this.k)};function W(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(W,F),W.prototype.split=function(l,y){for(var k=4194303,A=Math.min(l.length,9),S=0;S<A;S++)y.words[S]=l.words[S];if(y.length=A,l.length<=9){l.words[0]=0,l.length=1;return}var B=l.words[9];for(y.words[y.length++]=B&k,S=10;S<l.length;S++){var P=l.words[S]|0;l.words[S-10]=(P&k)<<4|B>>>22,B=P}B>>>=22,l.words[S-10]=B,B===0&&l.length>10?l.length-=10:l.length-=9},W.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var y=0,k=0;k<l.length;k++){var A=l.words[k]|0;y+=A*977,l.words[k]=y&67108863,y=A*64+(y/67108864|0)}return l.words[l.length-1]===0&&(l.length--,l.words[l.length-1]===0&&l.length--),l};function q(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(q,F);function Bt(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(Bt,F);function gt(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(gt,F),gt.prototype.imulK=function(l){for(var y=0,k=0;k<l.length;k++){var A=(l.words[k]|0)*19+y,S=A&67108863;A>>>=26,l.words[k]=S,y=A}return y!==0&&(l.words[l.length++]=y),l},a._prime=function(l){if(D[l])return D[l];var y;if(l==="k256")y=new W;else if(l==="p224")y=new q;else if(l==="p192")y=new Bt;else if(l==="p25519")y=new gt;else throw new Error("Unknown prime "+l);return D[l]=y,y};function ot(R){if(typeof R=="string"){var l=a._prime(R);this.m=l.p,this.prime=l}else n(R.gtn(1),"modulus must be greater than 1"),this.m=R,this.prime=null}ot.prototype._verify1=function(l){n(l.negative===0,"red works only with positives"),n(l.red,"red works only with red numbers")},ot.prototype._verify2=function(l,y){n((l.negative|y.negative)===0,"red works only with positives"),n(l.red&&l.red===y.red,"red works only with red numbers")},ot.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):(E(l,l.umod(this.m)._forceRed(this)),l)},ot.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},ot.prototype.add=function(l,y){this._verify2(l,y);var k=l.add(y);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},ot.prototype.iadd=function(l,y){this._verify2(l,y);var k=l.iadd(y);return k.cmp(this.m)>=0&&k.isub(this.m),k},ot.prototype.sub=function(l,y){this._verify2(l,y);var k=l.sub(y);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},ot.prototype.isub=function(l,y){this._verify2(l,y);var k=l.isub(y);return k.cmpn(0)<0&&k.iadd(this.m),k},ot.prototype.shl=function(l,y){return this._verify1(l),this.imod(l.ushln(y))},ot.prototype.imul=function(l,y){return this._verify2(l,y),this.imod(l.imul(y))},ot.prototype.mul=function(l,y){return this._verify2(l,y),this.imod(l.mul(y))},ot.prototype.isqr=function(l){return this.imul(l,l.clone())},ot.prototype.sqr=function(l){return this.mul(l,l)},ot.prototype.sqrt=function(l){if(l.isZero())return l.clone();var y=this.m.andln(3);if(n(y%2===1),y===3){var k=this.m.add(new a(1)).iushrn(2);return this.pow(l,k)}for(var A=this.m.subn(1),S=0;!A.isZero()&&A.andln(1)===0;)S++,A.iushrn(1);n(!A.isZero());var B=new a(1).toRed(this),P=B.redNeg(),w=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new a(2*d*d).toRed(this);this.pow(d,w).cmp(P)!==0;)d.redIAdd(P);for(var v=this.pow(d,A),Y=this.pow(l,A.addn(1).iushrn(1)),J=this.pow(l,A),X=S;J.cmp(B)!==0;){for(var ft=J,st=0;ft.cmp(B)!==0;st++)ft=ft.redSqr();n(st<X);var ht=this.pow(v,new a(1).iushln(X-st-1));Y=Y.redMul(ht),v=ht.redSqr(),J=J.redMul(v),X=st}return Y},ot.prototype.invm=function(l){var y=l._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},ot.prototype.pow=function(l,y){if(y.isZero())return new a(1).toRed(this);if(y.cmpn(1)===0)return l.clone();var k=4,A=new Array(1<<k);A[0]=new a(1).toRed(this),A[1]=l;for(var S=2;S<A.length;S++)A[S]=this.mul(A[S-1],l);var B=A[0],P=0,w=0,d=y.bitLength()%26;for(d===0&&(d=26),S=y.length-1;S>=0;S--){for(var v=y.words[S],Y=d-1;Y>=0;Y--){var J=v>>Y&1;if(B!==A[0]&&(B=this.sqr(B)),J===0&&P===0){w=0;continue}P<<=1,P|=J,w++,!(w!==k&&(S!==0||Y!==0))&&(B=this.mul(B,A[P]),w=0,P=0)}d=26}return B},ot.prototype.convertTo=function(l){var y=l.umod(this.m);return y===l?y.clone():y},ot.prototype.convertFrom=function(l){var y=l.clone();return y.red=null,y},a.mont=function(l){return new At(l)};function At(R){ot.call(this,R),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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(At,ot),At.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},At.prototype.convertFrom=function(l){var y=this.imod(l.mul(this.rinv));return y.red=null,y},At.prototype.imul=function(l,y){if(l.isZero()||y.isZero())return l.words[0]=0,l.length=1,l;var k=l.imul(y),A=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=k.isub(A).iushrn(this.shift),B=S;return S.cmp(this.m)>=0?B=S.isub(this.m):S.cmpn(0)<0&&(B=S.iadd(this.m)),B._forceRed(this)},At.prototype.mul=function(l,y){if(l.isZero()||y.isZero())return new a(0)._forceRed(this);var k=l.mul(y),A=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=k.isub(A).iushrn(this.shift),B=S;return S.cmp(this.m)>=0?B=S.isub(this.m):S.cmpn(0)<0&&(B=S.iadd(this.m)),B._forceRed(this)},At.prototype.invm=function(l){var y=this.imod(l._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(o,Ve)}(Ti);var Us=Ti.exports;const Cs=ln(Us);var Mi={exports:{}},Fs={};/*!
|
|
7
|
+
* The buffer module from node.js, for the browser.
|
|
8
|
+
*
|
|
9
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
10
|
+
* @license MIT
|
|
11
|
+
*/(function(o){const t=Hr,e=dn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=$,o.INSPECT_MAX_BYTES=50;const s=2147483647;o.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=a(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>s)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(c)}return p(c,r,i)}u.poolSize=8192;function p(c,r,i){if(typeof c=="string")return M(c,r);if(ArrayBuffer.isView(c))return U(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(It(c,ArrayBuffer)||c&&It(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(It(c,SharedArrayBuffer)||c&&It(c.buffer,SharedArrayBuffer)))return _(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=L(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return p(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function b(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function E(c,r,i){return b(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return E(c,r,i)};function I(c){return b(c),f(c<0?0:C(c)|0)}u.allocUnsafe=function(c){return I(c)},u.allocUnsafeSlow=function(c){return I(c)};function M(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=N(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function T(c){const r=c.length<0?0:C(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function U(c){if(It(c,Uint8Array)){const r=new Uint8Array(c);return _(r.buffer,r.byteOffset,r.byteLength)}return T(c)}function _(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function L(c){if(u.isBuffer(c)){const r=C(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||Rt(c.length)?f(0):T(c);if(c.type==="Buffer"&&Array.isArray(c.data))return T(c.data)}function C(c){if(c>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return c|0}function $(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(It(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),It(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let m=0,x=Math.min(h,g);m<x;++m)if(r[m]!==i[m]){h=r[m],g=i[m];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let m=0;for(h=0;h<r.length;++h){let x=r[h];if(It(x,Uint8Array))m+x.length>g.length?(u.isBuffer(x)||(x=u.from(x)),x.copy(g,m)):Uint8Array.prototype.set.call(g,x,m);else if(u.isBuffer(x))x.copy(g,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=x.length}return g};function N(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||It(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return _t(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return Nt(c).length;default:if(g)return h?-1:_t(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=N;function H(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return B(this,r,i);case"utf8":case"utf-8":return l(this,r,i);case"ascii":return A(this,r,i);case"latin1":case"binary":return S(this,r,i);case"base64":return R(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function D(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)D(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)D(this,i,i+3),D(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)D(this,i,i+7),D(this,i+1,i+6),D(this,i+2,i+5),D(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?l(this,0,r):H.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,m){if(It(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),m===void 0&&(m=this.length),i<0||h>r.length||g<0||m>this.length)throw new RangeError("out of range index");if(g>=m&&i>=h)return 0;if(g>=m)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,m>>>=0,this===r)return 0;let x=m-g,K=h-i;const Z=Math.min(x,K),G=this.slice(g,m),it=r.slice(i,h);for(let V=0;V<Z;++V)if(G[V]!==it[V]){x=G[V],K=it[V];break}return x<K?-1:K<x?1:0};function F(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,Rt(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:W(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):W(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function W(c,r,i,h,g){let m=1,x=c.length,K=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;m=2,x/=2,K/=2,i/=2}function Z(it,V){return m===1?it[V]:it.readUInt16BE(V*m)}let G;if(g){let it=-1;for(G=i;G<x;G++)if(Z(c,G)===Z(r,it===-1?0:G-it)){if(it===-1&&(it=G),G-it+1===K)return it*m}else it!==-1&&(G-=G-it),it=-1}else for(i+K>x&&(i=x-K),G=i;G>=0;G--){let it=!0;for(let V=0;V<K;V++)if(Z(c,G+V)!==Z(r,V)){it=!1;break}if(it)return G}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return F(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return F(this,r,i,h,!1)};function q(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const m=r.length;h>m/2&&(h=m/2);let x;for(x=0;x<h;++x){const K=parseInt(r.substr(x*2,2),16);if(Rt(K))return x;c[i+x]=K}return x}function Bt(c,r,i,h){return vt(_t(r,c.length-i),c,i,h)}function gt(c,r,i,h){return vt(qt(r),c,i,h)}function ot(c,r,i,h){return vt(Nt(r),c,i,h)}function At(c,r,i,h){return vt(ur(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const m=this.length-i;if((h===void 0||h>m)&&(h=m),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let x=!1;for(;;)switch(g){case"hex":return q(this,r,i,h);case"utf8":case"utf-8":return Bt(this,r,i,h);case"ascii":case"latin1":case"binary":return gt(this,r,i,h);case"base64":return ot(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return At(this,r,i,h);default:if(x)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),x=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function R(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function l(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const m=c[g];let x=null,K=m>239?4:m>223?3:m>191?2:1;if(g+K<=i){let Z,G,it,V;switch(K){case 1:m<128&&(x=m);break;case 2:Z=c[g+1],(Z&192)===128&&(V=(m&31)<<6|Z&63,V>127&&(x=V));break;case 3:Z=c[g+1],G=c[g+2],(Z&192)===128&&(G&192)===128&&(V=(m&15)<<12|(Z&63)<<6|G&63,V>2047&&(V<55296||V>57343)&&(x=V));break;case 4:Z=c[g+1],G=c[g+2],it=c[g+3],(Z&192)===128&&(G&192)===128&&(it&192)===128&&(V=(m&15)<<18|(Z&63)<<12|(G&63)<<6|it&63,V>65535&&V<1114112&&(x=V))}}x===null?(x=65533,K=1):x>65535&&(x-=65536,h.push(x>>>10&1023|55296),x=56320|x&1023),h.push(x),g+=K}return k(h)}const y=4096;function k(c){const r=c.length;if(r<=y)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=y));return i}function A(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function S(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function B(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let m=r;m<i;++m)g+=Dt[c[m]];return g}function P(c,r,i){const h=c.slice(r,i);let g="";for(let m=0;m<h.length-1;m+=2)g+=String.fromCharCode(h[m]+h[m+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function w(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r],m=1,x=0;for(;++x<i&&(m*=256);)g+=this[r+x]*m;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r+--i],m=1;for(;i>0&&(m*=256);)g+=this[r+--i]*m;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||w(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||w(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||w(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||w(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,m=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(m)<<BigInt(32))}),u.prototype.readBigUInt64BE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],m=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(m)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r],m=1,x=0;for(;++x<i&&(m*=256);)g+=this[r+x]*m;return m*=128,g>=m&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=i,m=1,x=this[r+--g];for(;g>0&&(m*=256);)x+=this[r+--g]*m;return m*=128,x>=m&&(x-=Math.pow(2,8*i)),x},u.prototype.readInt8=function(r,i){return r=r>>>0,i||w(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||w(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||w(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||w(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||w(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||w(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||w(r,8,this.length),e.read(this,r,!1,52,8)};function d(c,r,i,h,g,m){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<m)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const K=Math.pow(2,8*h)-1;d(this,r,i,h,K,0)}let m=1,x=0;for(this[i]=r&255;++x<h&&(m*=256);)this[i+x]=r/m&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const K=Math.pow(2,8*h)-1;d(this,r,i,h,K,0)}let m=h-1,x=1;for(this[i+m]=r&255;--m>=0&&(x*=256);)this[i+m]=r/x&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function v(c,r,i,h,g){yt(r,h,g,c,i,7);let m=Number(r&BigInt(4294967295));c[i++]=m,m=m>>8,c[i++]=m,m=m>>8,c[i++]=m,m=m>>8,c[i++]=m;let x=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=x,x=x>>8,c[i++]=x,x=x>>8,c[i++]=x,x=x>>8,c[i++]=x,i}function Y(c,r,i,h,g){yt(r,h,g,c,i,7);let m=Number(r&BigInt(4294967295));c[i+7]=m,m=m>>8,c[i+6]=m,m=m>>8,c[i+5]=m,m=m>>8,c[i+4]=m;let x=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=x,x=x>>8,c[i+2]=x,x=x>>8,c[i+1]=x,x=x>>8,c[i]=x,i+8}u.prototype.writeBigUInt64LE=Ft(function(r,i=0){return v(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Ft(function(r,i=0){return Y(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const Z=Math.pow(2,8*h-1);d(this,r,i,h,Z-1,-Z)}let m=0,x=1,K=0;for(this[i]=r&255;++m<h&&(x*=256);)r<0&&K===0&&this[i+m-1]!==0&&(K=1),this[i+m]=(r/x>>0)-K&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const Z=Math.pow(2,8*h-1);d(this,r,i,h,Z-1,-Z)}let m=h-1,x=1,K=0;for(this[i+m]=r&255;--m>=0&&(x*=256);)r<0&&K===0&&this[i+m+1]!==0&&(K=1),this[i+m]=(r/x>>0)-K&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=Ft(function(r,i=0){return v(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Ft(function(r,i=0){return Y(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function J(c,r,i,h,g,m){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function X(c,r,i,h,g){return r=+r,i=i>>>0,g||J(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return X(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return X(this,r,i,!1,h)};function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||J(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return ft(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const m=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),m},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const x=r.charCodeAt(0);(g==="utf8"&&x<128||g==="latin1")&&(r=x)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let m;if(typeof r=="number")for(m=i;m<h;++m)this[m]=r;else{const x=u.isBuffer(r)?r:u.from(r,g),K=x.length;if(K===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(m=0;m<h-i;++m)this[m+i]=x[m%K]}return this};const st={};function ht(c,r,i){st[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ht("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),ht("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Wt(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Wt(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Wt(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function wt(c,r,i){mt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&dt(r,c.length-(i+1))}function yt(c,r,i,h,g,m){if(c>i||c<r){const x=typeof r=="bigint"?"n":"";let K;throw m>3?r===0||r===BigInt(0)?K=`>= 0${x} and < 2${x} ** ${(m+1)*8}${x}`:K=`>= -(2${x} ** ${(m+1)*8-1}${x}) and < 2 ** ${(m+1)*8-1}${x}`:K=`>= ${r}${x} and <= ${i}${x}`,new st.ERR_OUT_OF_RANGE("value",K,c)}wt(h,g,m)}function mt(c,r){if(typeof c!="number")throw new st.ERR_INVALID_ARG_TYPE(r,"number",c)}function dt(c,r,i){throw Math.floor(c)!==c?(mt(c,i),new st.ERR_OUT_OF_RANGE(i||"offset","an integer",c)):r<0?new st.ERR_BUFFER_OUT_OF_BOUNDS:new st.ERR_OUT_OF_RANGE(i||"offset",`>= ${i?1:0} and <= ${r}`,c)}const Mt=/[^+/0-9A-Za-z-_]/g;function Oe(c){if(c=c.split("=")[0],c=c.trim().replace(Mt,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function _t(c,r){r=r||1/0;let i;const h=c.length;let g=null;const m=[];for(let x=0;x<h;++x){if(i=c.charCodeAt(x),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&m.push(239,191,189);continue}else if(x+1===h){(r-=3)>-1&&m.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&m.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&m.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;m.push(i)}else if(i<2048){if((r-=2)<0)break;m.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;m.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;m.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return m}function qt(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function ur(c,r){let i,h,g;const m=[];for(let x=0;x<c.length&&!((r-=2)<0);++x)i=c.charCodeAt(x),h=i>>8,g=i%256,m.push(g),m.push(h);return m}function Nt(c){return t.toByteArray(Oe(c))}function vt(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function It(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function Rt(c){return c!==c}const Dt=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function Ft(c){return typeof BigInt>"u"?Kt:c}function Kt(){throw new Error("BigInt not supported")}})(Fs);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(o,t){var e=Fs,n=e.Buffer;function s(f,u){for(var p in f)u[p]=f[p]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?o.exports=e:(s(e,t),t.Buffer=a);function a(f,u,p){return n(f,u,p)}a.prototype=Object.create(n.prototype),s(n,a),a.from=function(f,u,p){if(typeof f=="number")throw new TypeError("Argument must not be a number");return n(f,u,p)},a.alloc=function(f,u,p){if(typeof f!="number")throw new TypeError("Argument must be a number");var b=n(f);return u!==void 0?typeof p=="string"?b.fill(u,p):b.fill(u):b.fill(0),b},a.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return n(f)},a.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(f)}})(Mi,Mi.exports);var qu=Mi.exports,On=qu.Buffer;function Hu(o){if(o.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var n=0;n<o.length;n++){var s=o.charAt(n),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=n}var f=o.length,u=o.charAt(0),p=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function E(T){if((Array.isArray(T)||T instanceof Uint8Array)&&(T=On.from(T)),!On.isBuffer(T))throw new TypeError("Expected Buffer");if(T.length===0)return"";for(var U=0,_=0,L=0,C=T.length;L!==C&&T[L]===0;)L++,U++;for(var $=(C-L)*b+1>>>0,N=new Uint8Array($);L!==C;){for(var H=T[L],D=0,F=$-1;(H!==0||D<_)&&F!==-1;F--,D++)H+=256*N[F]>>>0,N[F]=H%f>>>0,H=H/f>>>0;if(H!==0)throw new Error("Non-zero carry");_=D,L++}for(var W=$-_;W!==$&&N[W]===0;)W++;for(var q=u.repeat(U);W<$;++W)q+=o.charAt(N[W]);return q}function I(T){if(typeof T!="string")throw new TypeError("Expected String");if(T.length===0)return On.alloc(0);for(var U=0,_=0,L=0;T[U]===u;)_++,U++;for(var C=(T.length-U)*p+1>>>0,$=new Uint8Array(C);T[U];){var N=t[T.charCodeAt(U)];if(N===255)return;for(var H=0,D=C-1;(N!==0||H<L)&&D!==-1;D--,H++)N+=f*$[D]>>>0,$[D]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");L=H,U++}for(var F=C-L;F!==C&&$[F]===0;)F++;var W=On.allocUnsafe(_+(C-F));W.fill(0,0,_);for(var q=_;F!==C;)W[q++]=$[F++];return W}function M(T){var U=I(T);if(U)return U;throw new Error("Non-base"+f+" character")}return{encode:E,decodeUnsafe:I,decode:M}}var Vu=Hu,ju=Vu,Gu="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Os=ju(Gu);const ke=ln(Os),Yu=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]),kr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Er=new Uint32Array(64);class Zu extends fs{constructor(){super(64,32,8,!1),this.A=kr[0]|0,this.B=kr[1]|0,this.C=kr[2]|0,this.D=kr[3]|0,this.E=kr[4]|0,this.F=kr[5]|0,this.G=kr[6]|0,this.H=kr[7]|0}get(){const{A:t,B:e,C:n,D:s,E:a,F:f,G:u,H:p}=this;return[t,e,n,s,a,f,u,p]}set(t,e,n,s,a,f,u,p){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=a|0,this.F=f|0,this.G=u|0,this.H=p|0}process(t,e){for(let I=0;I<16;I++,e+=4)Er[I]=t.getUint32(e,!1);for(let I=16;I<64;I++){const M=Er[I-15],T=Er[I-2],U=Xe(M,7)^Xe(M,18)^M>>>3,_=Xe(T,17)^Xe(T,19)^T>>>10;Er[I]=_+Er[I-7]+U+Er[I-16]|0}let{A:n,B:s,C:a,D:f,E:u,F:p,G:b,H:E}=this;for(let I=0;I<64;I++){const M=Xe(u,6)^Xe(u,11)^Xe(u,25),T=E+M+Yc(u,p,b)+Yu[I]+Er[I]|0,_=(Xe(n,2)^Xe(n,13)^Xe(n,22))+Zc(n,s,a)|0;E=b,b=p,p=u,u=f+T|0,f=a,a=s,s=n,n=T+_|0}n=n+this.A|0,s=s+this.B|0,a=a+this.C|0,f=f+this.D|0,u=u+this.E|0,p=p+this.F|0,b=b+this.G|0,E=E+this.H|0,this.set(n,s,a,f,u,p,b,E)}roundClean(){Er.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Pi=mi(()=>new Zu);var Se={};function lr(o,t,e){return t<=o&&o<=e}function Nn(o){if(o===void 0)return{};if(o===Object(o))return o;throw TypeError("Could not convert argument to dictionary")}function Ju(o){for(var t=String(o),e=t.length,n=0,s=[];n<e;){var a=t.charCodeAt(n);if(a<55296||a>57343)s.push(a);else if(56320<=a&&a<=57343)s.push(65533);else if(55296<=a&&a<=56319)if(n===e-1)s.push(65533);else{var f=o.charCodeAt(n+1);if(56320<=f&&f<=57343){var u=a&1023,p=f&1023;s.push(65536+(u<<10)+p),n+=1}else s.push(65533)}n+=1}return s}function Xu(o){for(var t="",e=0;e<o.length;++e){var n=o[e];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return t}var zn=-1;function Li(o){this.tokens=[].slice.call(o)}Li.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():zn},prepend:function(o){if(Array.isArray(o))for(var t=o;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(o)},push:function(o){if(Array.isArray(o))for(var t=o;t.length;)this.tokens.push(t.shift());else this.tokens.push(o)}};var Qr=-1;function Ui(o,t){if(o)throw TypeError("Decoder error");return t||65533}var Dn="utf-8";function $n(o,t){if(!(this instanceof $n))return new $n(o,t);if(o=o!==void 0?String(o).toLowerCase():Dn,o!==Dn)throw new Error("Encoding not supported. Only utf-8 is supported");t=Nn(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})}$n.prototype={decode:function(t,e){var n;typeof t=="object"&&t instanceof ArrayBuffer?n=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):n=new Uint8Array(0),e=Nn(e),this._streaming||(this._decoder=new Qu({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new Li(n),a=[],f;!s.endOfStream()&&(f=this._decoder.handler(s,s.read()),f!==Qr);)f!==null&&(Array.isArray(f)?a.push.apply(a,f):a.push(f));if(!this._streaming){do{if(f=this._decoder.handler(s,s.read()),f===Qr)break;f!==null&&(Array.isArray(f)?a.push.apply(a,f):a.push(f))}while(!s.endOfStream());this._decoder=null}return a.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(a[0]===65279?(this._BOMseen=!0,a.shift()):this._BOMseen=!0),Xu(a)}};function Wn(o,t){if(!(this instanceof Wn))return new Wn(o,t);if(o=o!==void 0?String(o).toLowerCase():Dn,o!==Dn)throw new Error("Encoding not supported. Only utf-8 is supported");t=Nn(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Wn.prototype={encode:function(t,e){t=t?String(t):"",e=Nn(e),this._streaming||(this._encoder=new tf(this._options)),this._streaming=!!e.stream;for(var n=[],s=new Li(Ju(t)),a;!s.endOfStream()&&(a=this._encoder.handler(s,s.read()),a!==Qr);)Array.isArray(a)?n.push.apply(n,a):n.push(a);if(!this._streaming){for(;a=this._encoder.handler(s,s.read()),a!==Qr;)Array.isArray(a)?n.push.apply(n,a):n.push(a);this._encoder=null}return new Uint8Array(n)}};function Qu(o){var t=o.fatal,e=0,n=0,s=0,a=128,f=191;this.handler=function(u,p){if(p===zn&&s!==0)return s=0,Ui(t);if(p===zn)return Qr;if(s===0){if(lr(p,0,127))return p;if(lr(p,194,223))s=1,e=p-192;else if(lr(p,224,239))p===224&&(a=160),p===237&&(f=159),s=2,e=p-224;else if(lr(p,240,244))p===240&&(a=144),p===244&&(f=143),s=3,e=p-240;else return Ui(t);return e=e<<6*s,null}if(!lr(p,a,f))return e=s=n=0,a=128,f=191,u.prepend(p),Ui(t);if(a=128,f=191,n+=1,e+=p-128<<6*(s-n),n!==s)return null;var b=e;return e=s=n=0,b}}function tf(o){o.fatal,this.handler=function(t,e){if(e===zn)return Qr;if(lr(e,0,127))return e;var n,s;lr(e,128,2047)?(n=1,s=192):lr(e,2048,65535)?(n=2,s=224):lr(e,65536,1114111)&&(n=3,s=240);for(var a=[(e>>6*n)+s];n>0;){var f=e>>6*(n-1);a.push(128|f&63),n-=1}return a}}const ef=li(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:$n,TextEncoder:Wn},Symbol.toStringTag,{value:"Module"})));var rf=Ve&&Ve.__createBinding||(Object.create?function(o,t,e,n){n===void 0&&(n=e),Object.defineProperty(o,n,{enumerable:!0,get:function(){return t[e]}})}:function(o,t,e,n){n===void 0&&(n=e),o[n]=t[e]}),nf=Ve&&Ve.__setModuleDefault||(Object.create?function(o,t){Object.defineProperty(o,"default",{enumerable:!0,value:t})}:function(o,t){o.default=t}),Qe=Ve&&Ve.__decorate||function(o,t,e,n){var s=arguments.length,a=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(o,t,e,n);else for(var u=o.length-1;u>=0;u--)(f=o[u])&&(a=(s<3?f(a):s>3?f(t,e,a):f(t,e))||a);return s>3&&a&&Object.defineProperty(t,e,a),a},of=Ve&&Ve.__importStar||function(o){if(o&&o.__esModule)return o;var t={};if(o!=null)for(var e in o)e!=="default"&&Object.hasOwnProperty.call(o,e)&&rf(t,o,e);return nf(t,o),t},Ns=Ve&&Ve.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(Se,"__esModule",{value:!0});var zs=Se.deserializeUnchecked=Hs=Se.deserialize=qs=Se.serialize=Se.BinaryReader=Se.BinaryWriter=Se.BorshError=Se.baseDecode=Se.baseEncode=void 0;const Ir=Ns(Us),Ds=Ns(Os),sf=of(ef),af=typeof TextDecoder!="function"?sf.TextDecoder:TextDecoder,cf=new af("utf-8",{fatal:!0});function uf(o){return typeof o=="string"&&(o=Buffer.from(o,"utf8")),Ds.default.encode(Buffer.from(o))}Se.baseEncode=uf;function ff(o){return Buffer.from(Ds.default.decode(o))}Se.baseDecode=ff;const Ci=1024;class Pe 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(".")}}Se.BorshError=Pe;class $s{constructor(){this.buf=Buffer.alloc(Ci),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Ci)]))}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 Ir.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Ir.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Ir.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Ir.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(Ci)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const n of t)this.maybeResize(),e(n)}toArray(){return this.buf.subarray(0,this.length)}}Se.BinaryWriter=$s;function tr(o,t,e){const n=e.value;e.value=function(...s){try{return n.apply(this,s)}catch(a){if(a instanceof RangeError){const f=a.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(f)>=0)throw new Pe("Reached the end of buffer when deserializing")}throw a}}}class ze{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 Ir.default(t,"le")}readU128(){const t=this.readBuffer(16);return new Ir.default(t,"le")}readU256(){const t=this.readBuffer(32);return new Ir.default(t,"le")}readU512(){const t=this.readBuffer(64);return new Ir.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new Pe(`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 cf.decode(e)}catch(n){throw new Pe(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),n=Array();for(let s=0;s<e;++s)n.push(t());return n}}Qe([tr],ze.prototype,"readU8",null),Qe([tr],ze.prototype,"readU16",null),Qe([tr],ze.prototype,"readU32",null),Qe([tr],ze.prototype,"readU64",null),Qe([tr],ze.prototype,"readU128",null),Qe([tr],ze.prototype,"readU256",null),Qe([tr],ze.prototype,"readU512",null),Qe([tr],ze.prototype,"readString",null),Qe([tr],ze.prototype,"readFixedArray",null),Qe([tr],ze.prototype,"readArray",null),Se.BinaryReader=ze;function Ws(o){return o.charAt(0).toUpperCase()+o.slice(1)}function Lr(o,t,e,n,s){try{if(typeof n=="string")s[`write${Ws(n)}`](e);else if(n instanceof Array)if(typeof n[0]=="number"){if(e.length!==n[0])throw new Pe(`Expecting byte array of length ${n[0]}, but got ${e.length} bytes`);s.writeFixedArray(e)}else if(n.length===2&&typeof n[1]=="number"){if(e.length!==n[1])throw new Pe(`Expecting byte array of length ${n[1]}, but got ${e.length} bytes`);for(let a=0;a<n[1];a++)Lr(o,null,e[a],n[0],s)}else s.writeArray(e,a=>{Lr(o,t,a,n[0],s)});else if(n.kind!==void 0)switch(n.kind){case"option":{e==null?s.writeU8(0):(s.writeU8(1),Lr(o,t,e,n.type,s));break}case"map":{s.writeU32(e.size),e.forEach((a,f)=>{Lr(o,t,f,n.key,s),Lr(o,t,a,n.value,s)});break}default:throw new Pe(`FieldType ${n} unrecognized`)}else Ks(o,e,s)}catch(a){throw a instanceof Pe&&a.addToFieldPath(t),a}}function Ks(o,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const n=o.get(t.constructor);if(!n)throw new Pe(`Class ${t.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([s,a])=>{Lr(o,s,t[s],a,e)});else if(n.kind==="enum"){const s=t[n.field];for(let a=0;a<n.values.length;++a){const[f,u]=n.values[a];if(f===s){e.writeU8(a),Lr(o,f,t[f],u,e);break}}}else throw new Pe(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function hf(o,t,e=$s){const n=new e;return Ks(o,t,n),n.toArray()}var qs=Se.serialize=hf;function Ur(o,t,e,n){try{if(typeof e=="string")return n[`read${Ws(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return n.readFixedArray(e[0]);if(typeof e[1]=="number"){const s=[];for(let a=0;a<e[1];a++)s.push(Ur(o,null,e[0],n));return s}else return n.readArray(()=>Ur(o,t,e[0],n))}if(e.kind==="option")return n.readU8()?Ur(o,t,e.type,n):void 0;if(e.kind==="map"){let s=new Map;const a=n.readU32();for(let f=0;f<a;f++){const u=Ur(o,t,e.key,n),p=Ur(o,t,e.value,n);s.set(u,p)}return s}return Fi(o,e,n)}catch(s){throw s instanceof Pe&&s.addToFieldPath(t),s}}function Fi(o,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const n=o.get(t);if(!n)throw new Pe(`Class ${t.name} is missing in schema`);if(n.kind==="struct"){const s={};for(const[a,f]of o.get(t).fields)s[a]=Ur(o,a,f,e);return new t(s)}if(n.kind==="enum"){const s=e.readU8();if(s>=n.values.length)throw new Pe(`Enum index: ${s} is out of range`);const[a,f]=n.values[s],u=Ur(o,a,f,e);return new t({[a]:u})}throw new Pe(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function lf(o,t,e,n=ze){const s=new n(e),a=Fi(o,t,s);if(s.offset<e.length)throw new Pe(`Unexpected ${e.length-s.offset} bytes after deserialized data`);return a}var Hs=Se.deserialize=lf;function df(o,t,e,n=ze){const s=new n(e);return Fi(o,t,s)}zs=Se.deserializeUnchecked=df;var z={},Vs={};/*!
|
|
12
|
+
* The buffer module from node.js, for the browser.
|
|
13
|
+
*
|
|
14
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
15
|
+
* @license MIT
|
|
16
|
+
*/(function(o){const t=Hr,e=dn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=$,o.INSPECT_MAX_BYTES=50;const s=2147483647;o.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=a(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>s)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(c)}return p(c,r,i)}u.poolSize=8192;function p(c,r,i){if(typeof c=="string")return M(c,r);if(ArrayBuffer.isView(c))return U(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(It(c,ArrayBuffer)||c&&It(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(It(c,SharedArrayBuffer)||c&&It(c.buffer,SharedArrayBuffer)))return _(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=L(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return p(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function b(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function E(c,r,i){return b(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return E(c,r,i)};function I(c){return b(c),f(c<0?0:C(c)|0)}u.allocUnsafe=function(c){return I(c)},u.allocUnsafeSlow=function(c){return I(c)};function M(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=N(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function T(c){const r=c.length<0?0:C(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function U(c){if(It(c,Uint8Array)){const r=new Uint8Array(c);return _(r.buffer,r.byteOffset,r.byteLength)}return T(c)}function _(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function L(c){if(u.isBuffer(c)){const r=C(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||Rt(c.length)?f(0):T(c);if(c.type==="Buffer"&&Array.isArray(c.data))return T(c.data)}function C(c){if(c>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return c|0}function $(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(It(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),It(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let m=0,x=Math.min(h,g);m<x;++m)if(r[m]!==i[m]){h=r[m],g=i[m];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let m=0;for(h=0;h<r.length;++h){let x=r[h];if(It(x,Uint8Array))m+x.length>g.length?(u.isBuffer(x)||(x=u.from(x)),x.copy(g,m)):Uint8Array.prototype.set.call(g,x,m);else if(u.isBuffer(x))x.copy(g,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=x.length}return g};function N(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||It(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return _t(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return Nt(c).length;default:if(g)return h?-1:_t(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=N;function H(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return B(this,r,i);case"utf8":case"utf-8":return l(this,r,i);case"ascii":return A(this,r,i);case"latin1":case"binary":return S(this,r,i);case"base64":return R(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function D(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)D(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)D(this,i,i+3),D(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)D(this,i,i+7),D(this,i+1,i+6),D(this,i+2,i+5),D(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?l(this,0,r):H.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,m){if(It(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),m===void 0&&(m=this.length),i<0||h>r.length||g<0||m>this.length)throw new RangeError("out of range index");if(g>=m&&i>=h)return 0;if(g>=m)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,m>>>=0,this===r)return 0;let x=m-g,K=h-i;const Z=Math.min(x,K),G=this.slice(g,m),it=r.slice(i,h);for(let V=0;V<Z;++V)if(G[V]!==it[V]){x=G[V],K=it[V];break}return x<K?-1:K<x?1:0};function F(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,Rt(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:W(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):W(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function W(c,r,i,h,g){let m=1,x=c.length,K=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;m=2,x/=2,K/=2,i/=2}function Z(it,V){return m===1?it[V]:it.readUInt16BE(V*m)}let G;if(g){let it=-1;for(G=i;G<x;G++)if(Z(c,G)===Z(r,it===-1?0:G-it)){if(it===-1&&(it=G),G-it+1===K)return it*m}else it!==-1&&(G-=G-it),it=-1}else for(i+K>x&&(i=x-K),G=i;G>=0;G--){let it=!0;for(let V=0;V<K;V++)if(Z(c,G+V)!==Z(r,V)){it=!1;break}if(it)return G}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return F(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return F(this,r,i,h,!1)};function q(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const m=r.length;h>m/2&&(h=m/2);let x;for(x=0;x<h;++x){const K=parseInt(r.substr(x*2,2),16);if(Rt(K))return x;c[i+x]=K}return x}function Bt(c,r,i,h){return vt(_t(r,c.length-i),c,i,h)}function gt(c,r,i,h){return vt(qt(r),c,i,h)}function ot(c,r,i,h){return vt(Nt(r),c,i,h)}function At(c,r,i,h){return vt(ur(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const m=this.length-i;if((h===void 0||h>m)&&(h=m),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let x=!1;for(;;)switch(g){case"hex":return q(this,r,i,h);case"utf8":case"utf-8":return Bt(this,r,i,h);case"ascii":case"latin1":case"binary":return gt(this,r,i,h);case"base64":return ot(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return At(this,r,i,h);default:if(x)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),x=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function R(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function l(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const m=c[g];let x=null,K=m>239?4:m>223?3:m>191?2:1;if(g+K<=i){let Z,G,it,V;switch(K){case 1:m<128&&(x=m);break;case 2:Z=c[g+1],(Z&192)===128&&(V=(m&31)<<6|Z&63,V>127&&(x=V));break;case 3:Z=c[g+1],G=c[g+2],(Z&192)===128&&(G&192)===128&&(V=(m&15)<<12|(Z&63)<<6|G&63,V>2047&&(V<55296||V>57343)&&(x=V));break;case 4:Z=c[g+1],G=c[g+2],it=c[g+3],(Z&192)===128&&(G&192)===128&&(it&192)===128&&(V=(m&15)<<18|(Z&63)<<12|(G&63)<<6|it&63,V>65535&&V<1114112&&(x=V))}}x===null?(x=65533,K=1):x>65535&&(x-=65536,h.push(x>>>10&1023|55296),x=56320|x&1023),h.push(x),g+=K}return k(h)}const y=4096;function k(c){const r=c.length;if(r<=y)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=y));return i}function A(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function S(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function B(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let m=r;m<i;++m)g+=Dt[c[m]];return g}function P(c,r,i){const h=c.slice(r,i);let g="";for(let m=0;m<h.length-1;m+=2)g+=String.fromCharCode(h[m]+h[m+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function w(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r],m=1,x=0;for(;++x<i&&(m*=256);)g+=this[r+x]*m;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r+--i],m=1;for(;i>0&&(m*=256);)g+=this[r+--i]*m;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||w(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||w(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||w(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||w(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,m=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(m)<<BigInt(32))}),u.prototype.readBigUInt64BE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],m=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(m)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=this[r],m=1,x=0;for(;++x<i&&(m*=256);)g+=this[r+x]*m;return m*=128,g>=m&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||w(r,i,this.length);let g=i,m=1,x=this[r+--g];for(;g>0&&(m*=256);)x+=this[r+--g]*m;return m*=128,x>=m&&(x-=Math.pow(2,8*i)),x},u.prototype.readInt8=function(r,i){return r=r>>>0,i||w(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||w(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||w(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||w(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=Ft(function(r){r=r>>>0,mt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&dt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||w(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||w(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||w(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||w(r,8,this.length),e.read(this,r,!1,52,8)};function d(c,r,i,h,g,m){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<m)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const K=Math.pow(2,8*h)-1;d(this,r,i,h,K,0)}let m=1,x=0;for(this[i]=r&255;++x<h&&(m*=256);)this[i+x]=r/m&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const K=Math.pow(2,8*h)-1;d(this,r,i,h,K,0)}let m=h-1,x=1;for(this[i+m]=r&255;--m>=0&&(x*=256);)this[i+m]=r/x&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function v(c,r,i,h,g){yt(r,h,g,c,i,7);let m=Number(r&BigInt(4294967295));c[i++]=m,m=m>>8,c[i++]=m,m=m>>8,c[i++]=m,m=m>>8,c[i++]=m;let x=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=x,x=x>>8,c[i++]=x,x=x>>8,c[i++]=x,x=x>>8,c[i++]=x,i}function Y(c,r,i,h,g){yt(r,h,g,c,i,7);let m=Number(r&BigInt(4294967295));c[i+7]=m,m=m>>8,c[i+6]=m,m=m>>8,c[i+5]=m,m=m>>8,c[i+4]=m;let x=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=x,x=x>>8,c[i+2]=x,x=x>>8,c[i+1]=x,x=x>>8,c[i]=x,i+8}u.prototype.writeBigUInt64LE=Ft(function(r,i=0){return v(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Ft(function(r,i=0){return Y(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const Z=Math.pow(2,8*h-1);d(this,r,i,h,Z-1,-Z)}let m=0,x=1,K=0;for(this[i]=r&255;++m<h&&(x*=256);)r<0&&K===0&&this[i+m-1]!==0&&(K=1),this[i+m]=(r/x>>0)-K&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const Z=Math.pow(2,8*h-1);d(this,r,i,h,Z-1,-Z)}let m=h-1,x=1,K=0;for(this[i+m]=r&255;--m>=0&&(x*=256);)r<0&&K===0&&this[i+m+1]!==0&&(K=1),this[i+m]=(r/x>>0)-K&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||d(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=Ft(function(r,i=0){return v(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Ft(function(r,i=0){return Y(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function J(c,r,i,h,g,m){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function X(c,r,i,h,g){return r=+r,i=i>>>0,g||J(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return X(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return X(this,r,i,!1,h)};function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||J(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return ft(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const m=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),m},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const x=r.charCodeAt(0);(g==="utf8"&&x<128||g==="latin1")&&(r=x)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let m;if(typeof r=="number")for(m=i;m<h;++m)this[m]=r;else{const x=u.isBuffer(r)?r:u.from(r,g),K=x.length;if(K===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(m=0;m<h-i;++m)this[m+i]=x[m%K]}return this};const st={};function ht(c,r,i){st[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ht("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),ht("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Wt(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Wt(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Wt(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function wt(c,r,i){mt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&dt(r,c.length-(i+1))}function yt(c,r,i,h,g,m){if(c>i||c<r){const x=typeof r=="bigint"?"n":"";let K;throw m>3?r===0||r===BigInt(0)?K=`>= 0${x} and < 2${x} ** ${(m+1)*8}${x}`:K=`>= -(2${x} ** ${(m+1)*8-1}${x}) and < 2 ** ${(m+1)*8-1}${x}`:K=`>= ${r}${x} and <= ${i}${x}`,new st.ERR_OUT_OF_RANGE("value",K,c)}wt(h,g,m)}function mt(c,r){if(typeof c!="number")throw new st.ERR_INVALID_ARG_TYPE(r,"number",c)}function dt(c,r,i){throw Math.floor(c)!==c?(mt(c,i),new st.ERR_OUT_OF_RANGE(i||"offset","an integer",c)):r<0?new st.ERR_BUFFER_OUT_OF_BOUNDS:new st.ERR_OUT_OF_RANGE(i||"offset",`>= ${i?1:0} and <= ${r}`,c)}const Mt=/[^+/0-9A-Za-z-_]/g;function Oe(c){if(c=c.split("=")[0],c=c.trim().replace(Mt,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function _t(c,r){r=r||1/0;let i;const h=c.length;let g=null;const m=[];for(let x=0;x<h;++x){if(i=c.charCodeAt(x),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&m.push(239,191,189);continue}else if(x+1===h){(r-=3)>-1&&m.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&m.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&m.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;m.push(i)}else if(i<2048){if((r-=2)<0)break;m.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;m.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;m.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return m}function qt(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function ur(c,r){let i,h,g;const m=[];for(let x=0;x<c.length&&!((r-=2)<0);++x)i=c.charCodeAt(x),h=i>>8,g=i%256,m.push(g),m.push(h);return m}function Nt(c){return t.toByteArray(Oe(c))}function vt(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function It(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function Rt(c){return c!==c}const Dt=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function Ft(c){return typeof BigInt>"u"?Kt:c}function Kt(){throw new Error("BigInt not supported")}})(Vs),Object.defineProperty(z,"__esModule",{value:!0}),z.s16=z.s8=z.nu64be=z.u48be=z.u40be=z.u32be=z.u24be=z.u16be=Be=z.nu64=z.u48=z.u40=at=z.u32=z.u24=qe=z.u16=Pt=z.u8=Sr=z.offset=z.greedy=z.Constant=z.UTF8=z.CString=z.Blob=z.Boolean=z.BitField=z.BitStructure=z.VariantLayout=z.Union=z.UnionLayoutDiscriminator=z.UnionDiscriminator=z.Structure=z.Sequence=z.DoubleBE=z.Double=z.FloatBE=z.Float=z.NearInt64BE=z.NearInt64=z.NearUInt64BE=z.NearUInt64=z.IntBE=z.Int=z.UIntBE=z.UInt=z.OffsetLayout=z.GreedyCount=z.ExternalLayout=z.bindConstructorLayout=z.nameWithProperty=z.Layout=z.uint8ArrayToBuffer=z.checkUint8Array=void 0,z.constant=z.utf8=z.cstr=jt=z.blob=z.unionLayoutDiscriminator=z.union=Ae=z.seq=z.bits=ct=z.struct=z.f64be=z.f64=z.f32be=z.f32=z.ns64be=z.s48be=z.s40be=z.s32be=z.s24be=z.s16be=De=z.ns64=z.s48=z.s40=z.s32=z.s24=void 0;const Oi=Vs;function tn(o){if(!(o instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}z.checkUint8Array=tn;function Ut(o){return tn(o),Oi.Buffer.from(o.buffer,o.byteOffset,o.length)}z.uint8ArrayToBuffer=Ut;class $t{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){}}z.Layout=$t;function Ni(o,t){return t.property?o+"["+t.property+"]":o}z.nameWithProperty=Ni;function pf(o,t){if(typeof o!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(o,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof $t))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");o.layout_=t,t.boundConstructor_=o,t.makeDestinationObject=()=>new o,Object.defineProperty(o.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(o,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}z.bindConstructorLayout=pf;class Le extends $t{isCount(){throw new Error("ExternalLayout is abstract")}}z.ExternalLayout=Le;class js extends Le{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){tn(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}z.GreedyCount=js;class zi extends Le{constructor(t,e=0,n){if(!(t instanceof $t))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Ke||this.layout instanceof Ge}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,n=0){return this.layout.encode(t,e,n+this.offset)}}z.OffsetLayout=zi;class Ke extends $t{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Ut(t).readUIntLE(e,this.span)}encode(t,e,n=0){return Ut(e).writeUIntLE(t,n,this.span),this.span}}z.UInt=Ke;class Ge extends $t{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Ut(t).readUIntBE(e,this.span)}encode(t,e,n=0){return Ut(e).writeUIntBE(t,n,this.span),this.span}}z.UIntBE=Ge;class Cr extends $t{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Ut(t).readIntLE(e,this.span)}encode(t,e,n=0){return Ut(e).writeIntLE(t,n,this.span),this.span}}z.Int=Cr;class en extends $t{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Ut(t).readIntBE(e,this.span)}encode(t,e,n=0){return Ut(e).writeIntBE(t,n,this.span),this.span}}z.IntBE=en;const Di=Math.pow(2,32);function Kn(o){const t=Math.floor(o/Di),e=o-t*Di;return{hi32:t,lo32:e}}function qn(o,t){return o*Di+t}class Gs extends $t{constructor(t){super(8,t)}decode(t,e=0){const n=Ut(t),s=n.readUInt32LE(e),a=n.readUInt32LE(e+4);return qn(a,s)}encode(t,e,n=0){const s=Kn(t),a=Ut(e);return a.writeUInt32LE(s.lo32,n),a.writeUInt32LE(s.hi32,n+4),8}}z.NearUInt64=Gs;class Ys extends $t{constructor(t){super(8,t)}decode(t,e=0){const n=Ut(t),s=n.readUInt32BE(e),a=n.readUInt32BE(e+4);return qn(s,a)}encode(t,e,n=0){const s=Kn(t),a=Ut(e);return a.writeUInt32BE(s.hi32,n),a.writeUInt32BE(s.lo32,n+4),8}}z.NearUInt64BE=Ys;class Zs extends $t{constructor(t){super(8,t)}decode(t,e=0){const n=Ut(t),s=n.readUInt32LE(e),a=n.readInt32LE(e+4);return qn(a,s)}encode(t,e,n=0){const s=Kn(t),a=Ut(e);return a.writeUInt32LE(s.lo32,n),a.writeInt32LE(s.hi32,n+4),8}}z.NearInt64=Zs;class Js extends $t{constructor(t){super(8,t)}decode(t,e=0){const n=Ut(t),s=n.readInt32BE(e),a=n.readUInt32BE(e+4);return qn(s,a)}encode(t,e,n=0){const s=Kn(t),a=Ut(e);return a.writeInt32BE(s.hi32,n),a.writeUInt32BE(s.lo32,n+4),8}}z.NearInt64BE=Js;class Xs extends $t{constructor(t){super(4,t)}decode(t,e=0){return Ut(t).readFloatLE(e)}encode(t,e,n=0){return Ut(e).writeFloatLE(t,n),4}}z.Float=Xs;class Qs extends $t{constructor(t){super(4,t)}decode(t,e=0){return Ut(t).readFloatBE(e)}encode(t,e,n=0){return Ut(e).writeFloatBE(t,n),4}}z.FloatBE=Qs;class ta extends $t{constructor(t){super(8,t)}decode(t,e=0){return Ut(t).readDoubleLE(e)}encode(t,e,n=0){return Ut(e).writeDoubleLE(t,n),8}}z.Double=ta;class ea extends $t{constructor(t){super(8,t)}decode(t,e=0){return Ut(t).readDoubleBE(e)}encode(t,e,n=0){return Ut(e).writeDoubleBE(t,n),8}}z.DoubleBE=ea;class ra extends $t{constructor(t,e,n){if(!(t instanceof $t))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Le&&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 Le)&&0<t.span&&(s=e*t.span),super(s,n),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0,s=this.count;if(s instanceof Le&&(s=s.decode(t,e)),0<this.elementLayout.span)n=s*this.elementLayout.span;else{let a=0;for(;a<s;)n+=this.elementLayout.getSpan(t,e+n),++a}return n}decode(t,e=0){const n=[];let s=0,a=this.count;for(a instanceof Le&&(a=a.decode(t,e));s<a;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),s+=1;return n}encode(t,e,n=0){const s=this.elementLayout,a=t.reduce((f,u)=>f+s.encode(u,e,n+f),0);return this.count instanceof Le&&this.count.encode(t.length,e,n),a}}z.Sequence=ra;class na extends $t{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((a,f)=>a&&f instanceof $t,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(const a of t)if(0>a.span&&a.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let s=-1;try{s=t.reduce((a,f)=>a+f.getSpan(),0)}catch{}super(s,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((s,a)=>{const f=a.getSpan(t,e);return e+=f,s+f},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e=0){tn(t);const n=this.makeDestinationObject();for(const s of this.fields)if(s.property!==void 0&&(n[s.property]=s.decode(t,e)),e+=s.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n=0){const s=n;let a=0,f=0;for(const u of this.fields){let p=u.span;if(f=0<p?p:0,u.property!==void 0){const b=t[u.property];b!==void 0&&(f=u.encode(b,e,n),0>p&&(p=u.getSpan(e,n)))}a=n,n+=p}return a+f-s}fromArray(t){const e=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}}z.Structure=na;class $i{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}z.UnionDiscriminator=$i;class Hn extends $i{constructor(t,e){if(!(t instanceof Le&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}}z.UnionLayoutDiscriminator=Hn;class Wi extends $t{constructor(t,e,n){let s;if(t instanceof Ke||t instanceof Ge)s=new Hn(new zi(t));else if(t instanceof Le&&t.isCount())s=new Hn(t);else if(t instanceof $i)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 $t))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 a=-1;e&&(a=e.span,0<=a&&(t instanceof Ke||t instanceof Ge)&&(a+=s.layout.span)),super(a,n),this.discriminator=s,this.usesPrefixDiscriminator=t instanceof Ke||t instanceof Ge,this.defaultLayout=e,this.registry={};let f=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(u){return f(u)},this.configGetSourceVariant=function(u){f=u.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n;const s=this.discriminator,a=s.decode(t,e),f=this.registry[a];if(f===void 0){const u=this.defaultLayout;let p=0;this.usesPrefixDiscriminator&&(p=s.layout.span),n=this.makeDestinationObject(),n[s.property]=a,n[u.property]=u.decode(t,e+p)}else n=f.decode(t,e);return n}encode(t,e,n=0){const s=this.getSourceVariant(t);if(s===void 0){const a=this.discriminator,f=this.defaultLayout;let u=0;return this.usesPrefixDiscriminator&&(u=a.layout.span),a.encode(t[a.property],e,n),u+f.encode(t[f.property],e,n+u)}return s.encode(t,e,n)}addVariant(t,e,n){const s=new ia(this,t,e,n);return this.registry[t]=s,s}getVariant(t,e=0){let n;return t instanceof Uint8Array?n=this.discriminator.decode(t,e):n=t,this.registry[n]}}z.Union=Wi;class ia extends $t{constructor(t,e,n,s){if(!(t instanceof Wi))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&s===void 0&&(s=n,n=null),n){if(!(n instanceof $t))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof s!="string")throw new TypeError("variant must have a String property")}let a=t.span;0>t.span&&(a=n?n.span:0,0<=a&&t.usesPrefixDiscriminator&&(a+=t.discriminator.layout.span)),super(a,s),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let s=0;return this.layout&&(s=this.layout.getSpan(t,e+n)),n+s}decode(t,e=0){const n=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?n[this.property]=this.layout.decode(t,e+s):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n=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,n);let a=s;if(this.layout&&(this.layout.encode(t[this.property],e,n+s),a+=this.layout.getSpan(e,n+s),0<=this.union.span&&a>this.union.span))throw new Error("encoded variant overruns containing union");return a}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}z.VariantLayout=ia;function rn(o){return 0>o&&(o+=4294967296),o}class Ki extends $t{constructor(t,e,n){if(!(t instanceof Ke||t instanceof Ge))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&n===void 0&&(n=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let s=0;this._packedSetValue=function(a){return s=rn(a),this},this._packedGetValue=function(){return s}}decode(t,e=0){const n=this.makeDestinationObject(),s=this.word.decode(t,e);this._packedSetValue(s);for(const a of this.fields)a.property!==void 0&&(n[a.property]=a.decode(t));return n}encode(t,e,n=0){const s=this.word.decode(e,n);this._packedSetValue(s);for(const a of this.fields)if(a.property!==void 0){const f=t[a.property];f!==void 0&&a.encode(f)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){const n=new qi(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new oa(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}}z.BitStructure=Ki;class qi{constructor(t,e,n){if(!(t instanceof Ki))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,a=t.fields.reduce((f,u)=>f+u.bits,0);if(e+a>s)throw new Error("bits too long for span remainder ("+(s-a)+" of "+s+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=a,this.container.msb&&(this.start=s-a-e),this.wordMask=rn(this.valueMask<<this.start),this.property=n}decode(t,e){const n=this.container._packedGetValue();return rn(n&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==rn(t&this.valueMask))throw new TypeError(Ni("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=rn(t<<this.start);this.container._packedSetValue(rn(e&~this.wordMask)|n)}}z.BitField=qi;let oa=class extends qi{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)}};z.Boolean=oa;class sa extends $t{constructor(t,e){if(!(t instanceof Le&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof Le||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e=0){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),Ut(t).slice(e,e+n)}encode(t,e,n){let s=this.length;if(this.length instanceof Le&&(s=t.length),!(t instanceof Uint8Array&&s===t.length))throw new TypeError(Ni("Blob.encode",this)+" requires (length "+s+") Uint8Array as src");if(n+s>e.length)throw new RangeError("encoding overruns Uint8Array");const a=Ut(t);return Ut(e).write(a.toString("hex"),n,s,"hex"),this.length instanceof Le&&this.length.encode(s,e,n),s}}z.Blob=sa;class aa extends $t{constructor(t){super(-1,t)}getSpan(t,e=0){tn(t);let n=e;for(;n<t.length&&t[n]!==0;)n+=1;return 1+n-e}decode(t,e=0){const n=this.getSpan(t,e);return Ut(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const s=Oi.Buffer.from(t,"utf8"),a=s.length;if(n+a>e.length)throw new RangeError("encoding overruns Buffer");const f=Ut(e);return s.copy(f,n),f[n+a]=0,a+1}}z.CString=aa;class ca extends $t{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 tn(t),t.length-e}decode(t,e=0){const n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return Ut(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const s=Oi.Buffer.from(t,"utf8"),a=s.length;if(0<=this.maxSpan&&this.maxSpan<a)throw new RangeError("text length exceeds maxSpan");if(n+a>e.length)throw new RangeError("encoding overruns Buffer");return s.copy(Ut(e),n),a}}z.UTF8=ca;class ua extends $t{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}z.Constant=ua,z.greedy=(o,t)=>new js(o,t);var Sr=z.offset=(o,t,e)=>new zi(o,t,e),Pt=z.u8=o=>new Ke(1,o),qe=z.u16=o=>new Ke(2,o);z.u24=o=>new Ke(3,o);var at=z.u32=o=>new Ke(4,o);z.u40=o=>new Ke(5,o),z.u48=o=>new Ke(6,o);var Be=z.nu64=o=>new Gs(o);z.u16be=o=>new Ge(2,o),z.u24be=o=>new Ge(3,o),z.u32be=o=>new Ge(4,o),z.u40be=o=>new Ge(5,o),z.u48be=o=>new Ge(6,o),z.nu64be=o=>new Ys(o),z.s8=o=>new Cr(1,o),z.s16=o=>new Cr(2,o),z.s24=o=>new Cr(3,o),z.s32=o=>new Cr(4,o),z.s40=o=>new Cr(5,o),z.s48=o=>new Cr(6,o);var De=z.ns64=o=>new Zs(o);z.s16be=o=>new en(2,o),z.s24be=o=>new en(3,o),z.s32be=o=>new en(4,o),z.s40be=o=>new en(5,o),z.s48be=o=>new en(6,o),z.ns64be=o=>new Js(o),z.f32=o=>new Xs(o),z.f32be=o=>new Qs(o),z.f64=o=>new ta(o),z.f64be=o=>new ea(o);var ct=z.struct=(o,t,e)=>new na(o,t,e);z.bits=(o,t,e)=>new Ki(o,t,e);var Ae=z.seq=(o,t,e)=>new ra(o,t,e);z.union=(o,t,e)=>new Wi(o,t,e),z.unionLayoutDiscriminator=(o,t)=>new Hn(o,t);var jt=z.blob=(o,t)=>new sa(o,t);z.cstr=o=>new aa(o),z.utf8=(o,t)=>new ca(o,t),z.constant=(o,t)=>new ua(o,t);var mn={};Object.defineProperty(mn,"__esModule",{value:!0});function gf(o){{const t=Buffer.from(o);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var yf=mn.toBigIntLE=gf;function mf(o){{const t=o.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}mn.toBigIntBE=mf;function wf(o,t){{const e=o.toString(16),n=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return n.reverse(),n}}var fa=mn.toBufferLE=wf;function bf(o,t){{const e=o.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}mn.toBufferBE=bf;class xf extends TypeError{constructor(t,e){let n;const{message:s,explanation:a,...f}=t,{path:u}=t,p=u.length===0?s:`At path: ${u.join(".")} -- ${s}`;super(a??p),a!=null&&(this.cause=p),Object.assign(this,f),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function kf(o){return dr(o)&&typeof o[Symbol.iterator]=="function"}function dr(o){return typeof o=="object"&&o!=null}function Ye(o){return typeof o=="symbol"?o.toString():typeof o=="string"?JSON.stringify(o):`${o}`}function Ef(o){const{done:t,value:e}=o.next();return t?void 0:e}function If(o,t,e,n){if(o===!0)return;o===!1?o={}:typeof o=="string"&&(o={message:o});const{path:s,branch:a}=t,{type:f}=e,{refinement:u,message:p=`Expected a value of type \`${f}\`${u?` with refinement \`${u}\``:""}, but received: \`${Ye(n)}\``}=o;return{value:n,type:f,refinement:u,key:s[s.length-1],path:s,branch:a,...o,message:p}}function*ha(o,t,e,n){kf(o)||(o=[o]);for(const s of o){const a=If(s,t,e,n);a&&(yield a)}}function*Hi(o,t,e={}){const{path:n=[],branch:s=[o],coerce:a=!1,mask:f=!1}=e,u={path:n,branch:s};if(a&&(o=t.coercer(o,u),f&&t.type!=="type"&&dr(t.schema)&&dr(o)&&!Array.isArray(o)))for(const b in o)t.schema[b]===void 0&&delete o[b];let p="valid";for(const b of t.validator(o,u))b.explanation=e.message,p="not_valid",yield[b,void 0];for(let[b,E,I]of t.entries(o,u)){const M=Hi(E,I,{path:b===void 0?n:[...n,b],branch:b===void 0?s:[...s,E],coerce:a,mask:f,message:e.message});for(const T of M)T[0]?(p=T[0].refinement!=null?"not_refined":"not_valid",yield[T[0],void 0]):a&&(E=T[1],b===void 0?o=E:o instanceof Map?o.set(b,E):o instanceof Set?o.add(E):dr(o)&&(E!==void 0||b in o)&&(o[b]=E))}if(p!=="not_valid")for(const b of t.refiner(o,u))b.explanation=e.message,p="not_refined",yield[b,void 0];p==="valid"&&(yield[void 0,o])}let er=class{constructor(t){const{type:e,schema:n,validator:s,refiner:a,coercer:f=p=>p,entries:u=function*(){}}=t;this.type=e,this.schema=n,this.entries=u,this.coercer=f,s?this.validator=(p,b)=>{const E=s(p,b);return ha(E,b,this,p)}:this.validator=()=>[],a?this.refiner=(p,b)=>{const E=a(p,b);return ha(E,b,this,p)}:this.refiner=()=>[]}assert(t,e){return la(t,this,e)}create(t,e){return et(t,this,e)}is(t){return da(t,this)}mask(t,e){return Sf(t,this,e)}validate(t,e={}){return wn(t,this,e)}};function la(o,t,e){const n=wn(o,t,{message:e});if(n[0])throw n[0]}function et(o,t,e){const n=wn(o,t,{coerce:!0,message:e});if(n[0])throw n[0];return n[1]}function Sf(o,t,e){const n=wn(o,t,{coerce:!0,mask:!0,message:e});if(n[0])throw n[0];return n[1]}function da(o,t){return!wn(o,t)[0]}function wn(o,t,e={}){const n=Hi(o,t,e),s=Ef(n);return s[0]?[new xf(s[0],function*(){for(const f of n)f[0]&&(yield f[0])}),void 0]:[void 0,s[1]]}function Fr(o,t){return new er({type:o,schema:null,validator:t})}function Bf(){return Fr("any",()=>!0)}function nt(o){return new er({type:"array",schema:o,*entries(t){if(o&&Array.isArray(t))for(const[e,n]of t.entries())yield[e,n,o]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${Ye(t)}`}})}function rr(){return Fr("boolean",o=>typeof o=="boolean")}function Vi(o){return Fr("instance",t=>t instanceof o||`Expected a \`${o.name}\` instance, but received: ${Ye(t)}`)}function Jt(o){const t=Ye(o),e=typeof o;return new er({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?o:null,validator(n){return n===o||`Expected the literal \`${t}\`, but received: ${Ye(n)}`}})}function Af(){return Fr("never",()=>!1)}function rt(o){return new er({...o,validator:(t,e)=>t===null||o.validator(t,e),refiner:(t,e)=>t===null||o.refiner(t,e)})}function O(){return Fr("number",o=>typeof o=="number"&&!isNaN(o)||`Expected a number, but received: ${Ye(o)}`)}function pt(o){return new er({...o,validator:(t,e)=>t===void 0||o.validator(t,e),refiner:(t,e)=>t===void 0||o.refiner(t,e)})}function pa(o,t){return new er({type:"record",schema:null,*entries(e){if(dr(e))for(const n in e){const s=e[n];yield[n,n,o],yield[n,s,t]}},validator(e){return dr(e)||`Expected an object, but received: ${Ye(e)}`}})}function Q(){return Fr("string",o=>typeof o=="string"||`Expected a string, but received: ${Ye(o)}`)}function ji(o){const t=Af();return new er({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const n=Math.max(o.length,e.length);for(let s=0;s<n;s++)yield[s,e[s],o[s]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Ye(e)}`}})}function j(o){const t=Object.keys(o);return new er({type:"type",schema:o,*entries(e){if(dr(e))for(const n of t)yield[n,e[n],o[n]]},validator(e){return dr(e)||`Expected an object, but received: ${Ye(e)}`},coercer(e){return dr(e)?{...e}:e}})}function Ue(o){const t=o.map(e=>e.type).join(" | ");return new er({type:"union",schema:null,coercer(e){for(const n of o){const[s,a]=n.validate(e,{coerce:!0});if(!s)return a}return e},validator(e,n){const s=[];for(const a of o){const[...f]=Hi(e,a,n),[u]=f;if(u[0])for(const[p]of f)p&&s.push(p);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Ye(e)}`,...s]}})}function bn(){return Fr("unknown",()=>!0)}function xn(o,t,e){return new er({...o,coercer:(n,s)=>da(n,t)?o.coercer(e(n,s),s):o.coercer(n,s)})}var Vn,vf=new Uint8Array(16);function ga(){if(!Vn&&(Vn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Vn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Vn(vf)}const _f=/^(?:[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 jn(o){return typeof o=="string"&&_f.test(o)}for(var ve=[],Gi=0;Gi<256;++Gi)ve.push((Gi+256).toString(16).substr(1));function Gn(o){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(ve[o[t+0]]+ve[o[t+1]]+ve[o[t+2]]+ve[o[t+3]]+"-"+ve[o[t+4]]+ve[o[t+5]]+"-"+ve[o[t+6]]+ve[o[t+7]]+"-"+ve[o[t+8]]+ve[o[t+9]]+"-"+ve[o[t+10]]+ve[o[t+11]]+ve[o[t+12]]+ve[o[t+13]]+ve[o[t+14]]+ve[o[t+15]]).toLowerCase();if(!jn(e))throw TypeError("Stringified UUID is invalid");return e}var ya,Yi,Zi=0,Ji=0;function Rf(o,t,e){var n=t&&e||0,s=t||new Array(16);o=o||{};var a=o.node||ya,f=o.clockseq!==void 0?o.clockseq:Yi;if(a==null||f==null){var u=o.random||(o.rng||ga)();a==null&&(a=ya=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),f==null&&(f=Yi=(u[6]<<8|u[7])&16383)}var p=o.msecs!==void 0?o.msecs:Date.now(),b=o.nsecs!==void 0?o.nsecs:Ji+1,E=p-Zi+(b-Ji)/1e4;if(E<0&&o.clockseq===void 0&&(f=f+1&16383),(E<0||p>Zi)&&o.nsecs===void 0&&(b=0),b>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Zi=p,Ji=b,Yi=f,p+=122192928e5;var I=((p&268435455)*1e4+b)%4294967296;s[n++]=I>>>24&255,s[n++]=I>>>16&255,s[n++]=I>>>8&255,s[n++]=I&255;var M=p/4294967296*1e4&268435455;s[n++]=M>>>8&255,s[n++]=M&255,s[n++]=M>>>24&15|16,s[n++]=M>>>16&255,s[n++]=f>>>8|128,s[n++]=f&255;for(var T=0;T<6;++T)s[n+T]=a[T];return t||Gn(s)}function ma(o){if(!jn(o))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(o.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(o.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(o.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(o.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(o.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function Tf(o){o=unescape(encodeURIComponent(o));for(var t=[],e=0;e<o.length;++e)t.push(o.charCodeAt(e));return t}var Mf="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Pf="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function wa(o,t,e){function n(s,a,f,u){if(typeof s=="string"&&(s=Tf(s)),typeof a=="string"&&(a=ma(a)),a.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var p=new Uint8Array(16+s.length);if(p.set(a),p.set(s,a.length),p=e(p),p[6]=p[6]&15|t,p[8]=p[8]&63|128,f){u=u||0;for(var b=0;b<16;++b)f[u+b]=p[b];return f}return Gn(p)}try{n.name=o}catch{}return n.DNS=Mf,n.URL=Pf,n}function Lf(o){if(typeof o=="string"){var t=unescape(encodeURIComponent(o));o=new Uint8Array(t.length);for(var e=0;e<t.length;++e)o[e]=t.charCodeAt(e)}return Uf(Cf(Ff(o),o.length*8))}function Uf(o){for(var t=[],e=o.length*32,n="0123456789abcdef",s=0;s<e;s+=8){var a=o[s>>5]>>>s%32&255,f=parseInt(n.charAt(a>>>4&15)+n.charAt(a&15),16);t.push(f)}return t}function ba(o){return(o+64>>>9<<4)+14+1}function Cf(o,t){o[t>>5]|=128<<t%32,o[ba(t)-1]=t;for(var e=1732584193,n=-271733879,s=-1732584194,a=271733878,f=0;f<o.length;f+=16){var u=e,p=n,b=s,E=a;e=_e(e,n,s,a,o[f],7,-680876936),a=_e(a,e,n,s,o[f+1],12,-389564586),s=_e(s,a,e,n,o[f+2],17,606105819),n=_e(n,s,a,e,o[f+3],22,-1044525330),e=_e(e,n,s,a,o[f+4],7,-176418897),a=_e(a,e,n,s,o[f+5],12,1200080426),s=_e(s,a,e,n,o[f+6],17,-1473231341),n=_e(n,s,a,e,o[f+7],22,-45705983),e=_e(e,n,s,a,o[f+8],7,1770035416),a=_e(a,e,n,s,o[f+9],12,-1958414417),s=_e(s,a,e,n,o[f+10],17,-42063),n=_e(n,s,a,e,o[f+11],22,-1990404162),e=_e(e,n,s,a,o[f+12],7,1804603682),a=_e(a,e,n,s,o[f+13],12,-40341101),s=_e(s,a,e,n,o[f+14],17,-1502002290),n=_e(n,s,a,e,o[f+15],22,1236535329),e=Re(e,n,s,a,o[f+1],5,-165796510),a=Re(a,e,n,s,o[f+6],9,-1069501632),s=Re(s,a,e,n,o[f+11],14,643717713),n=Re(n,s,a,e,o[f],20,-373897302),e=Re(e,n,s,a,o[f+5],5,-701558691),a=Re(a,e,n,s,o[f+10],9,38016083),s=Re(s,a,e,n,o[f+15],14,-660478335),n=Re(n,s,a,e,o[f+4],20,-405537848),e=Re(e,n,s,a,o[f+9],5,568446438),a=Re(a,e,n,s,o[f+14],9,-1019803690),s=Re(s,a,e,n,o[f+3],14,-187363961),n=Re(n,s,a,e,o[f+8],20,1163531501),e=Re(e,n,s,a,o[f+13],5,-1444681467),a=Re(a,e,n,s,o[f+2],9,-51403784),s=Re(s,a,e,n,o[f+7],14,1735328473),n=Re(n,s,a,e,o[f+12],20,-1926607734),e=Te(e,n,s,a,o[f+5],4,-378558),a=Te(a,e,n,s,o[f+8],11,-2022574463),s=Te(s,a,e,n,o[f+11],16,1839030562),n=Te(n,s,a,e,o[f+14],23,-35309556),e=Te(e,n,s,a,o[f+1],4,-1530992060),a=Te(a,e,n,s,o[f+4],11,1272893353),s=Te(s,a,e,n,o[f+7],16,-155497632),n=Te(n,s,a,e,o[f+10],23,-1094730640),e=Te(e,n,s,a,o[f+13],4,681279174),a=Te(a,e,n,s,o[f],11,-358537222),s=Te(s,a,e,n,o[f+3],16,-722521979),n=Te(n,s,a,e,o[f+6],23,76029189),e=Te(e,n,s,a,o[f+9],4,-640364487),a=Te(a,e,n,s,o[f+12],11,-421815835),s=Te(s,a,e,n,o[f+15],16,530742520),n=Te(n,s,a,e,o[f+2],23,-995338651),e=Me(e,n,s,a,o[f],6,-198630844),a=Me(a,e,n,s,o[f+7],10,1126891415),s=Me(s,a,e,n,o[f+14],15,-1416354905),n=Me(n,s,a,e,o[f+5],21,-57434055),e=Me(e,n,s,a,o[f+12],6,1700485571),a=Me(a,e,n,s,o[f+3],10,-1894986606),s=Me(s,a,e,n,o[f+10],15,-1051523),n=Me(n,s,a,e,o[f+1],21,-2054922799),e=Me(e,n,s,a,o[f+8],6,1873313359),a=Me(a,e,n,s,o[f+15],10,-30611744),s=Me(s,a,e,n,o[f+6],15,-1560198380),n=Me(n,s,a,e,o[f+13],21,1309151649),e=Me(e,n,s,a,o[f+4],6,-145523070),a=Me(a,e,n,s,o[f+11],10,-1120210379),s=Me(s,a,e,n,o[f+2],15,718787259),n=Me(n,s,a,e,o[f+9],21,-343485551),e=Br(e,u),n=Br(n,p),s=Br(s,b),a=Br(a,E)}return[e,n,s,a]}function Ff(o){if(o.length===0)return[];for(var t=o.length*8,e=new Uint32Array(ba(t)),n=0;n<t;n+=8)e[n>>5]|=(o[n/8]&255)<<n%32;return e}function Br(o,t){var e=(o&65535)+(t&65535),n=(o>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function Of(o,t){return o<<t|o>>>32-t}function Yn(o,t,e,n,s,a){return Br(Of(Br(Br(t,o),Br(n,a)),s),e)}function _e(o,t,e,n,s,a,f){return Yn(t&e|~t&n,o,t,s,a,f)}function Re(o,t,e,n,s,a,f){return Yn(t&n|e&~n,o,t,s,a,f)}function Te(o,t,e,n,s,a,f){return Yn(t^e^n,o,t,s,a,f)}function Me(o,t,e,n,s,a,f){return Yn(e^(t|~n),o,t,s,a,f)}var Nf=wa("v3",48,Lf);const zf=Nf;function Df(o,t,e){o=o||{};var n=o.random||(o.rng||ga)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var s=0;s<16;++s)t[e+s]=n[s];return t}return Gn(n)}function $f(o,t,e,n){switch(o){case 0:return t&e^~t&n;case 1:return t^e^n;case 2:return t&e^t&n^e&n;case 3:return t^e^n}}function Xi(o,t){return o<<t|o>>>32-t}function Wf(o){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof o=="string"){var n=unescape(encodeURIComponent(o));o=[];for(var s=0;s<n.length;++s)o.push(n.charCodeAt(s))}else Array.isArray(o)||(o=Array.prototype.slice.call(o));o.push(128);for(var a=o.length/4+2,f=Math.ceil(a/16),u=new Array(f),p=0;p<f;++p){for(var b=new Uint32Array(16),E=0;E<16;++E)b[E]=o[p*64+E*4]<<24|o[p*64+E*4+1]<<16|o[p*64+E*4+2]<<8|o[p*64+E*4+3];u[p]=b}u[f-1][14]=(o.length-1)*8/Math.pow(2,32),u[f-1][14]=Math.floor(u[f-1][14]),u[f-1][15]=(o.length-1)*8&4294967295;for(var I=0;I<f;++I){for(var M=new Uint32Array(80),T=0;T<16;++T)M[T]=u[I][T];for(var U=16;U<80;++U)M[U]=Xi(M[U-3]^M[U-8]^M[U-14]^M[U-16],1);for(var _=e[0],L=e[1],C=e[2],$=e[3],N=e[4],H=0;H<80;++H){var D=Math.floor(H/20),F=Xi(_,5)+$f(D,L,C,$)+N+t[D]+M[H]>>>0;N=$,$=C,C=Xi(L,30)>>>0,L=_,_=F}e[0]=e[0]+_>>>0,e[1]=e[1]+L>>>0,e[2]=e[2]+C>>>0,e[3]=e[3]+$>>>0,e[4]=e[4]+N>>>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 Kf=wa("v5",80,Wf);const qf=Kf,Hf="00000000-0000-0000-0000-000000000000";function Vf(o){if(!jn(o))throw TypeError("Invalid UUID");return parseInt(o.substr(14,1),16)}const xa=li(Object.freeze(Object.defineProperty({__proto__:null,NIL:Hf,parse:ma,stringify:Gn,v1:Rf,v3:zf,v4:Df,v5:qf,validate:jn,version:Vf},Symbol.toStringTag,{value:"Module"}))),jf=xa.v4;var Gf=function(o,t,e,n){if(typeof o!="string")throw new TypeError(o+" must be a string");n=n||{};const s=typeof n.version=="number"?n.version:2;if(s!==1&&s!==2)throw new TypeError(s+" must be 1 or 2");const a={method:o};if(s===2&&(a.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");a.params=t}if(typeof e>"u"){const f=typeof n.generator=="function"?n.generator:function(){return jf()};a.id=f(a,n)}else s===2&&e===null?n.notificationIdNull&&(a.id=null):a.id=e;return a};const Yf=xa.v4,Zf=Gf,kn=function(o,t){if(!(this instanceof kn))return new kn(o,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return Yf()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=o};var Jf=kn;kn.prototype.request=function(o,t,e,n){const s=this;let a=null;const f=Array.isArray(o)&&typeof t=="function";if(this.options.version===1&&f)throw new TypeError("JSON-RPC 1.0 does not support batching");if(f||!f&&o&&typeof o=="object"&&typeof t=="function")n=t,a=o;else{typeof e=="function"&&(n=e,e=void 0);const b=typeof n=="function";try{a=Zf(o,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(E){if(b)return n(E);throw E}if(!b)return a}let p;try{p=JSON.stringify(a,this.options.replacer)}catch(b){return n(b)}return this.callServer(p,function(b,E){s._parseResponse(b,E,n)}),a},kn.prototype._parseResponse=function(o,t,e){if(o){e(o);return}if(!t)return e();let n;try{n=JSON.parse(t,this.options.reviver)}catch(s){return e(s)}if(e.length===3)if(Array.isArray(n)){const s=function(f){return typeof f.error<"u"},a=function(f){return!s(f)};return e(null,n.filter(s),n.filter(a))}else return e(null,n.error,n.result);e(null,n)};const Xf=ln(Jf);var ka={exports:{}};(function(o){var t=Object.prototype.hasOwnProperty,e="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(e=!1));function s(p,b,E){this.fn=p,this.context=b,this.once=E||!1}function a(p,b,E,I,M){if(typeof E!="function")throw new TypeError("The listener must be a function");var T=new s(E,I||p,M),U=e?e+b:b;return p._events[U]?p._events[U].fn?p._events[U]=[p._events[U],T]:p._events[U].push(T):(p._events[U]=T,p._eventsCount++),p}function f(p,b){--p._eventsCount===0?p._events=new n:delete p._events[b]}function u(){this._events=new n,this._eventsCount=0}u.prototype.eventNames=function(){var b=[],E,I;if(this._eventsCount===0)return b;for(I in E=this._events)t.call(E,I)&&b.push(e?I.slice(1):I);return Object.getOwnPropertySymbols?b.concat(Object.getOwnPropertySymbols(E)):b},u.prototype.listeners=function(b){var E=e?e+b:b,I=this._events[E];if(!I)return[];if(I.fn)return[I.fn];for(var M=0,T=I.length,U=new Array(T);M<T;M++)U[M]=I[M].fn;return U},u.prototype.listenerCount=function(b){var E=e?e+b:b,I=this._events[E];return I?I.fn?1:I.length:0},u.prototype.emit=function(b,E,I,M,T,U){var _=e?e+b:b;if(!this._events[_])return!1;var L=this._events[_],C=arguments.length,$,N;if(L.fn){switch(L.once&&this.removeListener(b,L.fn,void 0,!0),C){case 1:return L.fn.call(L.context),!0;case 2:return L.fn.call(L.context,E),!0;case 3:return L.fn.call(L.context,E,I),!0;case 4:return L.fn.call(L.context,E,I,M),!0;case 5:return L.fn.call(L.context,E,I,M,T),!0;case 6:return L.fn.call(L.context,E,I,M,T,U),!0}for(N=1,$=new Array(C-1);N<C;N++)$[N-1]=arguments[N];L.fn.apply(L.context,$)}else{var H=L.length,D;for(N=0;N<H;N++)switch(L[N].once&&this.removeListener(b,L[N].fn,void 0,!0),C){case 1:L[N].fn.call(L[N].context);break;case 2:L[N].fn.call(L[N].context,E);break;case 3:L[N].fn.call(L[N].context,E,I);break;case 4:L[N].fn.call(L[N].context,E,I,M);break;default:if(!$)for(D=1,$=new Array(C-1);D<C;D++)$[D-1]=arguments[D];L[N].fn.apply(L[N].context,$)}}return!0},u.prototype.on=function(b,E,I){return a(this,b,E,I,!1)},u.prototype.once=function(b,E,I){return a(this,b,E,I,!0)},u.prototype.removeListener=function(b,E,I,M){var T=e?e+b:b;if(!this._events[T])return this;if(!E)return f(this,T),this;var U=this._events[T];if(U.fn)U.fn===E&&(!M||U.once)&&(!I||U.context===I)&&f(this,T);else{for(var _=0,L=[],C=U.length;_<C;_++)(U[_].fn!==E||M&&!U[_].once||I&&U[_].context!==I)&&L.push(U[_]);L.length?this._events[T]=L.length===1?L[0]:L:f(this,T)}return this},u.prototype.removeAllListeners=function(b){var E;return b?(E=e?e+b:b,this._events[E]&&f(this,E)):(this._events=new n,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,o.exports=u})(ka);var Qf=ka.exports;const Ea=ln(Qf);var th=class extends Ea{constructor(t,e,n){super();we(this,"socket");this.socket=new window.WebSocket(t,n),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,n){const s=n||e;try{this.socket.send(t),s()}catch(a){s(a)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,n){this.socket.addEventListener(t,e,n)}};function eh(o,t){return new th(o,t)}var rh=class{encode(o){return JSON.stringify(o)}decode(o){return JSON.parse(o)}},nh=class extends Ea{constructor(t,e="ws://localhost:8080",{autoconnect:n=!0,reconnect:s=!0,reconnect_interval:a=1e3,max_reconnects:f=5,...u}={},p,b){super();we(this,"address");we(this,"rpc_id");we(this,"queue");we(this,"options");we(this,"autoconnect");we(this,"ready");we(this,"reconnect");we(this,"reconnect_timer_id");we(this,"reconnect_interval");we(this,"max_reconnects");we(this,"rest_options");we(this,"current_reconnects");we(this,"generate_request_id");we(this,"socket");we(this,"webSocketFactory");we(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=n,this.ready=!1,this.reconnect=s,this.reconnect_timer_id=void 0,this.reconnect_interval=a,this.max_reconnects=f,this.rest_options=u,this.current_reconnects=0,this.generate_request_id=p||(()=>++this.rpc_id),b?this.dataPack=b:this.dataPack=new rh,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(t,e,n,s){return!s&&typeof n=="object"&&(s=n,n=null),new Promise((a,f)=>{if(!this.ready)return f(new Error("socket not ready"));const u=this.generate_request_id(t,e),p={jsonrpc:"2.0",method:t,params:e||void 0,id:u};this.socket.send(this.dataPack.encode(p),s,b=>{if(b)return f(b);this.queue[u]={promise:[a,f]},n&&(this.queue[u].timeout=setTimeout(()=>{delete this.queue[u],f(new Error("reply timeout"))},n))})})}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise((n,s)=>{if(!this.ready)return s(new Error("socket not ready"));const a={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(a),f=>{if(f)return s(f);n()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:n})=>{n instanceof ArrayBuffer&&(n=lt.Buffer.from(n).toString());try{n=this.dataPack.decode(n)}catch{return}if(n.notification&&this.listeners(n.notification).length){if(!Object.keys(n.params).length)return this.emit(n.notification);const s=[n.notification];if(n.params.constructor===Object)s.push(n.params);else for(let a=0;a<n.params.length;a++)s.push(n.params[a]);return Promise.resolve().then(()=>{this.emit.apply(this,s)})}if(!this.queue[n.id])return n.method?Promise.resolve().then(()=>{this.emit(n.method,n==null?void 0:n.params)}):void 0;"error"in n=="result"in n&&this.queue[n.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[n.id].timeout&&clearTimeout(this.queue[n.id].timeout),n.error?this.queue[n.id].promise[1](n.error):this.queue[n.id].promise[0](n.result),delete this.queue[n.id]}),this.socket.addEventListener("error",n=>this.emit("error",n)),this.socket.addEventListener("close",({code:n,reason:s})=>{this.ready&&setTimeout(()=>this.emit("close",n,s),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(t,e),this.reconnect_interval)))})}};const Ia=[],Sa=[],Ba=[],ih=BigInt(0),En=BigInt(1),oh=BigInt(2),sh=BigInt(7),ah=BigInt(256),ch=BigInt(113);for(let o=0,t=En,e=1,n=0;o<24;o++){[e,n]=[n,(2*e+3*n)%5],Ia.push(2*(5*n+e)),Sa.push((o+1)*(o+2)/2%64);let s=ih;for(let a=0;a<7;a++)t=(t<<En^(t>>sh)*ch)%ah,t&oh&&(s^=En<<(En<<BigInt(a))-En);Ba.push(s)}const[uh,fh]=ls(Ba,!0),Aa=(o,t,e)=>e>32?gs(o,t,e):ds(o,t,e),va=(o,t,e)=>e>32?ys(o,t,e):ps(o,t,e);function hh(o,t=24){const e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let f=0;f<10;f++)e[f]=o[f]^o[f+10]^o[f+20]^o[f+30]^o[f+40];for(let f=0;f<10;f+=2){const u=(f+8)%10,p=(f+2)%10,b=e[p],E=e[p+1],I=Aa(b,E,1)^e[u],M=va(b,E,1)^e[u+1];for(let T=0;T<50;T+=10)o[f+T]^=I,o[f+T+1]^=M}let s=o[2],a=o[3];for(let f=0;f<24;f++){const u=Sa[f],p=Aa(s,a,u),b=va(s,a,u),E=Ia[f];s=o[E],a=o[E+1],o[E]=p,o[E+1]=b}for(let f=0;f<50;f+=10){for(let u=0;u<10;u++)e[u]=o[f+u];for(let u=0;u<10;u++)o[f+u]^=~e[(u+2)%10]&e[(u+4)%10]}o[0]^=uh[n],o[1]^=fh[n]}e.fill(0)}class Qi extends yi{constructor(t,e,n,s=!1,a=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=s,this.rounds=a,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Pn(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Vc(this.state)}keccak(){os||ss(this.state32),hh(this.state32,this.rounds),os||ss(this.state32),this.posOut=0,this.pos=0}update(t){jr(this);const{blockLen:e,state:n}=this;t=Ln(t);const s=t.length;for(let a=0;a<s;){const f=Math.min(e-this.pos,s-a);for(let u=0;u<f;u++)n[this.pos++]^=t[a++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:s}=this;t[n]^=e,e&128&&n===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){jr(this,!1),pn(t),this.finish();const e=this.state,{blockLen:n}=this;for(let s=0,a=t.length;s<a;){this.posOut>=n&&this.keccak();const f=Math.min(n-this.posOut,a-s);t.set(e.subarray(this.posOut,this.posOut+f),s),this.posOut+=f,s+=f}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Pn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(is(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:s,rounds:a,enableXOF:f}=this;return t||(t=new Qi(e,n,s,f,a)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=n,t.outputLen=s,t.enableXOF=f,t.destroyed=this.destroyed,t}}const _a=((o,t,e)=>mi(()=>new Qi(t,o,e)))(1,136,256/8);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lh(o){const t=Bi(o);Jr(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:n,a:s}=t;if(e){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:dh,hexToBytes:ph}=bu,Or={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(o){const{Err:t}=Or;if(o.length<2||o[0]!==2)throw new t("Invalid signature integer tag");const e=o[1],n=o.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:dh(n),l:o.subarray(e+2)}},toSig(o){const{Err:t}=Or,e=typeof o=="string"?ph(o):o;gn(e);let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");const{d:s,l:a}=Or._parseInt(e.subarray(2)),{d:f,l:u}=Or._parseInt(a);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:f}},hexFromSig(o){const t=b=>Number.parseInt(b[0],16)&8?"00"+b:b,e=b=>{const E=b.toString(16);return E.length&1?`0${E}`:E},n=t(e(o.s)),s=t(e(o.r)),a=n.length/2,f=s.length/2,u=e(a),p=e(f);return`30${e(f+a+4)}02${p}${s}02${u}${n}`}},pr=BigInt(0),He=BigInt(1);BigInt(2);const Ra=BigInt(3);BigInt(4);function gh(o){const t=lh(o),{Fp:e}=t,n=t.toBytes||((U,_,L)=>{const C=_.toAffine();return Mr(Uint8Array.from([4]),e.toBytes(C.x),e.toBytes(C.y))}),s=t.fromBytes||(U=>{const _=U.subarray(1),L=e.fromBytes(_.subarray(0,e.BYTES)),C=e.fromBytes(_.subarray(e.BYTES,2*e.BYTES));return{x:L,y:C}});function a(U){const{a:_,b:L}=t,C=e.sqr(U),$=e.mul(C,U);return e.add(e.add($,e.mul(U,_)),L)}if(!e.eql(e.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function f(U){return typeof U=="bigint"&&pr<U&&U<t.n}function u(U){if(!f(U))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function p(U){const{allowedPrivateKeyLengths:_,nByteLength:L,wrapPrivateKey:C,n:$}=t;if(_&&typeof U!="bigint"){if(_r(U)&&(U=Rr(U)),typeof U!="string"||!_.includes(U.length))throw new Error("Invalid key");U=U.padStart(L*2,"0")}let N;try{N=typeof U=="bigint"?U:Tr(be("private key",U,L))}catch{throw new Error(`private key must be ${L} bytes, hex or bigint, not ${typeof U}`)}return C&&(N=Gt(N,$)),u(N),N}const b=new Map;function E(U){if(!(U instanceof I))throw new Error("ProjectivePoint expected")}class I{constructor(_,L,C){if(this.px=_,this.py=L,this.pz=C,_==null||!e.isValid(_))throw new Error("x required");if(L==null||!e.isValid(L))throw new Error("y required");if(C==null||!e.isValid(C))throw new Error("z required")}static fromAffine(_){const{x:L,y:C}=_||{};if(!_||!e.isValid(L)||!e.isValid(C))throw new Error("invalid affine point");if(_ instanceof I)throw new Error("projective point not allowed");const $=N=>e.eql(N,e.ZERO);return $(L)&&$(C)?I.ZERO:new I(L,C,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(_){const L=e.invertBatch(_.map(C=>C.pz));return _.map((C,$)=>C.toAffine(L[$])).map(I.fromAffine)}static fromHex(_){const L=I.fromAffine(s(be("pointHex",_)));return L.assertValidity(),L}static fromPrivateKey(_){return I.BASE.multiply(p(_))}_setWindowSize(_){this._WINDOW_SIZE=_,b.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:_,y:L}=this.toAffine();if(!e.isValid(_)||!e.isValid(L))throw new Error("bad point: x or y not FE");const C=e.sqr(L),$=a(_);if(!e.eql(C,$))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:_}=this.toAffine();if(e.isOdd)return!e.isOdd(_);throw new Error("Field doesn't support isOdd")}equals(_){E(_);const{px:L,py:C,pz:$}=this,{px:N,py:H,pz:D}=_,F=e.eql(e.mul(L,D),e.mul(N,$)),W=e.eql(e.mul(C,D),e.mul(H,$));return F&&W}negate(){return new I(this.px,e.neg(this.py),this.pz)}double(){const{a:_,b:L}=t,C=e.mul(L,Ra),{px:$,py:N,pz:H}=this;let D=e.ZERO,F=e.ZERO,W=e.ZERO,q=e.mul($,$),Bt=e.mul(N,N),gt=e.mul(H,H),ot=e.mul($,N);return ot=e.add(ot,ot),W=e.mul($,H),W=e.add(W,W),D=e.mul(_,W),F=e.mul(C,gt),F=e.add(D,F),D=e.sub(Bt,F),F=e.add(Bt,F),F=e.mul(D,F),D=e.mul(ot,D),W=e.mul(C,W),gt=e.mul(_,gt),ot=e.sub(q,gt),ot=e.mul(_,ot),ot=e.add(ot,W),W=e.add(q,q),q=e.add(W,q),q=e.add(q,gt),q=e.mul(q,ot),F=e.add(F,q),gt=e.mul(N,H),gt=e.add(gt,gt),q=e.mul(gt,ot),D=e.sub(D,q),W=e.mul(gt,Bt),W=e.add(W,W),W=e.add(W,W),new I(D,F,W)}add(_){E(_);const{px:L,py:C,pz:$}=this,{px:N,py:H,pz:D}=_;let F=e.ZERO,W=e.ZERO,q=e.ZERO;const Bt=t.a,gt=e.mul(t.b,Ra);let ot=e.mul(L,N),At=e.mul(C,H),R=e.mul($,D),l=e.add(L,C),y=e.add(N,H);l=e.mul(l,y),y=e.add(ot,At),l=e.sub(l,y),y=e.add(L,$);let k=e.add(N,D);return y=e.mul(y,k),k=e.add(ot,R),y=e.sub(y,k),k=e.add(C,$),F=e.add(H,D),k=e.mul(k,F),F=e.add(At,R),k=e.sub(k,F),q=e.mul(Bt,y),F=e.mul(gt,R),q=e.add(F,q),F=e.sub(At,q),q=e.add(At,q),W=e.mul(F,q),At=e.add(ot,ot),At=e.add(At,ot),R=e.mul(Bt,R),y=e.mul(gt,y),At=e.add(At,R),R=e.sub(ot,R),R=e.mul(Bt,R),y=e.add(y,R),ot=e.mul(At,y),W=e.add(W,ot),ot=e.mul(k,y),F=e.mul(l,F),F=e.sub(F,ot),ot=e.mul(l,At),q=e.mul(k,q),q=e.add(q,ot),new I(F,W,q)}subtract(_){return this.add(_.negate())}is0(){return this.equals(I.ZERO)}wNAF(_){return T.wNAFCached(this,b,_,L=>{const C=e.invertBatch(L.map($=>$.pz));return L.map(($,N)=>$.toAffine(C[N])).map(I.fromAffine)})}multiplyUnsafe(_){const L=I.ZERO;if(_===pr)return L;if(u(_),_===He)return this;const{endo:C}=t;if(!C)return T.unsafeLadder(this,_);let{k1neg:$,k1:N,k2neg:H,k2:D}=C.splitScalar(_),F=L,W=L,q=this;for(;N>pr||D>pr;)N&He&&(F=F.add(q)),D&He&&(W=W.add(q)),q=q.double(),N>>=He,D>>=He;return $&&(F=F.negate()),H&&(W=W.negate()),W=new I(e.mul(W.px,C.beta),W.py,W.pz),F.add(W)}multiply(_){u(_);let L=_,C,$;const{endo:N}=t;if(N){const{k1neg:H,k1:D,k2neg:F,k2:W}=N.splitScalar(L);let{p:q,f:Bt}=this.wNAF(D),{p:gt,f:ot}=this.wNAF(W);q=T.constTimeNegate(H,q),gt=T.constTimeNegate(F,gt),gt=new I(e.mul(gt.px,N.beta),gt.py,gt.pz),C=q.add(gt),$=Bt.add(ot)}else{const{p:H,f:D}=this.wNAF(L);C=H,$=D}return I.normalizeZ([C,$])[0]}multiplyAndAddUnsafe(_,L,C){const $=I.BASE,N=(D,F)=>F===pr||F===He||!D.equals($)?D.multiplyUnsafe(F):D.multiply(F),H=N(this,L).add(N(_,C));return H.is0()?void 0:H}toAffine(_){const{px:L,py:C,pz:$}=this,N=this.is0();_==null&&(_=N?e.ONE:e.inv($));const H=e.mul(L,_),D=e.mul(C,_),F=e.mul($,_);if(N)return{x:e.ZERO,y:e.ZERO};if(!e.eql(F,e.ONE))throw new Error("invZ was invalid");return{x:H,y:D}}isTorsionFree(){const{h:_,isTorsionFree:L}=t;if(_===He)return!0;if(L)return L(I,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:_,clearCofactor:L}=t;return _===He?this:L?L(I,this):this.multiplyUnsafe(t.h)}toRawBytes(_=!0){return this.assertValidity(),n(I,this,_)}toHex(_=!0){return Rr(this.toRawBytes(_))}}I.BASE=new I(t.Gx,t.Gy,e.ONE),I.ZERO=new I(e.ZERO,e.ONE,e.ZERO);const M=t.nBitLength,T=Rs(I,t.endo?Math.ceil(M/2):M);return{CURVE:t,ProjectivePoint:I,normPrivateKeyToScalar:p,weierstrassEquation:a,isWithinCurveOrder:f}}function yh(o){const t=Bi(o);return Jr(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function mh(o){const t=yh(o),{Fp:e,n}=t,s=e.BYTES+1,a=2*e.BYTES+1;function f(y){return pr<y&&y<e.ORDER}function u(y){return Gt(y,n)}function p(y){return Ii(y,n)}const{ProjectivePoint:b,normPrivateKeyToScalar:E,weierstrassEquation:I,isWithinCurveOrder:M}=gh({...t,toBytes(y,k,A){const S=k.toAffine(),B=e.toBytes(S.x),P=Mr;return A?P(Uint8Array.from([k.hasEvenY()?2:3]),B):P(Uint8Array.from([4]),B,e.toBytes(S.y))},fromBytes(y){const k=y.length,A=y[0],S=y.subarray(1);if(k===s&&(A===2||A===3)){const B=Tr(S);if(!f(B))throw new Error("Point is not on curve");const P=I(B);let w;try{w=e.sqrt(P)}catch(Y){const J=Y instanceof Error?": "+Y.message:"";throw new Error("Point is not on curve"+J)}const d=(w&He)===He;return(A&1)===1!==d&&(w=e.neg(w)),{x:B,y:w}}else if(k===a&&A===4){const B=e.fromBytes(S.subarray(0,e.BYTES)),P=e.fromBytes(S.subarray(e.BYTES,2*e.BYTES));return{x:B,y:P}}else throw new Error(`Point of length ${k} was invalid. Expected ${s} compressed bytes or ${a} uncompressed bytes`)}}),T=y=>Rr(Zr(y,t.nByteLength));function U(y){const k=n>>He;return y>k}function _(y){return U(y)?u(-y):y}const L=(y,k,A)=>Tr(y.slice(k,A));class C{constructor(k,A,S){this.r=k,this.s=A,this.recovery=S,this.assertValidity()}static fromCompact(k){const A=t.nByteLength;return k=be("compactSignature",k,A*2),new C(L(k,0,A),L(k,A,2*A))}static fromDER(k){const{r:A,s:S}=Or.toSig(be("DER",k));return new C(A,S)}assertValidity(){if(!M(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!M(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(k){return new C(this.r,this.s,k)}recoverPublicKey(k){const{r:A,s:S,recovery:B}=this,P=W(be("msgHash",k));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");const w=B===2||B===3?A+t.n:A;if(w>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=B&1?"03":"02",v=b.fromHex(d+T(w)),Y=p(w),J=u(-P*Y),X=u(S*Y),ft=b.BASE.multiplyAndAddUnsafe(v,J,X);if(!ft)throw new Error("point at infinify");return ft.assertValidity(),ft}hasHighS(){return U(this.s)}normalizeS(){return this.hasHighS()?new C(this.r,u(-this.s),this.recovery):this}toDERRawBytes(){return Gr(this.toDERHex())}toDERHex(){return Or.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gr(this.toCompactHex())}toCompactHex(){return T(this.r)+T(this.s)}}const $={isValidPrivateKey(y){try{return E(y),!0}catch{return!1}},normPrivateKeyToScalar:E,randomPrivateKey:()=>{const y=_s(t.n);return Tu(t.randomBytes(y),t.n)},precompute(y=8,k=b.BASE){return k._setWindowSize(y),k.multiply(BigInt(3)),k}};function N(y,k=!0){return b.fromPrivateKey(y).toRawBytes(k)}function H(y){const k=_r(y),A=typeof y=="string",S=(k||A)&&y.length;return k?S===s||S===a:A?S===2*s||S===2*a:y instanceof b}function D(y,k,A=!0){if(H(y))throw new Error("first arg must be private key");if(!H(k))throw new Error("second arg must be public key");return b.fromHex(k).multiply(E(y)).toRawBytes(A)}const F=t.bits2int||function(y){const k=Tr(y),A=y.length*8-t.nBitLength;return A>0?k>>BigInt(A):k},W=t.bits2int_modN||function(y){return u(F(y))},q=xi(t.nBitLength);function Bt(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(pr<=y&&y<q))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Zr(y,t.nByteLength)}function gt(y,k,A=ot){if(["recovered","canonical"].some(ht=>ht in A))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:B}=t;let{lowS:P,prehash:w,extraEntropy:d}=A;P==null&&(P=!0),y=be("msgHash",y),w&&(y=be("prehashed msgHash",S(y)));const v=W(y),Y=E(k),J=[Bt(Y),Bt(v)];if(d!=null&&d!==!1){const ht=d===!0?B(e.BYTES):d;J.push(be("extraEntropy",ht))}const X=Mr(...J),ft=v;function st(ht){const Wt=F(ht);if(!M(Wt))return;const wt=p(Wt),yt=b.BASE.multiply(Wt).toAffine(),mt=u(yt.x);if(mt===pr)return;const dt=u(wt*u(ft+mt*Y));if(dt===pr)return;let Mt=(yt.x===mt?0:2)|Number(yt.y&He),Oe=dt;return P&&U(dt)&&(Oe=_(dt),Mt^=1),new C(mt,Oe,Mt)}return{seed:X,k2sig:st}}const ot={lowS:t.lowS,prehash:!1},At={lowS:t.lowS,prehash:!1};function R(y,k,A=ot){const{seed:S,k2sig:B}=gt(y,k,A),P=t;return Es(P.hash.outputLen,P.nByteLength,P.hmac)(S,B)}b.BASE._setWindowSize(8);function l(y,k,A,S=At){var yt;const B=y;if(k=be("msgHash",k),A=be("publicKey",A),"strict"in S)throw new Error("options.strict was renamed to lowS");const{lowS:P,prehash:w}=S;let d,v;try{if(typeof B=="string"||_r(B))try{d=C.fromDER(B)}catch(mt){if(!(mt instanceof Or.Err))throw mt;d=C.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){const{r:mt,s:dt}=B;d=new C(mt,dt)}else throw new Error("PARSE");v=b.fromHex(A)}catch(mt){if(mt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&d.hasHighS())return!1;w&&(k=t.hash(k));const{r:Y,s:J}=d,X=W(k),ft=p(J),st=u(X*ft),ht=u(Y*ft),Wt=(yt=b.BASE.multiplyAndAddUnsafe(v,st,ht))==null?void 0:yt.toAffine();return Wt?u(Wt.x)===Y:!1}return{CURVE:t,getPublicKey:N,getSharedSecret:D,sign:R,verify:l,ProjectivePoint:b,Signature:C,utils:$}}class Ta extends yi{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Hc(t);const n=Ln(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,a=new Uint8Array(s);a.set(n.length>s?t.create().update(n).digest():n);for(let f=0;f<a.length;f++)a[f]^=54;this.iHash.update(a),this.oHash=t.create();for(let f=0;f<a.length;f++)a[f]^=106;this.oHash.update(a),a.fill(0)}update(t){return jr(this),this.iHash.update(t),this}digestInto(t){jr(this),pn(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:s,destroyed:a,blockLen:f,outputLen:u}=this;return t=t,t.finished=s,t.destroyed=a,t.blockLen=f,t.outputLen=u,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ma=(o,t,e)=>new Ta(o,t).update(e).digest();Ma.create=(o,t)=>new Ta(o,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wh(o){return{hash:o,hmac:(t,...e)=>Ma(o,t,cs(...e)),randomBytes:us}}function bh(o,t){const e=n=>mh({...o,...wh(n)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),La=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xh=BigInt(1),to=BigInt(2),Ua=(o,t)=>(o+t/to)/t;function kh(o){const t=Pa,e=BigInt(3),n=BigInt(6),s=BigInt(11),a=BigInt(22),f=BigInt(23),u=BigInt(44),p=BigInt(88),b=o*o*o%t,E=b*b*o%t,I=Xt(E,e,t)*E%t,M=Xt(I,e,t)*E%t,T=Xt(M,to,t)*b%t,U=Xt(T,s,t)*T%t,_=Xt(U,a,t)*U%t,L=Xt(_,u,t)*_%t,C=Xt(L,p,t)*L%t,$=Xt(C,u,t)*_%t,N=Xt($,e,t)*E%t,H=Xt(N,f,t)*U%t,D=Xt(H,n,t)*b%t,F=Xt(D,to,t);if(!eo.eql(eo.sqr(F),o))throw new Error("Cannot find square root");return F}const eo=As(Pa,void 0,void 0,{sqrt:kh}),Zn=bh({a:BigInt(0),b:BigInt(7),Fp:eo,n:La,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:o=>{const t=La,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-xh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=e,f=BigInt("0x100000000000000000000000000000000"),u=Ua(a*o,t),p=Ua(-n*o,t);let b=Gt(o-u*e-p*s,t),E=Gt(-u*n-p*a,t);const I=b>f,M=E>f;if(I&&(b=t-b),M&&(E=t-E),b>f||E>f)throw new Error("splitScalar: Endomorphism failed, k="+o);return{k1neg:I,k1:b,k2neg:M,k2:E}}}},Pi);BigInt(0),Zn.ProjectivePoint;const Eh=Xr.utils.randomPrivateKey,Ca=()=>{const o=Xr.utils.randomPrivateKey(),t=Jn(o),e=new Uint8Array(64);return e.set(o),e.set(t,32),{publicKey:t,secretKey:e}},Jn=Xr.getPublicKey;function Fa(o){try{return Xr.ExtendedPoint.fromHex(o),!0}catch{return!1}}const ro=(o,t)=>Xr.sign(o,t.slice(0,32)),Ih=Xr.verify,xt=o=>lt.Buffer.isBuffer(o)?o:o instanceof Uint8Array?lt.Buffer.from(o.buffer,o.byteOffset,o.byteLength):lt.Buffer.from(o);class no{constructor(t){Object.assign(this,t)}encode(){return lt.Buffer.from(qs(In,this))}static decode(t){return Hs(In,this,t)}static decodeUnchecked(t){return zs(In,this,t)}}class Sh extends no{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 In=new Map;var Oa;const Na=32,nr=32;function Bh(o){return o._bn!==void 0}let za=1;class tt extends no{constructor(t){if(super({}),this._bn=void 0,Bh(t))this._bn=t._bn;else{if(typeof t=="string"){const e=ke.decode(t);if(e.length!=nr)throw new Error("Invalid public key input");this._bn=new Cs(e)}else this._bn=new Cs(t);if(this._bn.byteLength()>nr)throw new Error("Invalid public key input")}}static unique(){const t=new tt(za);return za+=1,new tt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ke.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(lt.Buffer);if(t.length===nr)return t;const e=lt.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,n){const s=lt.Buffer.concat([t.toBuffer(),lt.Buffer.from(e),n.toBuffer()]),a=Pi(s);return new tt(a)}static createProgramAddressSync(t,e){let n=lt.Buffer.alloc(0);t.forEach(function(a){if(a.length>Na)throw new TypeError("Max seed length exceeded");n=lt.Buffer.concat([n,xt(a)])}),n=lt.Buffer.concat([n,e.toBuffer(),lt.Buffer.from("ProgramDerivedAddress")]);const s=Pi(n);if(Fa(s))throw new Error("Invalid seeds, address must fall off the curve");return new tt(s)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n=255,s;for(;n!=0;){try{const a=t.concat(lt.Buffer.from([n]));s=this.createProgramAddressSync(a,e)}catch(a){if(a instanceof TypeError)throw a;n--;continue}return[s,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new tt(t);return Fa(e.toBytes())}}Oa=tt,tt.default=new Oa("11111111111111111111111111111111"),In.set(tt,{kind:"struct",fields:[["_bn","u256"]]});class Ah{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=xt(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=xt(Eh()),this._publicKey=xt(Jn(this._secretKey))}get publicKey(){return new tt(this._publicKey)}get secretKey(){return lt.Buffer.concat([this._secretKey,this._publicKey],64)}}const vh=new tt("BPFLoader1111111111111111111111111111111111"),Ar=1280-40-8,Xn=127,Sn=64;class io extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(io.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class oo 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(oo.prototype,"name",{value:"TransactionExpiredTimeoutError"});class nn extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(nn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Bn{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>255+1)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((a,f)=>{n.set(a.toBase58(),f)});const s=a=>{const f=n.get(a.toBase58());if(f===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return f};return t.map(a=>({programIdIndex:s(a.programId),accountKeyIndexes:a.keys.map(f=>s(f.pubkey)),data:a.data}))}}const St=(o="publicKey")=>jt(32,o),_h=(o="signature")=>jt(64,o),Nr=(o="string")=>{const t=ct([at("length"),at("lengthPadding"),jt(Sr(at(),-8),"chars")],o),e=t.decode.bind(t),n=t.encode.bind(t),s=t;return s.decode=(a,f)=>e(a,f).chars.toString(),s.encode=(a,f,u)=>{const p={chars:lt.Buffer.from(a,"utf8")};return n(p,f,u)},s.alloc=a=>at().span+at().span+lt.Buffer.from(a,"utf8").length,s},Rh=(o="authorized")=>ct([St("staker"),St("withdrawer")],o),Th=(o="lockup")=>ct([De("unixTimestamp"),De("epoch"),St("custodian")],o),Mh=(o="voteInit")=>ct([St("nodePubkey"),St("authorizedVoter"),St("authorizedWithdrawer"),Pt("commission")],o),Ph=(o="voteAuthorizeWithSeedArgs")=>ct([at("voteAuthorizationType"),St("currentAuthorityDerivedKeyOwnerPubkey"),Nr("currentAuthorityDerivedKeySeed"),St("newAuthorized")],o);function Da(o,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 a=t[s.property];if(Array.isArray(a))return a.length*e(s.elementLayout)}else if("fields"in s)return Da({layout:s},t[s.property]);return 0};let n=0;return o.layout.fields.forEach(s=>{n+=e(s)}),n}function Ce(o){let t=0,e=0;for(;;){let n=o.shift();if(t|=(n&127)<<e*7,e+=1,!(n&128))break}return t}function $e(o,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){o.push(n);break}else n|=128,o.push(n)}}function Ct(o,t){if(!o)throw new Error(t||"Assertion failed")}class Qn{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const n=new Map,s=f=>{const u=f.toBase58();let p=n.get(u);return p===void 0&&(p={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(u,p)),p},a=s(e);a.isSigner=!0,a.isWritable=!0;for(const f of t){s(f.programId).isInvoked=!0;for(const u of f.keys){const p=s(u.pubkey);p.isSigner||(p.isSigner=u.isSigner),p.isWritable||(p.isWritable=u.isWritable)}}return new Qn(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];Ct(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,p])=>p.isSigner&&p.isWritable),n=t.filter(([,p])=>p.isSigner&&!p.isWritable),s=t.filter(([,p])=>!p.isSigner&&p.isWritable),a=t.filter(([,p])=>!p.isSigner&&!p.isWritable),f={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:a.length};{Ct(e.length>0,"Expected at least one writable signer key");const[p]=e[0];Ct(p===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const u=[...e.map(([p])=>new tt(p)),...n.map(([p])=>new tt(p)),...s.map(([p])=>new tt(p)),...a.map(([p])=>new tt(p))];return[f,u]}extractTableLookup(t){const[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,f=>!f.isSigner&&!f.isInvoked&&f.isWritable),[s,a]=this.drainKeysFoundInLookupTable(t.state.addresses,f=>!f.isSigner&&!f.isInvoked&&!f.isWritable);if(!(e.length===0&&s.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:s},{writable:n,readonly:a}]}drainKeysFoundInLookupTable(t,e){const n=new Array,s=new Array;for(const[a,f]of this.keyMetaMap.entries())if(e(f)){const u=new tt(a),p=t.findIndex(b=>b.equals(u));p>=0&&(Ct(p<256,"Max lookup table index exceeded"),n.push(p),s.push(u),this.keyMetaMap.delete(a))}return[n,s]}}const $a="Reached end of buffer unexpectedly";function ir(o){if(o.length===0)throw new Error($a);return o.shift()}function Fe(o,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>o.length:e>=o.length)throw new Error($a);return o.splice(...t)}class Ze{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 tt(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:ke.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Bn(this.staticAccountKeys)}static compile(t){const e=Qn.compile(t.instructions,t.payerKey),[n,s]=e.getMessageComponents(),f=new Bn(s).compileInstructions(t.instructions).map(u=>({programIdIndex:u.programIdIndex,accounts:u.accountKeyIndexes,data:ke.encode(u.data)}));return new Ze({header:n,accountKeys:s,recentBlockhash:t.recentBlockhash,instructions:f})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const n=t-e,a=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<a}else{const n=e-this.header.numReadonlySignedAccounts;return t<n}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];$e(e,t);const n=this.instructions.map(I=>{const{accounts:M,programIdIndex:T}=I,U=Array.from(ke.decode(I.data));let _=[];$e(_,M.length);let L=[];return $e(L,U.length),{programIdIndex:T,keyIndicesCount:lt.Buffer.from(_),keyIndices:M,dataLength:lt.Buffer.from(L),data:U}});let s=[];$e(s,n.length);let a=lt.Buffer.alloc(Ar);lt.Buffer.from(s).copy(a);let f=s.length;n.forEach(I=>{const T=ct([Pt("programIdIndex"),jt(I.keyIndicesCount.length,"keyIndicesCount"),Ae(Pt("keyIndex"),I.keyIndices.length,"keyIndices"),jt(I.dataLength.length,"dataLength"),Ae(Pt("userdatum"),I.data.length,"data")]).encode(I,a,f);f+=T}),a=a.slice(0,f);const u=ct([jt(1,"numRequiredSignatures"),jt(1,"numReadonlySignedAccounts"),jt(1,"numReadonlyUnsignedAccounts"),jt(e.length,"keyCount"),Ae(St("key"),t,"keys"),St("recentBlockhash")]),p={numRequiredSignatures:lt.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:lt.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:lt.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:lt.Buffer.from(e),keys:this.accountKeys.map(I=>xt(I.toBytes())),recentBlockhash:ke.decode(this.recentBlockhash)};let b=lt.Buffer.alloc(2048);const E=u.encode(p,b);return a.copy(b,E),b.slice(0,E+a.length)}static from(t){let e=[...t];const n=ir(e);if(n!==(n&Xn))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=ir(e),a=ir(e),f=Ce(e);let u=[];for(let M=0;M<f;M++){const T=Fe(e,0,nr);u.push(new tt(lt.Buffer.from(T)))}const p=Fe(e,0,nr),b=Ce(e);let E=[];for(let M=0;M<b;M++){const T=ir(e),U=Ce(e),_=Fe(e,0,U),L=Ce(e),C=Fe(e,0,L),$=ke.encode(lt.Buffer.from(C));E.push({programIdIndex:T,accounts:_,data:$})}const I={header:{numRequiredSignatures:n,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:a},recentBlockhash:ke.encode(lt.Buffer.from(p)),accountKeys:u,instructions:E};return new Ze(I)}}class zr{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 Bn(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(t>=n){const s=t-n,a=this.addressTableLookups.reduce((f,u)=>f+u.writableIndexes.length,0);return s<a}else if(t>=this.header.numRequiredSignatures){const s=t-e,f=n-e-this.header.numReadonlyUnsignedAccounts;return s<f}else{const s=e-this.header.numReadonlySignedAccounts;return t<s}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const n of this.addressTableLookups){const s=t.find(a=>a.key.equals(n.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const a of n.writableIndexes)if(a<s.state.addresses.length)e.writable.push(s.state.addresses[a]);else throw new Error(`Failed to find address for index ${a} in address lookup table ${n.accountKey.toBase58()}`);for(const a of n.readonlyIndexes)if(a<s.state.addresses.length)e.readonly.push(s.state.addresses[a]);else throw new Error(`Failed to find address for index ${a} in address lookup table ${n.accountKey.toBase58()}`)}return e}static compile(t){const e=Qn.compile(t.instructions,t.payerKey),n=new Array,s={writable:new Array,readonly:new Array},a=t.addressLookupTableAccounts||[];for(const E of a){const I=e.extractTableLookup(E);if(I!==void 0){const[M,{writable:T,readonly:U}]=I;n.push(M),s.writable.push(...T),s.readonly.push(...U)}}const[f,u]=e.getMessageComponents(),b=new Bn(u,s).compileInstructions(t.instructions);return new zr({header:f,staticAccountKeys:u,recentBlockhash:t.recentBlockhash,compiledInstructions:b,addressTableLookups:n})}serialize(){const t=Array();$e(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();$e(n,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),a=Array();$e(a,this.addressTableLookups.length);const f=ct([Pt("prefix"),ct([Pt("numRequiredSignatures"),Pt("numReadonlySignedAccounts"),Pt("numReadonlyUnsignedAccounts")],"header"),jt(t.length,"staticAccountKeysLength"),Ae(St(),this.staticAccountKeys.length,"staticAccountKeys"),St("recentBlockhash"),jt(n.length,"instructionsLength"),jt(e.length,"serializedInstructions"),jt(a.length,"addressTableLookupsLength"),jt(s.length,"serializedAddressTableLookups")]),u=new Uint8Array(Ar),p=128,b=f.encode({prefix:p,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(E=>E.toBytes()),recentBlockhash:ke.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(a),serializedAddressTableLookups:s},u);return u.slice(0,b)}serializeInstructions(){let t=0;const e=new Uint8Array(Ar);for(const n of this.compiledInstructions){const s=Array();$e(s,n.accountKeyIndexes.length);const a=Array();$e(a,n.data.length);const f=ct([Pt("programIdIndex"),jt(s.length,"encodedAccountKeyIndexesLength"),Ae(Pt(),n.accountKeyIndexes.length,"accountKeyIndexes"),jt(a.length,"encodedDataLength"),jt(n.data.length,"data")]);t+=f.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(a),data:n.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(Ar);for(const n of this.addressTableLookups){const s=Array();$e(s,n.writableIndexes.length);const a=Array();$e(a,n.readonlyIndexes.length);const f=ct([St("accountKey"),jt(s.length,"encodedWritableIndexesLength"),Ae(Pt(),n.writableIndexes.length,"writableIndexes"),jt(a.length,"encodedReadonlyIndexesLength"),Ae(Pt(),n.readonlyIndexes.length,"readonlyIndexes")]);t+=f.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(a),readonlyIndexes:n.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const n=ir(e),s=n&Xn;Ct(n!==s,"Expected versioned message but received legacy message");const a=s;Ct(a===0,`Expected versioned message with version 0 but found version ${a}`);const f={numRequiredSignatures:ir(e),numReadonlySignedAccounts:ir(e),numReadonlyUnsignedAccounts:ir(e)},u=[],p=Ce(e);for(let U=0;U<p;U++)u.push(new tt(Fe(e,0,nr)));const b=ke.encode(Fe(e,0,nr)),E=Ce(e),I=[];for(let U=0;U<E;U++){const _=ir(e),L=Ce(e),C=Fe(e,0,L),$=Ce(e),N=new Uint8Array(Fe(e,0,$));I.push({programIdIndex:_,accountKeyIndexes:C,data:N})}const M=Ce(e),T=[];for(let U=0;U<M;U++){const _=new tt(Fe(e,0,nr)),L=Ce(e),C=Fe(e,0,L),$=Ce(e),N=Fe(e,0,$);T.push({accountKey:_,writableIndexes:C,readonlyIndexes:N})}return new zr({header:f,staticAccountKeys:u,recentBlockhash:b,compiledInstructions:I,addressTableLookups:T})}}const so={deserializeMessageVersion(o){const t=o[0],e=t&Xn;return e===t?"legacy":e},deserialize:o=>{const t=so.deserializeMessageVersion(o);if(t==="legacy")return Ze.from(o);if(t===0)return zr.deserialize(o);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let gr=function(o){return o[o.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",o[o.PROCESSED=1]="PROCESSED",o[o.TIMED_OUT=2]="TIMED_OUT",o[o.NONCE_INVALID=3]="NONCE_INVALID",o}({});const Lh=lt.Buffer.alloc(Sn).fill(0);class Ht{constructor(t){this.keys=void 0,this.programId=void 0,this.data=lt.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}class Ot{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{const{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Ht(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let _=0;_<e.length;_++)if(e[_].programId===void 0)throw new Error(`Transaction instruction index ${_} has undefined program id`);const s=[],a=[];e.forEach(_=>{_.keys.forEach(C=>{a.push({...C})});const L=_.programId.toString();s.includes(L)||s.push(L)}),s.forEach(_=>{a.push({pubkey:new tt(_),isSigner:!1,isWritable:!1})});const f=[];a.forEach(_=>{const L=_.pubkey.toString(),C=f.findIndex($=>$.pubkey.toString()===L);C>-1?(f[C].isWritable=f[C].isWritable||_.isWritable,f[C].isSigner=f[C].isSigner||_.isSigner):f.push(_)}),f.sort(function(_,L){if(_.isSigner!==L.isSigner)return _.isSigner?-1:1;if(_.isWritable!==L.isWritable)return _.isWritable?-1:1;const C={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return _.pubkey.toBase58().localeCompare(L.pubkey.toBase58(),"en",C)});const u=f.findIndex(_=>_.pubkey.equals(n));if(u>-1){const[_]=f.splice(u,1);_.isSigner=!0,_.isWritable=!0,f.unshift(_)}else f.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const _ of this.signatures){const L=f.findIndex(C=>C.pubkey.equals(_.publicKey));if(L>-1)f[L].isSigner||(f[L].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: ${_.publicKey.toString()}`)}let p=0,b=0,E=0;const I=[],M=[];f.forEach(({pubkey:_,isSigner:L,isWritable:C})=>{L?(I.push(_.toString()),p+=1,C||(b+=1)):(M.push(_.toString()),C||(E+=1))});const T=I.concat(M),U=e.map(_=>{const{data:L,programId:C}=_;return{programIdIndex:T.indexOf(C.toString()),accounts:_.keys.map($=>T.indexOf($.pubkey.toString())),data:ke.encode(L)}});return U.forEach(_=>{Ct(_.programIdIndex>=0),_.accounts.forEach(L=>Ct(L>=0))}),new Ze({header:{numRequiredSignatures:p,numReadonlySignedAccounts:b,numReadonlyUnsignedAccounts:E},accountKeys:T,recentBlockhash:t,instructions:U})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((s,a)=>e[a].equals(s.publicKey))||(this.signatures=e.map(n=>({signature:null,publicKey:n}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(n=>{const s=n.toString();return e.has(s)?!1:(e.add(s),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const a of t){const f=a.publicKey.toString();e.has(f)||(e.add(f),n.push(a))}this.signatures=n.map(a=>({signature:null,publicKey:a.publicKey}));const s=this._compile();this._partialSign(s,...n)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const a of t){const f=a.publicKey.toString();e.has(f)||(e.add(f),n.push(a))}const s=this._compile();this._partialSign(s,...n)}_partialSign(t,...e){const n=t.serialize();e.forEach(s=>{const a=ro(n,s.secretKey);this._addSignature(s.publicKey,xt(a))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){Ct(e.length===64);const n=this.signatures.findIndex(s=>t.equals(s.publicKey));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=lt.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const n={};for(const{signature:s,publicKey:a}of this.signatures)s===null?e&&(n.missing||(n.missing=[])).push(a):Ih(s,t,a.toBytes())||(n.invalid||(n.invalid=[])).push(a);return n.invalid||n.missing?n:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),s=this.serializeMessage();if(n){const a=this._getMessageSignednessErrors(s,e);if(a){let f="Signature verification failed.";throw a.invalid&&(f+=`
|
|
17
|
+
Invalid signature for public key${a.invalid.length===1?"":"(s)"} [\`${a.invalid.map(u=>u.toBase58()).join("`, `")}\`].`),a.missing&&(f+=`
|
|
18
|
+
Missing signature for public key${a.missing.length===1?"":"(s)"} [\`${a.missing.map(u=>u.toBase58()).join("`, `")}\`].`),new Error(f)}}return this._serialize(s)}_serialize(t){const{signatures:e}=this,n=[];$e(n,e.length);const s=n.length+e.length*64+t.length,a=lt.Buffer.alloc(s);return Ct(e.length<256),lt.Buffer.from(n).copy(a,0),e.forEach(({signature:f},u)=>{f!==null&&(Ct(f.length===64,"signature has invalid length"),lt.Buffer.from(f).copy(a,n.length+u*64))}),t.copy(a,n.length+e.length*64),Ct(a.length<=Ar,`Transaction too large: ${a.length} > ${Ar}`),a}get keys(){return Ct(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return Ct(this.instructions.length===1),this.instructions[0].programId}get data(){return Ct(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const n=Ce(e);let s=[];for(let a=0;a<n;a++){const f=Fe(e,0,Sn);s.push(ke.encode(lt.Buffer.from(f)))}return Ot.populate(Ze.from(e),s)}static populate(t,e=[]){const n=new Ot;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((s,a)=>{const f={signature:s==ke.encode(Lh)?null:ke.decode(s),publicKey:t.accountKeys[a]};n.signatures.push(f)}),t.instructions.forEach(s=>{const a=s.accounts.map(f=>{const u=t.accountKeys[f];return{pubkey:u,isSigner:n.signatures.some(p=>p.publicKey.toString()===u.toString())||t.isAccountSigner(f),isWritable:t.isAccountWritable(f)}});n.instructions.push(new Ht({keys:a,programId:t.accountKeys[s.programIdIndex],data:ke.decode(s.data)}))}),n._message=t,n._json=n.toJSON(),n}}class ao{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:n,compiledInstructions:s,recentBlockhash:a}=t,{numRequiredSignatures:f,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:p}=n,b=f-u;Ct(b>0,"Message header is invalid");const E=t.staticAccountKeys.length-f-p;Ct(E>=0,"Message header is invalid");const I=t.getAccountKeys(e),M=I.get(0);if(M===void 0)throw new Error("Failed to decompile message because no account keys were found");const T=[];for(const U of s){const _=[];for(const C of U.accountKeyIndexes){const $=I.get(C);if($===void 0)throw new Error(`Failed to find key for account key index ${C}`);const N=C<f;let H;N?H=C<b:C<I.staticAccountKeys.length?H=C-f<E:H=C-I.staticAccountKeys.length<I.accountKeysFromLookups.writable.length,_.push({pubkey:$,isSigner:C<n.numRequiredSignatures,isWritable:H})}const L=I.get(U.programIdIndex);if(L===void 0)throw new Error(`Failed to find program id for program id index ${U.programIdIndex}`);T.push(new Ht({programId:L,data:xt(U.data),keys:_}))}return new ao({payerKey:M,instructions:T,recentBlockhash:a})}compileToLegacyMessage(){return Ze.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return zr.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class co{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)Ct(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const n=[];for(let s=0;s<t.header.numRequiredSignatures;s++)n.push(new Uint8Array(Sn));this.signatures=n}this.message=t}serialize(){const t=this.message.serialize(),e=Array();$e(e,this.signatures.length);const n=ct([jt(e.length,"encodedSignaturesLength"),Ae(_h(),this.signatures.length,"signatures"),jt(t.length,"serializedMessage")]),s=new Uint8Array(2048),a=n.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},s);return s.slice(0,a)}static deserialize(t){let e=[...t];const n=[],s=Ce(e);for(let f=0;f<s;f++)n.push(new Uint8Array(Fe(e,0,Sn)));const a=so.deserialize(new Uint8Array(e));return new co(a,n)}sign(t){const e=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of t){const a=n.findIndex(f=>f.equals(s.publicKey));Ct(a>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[a]=ro(e,s.secretKey)}}addSignature(t,e){Ct(e.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(a=>a.equals(t));Ct(s>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=e}}const Wa=1e3/(160/64),or=new tt("SysvarC1ock11111111111111111111111111111111"),Uh=new tt("SysvarEpochSchedu1e111111111111111111111111"),Ch=new tt("Sysvar1nstructions1111111111111111111111111"),ti=new tt("SysvarRecentB1ockHashes11111111111111111111"),on=new tt("SysvarRent111111111111111111111111111111111"),Fh=new tt("SysvarRewards111111111111111111111111111111"),Oh=new tt("SysvarS1otHashes111111111111111111111111111"),Nh=new tt("SysvarS1otHistory11111111111111111111111111"),ei=new tt("SysvarStakeHistory1111111111111111111111111");class An extends Error{constructor({action:t,signature:e,transactionMessage:n,logs:s}){const a=s?`Logs:
|
|
19
|
+
${JSON.stringify(s.slice(-10),null,2)}. `:"",f="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let u;switch(t){case"send":u=`Transaction ${e} resulted in an error.
|
|
20
|
+
${n}. `+a+f;break;case"simulate":u=`Simulation failed.
|
|
21
|
+
Message: ${n}.
|
|
22
|
+
`+a+f;break;default:u=`Unknown action '${(p=>p)(t)}'`}super(u),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=n,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,n)=>{t.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const a=s.meta.logMessages;this.transactionLogs=a,e(a)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}const zh={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 ut extends Error{constructor({code:t,message:e,data:n},s){super(s!=null?`${s}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=n,this.name="SolanaJSONRPCError"}}async function uo(o,t,e,n){const s=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},a=await o.sendTransaction(t,e,s);let f;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)f=(await o.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},n&&n.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:u}=t.nonceInfo,p=u.keys[0].pubkey;f=(await o.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:p,nonceValue:t.nonceInfo.nonce,signature:a},n&&n.commitment)).value}else(n==null?void 0:n.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),f=(await o.confirmTransaction(a,n&&n.commitment)).value;if(f.err)throw a!=null?new An({action:"send",signature:a,transactionMessage:`Status: (${JSON.stringify(f)})`}):new Error(`Transaction ${a} failed (${JSON.stringify(f)})`);return a}function Dr(o){return new Promise(t=>setTimeout(t,o))}function Tt(o,t){const e=o.layout.span>=0?o.layout.span:Da(o,t),n=lt.Buffer.alloc(e),s=Object.assign({instruction:o.index},t);return o.layout.encode(s,n),n}function zt(o,t){let e;try{e=o.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.instruction!==o.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${o.index}`);return e}const Ka=Be("lamportsPerSignature"),qa=ct([at("version"),at("state"),St("authorizedPubkey"),St("nonce"),ct([Ka],"feeCalculator")]),fo=qa.span;class ri{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=qa.decode(xt(t),0);return new ri({authorizedPubkey:new tt(e.authorizedPubkey),nonce:new tt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const Dh=o=>{const t=o.decode.bind(o),e=o.encode.bind(o);return{decode:t,encode:e}},sn=(o=>t=>{const e=jt(o,t),{encode:n,decode:s}=Dh(e),a=e;return a.decode=(f,u)=>{const p=s(f,u);return yf(lt.Buffer.from(p))},a.encode=(f,u,p)=>{const b=fa(f,o);return n(b,u,p)},a})(8);class $h{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(Vt))if(f.index==n){s=a;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:n,programId:s}=zt(Vt.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:n,programId:new tt(s)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=zt(Vt.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:n,programId:s}=zt(Vt.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:n,programId:new tt(s)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=zt(Vt.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,space:s,programId:a}=zt(Vt.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new tt(e),seed:n,space:s,programId:new tt(a)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=zt(Vt.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new tt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,programId:s}=zt(Vt.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new tt(e),seed:n,programId:new tt(s)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:n,lamports:s,space:a,programId:f}=zt(Vt.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new tt(e),seed:n,lamports:s,space:a,programId:new tt(f)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=zt(Vt.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new tt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),zt(Vt.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}=zt(Vt.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}=zt(Vt.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new tt(e)}}static checkProgramId(t){if(!t.equals(Ee.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 Vt=Object.freeze({Create:{index:0,layout:ct([at("instruction"),De("lamports"),De("space"),St("programId")])},Assign:{index:1,layout:ct([at("instruction"),St("programId")])},Transfer:{index:2,layout:ct([at("instruction"),sn("lamports")])},CreateWithSeed:{index:3,layout:ct([at("instruction"),St("base"),Nr("seed"),De("lamports"),De("space"),St("programId")])},AdvanceNonceAccount:{index:4,layout:ct([at("instruction")])},WithdrawNonceAccount:{index:5,layout:ct([at("instruction"),De("lamports")])},InitializeNonceAccount:{index:6,layout:ct([at("instruction"),St("authorized")])},AuthorizeNonceAccount:{index:7,layout:ct([at("instruction"),St("authorized")])},Allocate:{index:8,layout:ct([at("instruction"),De("space")])},AllocateWithSeed:{index:9,layout:ct([at("instruction"),St("base"),Nr("seed"),De("space"),St("programId")])},AssignWithSeed:{index:10,layout:ct([at("instruction"),St("base"),Nr("seed"),St("programId")])},TransferWithSeed:{index:11,layout:ct([at("instruction"),sn("lamports"),Nr("seed"),St("programId")])},UpgradeNonceAccount:{index:12,layout:ct([at("instruction")])}});class Ee{constructor(){}static createAccount(t){const e=Vt.Create,n=Tt(e,{lamports:t.lamports,space:t.space,programId:xt(t.programId.toBuffer())});return new Ht({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(t){let e,n;if("basePubkey"in t){const s=Vt.TransferWithSeed;e=Tt(s,{lamports:BigInt(t.lamports),seed:t.seed,programId:xt(t.programId.toBuffer())}),n=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=Vt.Transfer;e=Tt(s,{lamports:BigInt(t.lamports)}),n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Ht({keys:n,programId:this.programId,data:e})}static assign(t){let e,n;if("basePubkey"in t){const s=Vt.AssignWithSeed;e=Tt(s,{base:xt(t.basePubkey.toBuffer()),seed:t.seed,programId:xt(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Vt.Assign;e=Tt(s,{programId:xt(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ht({keys:n,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=Vt.CreateWithSeed,n=Tt(e,{base:xt(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:xt(t.programId.toBuffer())});let s=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey!=t.fromPubkey&&s.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Ht({keys:s,programId:this.programId,data:n})}static createNonceAccount(t){const e=new Ot;"basePubkey"in t&&"seed"in t?e.add(Ee.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:fo,programId:this.programId})):e.add(Ee.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:fo,programId:this.programId}));const n={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(n)),e}static nonceInitialize(t){const e=Vt.InitializeNonceAccount,n=Tt(e,{authorized:xt(t.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ti,isSigner:!1,isWritable:!1},{pubkey:on,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Ht(s)}static nonceAdvance(t){const e=Vt.AdvanceNonceAccount,n=Tt(e),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ti,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Ht(s)}static nonceWithdraw(t){const e=Vt.WithdrawNonceAccount,n=Tt(e,{lamports:t.lamports});return new Ht({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ti,isSigner:!1,isWritable:!1},{pubkey:on,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(t){const e=Vt.AuthorizeNonceAccount,n=Tt(e,{authorized:xt(t.newAuthorizedPubkey.toBuffer())});return new Ht({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(t){let e,n;if("basePubkey"in t){const s=Vt.AllocateWithSeed;e=Tt(s,{base:xt(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:xt(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Vt.Allocate;e=Tt(s,{space:t.space}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ht({keys:n,programId:this.programId,data:e})}}Ee.programId=new tt("11111111111111111111111111111111");const Wh=Ar-300;class $r{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/$r.chunkSize)+1+1)}static async load(t,e,n,s,a){{const I=await t.getMinimumBalanceForRentExemption(a.length),M=await t.getAccountInfo(n.publicKey,"confirmed");let T=null;if(M!==null){if(M.executable)return console.error("Program load failed, account is already executable"),!1;M.data.length!==a.length&&(T=T||new Ot,T.add(Ee.allocate({accountPubkey:n.publicKey,space:a.length}))),M.owner.equals(s)||(T=T||new Ot,T.add(Ee.assign({accountPubkey:n.publicKey,programId:s}))),M.lamports<I&&(T=T||new Ot,T.add(Ee.transfer({fromPubkey:e.publicKey,toPubkey:n.publicKey,lamports:I-M.lamports})))}else T=new Ot().add(Ee.createAccount({fromPubkey:e.publicKey,newAccountPubkey:n.publicKey,lamports:I>0?I:1,space:a.length,programId:s}));T!==null&&await uo(t,T,[e,n],{commitment:"confirmed"})}const f=ct([at("instruction"),at("offset"),at("bytesLength"),at("bytesLengthPadding"),Ae(Pt("byte"),Sr(at(),-8),"bytes")]),u=$r.chunkSize;let p=0,b=a,E=[];for(;b.length>0;){const I=b.slice(0,u),M=lt.Buffer.alloc(u+16);f.encode({instruction:0,offset:p,bytes:I,bytesLength:0,bytesLengthPadding:0},M);const T=new Ot().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:M});E.push(uo(t,T,[e,n],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Dr(1e3/4),p+=u,b=b.slice(u)}await Promise.all(E);{const I=ct([at("instruction")]),M=lt.Buffer.alloc(I.span);I.encode({instruction:1},M);const T=new Ot().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:on,isSigner:!1,isWritable:!1}],programId:s,data:M}),U="processed",_=await t.sendTransaction(T,[e,n],{preflightCommitment:U}),{context:L,value:C}=await t.confirmTransaction({signature:_,lastValidBlockHeight:T.lastValidBlockHeight,blockhash:T.recentBlockhash},U);if(C.err)throw new Error(`Transaction ${_} failed (${JSON.stringify(C)})`);for(;;){try{if(await t.getSlot({commitment:U})>L.slot)break}catch{}await new Promise($=>setTimeout($,Math.round(Wa/2)))}}return!0}}$r.chunkSize=Wh;const Kh=new tt("BPFLoader2111111111111111111111111111111111");class qh{static getMinNumSignatures(t){return $r.getMinNumSignatures(t)}static load(t,e,n,s,a){return $r.load(t,e,n,a,s)}}function Hh(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var Vh=Object.prototype.toString,jh=Object.keys||function(o){var t=[];for(var e in o)t.push(e);return t};function vn(o,t){var e,n,s,a,f,u,p;if(o===!0)return"true";if(o===!1)return"false";switch(typeof o){case"object":if(o===null)return null;if(o.toJSON&&typeof o.toJSON=="function")return vn(o.toJSON(),t);if(p=Vh.call(o),p==="[object Array]"){for(s="[",n=o.length-1,e=0;e<n;e++)s+=vn(o[e],!0)+",";return n>-1&&(s+=vn(o[e],!0)),s+"]"}else if(p==="[object Object]"){for(a=jh(o).sort(),n=a.length,s="",e=0;e<n;)f=a[e],u=vn(o[f],!1),u!==void 0&&(s&&(s+=","),s+=JSON.stringify(f)+":"+u),e++;return"{"+s+"}"}else return JSON.stringify(o);case"function":case"undefined":return t?null:void 0;case"string":return JSON.stringify(o);default:return isFinite(o)?o:null}}var Gh=function(o){var t=vn(o,!1);if(t!==void 0)return""+t},Ha=Hh(Gh);const _n=32;function ho(o){let t=0;for(;o>1;)o/=2,t++;return t}function Yh(o){return o===0?1:(o--,o|=o>>1,o|=o>>2,o|=o>>4,o|=o>>8,o|=o>>16,o|=o>>32,o+1)}class Va{constructor(t,e,n,s,a){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=s,this.firstNormalSlot=a}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=ho(Yh(t+_n+1))-ho(_n)-1,n=this.getSlotsInEpoch(e),s=t-(n-_n);return[e,s]}else{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch),s=this.firstNormalEpoch+n,a=e%this.slotsPerEpoch;return[s,a]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*_n:(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+ho(_n)):this.slotsPerEpoch}}var Zh=globalThis.fetch;class Jh extends nh{constructor(t,e,n){const s=a=>{const f=eh(a,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in f?this.underlyingSocket=f.socket:this.underlyingSocket=f,f};super(s,t,e,n),this.underlyingSocket=void 0}call(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function Xh(o,t){let e;try{e=o.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.typeIndex!==o.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${o.index}`);return e}const ja=56;class lo{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=Xh(Qh,t),n=t.length-ja;Ct(n>=0,"lookup table is invalid"),Ct(n%32===0,"lookup table is invalid");const s=n/32,{addresses:a}=ct([Ae(St(),s,"addresses")]).decode(t.slice(ja));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new tt(e.authority[0]):void 0,addresses:a.map(f=>new tt(f))}}}const Qh={index:1,layout:ct([at("typeIndex"),sn("deactivationSlot"),Be("lastExtendedSlot"),Pt("lastExtendedStartIndex"),Pt(),Ae(St(),Sr(Pt(),-1),"authority")])},tl=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function el(o){const t=o.match(tl);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${o}\``);const[e,n,s,a]=t,f=o.startsWith("https:")?"wss:":"ws:",u=s==null?null:parseInt(s.slice(1),10),p=u==null?"":`:${u+1}`;return`${f}//${n}${p}${a}`}const te=xn(Vi(tt),Q(),o=>new tt(o)),Ga=ji([Q(),Jt("base64")]),po=xn(Vi(lt.Buffer),Ga,o=>lt.Buffer.from(o[0],"base64")),Ya=30*1e3;function rl(o){if(/^https?:/.test(o)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return o}function Yt(o){let t,e;if(typeof o=="string")t=o;else if(o){const{commitment:n,...s}=o;t=n,e=s}return{commitment:t,config:e}}function Za(o){return Ue([j({jsonrpc:Jt("2.0"),id:Q(),result:o}),j({jsonrpc:Jt("2.0"),id:Q(),error:j({code:bn(),message:Q(),data:pt(Bf())})})])}const nl=Za(bn());function kt(o){return xn(Za(o),nl,t=>"error"in t?t:{...t,result:et(t.result,o)})}function Qt(o){return kt(j({context:j({slot:O()}),value:o}))}function ni(o){return j({context:j({slot:O()}),value:o})}function go(o,t){return o===0?new zr({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new tt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:ke.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Ze(t)}const il=j({foundation:O(),foundationTerm:O(),initial:O(),taper:O(),terminal:O()}),ol=kt(nt(rt(j({epoch:O(),effectiveSlot:O(),amount:O(),postBalance:O(),commission:pt(rt(O()))})))),sl=nt(j({slot:O(),prioritizationFee:O()})),al=j({total:O(),validator:O(),foundation:O(),epoch:O()}),cl=j({epoch:O(),slotIndex:O(),slotsInEpoch:O(),absoluteSlot:O(),blockHeight:pt(O()),transactionCount:pt(O())}),ul=j({slotsPerEpoch:O(),leaderScheduleSlotOffset:O(),warmup:rr(),firstNormalEpoch:O(),firstNormalSlot:O()}),fl=pa(Q(),nt(O())),Wr=rt(Ue([j({}),Q()])),hl=j({err:Wr}),ll=Jt("receivedSignature"),dl=j({"solana-core":Q(),"feature-set":pt(O())}),Ja=Qt(j({err:rt(Ue([j({}),Q()])),logs:rt(nt(Q())),accounts:pt(rt(nt(rt(j({executable:rr(),owner:Q(),lamports:O(),data:nt(Q()),rentEpoch:pt(O())}))))),unitsConsumed:pt(O()),returnData:pt(rt(j({programId:Q(),data:ji([Q(),Jt("base64")])})))})),pl=Qt(j({byIdentity:pa(Q(),nt(O())),range:j({firstSlot:O(),lastSlot:O()})}));function gl(o,t,e,n,s,a){const f=e||Zh;let u;a!=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 p;return n&&(p=async(E,I)=>{const M=await new Promise((T,U)=>{try{n(E,I,(_,L)=>T([_,L]))}catch(_){U(_)}});return await f(...M)}),new Xf(async(E,I)=>{const M={method:"POST",body:E,agent:u,headers:Object.assign({"Content-Type":"application/json"},t||{},yd)};try{let T=5,U,_=500;for(;p?U=await p(o,M):U=await f(o,M),!(U.status!==429||s===!0||(T-=1,T===0));)console.error(`Server responded with ${U.status} ${U.statusText}. Retrying after ${_}ms delay...`),await Dr(_),_*=2;const L=await U.text();U.ok?I(null,L):I(new Error(`${U.status} ${U.statusText}: ${L}`))}catch(T){T instanceof Error&&I(T)}},{})}function yl(o){return(t,e)=>new Promise((n,s)=>{o.request(t,e,(a,f)=>{if(a){s(a);return}n(f)})})}function ml(o){return t=>new Promise((e,n)=>{t.length===0&&e([]);const s=t.map(a=>o.request(a.methodName,a.args));o.request(s,(a,f)=>{if(a){n(a);return}e(f)})})}const wl=kt(il),bl=kt(al),xl=kt(sl),kl=kt(cl),El=kt(ul),Il=kt(fl),Sl=kt(O()),Bl=Qt(j({total:O(),circulating:O(),nonCirculating:O(),nonCirculatingAccounts:nt(te)})),yo=j({amount:Q(),uiAmount:rt(O()),decimals:O(),uiAmountString:pt(Q())}),Al=Qt(nt(j({address:te,amount:Q(),uiAmount:rt(O()),decimals:O(),uiAmountString:pt(Q())}))),vl=Qt(nt(j({pubkey:te,account:j({executable:rr(),owner:te,lamports:O(),data:po,rentEpoch:O()})}))),mo=j({program:Q(),parsed:bn(),space:O()}),_l=Qt(nt(j({pubkey:te,account:j({executable:rr(),owner:te,lamports:O(),data:mo,rentEpoch:O()})}))),Rl=Qt(nt(j({lamports:O(),address:te}))),Rn=j({executable:rr(),owner:te,lamports:O(),data:po,rentEpoch:O()}),Tl=j({pubkey:te,account:Rn}),Ml=xn(Ue([Vi(lt.Buffer),mo]),Ue([Ga,mo]),o=>Array.isArray(o)?et(o,po):o),wo=j({executable:rr(),owner:te,lamports:O(),data:Ml,rentEpoch:O()}),Pl=j({pubkey:te,account:wo}),Ll=j({state:Ue([Jt("active"),Jt("inactive"),Jt("activating"),Jt("deactivating")]),active:O(),inactive:O()}),Ul=kt(nt(j({signature:Q(),slot:O(),err:Wr,memo:rt(Q()),blockTime:pt(rt(O()))}))),Cl=kt(nt(j({signature:Q(),slot:O(),err:Wr,memo:rt(Q()),blockTime:pt(rt(O()))}))),Fl=j({subscription:O(),result:ni(Rn)}),Ol=j({pubkey:te,account:Rn}),Nl=j({subscription:O(),result:ni(Ol)}),zl=j({parent:O(),slot:O(),root:O()}),Dl=j({subscription:O(),result:zl}),$l=Ue([j({type:Ue([Jt("firstShredReceived"),Jt("completed"),Jt("optimisticConfirmation"),Jt("root")]),slot:O(),timestamp:O()}),j({type:Jt("createdBank"),parent:O(),slot:O(),timestamp:O()}),j({type:Jt("frozen"),slot:O(),timestamp:O(),stats:j({numTransactionEntries:O(),numSuccessfulTransactions:O(),numFailedTransactions:O(),maxTransactionsPerEntry:O()})}),j({type:Jt("dead"),slot:O(),timestamp:O(),err:Q()})]),Wl=j({subscription:O(),result:$l}),Kl=j({subscription:O(),result:ni(Ue([hl,ll]))}),ql=j({subscription:O(),result:O()}),Hl=j({pubkey:Q(),gossip:rt(Q()),tpu:rt(Q()),rpc:rt(Q()),version:rt(Q())}),Xa=j({votePubkey:Q(),nodePubkey:Q(),activatedStake:O(),epochVoteAccount:rr(),epochCredits:nt(ji([O(),O(),O()])),commission:O(),lastVote:O(),rootSlot:rt(O())}),Vl=kt(j({current:nt(Xa),delinquent:nt(Xa)})),jl=Ue([Jt("processed"),Jt("confirmed"),Jt("finalized")]),Gl=j({slot:O(),confirmations:rt(O()),err:Wr,confirmationStatus:pt(jl)}),Yl=Qt(nt(rt(Gl))),Zl=kt(O()),Qa=j({accountKey:te,writableIndexes:nt(O()),readonlyIndexes:nt(O())}),bo=j({signatures:nt(Q()),message:j({accountKeys:nt(Q()),header:j({numRequiredSignatures:O(),numReadonlySignedAccounts:O(),numReadonlyUnsignedAccounts:O()}),instructions:nt(j({accounts:nt(O()),data:Q(),programIdIndex:O()})),recentBlockhash:Q(),addressTableLookups:pt(nt(Qa))})}),tc=j({pubkey:te,signer:rr(),writable:rr(),source:pt(Ue([Jt("transaction"),Jt("lookupTable")]))}),ec=j({accountKeys:nt(tc),signatures:nt(Q())}),rc=j({parsed:bn(),program:Q(),programId:te}),nc=j({accounts:nt(te),data:Q(),programId:te}),Jl=Ue([nc,rc]),Xl=Ue([j({parsed:bn(),program:Q(),programId:Q()}),j({accounts:nt(Q()),data:Q(),programId:Q()})]),ic=xn(Jl,Xl,o=>"accounts"in o?et(o,nc):et(o,rc)),oc=j({signatures:nt(Q()),message:j({accountKeys:nt(tc),instructions:nt(ic),recentBlockhash:Q(),addressTableLookups:pt(rt(nt(Qa)))})}),ii=j({accountIndex:O(),mint:Q(),owner:pt(Q()),uiTokenAmount:yo}),sc=j({writable:nt(te),readonly:nt(te)}),oi=j({err:Wr,fee:O(),innerInstructions:pt(rt(nt(j({index:O(),instructions:nt(j({accounts:nt(O()),data:Q(),programIdIndex:O()}))})))),preBalances:nt(O()),postBalances:nt(O()),logMessages:pt(rt(nt(Q()))),preTokenBalances:pt(rt(nt(ii))),postTokenBalances:pt(rt(nt(ii))),loadedAddresses:pt(sc),computeUnitsConsumed:pt(O())}),xo=j({err:Wr,fee:O(),innerInstructions:pt(rt(nt(j({index:O(),instructions:nt(ic)})))),preBalances:nt(O()),postBalances:nt(O()),logMessages:pt(rt(nt(Q()))),preTokenBalances:pt(rt(nt(ii))),postTokenBalances:pt(rt(nt(ii))),loadedAddresses:pt(sc),computeUnitsConsumed:pt(O())}),an=Ue([Jt(0),Jt("legacy")]),Kr=j({pubkey:Q(),lamports:O(),postBalance:rt(O()),rewardType:rt(Q()),commission:pt(rt(O()))}),Ql=kt(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:bo,meta:rt(oi),version:pt(an)})),rewards:pt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),td=kt(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),rewards:pt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),ed=kt(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:ec,meta:rt(oi),version:pt(an)})),rewards:pt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),rd=kt(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:oc,meta:rt(xo),version:pt(an)})),rewards:pt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),nd=kt(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:ec,meta:rt(xo),version:pt(an)})),rewards:pt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),id=kt(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),rewards:pt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),od=kt(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:bo,meta:rt(oi)})),rewards:pt(nt(Kr)),blockTime:rt(O())}))),ac=kt(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),signatures:nt(Q()),blockTime:rt(O())}))),ko=kt(rt(j({slot:O(),meta:rt(oi),blockTime:pt(rt(O())),transaction:bo,version:pt(an)}))),si=kt(rt(j({slot:O(),transaction:oc,meta:rt(xo),blockTime:pt(rt(O())),version:pt(an)}))),sd=Qt(j({blockhash:Q(),feeCalculator:j({lamportsPerSignature:O()})})),ad=Qt(j({blockhash:Q(),lastValidBlockHeight:O()})),cd=Qt(rr()),ud=j({slot:O(),numTransactions:O(),numSlots:O(),samplePeriodSecs:O()}),fd=kt(nt(ud)),hd=Qt(rt(j({feeCalculator:j({lamportsPerSignature:O()})}))),ld=kt(Q()),dd=kt(Q()),pd=j({err:Wr,logs:nt(Q()),signature:Q()}),gd=j({result:ni(pd),subscription:O()}),yd={"solana-client":"js/0.0.0-development"};class md{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 b={};return async E=>{const{commitment:I,config:M}=Yt(E),T=this._buildArgs([],I,void 0,M),U=Ha(T);return b[U]=b[U]??(async()=>{try{const _=await this._rpcRequest("getBlockHeight",T),L=et(_,kt(O()));if("error"in L)throw new ut(L.error,"failed to get block height information");return L.result}finally{delete b[U]}})(),await b[U]}})();let n,s,a,f,u,p;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,s=e.httpHeaders,a=e.fetch,f=e.fetchMiddleware,u=e.disableRetryOnRateLimit,p=e.httpAgent),this._rpcEndpoint=rl(t),this._rpcWsEndpoint=n||el(t),this._rpcClient=gl(t,s,a,f,u,p),this._rpcRequest=yl(this._rpcClient),this._rpcBatchRequest=ml(this._rpcClient),this._rpcWebSocket=new Jh(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t.toBase58()],n,void 0,s),f=await this._rpcRequest("getBalance",a),u=et(f,Qt(O()));if("error"in u)throw new ut(u.error,`failed to get balance for ${t.toBase58()}`);return u.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+n)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),n=et(e,kt(rt(O())));if("error"in n)throw new ut(n.error,`failed to get block time for slot ${t}`);return n.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=et(t,kt(O()));if("error"in e)throw new ut(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=et(t,Sl);if("error"in e)throw new ut(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[e]),s=et(n,Bl);if("error"in s)throw new ut(s.error,"failed to get supply");return s.result}async getTokenSupply(t,e){const n=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenSupply",n),a=et(s,Qt(yo));if("error"in a)throw new ut(a.error,"failed to get token supply");return a.result}async getTokenAccountBalance(t,e){const n=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenAccountBalance",n),a=et(s,Qt(yo));if("error"in a)throw new ut(a.error,"failed to get token account balance");return a.result}async getTokenAccountsByOwner(t,e,n){const{commitment:s,config:a}=Yt(n);let f=[t.toBase58()];"mint"in e?f.push({mint:e.mint.toBase58()}):f.push({programId:e.programId.toBase58()});const u=this._buildArgs(f,s,"base64",a),p=await this._rpcRequest("getTokenAccountsByOwner",u),b=et(p,vl);if("error"in b)throw new ut(b.error,`failed to get token accounts owned by account ${t.toBase58()}`);return b.result}async getParsedTokenAccountsByOwner(t,e,n){let s=[t.toBase58()];"mint"in e?s.push({mint:e.mint.toBase58()}):s.push({programId:e.programId.toBase58()});const a=this._buildArgs(s,n,"jsonParsed"),f=await this._rpcRequest("getTokenAccountsByOwner",a),u=et(f,_l);if("error"in u)throw new ut(u.error,`failed to get token accounts owned by account ${t.toBase58()}`);return u.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},n=e.filter||e.commitment?[e]:[],s=await this._rpcRequest("getLargestAccounts",n),a=et(s,Rl);if("error"in a)throw new ut(a.error,"failed to get largest accounts");return a.result}async getTokenLargestAccounts(t,e){const n=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenLargestAccounts",n),a=et(s,Al);if("error"in a)throw new ut(a.error,"failed to get token largest accounts");return a.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t.toBase58()],n,"base64",s),f=await this._rpcRequest("getAccountInfo",a),u=et(f,Qt(rt(Rn)));if("error"in u)throw new ut(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getParsedAccountInfo(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t.toBase58()],n,"jsonParsed",s),f=await this._rpcRequest("getAccountInfo",a),u=et(f,Qt(rt(wo)));if("error"in u)throw new ut(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(n){throw new Error("failed to get info about account "+t.toBase58()+": "+n)}}async getMultipleParsedAccounts(t,e){const{commitment:n,config:s}=Yt(e),a=t.map(b=>b.toBase58()),f=this._buildArgs([a],n,"jsonParsed",s),u=await this._rpcRequest("getMultipleAccounts",f),p=et(u,Qt(nt(rt(wo))));if("error"in p)throw new ut(p.error,`failed to get info for accounts ${a}`);return p.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:s}=Yt(e),a=t.map(b=>b.toBase58()),f=this._buildArgs([a],n,"base64",s),u=await this._rpcRequest("getMultipleAccounts",f),p=et(u,Qt(nt(rt(Rn))));if("error"in p)throw new ut(p.error,`failed to get info for accounts ${a}`);return p.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:s,config:a}=Yt(e),f=this._buildArgs([t.toBase58()],s,void 0,{...a,epoch:n??(a==null?void 0:a.epoch)}),u=await this._rpcRequest("getStakeActivation",f),p=et(u,kt(Ll));if("error"in p)throw new ut(p.error,`failed to get Stake Activation ${t.toBase58()}`);return p.result}async getProgramAccounts(t,e){const{commitment:n,config:s}=Yt(e),{encoding:a,...f}=s||{},u=this._buildArgs([t.toBase58()],n,a||"base64",f),p=await this._rpcRequest("getProgramAccounts",u),b=nt(Tl),E=f.withContext===!0?et(p,Qt(b)):et(p,kt(b));if("error"in E)throw new ut(E.error,`failed to get accounts owned by program ${t.toBase58()}`);return E.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t.toBase58()],n,"jsonParsed",s),f=await this._rpcRequest("getProgramAccounts",a),u=et(f,kt(nt(Pl)));if("error"in u)throw new ut(u.error,`failed to get accounts owned by program ${t.toBase58()}`);return u.result}async confirmTransaction(t,e){var a;let n;if(typeof t=="string")n=t;else{const f=t;if((a=f.abortSignal)!=null&&a.aborted)return Promise.reject(f.abortSignal.reason);n=f.signature}let s;try{s=ke.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return Ct(s.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:n}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,n)=>{t!=null&&(t.aborted?n(t.reason):t.addEventListener("abort",()=>{n(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let n,s,a=!1;const f=new Promise((p,b)=>{try{n=this.onSignature(e,(I,M)=>{n=void 0;const T={context:M,value:I};p({__type:gr.PROCESSED,response:T})},t);const E=new Promise(I=>{n==null?I():s=this._onSubscriptionStateChange(n,M=>{M==="subscribed"&&I()})});(async()=>{if(await E,a)return;const I=await this.getSignatureStatus(e);if(a||I==null)return;const{context:M,value:T}=I;if(T!=null)if(T!=null&&T.err)b(T.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(T.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(T.confirmationStatus==="processed"||T.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}a=!0,p({__type:gr.PROCESSED,response:{context:M,value:T}})}})()}catch(E){b(E)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:f}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:s}}){let a=!1;const f=new Promise(I=>{const M=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let T=await M();if(!a){for(;T<=n;)if(await Dr(1e3),a||(T=await M(),a))return;I({__type:gr.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:u,confirmationPromise:p}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),b=this.getCancellationPromise(e);let E;try{const I=await Promise.race([b,p,f]);if(I.__type===gr.PROCESSED)E=I.response;else throw new io(s)}finally{a=!0,u()}return E}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:s,nonceValue:a,signature:f}}){let u=!1;const p=new Promise(T=>{let U=a,_=null;const L=async()=>{try{const{context:C,value:$}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:n});return _=C.slot,$==null?void 0:$.nonce}catch{return U}};(async()=>{if(U=await L(),!u)for(;;){if(a!==U){T({__type:gr.NONCE_INVALID,slotInWhichNonceDidAdvance:_});return}if(await Dr(2e3),u||(U=await L(),u))return}})()}),{abortConfirmation:b,confirmationPromise:E}=this.getTransactionConfirmationPromise({commitment:t,signature:f}),I=this.getCancellationPromise(e);let M;try{const T=await Promise.race([I,E,p]);if(T.__type===gr.PROCESSED)M=T.response;else{let U;for(;;){const _=await this.getSignatureStatus(f);if(_==null)break;if(_.context.slot<(T.slotInWhichNonceDidAdvance??n)){await Dr(400);continue}U=_;break}if(U!=null&&U.value){const _=t||"finalized",{confirmationStatus:L}=U.value;switch(_){case"processed":case"recent":if(L!=="processed"&&L!=="confirmed"&&L!=="finalized")throw new nn(f);break;case"confirmed":case"single":case"singleGossip":if(L!=="confirmed"&&L!=="finalized")throw new nn(f);break;case"finalized":case"max":case"root":if(L!=="finalized")throw new nn(f);break;default:}M={context:U.context,value:{err:U.value.err}}}else throw new nn(f)}}finally{u=!0,b()}return M}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const s=new Promise(p=>{let b=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{b=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>p({__type:gr.TIMED_OUT,timeoutMs:b}),b)}),{abortConfirmation:a,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let u;try{const p=await Promise.race([f,s]);if(p.__type===gr.PROCESSED)u=p.response;else throw new oo(e,p.timeoutMs/1e3)}finally{clearTimeout(n),a()}return u}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=et(t,kt(nt(Hl)));if("error"in e)throw new ut(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getVoteAccounts",e),s=et(n,Vl);if("error"in s)throw new ut(s.error,"failed to get vote accounts");return s.result}async getSlot(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getSlot",s),f=et(a,kt(O()));if("error"in f)throw new ut(f.error,"failed to get slot");return f.result}async getSlotLeader(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getSlotLeader",s),f=et(a,kt(Q()));if("error"in f)throw new ut(f.error,"failed to get slot leader");return f.result}async getSlotLeaders(t,e){const n=[t,e],s=await this._rpcRequest("getSlotLeaders",n),a=et(s,kt(nt(te)));if("error"in a)throw new ut(a.error,"failed to get slot leaders");return a.result}async getSignatureStatus(t,e){const{context:n,value:s}=await this.getSignatureStatuses([t],e);Ct(s.length===1);const a=s[0];return{context:n,value:a}}async getSignatureStatuses(t,e){const n=[t];e&&n.push(e);const s=await this._rpcRequest("getSignatureStatuses",n),a=et(s,Yl);if("error"in a)throw new ut(a.error,"failed to get signature status");return a.result}async getTransactionCount(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getTransactionCount",s),f=et(a,kt(O()));if("error"in f)throw new ut(f.error,"failed to get transaction count");return f.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getInflationGovernor",e),s=et(n,wl);if("error"in s)throw new ut(s.error,"failed to get inflation");return s.result}async getInflationReward(t,e,n){const{commitment:s,config:a}=Yt(n),f=this._buildArgs([t.map(b=>b.toBase58())],s,void 0,{...a,epoch:e??(a==null?void 0:a.epoch)}),u=await this._rpcRequest("getInflationReward",f),p=et(u,ol);if("error"in p)throw new ut(p.error,"failed to get inflation reward");return p.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=et(t,bl);if("error"in e)throw new ut(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getEpochInfo",s),f=et(a,kl);if("error"in f)throw new ut(f.error,"failed to get epoch info");return f.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=et(t,El);if("error"in e)throw new ut(e.error,"failed to get epoch schedule");const n=e.result;return new Va(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=et(t,Il);if("error"in e)throw new ut(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const n=this._buildArgs([t],e),s=await this._rpcRequest("getMinimumBalanceForRentExemption",n),a=et(s,Zl);return"error"in a?(console.warn("Unable to fetch minimum balance for rent exemption"),0):a.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getRecentBlockhash",e),s=et(n,sd);if("error"in s)throw new ut(s.error,"failed to get recent blockhash");return s.result}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),n=et(e,fd);if("error"in n)throw new ut(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(t,e){const n=this._buildArgs([t],e),s=await this._rpcRequest("getFeeCalculatorForBlockhash",n),a=et(s,hd);if("error"in a)throw new ut(a.error,"failed to get fee calculator");const{context:f,value:u}=a.result;return{context:f,value:u!==null?u.feeCalculator:null}}async getFeeForMessage(t,e){const n=xt(t.serialize()).toString("base64"),s=this._buildArgs([n],e),a=await this._rpcRequest("getFeeForMessage",s),f=et(a,Qt(rt(O())));if("error"in f)throw new ut(f.error,"failed to get fee for message");if(f.result===null)throw new Error("invalid blockhash");return f.result}async getRecentPrioritizationFees(t){var f;const e=(f=t==null?void 0:t.lockedWritableAccounts)==null?void 0:f.map(u=>u.toBase58()),n=e!=null&&e.length?[e]:[],s=await this._rpcRequest("getRecentPrioritizationFees",n),a=et(s,xl);if("error"in a)throw new ut(a.error,"failed to get recent prioritization fees");return a.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getLatestBlockhash",s),f=et(a,ad);if("error"in f)throw new ut(f.error,"failed to get latest blockhash");return f.result}async isBlockhashValid(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t],n,void 0,s),f=await this._rpcRequest("isBlockhashValid",a),u=et(f,cd);if("error"in u)throw new ut(u.error,"failed to determine if the blockhash `"+t+"`is valid");return u.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=et(t,kt(dl));if("error"in e)throw new ut(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=et(t,kt(Q()));if("error"in e)throw new ut(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgsAtLeastConfirmed([t],n,void 0,s),f=await this._rpcRequest("getBlock",a);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const u=et(f,ed);if("error"in u)throw u.error;return u.result}case"none":{const u=et(f,td);if("error"in u)throw u.error;return u.result}default:{const u=et(f,Ql);if("error"in u)throw u.error;const{result:p}=u;return p?{...p,transactions:p.transactions.map(({transaction:b,meta:E,version:I})=>({meta:E,transaction:{...b,message:go(I,b.message)},version:I}))}:null}}}catch(u){throw new ut(u,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),f=await this._rpcRequest("getBlock",a);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const u=et(f,nd);if("error"in u)throw u.error;return u.result}case"none":{const u=et(f,id);if("error"in u)throw u.error;return u.result}default:{const u=et(f,rd);if("error"in u)throw u.error;return u.result}}}catch(u){throw new ut(u,"failed to get block")}}async getBlockProduction(t){let e,n;if(typeof t=="string")n=t;else if(t){const{commitment:u,...p}=t;n=u,e=p}const s=this._buildArgs([],n,"base64",e),a=await this._rpcRequest("getBlockProduction",s),f=et(a,pl);if("error"in f)throw new ut(f.error,"failed to get block production information");return f.result}async getTransaction(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgsAtLeastConfirmed([t],n,void 0,s),f=await this._rpcRequest("getTransaction",a),u=et(f,ko);if("error"in u)throw new ut(u.error,"failed to get transaction");const p=u.result;return p&&{...p,transaction:{...p.transaction,message:go(p.version,p.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),f=await this._rpcRequest("getTransaction",a),u=et(f,si);if("error"in u)throw new ut(u.error,"failed to get transaction");return u.result}async getParsedTransactions(t,e){const{commitment:n,config:s}=Yt(e),a=t.map(p=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([p],n,"jsonParsed",s)}));return(await this._rpcBatchRequest(a)).map(p=>{const b=et(p,si);if("error"in b)throw new ut(b.error,"failed to get transactions");return b.result})}async getTransactions(t,e){const{commitment:n,config:s}=Yt(e),a=t.map(p=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([p],n,void 0,s)}));return(await this._rpcBatchRequest(a)).map(p=>{const b=et(p,ko);if("error"in b)throw new ut(b.error,"failed to get transactions");const E=b.result;return E&&{...E,transaction:{...E.transaction,message:go(E.version,E.transaction.message)}}})}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedBlock",n),a=et(s,od);if("error"in a)throw new ut(a.error,"failed to get confirmed block");const f=a.result;if(!f)throw new Error("Confirmed block "+t+" not found");const u={...f,transactions:f.transactions.map(({transaction:p,meta:b})=>{const E=new Ze(p.message);return{meta:b,transaction:{...p,message:E}}})};return{...u,transactions:u.transactions.map(({transaction:p,meta:b})=>({meta:b,transaction:Ot.populate(p.message,p.signatures)}))}}async getBlocks(t,e,n){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),a=await this._rpcRequest("getBlocks",s),f=et(a,kt(nt(O())));if("error"in f)throw new ut(f.error,"failed to get blocks");return f.result}async getBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",n),a=et(s,ac);if("error"in a)throw new ut(a.error,"failed to get block");const f=a.result;if(!f)throw new Error("Block "+t+" not found");return f}async getConfirmedBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getConfirmedBlock",n),a=et(s,ac);if("error"in a)throw new ut(a.error,"failed to get confirmed block");const f=a.result;if(!f)throw new Error("Confirmed block "+t+" not found");return f}async getConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedTransaction",n),a=et(s,ko);if("error"in a)throw new ut(a.error,"failed to get transaction");const f=a.result;if(!f)return f;const u=new Ze(f.transaction.message),p=f.transaction.signatures;return{...f,transaction:Ot.populate(u,p)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getConfirmedTransaction",n),a=et(s,si);if("error"in a)throw new ut(a.error,"failed to get confirmed transaction");return a.result}async getParsedConfirmedTransactions(t,e){const n=t.map(f=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([f],e,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(f=>{const u=et(f,si);if("error"in u)throw new ut(u.error,"failed to get confirmed transactions");return u.result})}async getConfirmedSignaturesForAddress(t,e,n){let s={},a=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<a));)try{const p=await this.getConfirmedBlockSignatures(e,"finalized");p.signatures.length>0&&(s.until=p.signatures[p.signatures.length-1].toString())}catch(p){if(p instanceof Error&&p.message.includes("skipped"))continue;throw p}let f=await this.getSlot("finalized");for(;!("before"in s)&&(n++,!(n>f));)try{const p=await this.getConfirmedBlockSignatures(n);p.signatures.length>0&&(s.before=p.signatures[p.signatures.length-1].toString())}catch(p){if(p instanceof Error&&p.message.includes("skipped"))continue;throw p}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(p=>p.signature)}async getConfirmedSignaturesForAddress2(t,e,n){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),a=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),f=et(a,Ul);if("error"in f)throw new ut(f.error,"failed to get confirmed signatures for address");return f.result}async getSignaturesForAddress(t,e,n){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),a=await this._rpcRequest("getSignaturesForAddress",s),f=et(a,Cl);if("error"in f)throw new ut(f.error,"failed to get signatures for address");return f.result}async getAddressLookupTable(t,e){const{context:n,value:s}=await this.getAccountInfoAndContext(t,e);let a=null;return s!==null&&(a=new lo({key:t,state:lo.deserialize(s.data)})),{context:n,value:a}}async getNonceAndContext(t,e){const{context:n,value:s}=await this.getAccountInfoAndContext(t,e);let a=null;return s!==null&&(a=ri.fromAccountData(s.data)),{context:n,value:a}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+n)})}async requestAirdrop(t,e){const n=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),s=et(n,ld);if("error"in s)throw new ut(s.error,`airdrop to ${t.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Dr(100);const n=Date.now()-this._blockhashInfo.lastFetch>=Ya;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,n=e?e.blockhash:null;for(let s=0;s<50;s++){const a=await this.getLatestBlockhash("finalized");if(n!==a.blockhash)return this._blockhashInfo={latestBlockhash:a,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},a;await Dr(Wa/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,"base64",n),a=await this._rpcRequest("getStakeMinimumDelegation",s),f=et(a,Qt(O()));if("error"in f)throw new ut(f.error,"failed to get stake minimum delegation");return f.result}async simulateTransaction(t,e,n){if("message"in t){const _=t.serialize(),L=lt.Buffer.from(_).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const C=e||{};C.encoding="base64","commitment"in C||(C.commitment=this.commitment);const $=[L,C],N=await this._rpcRequest("simulateTransaction",$),H=et(N,Ja);if("error"in H)throw new Error("failed to simulate transaction: "+H.error.message);return H.result}let s;if(t instanceof Ot){let U=t;s=new Ot,s.feePayer=U.feePayer,s.instructions=t.instructions,s.nonceInfo=U.nonceInfo,s.signatures=U.signatures}else s=Ot.populate(t),s._message=s._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const a=e;if(s.nonceInfo&&a)s.sign(...a);else{let U=this._disableBlockhashCaching;for(;;){const _=await this._blockhashWithExpiryBlockHeight(U);if(s.lastValidBlockHeight=_.lastValidBlockHeight,s.recentBlockhash=_.blockhash,!a)break;if(s.sign(...a),!s.signature)throw new Error("!signature");const L=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(L)&&!this._blockhashInfo.transactionSignatures.includes(L)){this._blockhashInfo.simulatedSignatures.push(L);break}else U=!0}}const f=s._compile(),u=f.serialize(),b=s._serialize(u).toString("base64"),E={encoding:"base64",commitment:this.commitment};if(n){const U=(Array.isArray(n)?n:f.nonProgramIds()).map(_=>_.toBase58());E.accounts={encoding:"base64",addresses:U}}a&&(E.sigVerify=!0);const I=[b,E],M=await this._rpcRequest("simulateTransaction",I),T=et(M,Ja);if("error"in T){let U;if("data"in T.error&&(U=T.error.data.logs,U&&Array.isArray(U))){const _=`
|
|
23
|
+
`,L=_+U.join(_);console.error(T.error.message,L)}throw new An({action:"simulate",signature:"",transactionMessage:T.error.message,logs:U})}return T.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const f=t.serialize();return await this.sendRawTransaction(f,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(t.nonceInfo)t.sign(...s);else{let f=this._disableBlockhashCaching;for(;;){const u=await this._blockhashWithExpiryBlockHeight(f);if(t.lastValidBlockHeight=u.lastValidBlockHeight,t.recentBlockhash=u.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const p=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(p))f=!0;else{this._blockhashInfo.transactionSignatures.push(p);break}}}const a=t.serialize();return await this.sendRawTransaction(a,n)}async sendRawTransaction(t,e){const n=xt(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},s=e&&e.skipPreflight,a=s===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(n.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(n.minContextSlot=e.minContextSlot),s&&(n.skipPreflight=s),a&&(n.preflightCommitment=a);const f=[t,n],u=await this._rpcRequest("sendTransaction",f),p=et(u,dd);if("error"in p){let b;throw"data"in p.error&&(b=p.error.data.logs),new An({action:s?"send":"simulate",signature:"",transactionMessage:p.error.message,logs:b})}return p.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,n])=>{this._setSubscription(e,{...n,state:"pending"})})}_setSubscription(t,e){var s;const n=(s=this._subscriptionsByHash[t])==null?void 0:s.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const a=this._subscriptionStateChangeCallbacksByHash[t];a&&a.forEach(f=>{try{f(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var a;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const s=(a=this._subscriptionStateChangeCallbacksByHash)[n]||(a[n]=new Set);return s.add(e),()=>{s.delete(e),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const s=this._subscriptionsByHash[n];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[n],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:a,method:f}=s;try{this._setSubscription(n,{...s,state:"subscribing"});const u=await this._rpcWebSocket.call(f,a);this._setSubscription(n,{...s,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=s.callbacks,await this._updateSubscriptions()}catch(u){if(u instanceof Error&&console.error(`${f} error for argument`,a,u.message),!e())return;this._setSubscription(n,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:a,unsubscribeMethod:f}=s;if(this._subscriptionsAutoDisposedByRpc.has(a))this._subscriptionsAutoDisposedByRpc.delete(a);else{this._setSubscription(n,{...s,state:"unsubscribing"}),this._setSubscription(n,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(f,[a])}catch(u){if(u instanceof Error&&console.error(`${f} error:`,u.message),!e())return;this._setSubscription(n,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];n!==void 0&&n.forEach(s=>{try{s(...e)}catch(a){console.error(a)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=et(t,Fl);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,s=Ha([t.method,e]),a=this._subscriptionsByHash[s];return a===void 0?this._subscriptionsByHash[s]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:a.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const f=this._subscriptionsByHash[s];Ct(f!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),f.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const s=this._buildArgs([t.toBase58()],n||this._commitment||"finalized","base64");return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},s)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=et(t,Nl);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,s){const a=this._buildArgs([t.toBase58()],n||this._commitment||"finalized","base64",s?{filters: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,n){const s=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],n||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:n}=et(t,gd);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=et(t,Dl);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=et(t,Wl);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,n,s){const a=e||this._commitment;if(a||n||s){let f={};n&&(f.encoding=n),a&&(f.commitment=a),s&&(f=Object.assign(f,s)),t.push(f)}return t}_buildArgsAtLeastConfirmed(t,e,n,s){const a=e||this._commitment;if(a&&!["confirmed","finalized"].includes(a))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,s)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=et(t,Kl);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const s=this._buildArgs([t],n||this._commitment||"finalized"),a=this._makeSubscription({callback:(f,u)=>{if(f.type==="status"){e(f.result,u);try{this.removeSignatureListener(a)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return a}onSignatureWithOptions(t,e,n){const{commitment:s,...a}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},f=this._buildArgs([t],s,void 0,a),u=this._makeSubscription({callback:(p,b)=>{e(p,b);try{this.removeSignatureListener(u)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},f);return u}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=et(t,ql);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class cn{constructor(t){this._keypair=void 0,this._keypair=t??Ca()}static generate(){return new cn(Ca())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const n=t.slice(32,64);if(!e||!e.skipValidation){const s=t.slice(0,32),a=Jn(s);for(let f=0;f<32;f++)if(n[f]!==a[f])throw new Error("provided secretKey is invalid")}return new cn({publicKey:n,secretKey:t})}static fromSeed(t){const e=Jn(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new cn({publicKey:e,secretKey:n})}get publicKey(){return new tt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const yr=Object.freeze({CreateLookupTable:{index:0,layout:ct([at("instruction"),sn("recentSlot"),Pt("bumpSeed")])},FreezeLookupTable:{index:1,layout:ct([at("instruction")])},ExtendLookupTable:{index:2,layout:ct([at("instruction"),sn(),Ae(St(),Sr(at(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:ct([at("instruction")])},CloseLookupTable:{index:4,layout:ct([at("instruction")])}});class wd{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(yr))if(f.index==n){s=a;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}=zt(yr.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}=zt(yr.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(n=>new tt(n))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Eo.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 Eo{constructor(){}static createLookupTable(t){const[e,n]=tt.findProgramAddressSync([t.authority.toBuffer(),fa(BigInt(t.recentSlot),8)],this.programId),s=yr.CreateLookupTable,a=Tt(s,{recentSlot:BigInt(t.recentSlot),bumpSeed:n}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Ee.programId,isSigner:!1,isWritable:!1}];return[new Ht({programId:this.programId,keys:f,data:a}),e]}static freezeLookupTable(t){const e=yr.FreezeLookupTable,n=Tt(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ht({programId:this.programId,keys:s,data:n})}static extendLookupTable(t){const e=yr.ExtendLookupTable,n=Tt(e,{addresses:t.addresses.map(a=>a.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:Ee.programId,isSigner:!1,isWritable:!1}),new Ht({programId:this.programId,keys:s,data:n})}static deactivateLookupTable(t){const e=yr.DeactivateLookupTable,n=Tt(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ht({programId:this.programId,keys:s,data:n})}static closeLookupTable(t){const e=yr.CloseLookupTable,n=Tt(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 Ht({programId:this.programId,keys:s,data:n})}}Eo.programId=new tt("AddressLookupTab1e1111111111111111111111111");class bd{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Pt("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(sr))if(f.index==n){s=a;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:n}=zt(sr.RequestUnits,t.data);return{units:e,additionalFee:n}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=zt(sr.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=zt(sr.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=zt(sr.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(Io.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const sr=Object.freeze({RequestUnits:{index:0,layout:ct([Pt("instruction"),at("units"),at("additionalFee")])},RequestHeapFrame:{index:1,layout:ct([Pt("instruction"),at("bytes")])},SetComputeUnitLimit:{index:2,layout:ct([Pt("instruction"),at("units")])},SetComputeUnitPrice:{index:3,layout:ct([Pt("instruction"),sn("microLamports")])}});class Io{constructor(){}static requestUnits(t){const e=sr.RequestUnits,n=Tt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static requestHeapFrame(t){const e=sr.RequestHeapFrame,n=Tt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(t){const e=sr.SetComputeUnitLimit,n=Tt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(t){const e=sr.SetComputeUnitPrice,n=Tt(e,{microLamports:BigInt(t.microLamports)});return new Ht({keys:[],programId:this.programId,data:n})}}Io.programId=new tt("ComputeBudget111111111111111111111111111111");const cc=64,uc=32,fc=64,hc=ct([Pt("numSignatures"),Pt("padding"),qe("signatureOffset"),qe("signatureInstructionIndex"),qe("publicKeyOffset"),qe("publicKeyInstructionIndex"),qe("messageDataOffset"),qe("messageDataSize"),qe("messageInstructionIndex")]);class ai{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:s,instructionIndex:a}=t;Ct(e.length===uc,`Public Key must be ${uc} bytes but received ${e.length} bytes`),Ct(s.length===fc,`Signature must be ${fc} bytes but received ${s.length} bytes`);const f=hc.span,u=f+e.length,p=u+s.length,b=1,E=lt.Buffer.alloc(p+n.length),I=a??65535;return hc.encode({numSignatures:b,padding:0,signatureOffset:u,signatureInstructionIndex:I,publicKeyOffset:f,publicKeyInstructionIndex:I,messageDataOffset:p,messageDataSize:n.length,messageInstructionIndex:I},E),E.fill(e,f),E.fill(s,u),E.fill(n,p),new Ht({keys:[],programId:ai.programId,data:E})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:s}=t;Ct(e.length===cc,`Private key must be ${cc} bytes but received ${e.length} bytes`);try{const a=cn.fromSecretKey(e),f=a.publicKey.toBytes(),u=ro(n,a.secretKey);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:u,instructionIndex:s})}catch(a){throw new Error(`Error creating instruction; ${a}`)}}}ai.programId=new tt("Ed25519SigVerify111111111111111111111111111");const xd=(o,t)=>{const e=Zn.sign(o,t);return[e.toCompactRawBytes(),e.recovery]};Zn.utils.isValidPrivateKey;const kd=Zn.getPublicKey,lc=32,So=20,dc=64,Ed=11,Bo=ct([Pt("numSignatures"),qe("signatureOffset"),Pt("signatureInstructionIndex"),qe("ethAddressOffset"),Pt("ethAddressInstructionIndex"),qe("messageDataOffset"),qe("messageDataSize"),Pt("messageInstructionIndex"),jt(20,"ethAddress"),jt(64,"signature"),Pt("recoveryId")]);class un{constructor(){}static publicKeyToEthAddress(t){Ct(t.length===dc,`Public key must be ${dc} bytes but received ${t.length} bytes`);try{return lt.Buffer.from(_a(xt(t))).slice(-So)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:s,recoveryId:a,instructionIndex:f}=t;return un.createInstructionWithEthAddress({ethAddress:un.publicKeyToEthAddress(e),message:n,signature:s,recoveryId:a,instructionIndex:f})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:n,signature:s,recoveryId:a,instructionIndex:f=0}=t;let u;typeof e=="string"?e.startsWith("0x")?u=lt.Buffer.from(e.substr(2),"hex"):u=lt.Buffer.from(e,"hex"):u=e,Ct(u.length===So,`Address must be ${So} bytes but received ${u.length} bytes`);const p=1+Ed,b=p,E=p+u.length,I=E+s.length+1,M=1,T=lt.Buffer.alloc(Bo.span+n.length);return Bo.encode({numSignatures:M,signatureOffset:E,signatureInstructionIndex:f,ethAddressOffset:b,ethAddressInstructionIndex:f,messageDataOffset:I,messageDataSize:n.length,messageInstructionIndex:f,signature:xt(s),ethAddress:xt(u),recoveryId:a},T),T.fill(xt(n),Bo.span),new Ht({keys:[],programId:un.programId,data:T})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:s}=t;Ct(e.length===lc,`Private key must be ${lc} bytes but received ${e.length} bytes`);try{const a=xt(e),f=kd(a,!1).slice(1),u=lt.Buffer.from(_a(xt(n))),[p,b]=xd(u,a);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:p,recoveryId:b,instructionIndex:s})}catch(a){throw new Error(`Error creating instruction; ${a}`)}}}un.programId=new tt("KeccakSecp256k11111111111111111111111111111");var pc;const gc=new tt("StakeConfig11111111111111111111111111111111");class yc{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Tn{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}}pc=Tn,Tn.default=new pc(0,0,tt.default);class Id{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(Ie))if(f.index==n){s=a;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:n}=zt(Ie.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new yc(new tt(e.staker),new tt(e.withdrawer)),lockup:new Tn(n.unixTimestamp,n.epoch,new tt(n.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),zt(Ie.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:n}=zt(Ie.Authorize,t.data),s={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new tt(e),stakeAuthorizationType:{index:n}};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:n,authoritySeed:s,authorityOwner:a}=zt(Ie.AuthorizeWithSeed,t.data),f={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:s,authorityOwner:new tt(a),newAuthorizedPubkey:new tt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(f.custodianPubkey=t.keys[3].pubkey),f}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=zt(Ie.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),zt(Ie.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}=zt(Ie.Withdraw,t.data),n={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(n.custodianPubkey=t.keys[5].pubkey),n}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),zt(Ie.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(ci.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 Ie=Object.freeze({Initialize:{index:0,layout:ct([at("instruction"),Rh(),Th()])},Authorize:{index:1,layout:ct([at("instruction"),St("newAuthorized"),at("stakeAuthorizationType")])},Delegate:{index:2,layout:ct([at("instruction")])},Split:{index:3,layout:ct([at("instruction"),De("lamports")])},Withdraw:{index:4,layout:ct([at("instruction"),De("lamports")])},Deactivate:{index:5,layout:ct([at("instruction")])},Merge:{index:7,layout:ct([at("instruction")])},AuthorizeWithSeed:{index:8,layout:ct([at("instruction"),St("newAuthorized"),at("stakeAuthorizationType"),Nr("authoritySeed"),St("authorityOwner")])}}),Sd=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class ci{constructor(){}static initialize(t){const{stakePubkey:e,authorized:n,lockup:s}=t,a=s||Tn.default,f=Ie.Initialize,u=Tt(f,{authorized:{staker:xt(n.staker.toBuffer()),withdrawer:xt(n.withdrawer.toBuffer())},lockup:{unixTimestamp:a.unixTimestamp,epoch:a.epoch,custodian:xt(a.custodian.toBuffer())}}),p={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:on,isSigner:!1,isWritable:!1}],programId:this.programId,data:u};return new Ht(p)}static createAccountWithSeed(t){const e=new Ot;e.add(Ee.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:s,lockup:a}=t;return e.add(this.initialize({stakePubkey:n,authorized:s,lockup:a}))}static createAccount(t){const e=new Ot;e.add(Ee.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:s,lockup:a}=t;return e.add(this.initialize({stakePubkey:n,authorized:s,lockup:a}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:n,votePubkey:s}=t,a=Ie.Delegate,f=Tt(a);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ei,isSigner:!1,isWritable:!1},{pubkey:gc,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static authorize(t){const{stakePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:s,stakeAuthorizationType:a,custodianPubkey:f}=t,u=Ie.Authorize,p=Tt(u,{newAuthorized:xt(s.toBuffer()),stakeAuthorizationType:a.index}),b=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&b.push({pubkey:f,isSigner:!0,isWritable:!1}),new Ot().add({keys:b,programId:this.programId,data:p})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:n,authoritySeed:s,authorityOwner:a,newAuthorizedPubkey:f,stakeAuthorizationType:u,custodianPubkey:p}=t,b=Ie.AuthorizeWithSeed,E=Tt(b,{newAuthorized:xt(f.toBuffer()),stakeAuthorizationType:u.index,authoritySeed:s,authorityOwner:xt(a.toBuffer())}),I=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1}];return p&&I.push({pubkey:p,isSigner:!0,isWritable:!1}),new Ot().add({keys:I,programId:this.programId,data:E})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:s,lamports:a}=t,f=Ie.Split,u=Tt(f,{lamports:a});return new Ht({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:u})}static split(t,e){const n=new Ot;return n.add(Ee.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),n.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:n,authorizedPubkey:s,splitStakePubkey:a,basePubkey:f,seed:u,lamports:p}=t,b=new Ot;return b.add(Ee.allocate({accountPubkey:a,basePubkey:f,seed:u,space:this.space,programId:this.programId})),e&&e>0&&b.add(Ee.transfer({fromPubkey:t.authorizedPubkey,toPubkey:a,lamports:e})),b.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:s,splitStakePubkey:a,lamports:p}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:n,authorizedPubkey:s}=t,a=Ie.Merge,f=Tt(a);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ei,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:n,toPubkey:s,lamports:a,custodianPubkey:f}=t,u=Ie.Withdraw,p=Tt(u,{lamports:a}),b=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ei,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&b.push({pubkey:f,isSigner:!0,isWritable:!1}),new Ot().add({keys:b,programId:this.programId,data:p})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:n}=t,s=Ie.Deactivate,a=Tt(s);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}}ci.programId=new tt("Stake11111111111111111111111111111111111111"),ci.space=200;class mc{constructor(t,e,n,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=n,this.commission=s}}class Bd{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(ar))if(f.index==n){s=a;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}=zt(ar.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new mc(new tt(e.nodePubkey),new tt(e.authorizedVoter),new tt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:n}=zt(ar.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new tt(e),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:n,newAuthorized:s,voteAuthorizationType:a}}=zt(ar.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new tt(e),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new tt(s),voteAuthorizationType:{index:a},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=zt(ar.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(fn.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 ar=Object.freeze({InitializeAccount:{index:0,layout:ct([at("instruction"),Mh()])},Authorize:{index:1,layout:ct([at("instruction"),St("newAuthorized"),at("voteAuthorizationType")])},Withdraw:{index:3,layout:ct([at("instruction"),De("lamports")])},UpdateValidatorIdentity:{index:4,layout:ct([at("instruction")])},AuthorizeWithSeed:{index:10,layout:ct([at("instruction"),Ph()])}}),Ad=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class fn{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:n,voteInit:s}=t,a=ar.InitializeAccount,f=Tt(a,{voteInit:{nodePubkey:xt(s.nodePubkey.toBuffer()),authorizedVoter:xt(s.authorizedVoter.toBuffer()),authorizedWithdrawer:xt(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:on,isSigner:!1,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f};return new Ht(u)}static createAccount(t){const e=new Ot;return e.add(Ee.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:s,voteAuthorizationType:a}=t,f=ar.Authorize,u=Tt(f,{newAuthorized:xt(s.toBuffer()),voteAuthorizationType:a.index}),p=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:p,programId:this.programId,data:u})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:a,voteAuthorizationType:f,votePubkey:u}=t,p=ar.AuthorizeWithSeed,b=Tt(p,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:xt(n.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:xt(a.toBuffer()),voteAuthorizationType:f.index}}),E=[{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new Ot().add({keys:E,programId:this.programId,data:b})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,lamports:s,toPubkey:a}=t,f=ar.Withdraw,u=Tt(f,{lamports:s}),p=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:p,programId:this.programId,data:u})}static safeWithdraw(t,e,n){if(t.lamports>e-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return fn.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,nodePubkey:s}=t,a=ar.UpdateValidatorIdentity,f=Tt(a),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:u,programId:this.programId,data:f})}}fn.programId=new tt("Vote111111111111111111111111111111111111111"),fn.space=3762;const wc=new tt("Va1idator1nfo111111111111111111111111111111"),vd=j({name:Q(),website:pt(Q()),details:pt(Q()),keybaseUsername:pt(Q())});class Ao{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(Ce(e)!==2)return null;const s=[];for(let a=0;a<2;a++){const f=new tt(Fe(e,0,nr)),u=ir(e)===1;s.push({publicKey:f,isSigner:u})}if(s[0].publicKey.equals(wc)&&s[1].isSigner){const a=Nr().decode(lt.Buffer.from(e)),f=JSON.parse(a);return la(f,vd),new Ao(s[1].publicKey,f)}return null}}const _d=new tt("Vote111111111111111111111111111111111111111"),Rd=ct([St("nodePubkey"),St("authorizedWithdrawer"),Pt("commission"),Be(),Ae(ct([Be("slot"),at("confirmationCount")]),Sr(at(),-8),"votes"),Pt("rootSlotValid"),Be("rootSlot"),Be(),Ae(ct([Be("epoch"),St("authorizedVoter")]),Sr(at(),-8),"authorizedVoters"),ct([Ae(ct([St("authorizedPubkey"),Be("epochOfLastAuthorizedSwitch"),Be("targetEpoch")]),32,"buf"),Be("idx"),Pt("isEmpty")],"priorVoters"),Be(),Ae(ct([Be("epoch"),Be("credits"),Be("prevCredits")]),Sr(at(),-8),"epochCredits"),ct([Be("slot"),Be("timestamp")],"lastTimestamp")]);class vo{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const n=Rd.decode(xt(t),4);let s=n.rootSlot;return n.rootSlotValid||(s=null),new vo({nodePubkey:new tt(n.nodePubkey),authorizedWithdrawer:new tt(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:s,authorizedVoters:n.authorizedVoters.map(Td),priorVoters:Md(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function Td({authorizedVoter:o,epoch:t}){return{epoch:t,authorizedVoter:new tt(o)}}function bc({authorizedPubkey:o,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new tt(o),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function Md({buf:o,idx:t,isEmpty:e}){return e?[]:[...o.slice(t+1).map(bc),...o.slice(0,t).map(bc)]}const xc={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 Pd(o,t){const e=t===!1?"http":"https";if(!o)return xc[e].devnet;const n=xc[e][o];if(!n)throw new Error(`Unknown ${e} cluster: ${o}`);return n}async function Ld(o,t,e,n){let s,a;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(s=e,a=n):a=e;const f=a&&{skipPreflight:a.skipPreflight,preflightCommitment:a.preflightCommitment||a.commitment,minContextSlot:a.minContextSlot},u=await o.sendRawTransaction(t,f),p=a&&a.commitment,E=(await(s?o.confirmTransaction(s,p):o.confirmTransaction(u,p))).value;if(E.err)throw u!=null?new An({action:f!=null&&f.skipPreflight?"send":"simulate",signature:u,transactionMessage:`Status: (${JSON.stringify(E)})`}):new Error(`Raw transaction ${u} failed (${JSON.stringify(E)})`);return u}const ui=Object.freeze(Object.defineProperty({__proto__:null,Account:Ah,AddressLookupTableAccount:lo,AddressLookupTableInstruction:wd,AddressLookupTableProgram:Eo,Authorized:yc,BLOCKHASH_CACHE_TIMEOUT_MS:Ya,BPF_LOADER_DEPRECATED_PROGRAM_ID:vh,BPF_LOADER_PROGRAM_ID:Kh,BpfLoader:qh,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:sr,ComputeBudgetInstruction:bd,ComputeBudgetProgram:Io,Connection:md,Ed25519Program:ai,Enum:Sh,EpochSchedule:Va,FeeCalculatorLayout:Ka,Keypair:cn,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:yr,Loader:$r,Lockup:Tn,MAX_SEED_LENGTH:Na,Message:Ze,MessageAccountKeys:Bn,MessageV0:zr,NONCE_ACCOUNT_LENGTH:fo,NonceAccount:ri,PACKET_DATA_SIZE:Ar,PUBLIC_KEY_LENGTH:nr,PublicKey:tt,SIGNATURE_LENGTH_IN_BYTES:Sn,SOLANA_SCHEMA:In,STAKE_CONFIG_ID:gc,STAKE_INSTRUCTION_LAYOUTS:Ie,SYSTEM_INSTRUCTION_LAYOUTS:Vt,SYSVAR_CLOCK_PUBKEY:or,SYSVAR_EPOCH_SCHEDULE_PUBKEY:Uh,SYSVAR_INSTRUCTIONS_PUBKEY:Ch,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:ti,SYSVAR_RENT_PUBKEY:on,SYSVAR_REWARDS_PUBKEY:Fh,SYSVAR_SLOT_HASHES_PUBKEY:Oh,SYSVAR_SLOT_HISTORY_PUBKEY:Nh,SYSVAR_STAKE_HISTORY_PUBKEY:ei,Secp256k1Program:un,SendTransactionError:An,SolanaJSONRPCError:ut,SolanaJSONRPCErrorCode:zh,StakeAuthorizationLayout:Sd,StakeInstruction:Id,StakeProgram:ci,Struct:no,SystemInstruction:$h,SystemProgram:Ee,Transaction:Ot,TransactionExpiredBlockheightExceededError:io,TransactionExpiredNonceInvalidError:nn,TransactionExpiredTimeoutError:oo,TransactionInstruction:Ht,TransactionMessage:ao,TransactionStatus:gr,VALIDATOR_INFO_KEY:wc,VERSION_PREFIX_MASK:Xn,VOTE_PROGRAM_ID:_d,ValidatorInfo:Ao,VersionedMessage:so,VersionedTransaction:co,VoteAccount:vo,VoteAuthorizationLayout:Ad,VoteInit:mc,VoteInstruction:Bd,VoteProgram:fn,clusterApiUrl:Pd,sendAndConfirmRawTransaction:Ld,sendAndConfirmTransaction:uo},Symbol.toStringTag,{value:"Module"})),vr=ke;var _o={exports:{}};_o.exports,function(o){var t=function(){var e=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",a={};function f(p,b){if(!a[p]){a[p]={};for(var E=0;E<p.length;E++)a[p][p.charAt(E)]=E}return a[p][b]}var u={compressToBase64:function(p){if(p==null)return"";var b=u._compress(p,6,function(E){return n.charAt(E)});switch(b.length%4){default:case 0:return b;case 1:return b+"===";case 2:return b+"==";case 3:return b+"="}},decompressFromBase64:function(p){return p==null?"":p==""?null:u._decompress(p.length,32,function(b){return f(n,p.charAt(b))})},compressToUTF16:function(p){return p==null?"":u._compress(p,15,function(b){return e(b+32)})+" "},decompressFromUTF16:function(p){return p==null?"":p==""?null:u._decompress(p.length,16384,function(b){return p.charCodeAt(b)-32})},compressToUint8Array:function(p){for(var b=u.compress(p),E=new Uint8Array(b.length*2),I=0,M=b.length;I<M;I++){var T=b.charCodeAt(I);E[I*2]=T>>>8,E[I*2+1]=T%256}return E},decompressFromUint8Array:function(p){if(p==null)return u.decompress(p);for(var b=new Array(p.length/2),E=0,I=b.length;E<I;E++)b[E]=p[E*2]*256+p[E*2+1];var M=[];return b.forEach(function(T){M.push(e(T))}),u.decompress(M.join(""))},compressToEncodedURIComponent:function(p){return p==null?"":u._compress(p,6,function(b){return s.charAt(b)})},decompressFromEncodedURIComponent:function(p){return p==null?"":p==""?null:(p=p.replace(/ /g,"+"),u._decompress(p.length,32,function(b){return f(s,p.charAt(b))}))},compress:function(p){return u._compress(p,16,function(b){return e(b)})},_compress:function(p,b,E){if(p==null)return"";var I,M,T={},U={},_="",L="",C="",$=2,N=3,H=2,D=[],F=0,W=0,q;for(q=0;q<p.length;q+=1)if(_=p.charAt(q),Object.prototype.hasOwnProperty.call(T,_)||(T[_]=N++,U[_]=!0),L=C+_,Object.prototype.hasOwnProperty.call(T,L))C=L;else{if(Object.prototype.hasOwnProperty.call(U,C)){if(C.charCodeAt(0)<256){for(I=0;I<H;I++)F=F<<1,W==b-1?(W=0,D.push(E(F)),F=0):W++;for(M=C.charCodeAt(0),I=0;I<8;I++)F=F<<1|M&1,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}else{for(M=1,I=0;I<H;I++)F=F<<1|M,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=0;for(M=C.charCodeAt(0),I=0;I<16;I++)F=F<<1|M&1,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}$--,$==0&&($=Math.pow(2,H),H++),delete U[C]}else for(M=T[C],I=0;I<H;I++)F=F<<1|M&1,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;$--,$==0&&($=Math.pow(2,H),H++),T[L]=N++,C=String(_)}if(C!==""){if(Object.prototype.hasOwnProperty.call(U,C)){if(C.charCodeAt(0)<256){for(I=0;I<H;I++)F=F<<1,W==b-1?(W=0,D.push(E(F)),F=0):W++;for(M=C.charCodeAt(0),I=0;I<8;I++)F=F<<1|M&1,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}else{for(M=1,I=0;I<H;I++)F=F<<1|M,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=0;for(M=C.charCodeAt(0),I=0;I<16;I++)F=F<<1|M&1,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}$--,$==0&&($=Math.pow(2,H),H++),delete U[C]}else for(M=T[C],I=0;I<H;I++)F=F<<1|M&1,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;$--,$==0&&($=Math.pow(2,H),H++)}for(M=2,I=0;I<H;I++)F=F<<1|M&1,W==b-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;for(;;)if(F=F<<1,W==b-1){D.push(E(F));break}else W++;return D.join("")},decompress:function(p){return p==null?"":p==""?null:u._decompress(p.length,32768,function(b){return p.charCodeAt(b)})},_decompress:function(p,b,E){var I=[],M=4,T=4,U=3,_="",L=[],C,$,N,H,D,F,W,q={val:E(0),position:b,index:1};for(C=0;C<3;C+=1)I[C]=C;for(N=0,D=Math.pow(2,2),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=b,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;switch(N){case 0:for(N=0,D=Math.pow(2,8),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=b,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;W=e(N);break;case 1:for(N=0,D=Math.pow(2,16),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=b,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;W=e(N);break;case 2:return""}for(I[3]=W,$=W,L.push(W);;){if(q.index>p)return"";for(N=0,D=Math.pow(2,U),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=b,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;switch(W=N){case 0:for(N=0,D=Math.pow(2,8),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=b,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;I[T++]=e(N),W=T-1,M--;break;case 1:for(N=0,D=Math.pow(2,16),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=b,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;I[T++]=e(N),W=T-1,M--;break;case 2:return L.join("")}if(M==0&&(M=Math.pow(2,U),U++),I[W])_=I[W];else if(W===T)_=$+$.charAt(0);else return null;L.push(_),I[T++]=$+_.charAt(0),M--,$=_,M==0&&(M=Math.pow(2,U),U++)}}};return u}();o!=null?o.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(_o);var Ud=_o.exports;const cr=ln(Ud);class mr{constructor(t){we(this,"env");we(this,"url");this.env=t??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(t){return fetch(this.url+`/merchant/view/${t}`).then(e=>e.json()).then(e=>{var n;return((n=e.nSureSettings)==null?void 0:n.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}async getCreditBalance(t,e,n){const s=await fetch(this.url+`/api/customer/balances/${e}`,{method:"GET",headers:{"x-coinflow-auth-wallet":t,"x-coinflow-auth-blockchain":n}}),{credits:a}=await s.json();return a}static getCoinflowBaseUrl(t){return!t||t==="prod"?"https://coinflow.cash":t==="local"?"http://localhost:3000":`https://${t}.coinflow.cash`}static getCoinflowApiUrl(t){return!t||t==="prod"?"https://api.coinflow.cash":t==="local"?"http://localhost:5000":`https://api-${t}.coinflow.cash`}static getCoinflowUrl({walletPubkey:t,route:e,routePrefix:n,env:s,amount:a,transaction:f,blockchain:u,webhookInfo:p,email:b,loaderBackground:E,handleHeightChange:I,bankAccountLinkRedirect:M,additionalWallets:T,nearDeposit:U,chargebackProtectionData:_,merchantCss:L,color:C,rent:$,lockDefaultToken:N,token:H,tokens:D,planCode:F,disableApplePay:W,disableGooglePay:q,customerInfo:Bt,settlementType:gt,lockAmount:ot,nativeSolToConvert:At,theme:R,usePermit:l,transactionSigner:y,authOnly:k,deviceId:A,jwtToken:S,origins:B}){var d;const P=n?`/${n}/${u}`:`/${u}`,w=new URL(P+e,mr.getCoinflowBaseUrl(s));if(w.searchParams.append("pubkey",t),f&&w.searchParams.append("transaction",f),a&&w.searchParams.append("amount",a.toString()),p&&w.searchParams.append("webhookInfo",cr.compressToEncodedURIComponent(JSON.stringify(p))),R&&w.searchParams.append("theme",cr.compressToEncodedURIComponent(JSON.stringify(R))),Bt&&w.searchParams.append("customerInfo",cr.compressToEncodedURIComponent(JSON.stringify(Bt))),b&&w.searchParams.append("email",b),H&&w.searchParams.append("token",H.toString()),D&&w.searchParams.append("tokens",D.toString()),E&&w.searchParams.append("loaderBackground",E),I&&w.searchParams.append("useHeightChange","true"),M&&w.searchParams.append("bankAccountLinkRedirect",M),T&&w.searchParams.append("additionalWallets",cr.compressToEncodedURIComponent(JSON.stringify(T))),U&&w.searchParams.append("nearDeposit",U),_&&w.searchParams.append("chargebackProtectionData",cr.compressToEncodedURIComponent(JSON.stringify(_))),A)w.searchParams.append("deviceId",A);else if(typeof window<"u"){const v=(d=window==null?void 0:window.nSureSDK)==null?void 0:d.getDeviceId();v&&w.searchParams.append("deviceId",v)}return L&&w.searchParams.append("merchantCss",L),C&&w.searchParams.append("color",C),$&&w.searchParams.append("rent",$.lamports.toString()),At&&w.searchParams.append("nativeSolToConvert",At.lamports.toString()),N&&w.searchParams.append("lockDefaultToken","true"),F&&w.searchParams.append("planCode",F),W&&w.searchParams.append("disableApplePay","true"),q&&w.searchParams.append("disableGooglePay","true"),gt&&w.searchParams.append("settlementType",gt),ot&&w.searchParams.append("lockAmount","true"),l===!1&&w.searchParams.append("usePermit","false"),y&&w.searchParams.append("transactionSigner",y),k===!0&&w.searchParams.append("authOnly","true"),S&&w.searchParams.append("jwtToken",S),B&&w.searchParams.append("origins",cr.compressToEncodedURIComponent(JSON.stringify(B))),w.toString()}static getTransaction(t){return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!ui)throw new Error("@solana/web3.js dependency is required for Solana");if(!vr)throw new Error("bs58 dependency is required for Solana");if(e)return vr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))}})()}static byBlockchain(t,e){switch(t){case"solana":return e.solana;case"near":return e.near;case"polygon":return e.polygon;case"eth":return e.eth;case"base":return e.base;default:throw new Error("blockchain not supported!")}}}var kc=(o=>(o.SignMessage="signMessage",o.SignTransaction="signTransaction",o.SendTransaction="sendTransaction",o.HeightChange="heightChange",o.Success="success",o))(kc||{});function Ro({wallet:o}){return"publicKey"in o?o.publicKey.toString():"address"in o?o.address:"accountId"in o?o.accountId:null}function Ec(o,t){let e;try{if(e=JSON.parse(o),!("method"in e)||!("data"in e))return}catch(a){console.error("handleIFrameMessage JSON parse",a);return}const{data:n,method:s}=e;switch(s){case"signMessage":return t.handleSignMessage?t.handleSignMessage(n):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(n):void 0;case"sendTransaction":return t.handleSendTransaction(n);case"heightChange":return t.handleHeightChange?t.handleHeightChange(n):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${s} is not one of ${Object.values(kc)}`)}function To(o){return mr.byBlockchain(o.blockchain,{solana:()=>Cd(o),near:()=>Fd(o),eth:()=>Mo(o),polygon:()=>Mo(o),base:()=>Mo(o)})()}function Cd({wallet:o,onSuccess:t}){return{handleSendTransaction:async e=>{const n=Ic(e);return await o.sendTransaction(n)},handleSignMessage:async e=>{const n=o.signMessage;if(!n)throw new Error("signMessage is not supported by this wallet");const s=await n(new TextEncoder().encode(e));if(!vr)throw new Error("bs58 dependency is required");return vr.encode(s)},handleSignTransaction:async e=>{const n=o.signTransaction;if(!n)throw new Error("signTransaction is not supported by this wallet");const s=Ic(e),a=await n(s);if(!vr)throw new Error("bs58 dependency is required");return vr.encode(a.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function Ic(o){if(!ui)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!vr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=vr.decode(o),e=ui.VersionedTransaction.deserialize(t);return e.version==="legacy"?ui.Transaction.from(t):e}function Fd({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const s=JSON.parse(Buffer.from(n,"base64").toString()),a=await e.signAndSendTransaction(s);if(!a)throw new Error("Transaction did not send");const{transaction:f}=a;return f.hash},onSuccess:t}}function Mo({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const s=JSON.parse(Buffer.from(n,"base64").toString()),{hash:a}=await e.sendTransaction(s);return a},handleSignMessage:async n=>e.signMessage(n),onSuccess:t}}const fi="tokenExCardNumber",Mn="tokenExCardCvv",Sc={[qr.VISA]:"visa",[qr.MASTERCARD]:"masterCard",[qr.AMEX]:"americanExpress",[qr.DISCOVER]:"discover"};async function hi({token:o,origins:t,env:e}){return new Promise((n,s)=>{fetch(new mr(e).url+"/api/checkout/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:[...t??[],window.location.origin],token:o})}).then(async a=>{n(await a.json())}).catch(a=>s(a))})}function Po({env:o,setTokenExScriptLoaded:t}){const e="tokenex-script";if(document.head.querySelector(`#${e}`))return;const n=document.createElement("script");n.src=o==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",n.id=e,document.head.appendChild(n),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function Lo({iframe:o,setCachedToken:t,setLoaded:e}){const n=async()=>(o.tokenize(),await new Promise((s,a)=>{o.on("tokenize",f=>{t(f.token),s(f)}),o.on("validate",f=>{(!f.isValid||f.isCvvValid===!1)&&a(f)})}));return o.on("change",()=>t(void 0)),o.on("cvvChange",()=>t(void 0)),o.on("load",()=>{setTimeout(()=>e(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),e(!1),o.load(),{...o,tokenize:n}}async function Bc({token:o,cardType:t,css:e,debug:n,fontFamily:s,origins:a,tokenExScriptLoaded:f,env:u,setCachedToken:p,setLoaded:b}){if(!f&&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 E=Sc[t],I=await hi({token:o,origins:a,env:u}),{styles:M}=Uo(e),T={...I,placeholder:"CVV",enablePrettyFormat:!0,styles:M,token:o,cvvOnly:!0,cvv:!0,cvvContainerID:Mn,cardType:E,debug:n??!1,font:s},U=TokenEx.Iframe(Mn,T);return Lo({iframe:U,setCachedToken:p,setLoaded:b})}async function Ac({css:o,debug:t,fontFamily:e,origins:n,tokenExScriptLoaded:s,env:a,setCachedToken:f,setLoaded:u}){if(!s&&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 p=await hi({origins:n,env:a}),{styles:b}=Uo(o),E=TokenEx.Iframe(fi,{...p,placeholder:"0000 0000 0000 0000",cvvPlaceholder:"CVV",enablePrettyFormat:!0,cvv:!0,cvvContainerID:Mn,styles:b,font:e,debug:t??!1});return Lo({iframe:E,setCachedToken:f,setLoaded:u})}async function vc({css:o,debug:t,fontFamily:e,origins:n,tokenExScriptLoaded:s,env:a,setCachedToken:f,setLoaded:u}){if(!s&&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 p=await hi({origins:n,env:a}),{styles:b}=Uo(o),E=TokenEx.Iframe(fi,{...p,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,cvv:!1,styles:b,font:e,debug:t??!1});return Lo({iframe:E,setCachedToken:f,setLoaded:u})}function Uo(o){var n,s,a;const t=JSON.parse(o);return{styles:{base:hn(t.base),focus:hn(t.focus),error:hn(t.error),cvv:{base:hn((n=t.cvv)==null?void 0:n.base),focus:hn((s=t.cvv)==null?void 0:s.focus),error:hn((a=t.cvv)==null?void 0:a.error)}}}}function hn(o){if(!o)return"";if(typeof o=="string")return o;let t="";for(const[e,n]of Object.entries(o)){let s="";e.split("").forEach(a=>{a.toUpperCase()===a?s+="-"+a.toLowerCase():s+=a}),t+=s+":"+n+";"}return t}const Od=Et.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return mr.getCoinflowUrl(this.args)}},methods:{sendMessage(o){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(o,"*")},handleIframeMessages({data:o,origin:t}){if(!t.includes(mr.getCoinflowBaseUrl(this.args.env)))return;const e=Ec(o,this.args);e&&e.then(this.sendMessage).catch(n=>{console.error(n),this.sendMessage("ERROR "+n.message)})},async listenForMessage(o){let t;return new Promise((e,n)=>{if(t=({data:s,origin:a})=>{if(a.includes(mr.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){n(new Error(s.replace("ERROR","")));return}o(s)&&e(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(o,t){return this.sendMessage(o),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Co=(o,t)=>{const e=o.__vccOpts||o;for(const[n,s]of t)e[n]=s;return e},Nd=["src","scrolling"];function zd(o,t,e,n,s,a){return Et.openBlock(),Et.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera",title:"withdraw",frameBorder:"0",src:o.url,scrolling:o.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const f=o.$refs.iframeRef;f&&(f.style.opacity="1")})},null,40,Nd)}const Fo=Co(Od,[["render",zd]]),Dd=Et.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:Fo},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=Ro(this.args);return{...this.args,walletPubkey:o,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...To(this.args),handleHeightChange:this.args.handleHeightChange}}}});function $d(o,t,e,n,s,a){const f=Et.resolveComponent("coinflow-i-frame");return Et.openBlock(),Et.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const Wd=Co(Dd,[["render",$d]]),Kd=Et.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:Fo},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=Ro(this.args);return{...this.args,walletPubkey:o,route:`/purchase/${this.args.merchantId}`,transaction:mr.getTransaction(this.args)}},messageHandlers(){return{...To(this.args),handleHeightChange:this.args.handleHeightChange}}}});function qd(o,t,e,n,s,a){const f=Et.resolveComponent("coinflow-i-frame");return Et.openBlock(),Et.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const Hd=Co(Kd,[["render",qd]]),Vd=o=>{const t=Et.ref(!1),e=Et.ref(!1),n=Et.ref(void 0),s=Et.ref(void 0);Et.onMounted(()=>{Po({env:o,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const a=I=>s.value=I,f=()=>t.value=!0,u=I=>n.value=I,p=async({token:I,cardType:M,css:T,debug:U,fontFamily:_,origins:L})=>{const C=await Bc({token:I,cardType:M,css:T,debug:U,fontFamily:_,origins:L,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(C),C},b=async({css:I,fontFamily:M,debug:T,origins:U})=>{const _=await Ac({css:I,debug:T,fontFamily:M,origins:U,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(_),_},E=async({css:I,fontFamily:M,debug:T,origins:U})=>{const _=await vc({css:I,debug:T,fontFamily:M,origins:U,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(_),_};return Et.watchEffect(I=>{n.value&&(n.value.load(),I(()=>{var M;return(M=n.value)==null?void 0:M.remove()}))}),{tokenExIframe:n,initializeTokenExIframe:b,initializeCvvOnlyTokenExIframe:p,initializeTokenExCardOnlyIframe:E,loaded:t,cachedToken:s,setTokenExScriptTag:Po,tokenExScriptLoaded:e}},jd=["id"],Gd=Et.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{initializeTokenExIframe:n,tokenExIframe:s,tokenExScriptLoaded:a}=Vd(e.env);async function f(){if(!s.value)throw new Error("Unable to get token");return s.value.tokenize()}t({getToken:f});function u(){return JSON.stringify(e.css)}return Et.watchEffect(()=>{console.log("initializeTokenExIframe",{tokenExScriptLoaded:a.value}),n({css:u(),debug:e.debug,origins:e.origins})},{}),(p,b)=>(Et.openBlock(),Et.createElementBlock("div",{id:Et.unref(fi)},null,8,jd))}}),Yd=["id"],Zd=Et.defineComponent({__name:"CoinflowCvvInput",setup(o){return(t,e)=>(Et.openBlock(),Et.createElementBlock("div",{id:Et.unref(Mn)},null,8,Yd))}});Lt.CARD_TYPE_MAPPING=Sc,Lt.CardType=qr,Lt.CoinflowCardNumberInput=Gd,Lt.CoinflowCvvInput=Zd,Lt.CoinflowIframe=Fo,Lt.CoinflowPurchase=Hd,Lt.CoinflowUtils=mr,Lt.CoinflowWithdraw=Wd,Lt.MerchantStyle=rs,Lt.SettlementType=wr,Lt.TokenExCardNumberIframeId=fi,Lt.TokenExCvvContainerID=Mn,Lt.doInitializeCvvOnlyTokenExIframe=Bc,Lt.doInitializeTokenExCardOnlyIframe=vc,Lt.doInitializeTokenExIframe=Ac,Lt.getHandlers=To,Lt.getIframeConfig=hi,Lt.getWalletPubkey=Ro,Lt.handleIFrameMessage=Ec,Lt.setTokenExScriptTag=Po,Object.defineProperty(Lt,Symbol.toStringTag,{value:"Module"})});
|