@solana-agent-wallet-adapter/cli 0.1.0 → 0.2.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/dist/index.js +1122 -221
- package/dist/index.js.map +4 -4
- package/dist/wallet-host/assets/index-BF6JLAtr.js +3215 -0
- package/dist/wallet-host/assets/index-dftlursl.css +1 -0
- package/dist/wallet-host/assets/{mobile-wallet-adapter-CqDJSDZ5.js → mobile-wallet-adapter-B8zYDJwO.js} +1 -1
- package/dist/wallet-host/assets/solana-runtime-CsPLEN69.js +13 -0
- package/dist/wallet-host/assets/{wallet-standard-eoxEevjj.js → wallet-standard-CIBAN9Xp.js} +1 -1
- package/dist/wallet-host/index.html +5 -8
- package/dist/wallet-host/manifest.webmanifest +2 -13
- package/package.json +1 -1
- package/dist/wallet-host/assets/index-D5ySS2CU.js +0 -2143
- package/dist/wallet-host/assets/index-ZynMhs1G.css +0 -1
- package/dist/wallet-host/assets/solana-runtime-BhiDfU5_.js +0 -20
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var _a=Object.defineProperty;var Aa=(r,t,e)=>t in r?_a(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var ie=(r,t,e)=>Aa(r,typeof t!="symbol"?t+"":t,e);var Ne=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ar(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Ci(r){if(r.__esModule)return r;var t=r.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(r).forEach(function(n){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),e}const Ia={},ka=Object.freeze(Object.defineProperty({__proto__:null,default:Ia},Symbol.toStringTag,{value:"Module"})),Ma=Ci(ka);var dt={},Ir={};Ir.byteLength=Ca;Ir.toByteArray=Ua;Ir.fromByteArray=Oa;var qe=[],Ie=[],Ra=typeof Uint8Array<"u"?Uint8Array:Array,ri="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Sn=0,Ta=ri.length;Sn<Ta;++Sn)qe[Sn]=ri[Sn],Ie[ri.charCodeAt(Sn)]=Sn;Ie[45]=62;Ie[95]=63;function Ks(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Ca(r){var t=Ks(r),e=t[0],n=t[1];return(e+n)*3/4-n}function La(r,t,e){return(t+e)*3/4-e}function Ua(r){var t,e=Ks(r),n=e[0],s=e[1],i=new Ra(La(r,n,s)),o=0,c=s>0?n-4:n,d;for(d=0;d<c;d+=4)t=Ie[r.charCodeAt(d)]<<18|Ie[r.charCodeAt(d+1)]<<12|Ie[r.charCodeAt(d+2)]<<6|Ie[r.charCodeAt(d+3)],i[o++]=t>>16&255,i[o++]=t>>8&255,i[o++]=t&255;return s===2&&(t=Ie[r.charCodeAt(d)]<<2|Ie[r.charCodeAt(d+1)]>>4,i[o++]=t&255),s===1&&(t=Ie[r.charCodeAt(d)]<<10|Ie[r.charCodeAt(d+1)]<<4|Ie[r.charCodeAt(d+2)]>>2,i[o++]=t>>8&255,i[o++]=t&255),i}function Fa(r){return qe[r>>18&63]+qe[r>>12&63]+qe[r>>6&63]+qe[r&63]}function Na(r,t,e){for(var n,s=[],i=t;i<e;i+=3)n=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(r[i+2]&255),s.push(Fa(n));return s.join("")}function Oa(r){for(var t,e=r.length,n=e%3,s=[],i=16383,o=0,c=e-n;o<c;o+=i)s.push(Na(r,o,o+i>c?c:o+i));return n===1?(t=r[e-1],s.push(qe[t>>2]+qe[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],s.push(qe[t>>10]+qe[t>>4&63]+qe[t<<2&63]+"=")),s.join("")}var Li={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Li.read=function(r,t,e,n,s){var i,o,c=s*8-n-1,d=(1<<c)-1,v=d>>1,_=-7,I=e?s-1:0,A=e?-1:1,B=r[t+I];for(I+=A,i=B&(1<<-_)-1,B>>=-_,_+=c;_>0;i=i*256+r[t+I],I+=A,_-=8);for(o=i&(1<<-_)-1,i>>=-_,_+=n;_>0;o=o*256+r[t+I],I+=A,_-=8);if(i===0)i=1-v;else{if(i===d)return o?NaN:(B?-1:1)*(1/0);o=o+Math.pow(2,n),i=i-v}return(B?-1:1)*o*Math.pow(2,i-n)};Li.write=function(r,t,e,n,s,i){var o,c,d,v=i*8-s-1,_=(1<<v)-1,I=_>>1,A=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=n?0:i-1,M=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=_):(o=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-o))<1&&(o--,d*=2),o+I>=1?t+=A/d:t+=A*Math.pow(2,1-I),t*d>=2&&(o++,d/=2),o+I>=_?(c=0,o=_):o+I>=1?(c=(t*d-1)*Math.pow(2,s),o=o+I):(c=t*Math.pow(2,I-1)*Math.pow(2,s),o=0));s>=8;r[e+B]=c&255,B+=M,c/=256,s-=8);for(o=o<<s|c,v+=s;v>0;r[e+B]=o&255,B+=M,o/=256,v-=8);r[e+B-M]|=T*128};/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/(function(r){const t=Ir,e=Li,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=c,r.SlowBuffer=z,r.INSPECT_MAX_BYTES=50;const s=2147483647;r.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=i(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const g=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf(g,u),g.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function o(g){if(g>s)throw new RangeError('The value "'+g+'" is invalid for option "size"');const u=new Uint8Array(g);return Object.setPrototypeOf(u,c.prototype),u}function c(g,u,h){if(typeof g=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(g)}return d(g,u,h)}c.poolSize=8192;function d(g,u,h){if(typeof g=="string")return A(g,u);if(ArrayBuffer.isView(g))return M(g);if(g==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g);if(Se(g,ArrayBuffer)||g&&Se(g.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Se(g,SharedArrayBuffer)||g&&Se(g.buffer,SharedArrayBuffer)))return T(g,u,h);if(typeof g=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const b=g.valueOf&&g.valueOf();if(b!=null&&b!==g)return c.from(b,u,h);const R=C(g);if(R)return R;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof g[Symbol.toPrimitive]=="function")return c.from(g[Symbol.toPrimitive]("string"),u,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g)}c.from=function(g,u,h){return d(g,u,h)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function v(g){if(typeof g!="number")throw new TypeError('"size" argument must be of type number');if(g<0)throw new RangeError('The value "'+g+'" is invalid for option "size"')}function _(g,u,h){return v(g),g<=0?o(g):u!==void 0?typeof h=="string"?o(g).fill(u,h):o(g).fill(u):o(g)}c.alloc=function(g,u,h){return _(g,u,h)};function I(g){return v(g),o(g<0?0:F(g)|0)}c.allocUnsafe=function(g){return I(g)},c.allocUnsafeSlow=function(g){return I(g)};function A(g,u){if((typeof u!="string"||u==="")&&(u="utf8"),!c.isEncoding(u))throw new TypeError("Unknown encoding: "+u);const h=O(g,u)|0;let b=o(h);const R=b.write(g,u);return R!==h&&(b=b.slice(0,R)),b}function B(g){const u=g.length<0?0:F(g.length)|0,h=o(u);for(let b=0;b<u;b+=1)h[b]=g[b]&255;return h}function M(g){if(Se(g,Uint8Array)){const u=new Uint8Array(g);return T(u.buffer,u.byteOffset,u.byteLength)}return B(g)}function T(g,u,h){if(u<0||g.byteLength<u)throw new RangeError('"offset" is outside of buffer bounds');if(g.byteLength<u+(h||0))throw new RangeError('"length" is outside of buffer bounds');let b;return u===void 0&&h===void 0?b=new Uint8Array(g):h===void 0?b=new Uint8Array(g,u):b=new Uint8Array(g,u,h),Object.setPrototypeOf(b,c.prototype),b}function C(g){if(c.isBuffer(g)){const u=F(g.length)|0,h=o(u);return h.length===0||g.copy(h,0,0,u),h}if(g.length!==void 0)return typeof g.length!="number"||kt(g.length)?o(0):B(g);if(g.type==="Buffer"&&Array.isArray(g.data))return B(g.data)}function F(g){if(g>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return g|0}function z(g){return+g!=g&&(g=0),c.alloc(+g)}c.isBuffer=function(u){return u!=null&&u._isBuffer===!0&&u!==c.prototype},c.compare=function(u,h){if(Se(u,Uint8Array)&&(u=c.from(u,u.offset,u.byteLength)),Se(h,Uint8Array)&&(h=c.from(h,h.offset,h.byteLength)),!c.isBuffer(u)||!c.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(u===h)return 0;let b=u.length,R=h.length;for(let L=0,P=Math.min(b,R);L<P;++L)if(u[L]!==h[L]){b=u[L],R=h[L];break}return b<R?-1:R<b?1:0},c.isEncoding=function(u){switch(String(u).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}},c.concat=function(u,h){if(!Array.isArray(u))throw new TypeError('"list" argument must be an Array of Buffers');if(u.length===0)return c.alloc(0);let b;if(h===void 0)for(h=0,b=0;b<u.length;++b)h+=u[b].length;const R=c.allocUnsafe(h);let L=0;for(b=0;b<u.length;++b){let P=u[b];if(Se(P,Uint8Array))L+P.length>R.length?(c.isBuffer(P)||(P=c.from(P)),P.copy(R,L)):Uint8Array.prototype.set.call(R,P,L);else if(c.isBuffer(P))P.copy(R,L);else throw new TypeError('"list" argument must be an Array of Buffers');L+=P.length}return R};function O(g,u){if(c.isBuffer(g))return g.length;if(ArrayBuffer.isView(g)||Se(g,ArrayBuffer))return g.byteLength;if(typeof g!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof g);const h=g.length,b=arguments.length>2&&arguments[2]===!0;if(!b&&h===0)return 0;let R=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return It(g).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return Mt(g).length;default:if(R)return b?-1:It(g).length;u=(""+u).toLowerCase(),R=!0}}c.byteLength=O;function G(g,u,h){let b=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,u>>>=0,h<=u))return"";for(g||(g="utf8");;)switch(g){case"hex":return S(this,u,h);case"utf8":case"utf-8":return a(this,u,h);case"ascii":return w(this,u,h);case"latin1":case"binary":return x(this,u,h);case"base64":return m(this,u,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,u,h);default:if(b)throw new TypeError("Unknown encoding: "+g);g=(g+"").toLowerCase(),b=!0}}c.prototype._isBuffer=!0;function J(g,u,h){const b=g[u];g[u]=g[h],g[h]=b}c.prototype.swap16=function(){const u=this.length;if(u%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<u;h+=2)J(this,h,h+1);return this},c.prototype.swap32=function(){const u=this.length;if(u%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<u;h+=4)J(this,h,h+3),J(this,h+1,h+2);return this},c.prototype.swap64=function(){const u=this.length;if(u%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<u;h+=8)J(this,h,h+7),J(this,h+1,h+6),J(this,h+2,h+5),J(this,h+3,h+4);return this},c.prototype.toString=function(){const u=this.length;return u===0?"":arguments.length===0?a(this,0,u):G.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(u){if(!c.isBuffer(u))throw new TypeError("Argument must be a Buffer");return this===u?!0:c.compare(this,u)===0},c.prototype.inspect=function(){let u="";const h=r.INSPECT_MAX_BYTES;return u=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(u+=" ... "),"<Buffer "+u+">"},n&&(c.prototype[n]=c.prototype.inspect),c.prototype.compare=function(u,h,b,R,L){if(Se(u,Uint8Array)&&(u=c.from(u,u.offset,u.byteLength)),!c.isBuffer(u))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof u);if(h===void 0&&(h=0),b===void 0&&(b=u?u.length:0),R===void 0&&(R=0),L===void 0&&(L=this.length),h<0||b>u.length||R<0||L>this.length)throw new RangeError("out of range index");if(R>=L&&h>=b)return 0;if(R>=L)return-1;if(h>=b)return 1;if(h>>>=0,b>>>=0,R>>>=0,L>>>=0,this===u)return 0;let P=L-R,pt=b-h;const lt=Math.min(P,pt),ht=this.slice(R,L),At=u.slice(h,b);for(let at=0;at<lt;++at)if(ht[at]!==At[at]){P=ht[at],pt=At[at];break}return P<pt?-1:pt<P?1:0};function nt(g,u,h,b,R){if(g.length===0)return-1;if(typeof h=="string"?(b=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,kt(h)&&(h=R?0:g.length-1),h<0&&(h=g.length+h),h>=g.length){if(R)return-1;h=g.length-1}else if(h<0)if(R)h=0;else return-1;if(typeof u=="string"&&(u=c.from(u,b)),c.isBuffer(u))return u.length===0?-1:ut(g,u,h,b,R);if(typeof u=="number")return u=u&255,typeof Uint8Array.prototype.indexOf=="function"?R?Uint8Array.prototype.indexOf.call(g,u,h):Uint8Array.prototype.lastIndexOf.call(g,u,h):ut(g,[u],h,b,R);throw new TypeError("val must be string, number or Buffer")}function ut(g,u,h,b,R){let L=1,P=g.length,pt=u.length;if(b!==void 0&&(b=String(b).toLowerCase(),b==="ucs2"||b==="ucs-2"||b==="utf16le"||b==="utf-16le")){if(g.length<2||u.length<2)return-1;L=2,P/=2,pt/=2,h/=2}function lt(At,at){return L===1?At[at]:At.readUInt16BE(at*L)}let ht;if(R){let At=-1;for(ht=h;ht<P;ht++)if(lt(g,ht)===lt(u,At===-1?0:ht-At)){if(At===-1&&(At=ht),ht-At+1===pt)return At*L}else At!==-1&&(ht-=ht-At),At=-1}else for(h+pt>P&&(h=P-pt),ht=h;ht>=0;ht--){let At=!0;for(let at=0;at<pt;at++)if(lt(g,ht+at)!==lt(u,at)){At=!1;break}if(At)return ht}return-1}c.prototype.includes=function(u,h,b){return this.indexOf(u,h,b)!==-1},c.prototype.indexOf=function(u,h,b){return nt(this,u,h,b,!0)},c.prototype.lastIndexOf=function(u,h,b){return nt(this,u,h,b,!1)};function ot(g,u,h,b){h=Number(h)||0;const R=g.length-h;b?(b=Number(b),b>R&&(b=R)):b=R;const L=u.length;b>L/2&&(b=L/2);let P;for(P=0;P<b;++P){const pt=parseInt(u.substr(P*2,2),16);if(kt(pt))return P;g[h+P]=pt}return P}function q(g,u,h,b){return _t(It(u,g.length-h),g,h,b)}function Q(g,u,h,b){return _t(Ut(u),g,h,b)}function Z(g,u,h,b){return _t(Mt(u),g,h,b)}function X(g,u,h,b){return _t(rr(u,g.length-h),g,h,b)}c.prototype.write=function(u,h,b,R){if(h===void 0)R="utf8",b=this.length,h=0;else if(b===void 0&&typeof h=="string")R=h,b=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(b)?(b=b>>>0,R===void 0&&(R="utf8")):(R=b,b=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const L=this.length-h;if((b===void 0||b>L)&&(b=L),u.length>0&&(b<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");R||(R="utf8");let P=!1;for(;;)switch(R){case"hex":return ot(this,u,h,b);case"utf8":case"utf-8":return q(this,u,h,b);case"ascii":case"latin1":case"binary":return Q(this,u,h,b);case"base64":return Z(this,u,h,b);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return X(this,u,h,b);default:if(P)throw new TypeError("Unknown encoding: "+R);R=(""+R).toLowerCase(),P=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function m(g,u,h){return u===0&&h===g.length?t.fromByteArray(g):t.fromByteArray(g.slice(u,h))}function a(g,u,h){h=Math.min(g.length,h);const b=[];let R=u;for(;R<h;){const L=g[R];let P=null,pt=L>239?4:L>223?3:L>191?2:1;if(R+pt<=h){let lt,ht,At,at;switch(pt){case 1:L<128&&(P=L);break;case 2:lt=g[R+1],(lt&192)===128&&(at=(L&31)<<6|lt&63,at>127&&(P=at));break;case 3:lt=g[R+1],ht=g[R+2],(lt&192)===128&&(ht&192)===128&&(at=(L&15)<<12|(lt&63)<<6|ht&63,at>2047&&(at<55296||at>57343)&&(P=at));break;case 4:lt=g[R+1],ht=g[R+2],At=g[R+3],(lt&192)===128&&(ht&192)===128&&(At&192)===128&&(at=(L&15)<<18|(lt&63)<<12|(ht&63)<<6|At&63,at>65535&&at<1114112&&(P=at))}}P===null?(P=65533,pt=1):P>65535&&(P-=65536,b.push(P>>>10&1023|55296),P=56320|P&1023),b.push(P),R+=pt}return p(b)}const l=4096;function p(g){const u=g.length;if(u<=l)return String.fromCharCode.apply(String,g);let h="",b=0;for(;b<u;)h+=String.fromCharCode.apply(String,g.slice(b,b+=l));return h}function w(g,u,h){let b="";h=Math.min(g.length,h);for(let R=u;R<h;++R)b+=String.fromCharCode(g[R]&127);return b}function x(g,u,h){let b="";h=Math.min(g.length,h);for(let R=u;R<h;++R)b+=String.fromCharCode(g[R]);return b}function S(g,u,h){const b=g.length;(!u||u<0)&&(u=0),(!h||h<0||h>b)&&(h=b);let R="";for(let L=u;L<h;++L)R+=Ft[g[L]];return R}function k(g,u,h){const b=g.slice(u,h);let R="";for(let L=0;L<b.length-1;L+=2)R+=String.fromCharCode(b[L]+b[L+1]*256);return R}c.prototype.slice=function(u,h){const b=this.length;u=~~u,h=h===void 0?b:~~h,u<0?(u+=b,u<0&&(u=0)):u>b&&(u=b),h<0?(h+=b,h<0&&(h=0)):h>b&&(h=b),h<u&&(h=u);const R=this.subarray(u,h);return Object.setPrototypeOf(R,c.prototype),R};function y(g,u,h){if(g%1!==0||g<0)throw new RangeError("offset is not uint");if(g+u>h)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(u,h,b){u=u>>>0,h=h>>>0,b||y(u,h,this.length);let R=this[u],L=1,P=0;for(;++P<h&&(L*=256);)R+=this[u+P]*L;return R},c.prototype.readUintBE=c.prototype.readUIntBE=function(u,h,b){u=u>>>0,h=h>>>0,b||y(u,h,this.length);let R=this[u+--h],L=1;for(;h>0&&(L*=256);)R+=this[u+--h]*L;return R},c.prototype.readUint8=c.prototype.readUInt8=function(u,h){return u=u>>>0,h||y(u,1,this.length),this[u]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(u,h){return u=u>>>0,h||y(u,2,this.length),this[u]|this[u+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(u,h){return u=u>>>0,h||y(u,2,this.length),this[u]<<8|this[u+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(u,h){return u=u>>>0,h||y(u,4,this.length),(this[u]|this[u+1]<<8|this[u+2]<<16)+this[u+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(u,h){return u=u>>>0,h||y(u,4,this.length),this[u]*16777216+(this[u+1]<<16|this[u+2]<<8|this[u+3])},c.prototype.readBigUInt64LE=Le(function(u){u=u>>>0,Ae(u,"offset");const h=this[u],b=this[u+7];(h===void 0||b===void 0)&&St(u,this.length-8);const R=h+this[++u]*2**8+this[++u]*2**16+this[++u]*2**24,L=this[++u]+this[++u]*2**8+this[++u]*2**16+b*2**24;return BigInt(R)+(BigInt(L)<<BigInt(32))}),c.prototype.readBigUInt64BE=Le(function(u){u=u>>>0,Ae(u,"offset");const h=this[u],b=this[u+7];(h===void 0||b===void 0)&&St(u,this.length-8);const R=h*2**24+this[++u]*2**16+this[++u]*2**8+this[++u],L=this[++u]*2**24+this[++u]*2**16+this[++u]*2**8+b;return(BigInt(R)<<BigInt(32))+BigInt(L)}),c.prototype.readIntLE=function(u,h,b){u=u>>>0,h=h>>>0,b||y(u,h,this.length);let R=this[u],L=1,P=0;for(;++P<h&&(L*=256);)R+=this[u+P]*L;return L*=128,R>=L&&(R-=Math.pow(2,8*h)),R},c.prototype.readIntBE=function(u,h,b){u=u>>>0,h=h>>>0,b||y(u,h,this.length);let R=h,L=1,P=this[u+--R];for(;R>0&&(L*=256);)P+=this[u+--R]*L;return L*=128,P>=L&&(P-=Math.pow(2,8*h)),P},c.prototype.readInt8=function(u,h){return u=u>>>0,h||y(u,1,this.length),this[u]&128?(255-this[u]+1)*-1:this[u]},c.prototype.readInt16LE=function(u,h){u=u>>>0,h||y(u,2,this.length);const b=this[u]|this[u+1]<<8;return b&32768?b|4294901760:b},c.prototype.readInt16BE=function(u,h){u=u>>>0,h||y(u,2,this.length);const b=this[u+1]|this[u]<<8;return b&32768?b|4294901760:b},c.prototype.readInt32LE=function(u,h){return u=u>>>0,h||y(u,4,this.length),this[u]|this[u+1]<<8|this[u+2]<<16|this[u+3]<<24},c.prototype.readInt32BE=function(u,h){return u=u>>>0,h||y(u,4,this.length),this[u]<<24|this[u+1]<<16|this[u+2]<<8|this[u+3]},c.prototype.readBigInt64LE=Le(function(u){u=u>>>0,Ae(u,"offset");const h=this[u],b=this[u+7];(h===void 0||b===void 0)&&St(u,this.length-8);const R=this[u+4]+this[u+5]*2**8+this[u+6]*2**16+(b<<24);return(BigInt(R)<<BigInt(32))+BigInt(h+this[++u]*2**8+this[++u]*2**16+this[++u]*2**24)}),c.prototype.readBigInt64BE=Le(function(u){u=u>>>0,Ae(u,"offset");const h=this[u],b=this[u+7];(h===void 0||b===void 0)&&St(u,this.length-8);const R=(h<<24)+this[++u]*2**16+this[++u]*2**8+this[++u];return(BigInt(R)<<BigInt(32))+BigInt(this[++u]*2**24+this[++u]*2**16+this[++u]*2**8+b)}),c.prototype.readFloatLE=function(u,h){return u=u>>>0,h||y(u,4,this.length),e.read(this,u,!0,23,4)},c.prototype.readFloatBE=function(u,h){return u=u>>>0,h||y(u,4,this.length),e.read(this,u,!1,23,4)},c.prototype.readDoubleLE=function(u,h){return u=u>>>0,h||y(u,8,this.length),e.read(this,u,!0,52,8)},c.prototype.readDoubleBE=function(u,h){return u=u>>>0,h||y(u,8,this.length),e.read(this,u,!1,52,8)};function f(g,u,h,b,R,L){if(!c.isBuffer(g))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>R||u<L)throw new RangeError('"value" argument is out of bounds');if(h+b>g.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(u,h,b,R){if(u=+u,h=h>>>0,b=b>>>0,!R){const pt=Math.pow(2,8*b)-1;f(this,u,h,b,pt,0)}let L=1,P=0;for(this[h]=u&255;++P<b&&(L*=256);)this[h+P]=u/L&255;return h+b},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(u,h,b,R){if(u=+u,h=h>>>0,b=b>>>0,!R){const pt=Math.pow(2,8*b)-1;f(this,u,h,b,pt,0)}let L=b-1,P=1;for(this[h+L]=u&255;--L>=0&&(P*=256);)this[h+L]=u/P&255;return h+b},c.prototype.writeUint8=c.prototype.writeUInt8=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,1,255,0),this[h]=u&255,h+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,2,65535,0),this[h]=u&255,this[h+1]=u>>>8,h+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,2,65535,0),this[h]=u>>>8,this[h+1]=u&255,h+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,4,4294967295,0),this[h+3]=u>>>24,this[h+2]=u>>>16,this[h+1]=u>>>8,this[h]=u&255,h+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,4,4294967295,0),this[h]=u>>>24,this[h+1]=u>>>16,this[h+2]=u>>>8,this[h+3]=u&255,h+4};function E(g,u,h,b,R){Et(u,b,R,g,h,7);let L=Number(u&BigInt(4294967295));g[h++]=L,L=L>>8,g[h++]=L,L=L>>8,g[h++]=L,L=L>>8,g[h++]=L;let P=Number(u>>BigInt(32)&BigInt(4294967295));return g[h++]=P,P=P>>8,g[h++]=P,P=P>>8,g[h++]=P,P=P>>8,g[h++]=P,h}function V(g,u,h,b,R){Et(u,b,R,g,h,7);let L=Number(u&BigInt(4294967295));g[h+7]=L,L=L>>8,g[h+6]=L,L=L>>8,g[h+5]=L,L=L>>8,g[h+4]=L;let P=Number(u>>BigInt(32)&BigInt(4294967295));return g[h+3]=P,P=P>>8,g[h+2]=P,P=P>>8,g[h+1]=P,P=P>>8,g[h]=P,h+8}c.prototype.writeBigUInt64LE=Le(function(u,h=0){return E(this,u,h,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Le(function(u,h=0){return V(this,u,h,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(u,h,b,R){if(u=+u,h=h>>>0,!R){const lt=Math.pow(2,8*b-1);f(this,u,h,b,lt-1,-lt)}let L=0,P=1,pt=0;for(this[h]=u&255;++L<b&&(P*=256);)u<0&&pt===0&&this[h+L-1]!==0&&(pt=1),this[h+L]=(u/P>>0)-pt&255;return h+b},c.prototype.writeIntBE=function(u,h,b,R){if(u=+u,h=h>>>0,!R){const lt=Math.pow(2,8*b-1);f(this,u,h,b,lt-1,-lt)}let L=b-1,P=1,pt=0;for(this[h+L]=u&255;--L>=0&&(P*=256);)u<0&&pt===0&&this[h+L+1]!==0&&(pt=1),this[h+L]=(u/P>>0)-pt&255;return h+b},c.prototype.writeInt8=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,1,127,-128),u<0&&(u=255+u+1),this[h]=u&255,h+1},c.prototype.writeInt16LE=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,2,32767,-32768),this[h]=u&255,this[h+1]=u>>>8,h+2},c.prototype.writeInt16BE=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,2,32767,-32768),this[h]=u>>>8,this[h+1]=u&255,h+2},c.prototype.writeInt32LE=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,4,2147483647,-2147483648),this[h]=u&255,this[h+1]=u>>>8,this[h+2]=u>>>16,this[h+3]=u>>>24,h+4},c.prototype.writeInt32BE=function(u,h,b){return u=+u,h=h>>>0,b||f(this,u,h,4,2147483647,-2147483648),u<0&&(u=4294967295+u+1),this[h]=u>>>24,this[h+1]=u>>>16,this[h+2]=u>>>8,this[h+3]=u&255,h+4},c.prototype.writeBigInt64LE=Le(function(u,h=0){return E(this,u,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Le(function(u,h=0){return V(this,u,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $(g,u,h,b,R,L){if(h+b>g.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function Y(g,u,h,b,R){return u=+u,h=h>>>0,R||$(g,u,h,4),e.write(g,u,h,b,23,4),h+4}c.prototype.writeFloatLE=function(u,h,b){return Y(this,u,h,!0,b)},c.prototype.writeFloatBE=function(u,h,b){return Y(this,u,h,!1,b)};function mt(g,u,h,b,R){return u=+u,h=h>>>0,R||$(g,u,h,8),e.write(g,u,h,b,52,8),h+8}c.prototype.writeDoubleLE=function(u,h,b){return mt(this,u,h,!0,b)},c.prototype.writeDoubleBE=function(u,h,b){return mt(this,u,h,!1,b)},c.prototype.copy=function(u,h,b,R){if(!c.isBuffer(u))throw new TypeError("argument should be a Buffer");if(b||(b=0),!R&&R!==0&&(R=this.length),h>=u.length&&(h=u.length),h||(h=0),R>0&&R<b&&(R=b),R===b||u.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(b<0||b>=this.length)throw new RangeError("Index out of range");if(R<0)throw new RangeError("sourceEnd out of bounds");R>this.length&&(R=this.length),u.length-h<R-b&&(R=u.length-h+b);const L=R-b;return this===u&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,b,R):Uint8Array.prototype.set.call(u,this.subarray(b,R),h),L},c.prototype.fill=function(u,h,b,R){if(typeof u=="string"){if(typeof h=="string"?(R=h,h=0,b=this.length):typeof b=="string"&&(R=b,b=this.length),R!==void 0&&typeof R!="string")throw new TypeError("encoding must be a string");if(typeof R=="string"&&!c.isEncoding(R))throw new TypeError("Unknown encoding: "+R);if(u.length===1){const P=u.charCodeAt(0);(R==="utf8"&&P<128||R==="latin1")&&(u=P)}}else typeof u=="number"?u=u&255:typeof u=="boolean"&&(u=Number(u));if(h<0||this.length<h||this.length<b)throw new RangeError("Out of range index");if(b<=h)return this;h=h>>>0,b=b===void 0?this.length:b>>>0,u||(u=0);let L;if(typeof u=="number")for(L=h;L<b;++L)this[L]=u;else{const P=c.isBuffer(u)?u:c.from(u,R),pt=P.length;if(pt===0)throw new TypeError('The value "'+u+'" is invalid for argument "value"');for(L=0;L<b-h;++L)this[L+h]=P[L%pt]}return this};const ft={};function st(g,u,h){ft[g]=class extends h{constructor(){super(),Object.defineProperty(this,"message",{value:u.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${g}]`,this.stack,delete this.name}get code(){return g}set code(R){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:R,writable:!0})}toString(){return`${this.name} [${g}]: ${this.message}`}}}st("ERR_BUFFER_OUT_OF_BOUNDS",function(g){return g?`${g} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),st("ERR_INVALID_ARG_TYPE",function(g,u){return`The "${g}" argument must be of type number. Received type ${typeof u}`},TypeError),st("ERR_OUT_OF_RANGE",function(g,u,h){let b=`The value of "${g}" is out of range.`,R=h;return Number.isInteger(h)&&Math.abs(h)>2**32?R=Ct(String(h)):typeof h=="bigint"&&(R=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(R=Ct(R)),R+="n"),b+=` It must be ${u}. Received ${R}`,b},RangeError);function Ct(g){let u="",h=g.length;const b=g[0]==="-"?1:0;for(;h>=b+4;h-=3)u=`_${g.slice(h-3,h)}${u}`;return`${g.slice(0,h)}${u}`}function xt(g,u,h){Ae(u,"offset"),(g[u]===void 0||g[u+h]===void 0)&&St(u,g.length-(h+1))}function Et(g,u,h,b,R,L){if(g>h||g<u){const P=typeof u=="bigint"?"n":"";let pt;throw u===0||u===BigInt(0)?pt=`>= 0${P} and < 2${P} ** ${(L+1)*8}${P}`:pt=`>= -(2${P} ** ${(L+1)*8-1}${P}) and < 2 ** ${(L+1)*8-1}${P}`,new ft.ERR_OUT_OF_RANGE("value",pt,g)}xt(b,R,L)}function Ae(g,u){if(typeof g!="number")throw new ft.ERR_INVALID_ARG_TYPE(u,"number",g)}function St(g,u,h){throw Math.floor(g)!==g?(Ae(g,h),new ft.ERR_OUT_OF_RANGE("offset","an integer",g)):u<0?new ft.ERR_BUFFER_OUT_OF_BOUNDS:new ft.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${u}`,g)}const Lt=/[^+/0-9A-Za-z-_]/g;function nr(g){if(g=g.split("=")[0],g=g.trim().replace(Lt,""),g.length<2)return"";for(;g.length%4!==0;)g=g+"=";return g}function It(g,u){u=u||1/0;let h;const b=g.length;let R=null;const L=[];for(let P=0;P<b;++P){if(h=g.charCodeAt(P),h>55295&&h<57344){if(!R){if(h>56319){(u-=3)>-1&&L.push(239,191,189);continue}else if(P+1===b){(u-=3)>-1&&L.push(239,191,189);continue}R=h;continue}if(h<56320){(u-=3)>-1&&L.push(239,191,189),R=h;continue}h=(R-55296<<10|h-56320)+65536}else R&&(u-=3)>-1&&L.push(239,191,189);if(R=null,h<128){if((u-=1)<0)break;L.push(h)}else if(h<2048){if((u-=2)<0)break;L.push(h>>6|192,h&63|128)}else if(h<65536){if((u-=3)<0)break;L.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((u-=4)<0)break;L.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return L}function Ut(g){const u=[];for(let h=0;h<g.length;++h)u.push(g.charCodeAt(h)&255);return u}function rr(g,u){let h,b,R;const L=[];for(let P=0;P<g.length&&!((u-=2)<0);++P)h=g.charCodeAt(P),b=h>>8,R=h%256,L.push(R),L.push(b);return L}function Mt(g){return t.toByteArray(nr(g))}function _t(g,u,h,b){let R;for(R=0;R<b&&!(R+h>=u.length||R>=g.length);++R)u[R+h]=g[R];return R}function Se(g,u){return g instanceof u||g!=null&&g.constructor!=null&&g.constructor.name!=null&&g.constructor.name===u.name}function kt(g){return g!==g}const Ft=function(){const g="0123456789abcdef",u=new Array(256);for(let h=0;h<16;++h){const b=h*16;for(let R=0;R<16;++R)u[b+R]=g[h]+g[R]}return u}();function Le(g){return typeof BigInt>"u"?Nt:g}function Nt(){throw new Error("BigInt not supported")}})(dt);const Bn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Zn(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ei(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function yn(r,...t){if(!Zn(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function $s(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Ei(r.outputLen),Ei(r.blockLen)}function dr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Pa(r,t){yn(r);const e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Fn(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function ii(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Pe(r,t){return r<<32-t|r>>>t}const Hs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",qa=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function pn(r){if(yn(r),Hs)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=qa[r[e]];return t}const Ve={_0:48,_9:57,A:65,F:70,a:97,f:102};function ls(r){if(r>=Ve._0&&r<=Ve._9)return r-Ve._0;if(r>=Ve.A&&r<=Ve.F)return r-(Ve.A-10);if(r>=Ve.a&&r<=Ve.f)return r-(Ve.a-10)}function pr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Hs)return Uint8Array.fromHex(r);const t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(e);for(let s=0,i=0;s<e;s++,i+=2){const o=ls(r.charCodeAt(i)),c=ls(r.charCodeAt(i+1));if(o===void 0||c===void 0){const d=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+i)}n[s]=o*16+c}return n}function Da(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Ui(r){return typeof r=="string"&&(r=Da(r)),yn(r),r}function De(...r){let t=0;for(let n=0;n<r.length;n++){const s=r[n];yn(s),t+=s.length}const e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){const i=r[n];e.set(i,s),s+=i.length}return e}class Vs{}function js(r){const t=n=>r().update(Ui(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Fi(r=32){if(Bn&&typeof Bn.getRandomValues=="function")return Bn.getRandomValues(new Uint8Array(r));if(Bn&&typeof Bn.randomBytes=="function")return Uint8Array.from(Bn.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function za(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);const s=BigInt(32),i=BigInt(4294967295),o=Number(e>>s&i),c=Number(e&i),d=n?4:0,v=n?0:4;r.setUint32(t+d,o,n),r.setUint32(t+v,c,n)}function Ka(r,t,e){return r&t^~r&e}function $a(r,t,e){return r&t^r&e^t&e}class Ws extends Vs{constructor(t,e,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(t),this.view=ii(this.buffer)}update(t){dr(this),t=Ui(t),yn(t);const{view:e,buffer:n,blockLen:s}=this,i=t.length;for(let o=0;o<i;){const c=Math.min(s-this.pos,i-o);if(c===s){const d=ii(t);for(;s<=i-o;o+=s)this.process(d,o);continue}n.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){dr(this),Pa(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:s,isLE:i}=this;let{pos:o}=this;e[o++]=128,Fn(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(n,0),o=0);for(let I=o;I<s;I++)e[I]=0;za(n,s-8,BigInt(this.length*8),i),this.process(n,0);const c=ii(t),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const v=d/4,_=this.get();if(v>_.length)throw new Error("_sha2: outputLen bigger than state");for(let I=0;I<v;I++)c.setUint32(4*I,_[I],i)}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:i,destroyed:o,pos:c}=this;return t.destroyed=o,t.finished=i,t.length=s,t.pos=c,s%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const Xe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),de=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ir=BigInt(2**32-1),ds=BigInt(32);function Ha(r,t=!1){return t?{h:Number(r&ir),l:Number(r>>ds&ir)}:{h:Number(r>>ds&ir)|0,l:Number(r&ir)|0}}function Va(r,t=!1){const e=r.length;let n=new Uint32Array(e),s=new Uint32Array(e);for(let i=0;i<e;i++){const{h:o,l:c}=Ha(r[i],t);[n[i],s[i]]=[o,c]}return[n,s]}const ps=(r,t,e)=>r>>>e,gs=(r,t,e)=>r<<32-e|t>>>e,_n=(r,t,e)=>r>>>e|t<<32-e,An=(r,t,e)=>r<<32-e|t>>>e,sr=(r,t,e)=>r<<64-e|t>>>e-32,or=(r,t,e)=>r>>>e-32|t<<64-e;function je(r,t,e,n){const s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}const ja=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Wa=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ga=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Za=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,Ya=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),Xa=(r,t,e,n,s,i)=>t+e+n+s+i+(r/2**32|0)|0,Ja=Uint32Array.from([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]),Je=new Uint32Array(64);class Qa extends Ws{constructor(t=32){super(64,t,8,!1),this.A=Xe[0]|0,this.B=Xe[1]|0,this.C=Xe[2]|0,this.D=Xe[3]|0,this.E=Xe[4]|0,this.F=Xe[5]|0,this.G=Xe[6]|0,this.H=Xe[7]|0}get(){const{A:t,B:e,C:n,D:s,E:i,F:o,G:c,H:d}=this;return[t,e,n,s,i,o,c,d]}set(t,e,n,s,i,o,c,d){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=c|0,this.H=d|0}process(t,e){for(let I=0;I<16;I++,e+=4)Je[I]=t.getUint32(e,!1);for(let I=16;I<64;I++){const A=Je[I-15],B=Je[I-2],M=Pe(A,7)^Pe(A,18)^A>>>3,T=Pe(B,17)^Pe(B,19)^B>>>10;Je[I]=T+Je[I-7]+M+Je[I-16]|0}let{A:n,B:s,C:i,D:o,E:c,F:d,G:v,H:_}=this;for(let I=0;I<64;I++){const A=Pe(c,6)^Pe(c,11)^Pe(c,25),B=_+A+Ka(c,d,v)+Ja[I]+Je[I]|0,T=(Pe(n,2)^Pe(n,13)^Pe(n,22))+$a(n,s,i)|0;_=v,v=d,d=c,c=o+B|0,o=i,i=s,s=n,n=B+T|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,c=c+this.E|0,d=d+this.F|0,v=v+this.G|0,_=_+this.H|0,this.set(n,s,i,o,c,d,v,_)}roundClean(){Fn(Je)}destroy(){this.set(0,0,0,0,0,0,0,0),Fn(this.buffer)}}const Gs=Va(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),tc=Gs[0],ec=Gs[1],Qe=new Uint32Array(80),tn=new Uint32Array(80);class nc extends Ws{constructor(t=64){super(128,t,16,!1),this.Ah=de[0]|0,this.Al=de[1]|0,this.Bh=de[2]|0,this.Bl=de[3]|0,this.Ch=de[4]|0,this.Cl=de[5]|0,this.Dh=de[6]|0,this.Dl=de[7]|0,this.Eh=de[8]|0,this.El=de[9]|0,this.Fh=de[10]|0,this.Fl=de[11]|0,this.Gh=de[12]|0,this.Gl=de[13]|0,this.Hh=de[14]|0,this.Hl=de[15]|0}get(){const{Ah:t,Al:e,Bh:n,Bl:s,Ch:i,Cl:o,Dh:c,Dl:d,Eh:v,El:_,Fh:I,Fl:A,Gh:B,Gl:M,Hh:T,Hl:C}=this;return[t,e,n,s,i,o,c,d,v,_,I,A,B,M,T,C]}set(t,e,n,s,i,o,c,d,v,_,I,A,B,M,T,C){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=c|0,this.Dl=d|0,this.Eh=v|0,this.El=_|0,this.Fh=I|0,this.Fl=A|0,this.Gh=B|0,this.Gl=M|0,this.Hh=T|0,this.Hl=C|0}process(t,e){for(let O=0;O<16;O++,e+=4)Qe[O]=t.getUint32(e),tn[O]=t.getUint32(e+=4);for(let O=16;O<80;O++){const G=Qe[O-15]|0,J=tn[O-15]|0,nt=_n(G,J,1)^_n(G,J,8)^ps(G,J,7),ut=An(G,J,1)^An(G,J,8)^gs(G,J,7),ot=Qe[O-2]|0,q=tn[O-2]|0,Q=_n(ot,q,19)^sr(ot,q,61)^ps(ot,q,6),Z=An(ot,q,19)^or(ot,q,61)^gs(ot,q,6),X=Ga(ut,Z,tn[O-7],tn[O-16]),m=Za(X,nt,Q,Qe[O-7],Qe[O-16]);Qe[O]=m|0,tn[O]=X|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:c,Cl:d,Dh:v,Dl:_,Eh:I,El:A,Fh:B,Fl:M,Gh:T,Gl:C,Hh:F,Hl:z}=this;for(let O=0;O<80;O++){const G=_n(I,A,14)^_n(I,A,18)^sr(I,A,41),J=An(I,A,14)^An(I,A,18)^or(I,A,41),nt=I&B^~I&T,ut=A&M^~A&C,ot=Ya(z,J,ut,ec[O],tn[O]),q=Xa(ot,F,G,nt,tc[O],Qe[O]),Q=ot|0,Z=_n(n,s,28)^sr(n,s,34)^sr(n,s,39),X=An(n,s,28)^or(n,s,34)^or(n,s,39),m=n&i^n&c^i&c,a=s&o^s&d^o&d;F=T|0,z=C|0,T=B|0,C=M|0,B=I|0,M=A|0,{h:I,l:A}=je(v|0,_|0,q|0,Q|0),v=c|0,_=d|0,c=i|0,d=o|0,i=n|0,o=s|0;const l=ja(Q,X,a);n=Wa(l,q,Z,m),s=l|0}({h:n,l:s}=je(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=je(this.Bh|0,this.Bl|0,i|0,o|0),{h:c,l:d}=je(this.Ch|0,this.Cl|0,c|0,d|0),{h:v,l:_}=je(this.Dh|0,this.Dl|0,v|0,_|0),{h:I,l:A}=je(this.Eh|0,this.El|0,I|0,A|0),{h:B,l:M}=je(this.Fh|0,this.Fl|0,B|0,M|0),{h:T,l:C}=je(this.Gh|0,this.Gl|0,T|0,C|0),{h:F,l:z}=je(this.Hh|0,this.Hl|0,F|0,z|0),this.set(n,s,i,o,c,d,v,_,I,A,B,M,T,C,F,z)}roundClean(){Fn(Qe,tn)}destroy(){Fn(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Zs=js(()=>new Qa),rc=js(()=>new nc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ni=BigInt(0),Si=BigInt(1);function mn(r,t=""){if(typeof r!="boolean"){const e=t&&`"${t}"`;throw new Error(e+"expected boolean, got type="+typeof r)}return r}function Ue(r,t,e=""){const n=Zn(r),s=r==null?void 0:r.length,i=t!==void 0;if(!n||i&&s!==t){const o=e&&`"${e}" `,c=i?` of length ${t}`:"",d=n?`length=${s}`:`type=${typeof r}`;throw new Error(o+"expected Uint8Array"+c+", got "+d)}return r}function ar(r){const t=r.toString(16);return t.length&1?"0"+t:t}function Ys(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Ni:BigInt("0x"+r)}function kr(r){return Ys(pn(r))}function jn(r){return yn(r),Ys(pn(Uint8Array.from(r).reverse()))}function Oi(r,t){return pr(r.toString(16).padStart(t*2,"0"))}function Xs(r,t){return Oi(r,t).reverse()}function Pt(r,t,e){let n;if(typeof t=="string")try{n=pr(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(Zn(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");const s=n.length;if(typeof e=="number"&&s!==e)throw new Error(r+" of length "+e+" expected, got "+s);return n}function ms(r){return Uint8Array.from(r)}const si=r=>typeof r=="bigint"&&Ni<=r;function ic(r,t,e){return si(r)&&si(t)&&si(e)&&t<=r&&r<e}function Bi(r,t,e,n){if(!ic(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Js(r){let t;for(t=0;r>Ni;r>>=Si,t+=1);return t}const Yn=r=>(Si<<BigInt(r))-Si;function sc(r,t,e){if(typeof r!="number"||r<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");const n=B=>new Uint8Array(B),s=B=>Uint8Array.of(B);let i=n(r),o=n(r),c=0;const d=()=>{i.fill(1),o.fill(0),c=0},v=(...B)=>e(o,i,...B),_=(B=n(0))=>{o=v(s(0),B),i=v(),B.length!==0&&(o=v(s(1),B),i=v())},I=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let B=0;const M=[];for(;B<t;){i=v();const T=i.slice();M.push(T),B+=i.length}return De(...M)};return(B,M)=>{d(),_(B);let T;for(;!(T=M(I()));)_();return d(),T}}function Xn(r,t,e={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(s,i,o){const c=r[s];if(o&&c===void 0)return;const d=typeof c;if(d!==i||c===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${d}`)}Object.entries(t).forEach(([s,i])=>n(s,i,!1)),Object.entries(e).forEach(([s,i])=>n(s,i,!0))}function gr(r){const t=new WeakMap;return(e,...n)=>{const s=t.get(e);if(s!==void 0)return s;const i=r(e,...n);return t.set(e,i),i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ee=BigInt(0),le=BigInt(1),hn=BigInt(2),Qs=BigInt(3),to=BigInt(4),eo=BigInt(5),oc=BigInt(7),no=BigInt(8),ac=BigInt(9),ro=BigInt(16);function oe(r,t){const e=r%t;return e>=Ee?e:t+e}function Ot(r,t,e){let n=r;for(;t-- >Ee;)n*=n,n%=e;return n}function ys(r,t){if(r===Ee)throw new Error("invert: expected non-zero number");if(t<=Ee)throw new Error("invert: expected positive modulus, got "+t);let e=oe(r,t),n=t,s=Ee,i=le;for(;e!==Ee;){const c=n/e,d=n%e,v=s-i*c;n=e,e=d,s=i,i=v}if(n!==le)throw new Error("invert: does not exist");return oe(s,t)}function Pi(r,t,e){if(!r.eql(r.sqr(t),e))throw new Error("Cannot find square root")}function io(r,t){const e=(r.ORDER+le)/to,n=r.pow(t,e);return Pi(r,n,t),n}function cc(r,t){const e=(r.ORDER-eo)/no,n=r.mul(t,hn),s=r.pow(n,e),i=r.mul(t,s),o=r.mul(r.mul(i,hn),s),c=r.mul(i,r.sub(o,r.ONE));return Pi(r,c,t),c}function uc(r){const t=wn(r),e=so(r),n=e(t,t.neg(t.ONE)),s=e(t,n),i=e(t,t.neg(n)),o=(r+oc)/ro;return(c,d)=>{let v=c.pow(d,o),_=c.mul(v,n);const I=c.mul(v,s),A=c.mul(v,i),B=c.eql(c.sqr(_),d),M=c.eql(c.sqr(I),d);v=c.cmov(v,_,B),_=c.cmov(A,I,M);const T=c.eql(c.sqr(_),d),C=c.cmov(v,_,T);return Pi(c,C,d),C}}function so(r){if(r<Qs)throw new Error("sqrt is not defined for small field");let t=r-le,e=0;for(;t%hn===Ee;)t/=hn,e++;let n=hn;const s=wn(r);for(;ws(s,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return io;let i=s.pow(n,t);const o=(t+le)/hn;return function(d,v){if(d.is0(v))return v;if(ws(d,v)!==1)throw new Error("Cannot find square root");let _=e,I=d.mul(d.ONE,i),A=d.pow(v,t),B=d.pow(v,o);for(;!d.eql(A,d.ONE);){if(d.is0(A))return d.ZERO;let M=1,T=d.sqr(A);for(;!d.eql(T,d.ONE);)if(M++,T=d.sqr(T),M===_)throw new Error("Cannot find square root");const C=le<<BigInt(_-M-1),F=d.pow(I,C);_=M,I=d.sqr(F),A=d.mul(A,I),B=d.mul(B,F)}return B}}function fc(r){return r%to===Qs?io:r%no===eo?cc:r%ro===ac?uc(r):so(r)}const hc=(r,t)=>(oe(r,t)&le)===le,lc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function dc(r){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=lc.reduce((n,s)=>(n[s]="function",n),t);return Xn(r,e),r}function pc(r,t,e){if(e<Ee)throw new Error("invalid exponent, negatives unsupported");if(e===Ee)return r.ONE;if(e===le)return t;let n=r.ONE,s=t;for(;e>Ee;)e&le&&(n=r.mul(n,s)),s=r.sqr(s),e>>=le;return n}function oo(r,t,e=!1){const n=new Array(t.length).fill(e?r.ZERO:void 0),s=t.reduce((o,c,d)=>r.is0(c)?o:(n[d]=o,r.mul(o,c)),r.ONE),i=r.inv(s);return t.reduceRight((o,c,d)=>r.is0(c)?o:(n[d]=r.mul(o,n[d]),r.mul(o,c)),i),n}function ws(r,t){const e=(r.ORDER-le)/hn,n=r.pow(t,e),s=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),o=r.eql(n,r.neg(r.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function ao(r,t){t!==void 0&&Ei(t);const e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function wn(r,t,e=!1,n={}){if(r<=Ee)throw new Error("invalid field: expected ORDER > 0, got "+r);let s,i,o=!1,c;if(typeof t=="object"&&t!=null){if(n.sqrt||e)throw new Error("cannot specify opts in two arguments");const A=t;A.BITS&&(s=A.BITS),A.sqrt&&(i=A.sqrt),typeof A.isLE=="boolean"&&(e=A.isLE),typeof A.modFromBytes=="boolean"&&(o=A.modFromBytes),c=A.allowedLengths}else typeof t=="number"&&(s=t),n.sqrt&&(i=n.sqrt);const{nBitLength:d,nByteLength:v}=ao(r,s);if(v>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let _;const I=Object.freeze({ORDER:r,isLE:e,BITS:d,BYTES:v,MASK:Yn(d),ZERO:Ee,ONE:le,allowedLengths:c,create:A=>oe(A,r),isValid:A=>{if(typeof A!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof A);return Ee<=A&&A<r},is0:A=>A===Ee,isValidNot0:A=>!I.is0(A)&&I.isValid(A),isOdd:A=>(A&le)===le,neg:A=>oe(-A,r),eql:(A,B)=>A===B,sqr:A=>oe(A*A,r),add:(A,B)=>oe(A+B,r),sub:(A,B)=>oe(A-B,r),mul:(A,B)=>oe(A*B,r),pow:(A,B)=>pc(I,A,B),div:(A,B)=>oe(A*ys(B,r),r),sqrN:A=>A*A,addN:(A,B)=>A+B,subN:(A,B)=>A-B,mulN:(A,B)=>A*B,inv:A=>ys(A,r),sqrt:i||(A=>(_||(_=fc(r)),_(I,A))),toBytes:A=>e?Xs(A,v):Oi(A,v),fromBytes:(A,B=!0)=>{if(c){if(!c.includes(A.length)||A.length>v)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+A.length);const T=new Uint8Array(v);T.set(A,e?0:T.length-A.length),A=T}if(A.length!==v)throw new Error("Field.fromBytes: expected "+v+" bytes, got "+A.length);let M=e?jn(A):kr(A);if(o&&(M=oe(M,r)),!B&&!I.isValid(M))throw new Error("invalid field element: outside of range 0..ORDER");return M},invertBatch:A=>oo(I,A),cmov:(A,B,M)=>M?B:A});return Object.freeze(I)}function co(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const t=r.toString(2).length;return Math.ceil(t/8)}function uo(r){const t=co(r);return t+Math.ceil(t/2)}function gc(r,t,e=!1){const n=r.length,s=co(t),i=uo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const o=e?jn(r):kr(r),c=oe(o,t-le)+le;return e?Xs(c,s):Oi(c,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nn=BigInt(0),ln=BigInt(1);function mr(r,t){const e=t.negate();return r?e:t}function dn(r,t){const e=oo(r.Fp,t.map(n=>n.Z));return t.map((n,s)=>r.fromAffine(n.toAffine(e[s])))}function fo(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function oi(r,t){fo(r,t);const e=Math.ceil(t/r)+1,n=2**(r-1),s=2**r,i=Yn(r),o=BigInt(r);return{windows:e,windowSize:n,mask:i,maxNumber:s,shiftBy:o}}function bs(r,t,e){const{windowSize:n,mask:s,maxNumber:i,shiftBy:o}=e;let c=Number(r&s),d=r>>o;c>n&&(c-=i,d+=ln);const v=t*n,_=v+Math.abs(c)-1,I=c===0,A=c<0,B=t%2!==0;return{nextN:d,offset:_,isZero:I,isNeg:A,isNegF:B,offsetF:v}}function mc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function yc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}const ai=new WeakMap,ho=new WeakMap;function ci(r){return ho.get(r)||1}function vs(r){if(r!==Nn)throw new Error("invalid wNAF")}class lo{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,n=this.ZERO){let s=t;for(;e>Nn;)e&ln&&(n=n.add(s)),s=s.double(),e>>=ln;return n}precomputeWindow(t,e){const{windows:n,windowSize:s}=oi(e,this.bits),i=[];let o=t,c=o;for(let d=0;d<n;d++){c=o,i.push(c);for(let v=1;v<s;v++)c=c.add(o),i.push(c);o=c.double()}return i}wNAF(t,e,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let s=this.ZERO,i=this.BASE;const o=oi(t,this.bits);for(let c=0;c<o.windows;c++){const{nextN:d,offset:v,isZero:_,isNeg:I,isNegF:A,offsetF:B}=bs(n,c,o);n=d,_?i=i.add(mr(A,e[B])):s=s.add(mr(I,e[v]))}return vs(n),{p:s,f:i}}wNAFUnsafe(t,e,n,s=this.ZERO){const i=oi(t,this.bits);for(let o=0;o<i.windows&&n!==Nn;o++){const{nextN:c,offset:d,isZero:v,isNeg:_}=bs(n,o,i);if(n=c,!v){const I=e[d];s=s.add(_?I.negate():I)}}return vs(n),s}getPrecomputes(t,e,n){let s=ai.get(e);return s||(s=this.precomputeWindow(e,t),t!==1&&(typeof n=="function"&&(s=n(s)),ai.set(e,s))),s}cached(t,e,n){const s=ci(t);return this.wNAF(s,this.getPrecomputes(s,t,n),e)}unsafe(t,e,n,s){const i=ci(t);return i===1?this._unsafeLadder(t,e,s):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),e,s)}createCache(t,e){fo(e,this.bits),ho.set(t,e),ai.delete(t)}hasCache(t){return ci(t)!==1}}function wc(r,t,e,n){let s=t,i=r.ZERO,o=r.ZERO;for(;e>Nn||n>Nn;)e&ln&&(i=i.add(s)),n&ln&&(o=o.add(s)),s=s.double(),e>>=ln,n>>=ln;return{p1:i,p2:o}}function po(r,t,e,n){mc(e,r),yc(n,t);const s=e.length,i=n.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=r.ZERO,c=Js(BigInt(s));let d=1;c>12?d=c-3:c>4?d=c-2:c>0&&(d=2);const v=Yn(d),_=new Array(Number(v)+1).fill(o),I=Math.floor((t.BITS-1)/d)*d;let A=o;for(let B=I;B>=0;B-=d){_.fill(o);for(let T=0;T<i;T++){const C=n[T],F=Number(C>>BigInt(B)&v);_[F]=_[F].add(e[T])}let M=o;for(let T=_.length-1,C=o;T>0;T--)C=C.add(_[T]),M=M.add(C);if(A=A.add(M),B!==0)for(let T=0;T<d;T++)A=A.double()}return A}function xs(r,t,e){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return dc(t),t}else return wn(r,{isLE:e})}function go(r,t,e={},n){if(n===void 0&&(n=r==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(const d of["p","n","h"]){const v=t[d];if(!(typeof v=="bigint"&&v>Nn))throw new Error(`CURVE.${d} must be positive bigint`)}const s=xs(t.p,e.Fp,n),i=xs(t.n,e.Fn,n),c=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(const d of c)if(!s.isValid(t[d]))throw new Error(`CURVE.${d} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:s,Fn:i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const en=BigInt(0),ae=BigInt(1),ui=BigInt(2),bc=BigInt(8);function vc(r,t,e,n){const s=r.sqr(e),i=r.sqr(n),o=r.add(r.mul(t.a,s),i),c=r.add(r.ONE,r.mul(t.d,r.mul(s,i)));return r.eql(o,c)}function xc(r,t={}){const e=go("edwards",r,t,t.FpFnLE),{Fp:n,Fn:s}=e;let i=e.CURVE;const{h:o}=i;Xn(t,{},{uvRatio:"function"});const c=ui<<BigInt(s.BYTES*8)-ae,d=C=>n.create(C),v=t.uvRatio||((C,F)=>{try{return{isValid:!0,value:n.sqrt(n.div(C,F))}}catch{return{isValid:!1,value:en}}});if(!vc(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function _(C,F,z=!1){const O=z?ae:en;return Bi("coordinate "+C,F,O,c),F}function I(C){if(!(C instanceof M))throw new Error("ExtendedPoint expected")}const A=gr((C,F)=>{const{X:z,Y:O,Z:G}=C,J=C.is0();F==null&&(F=J?bc:n.inv(G));const nt=d(z*F),ut=d(O*F),ot=n.mul(G,F);if(J)return{x:en,y:ae};if(ot!==ae)throw new Error("invZ was invalid");return{x:nt,y:ut}}),B=gr(C=>{const{a:F,d:z}=i;if(C.is0())throw new Error("bad point: ZERO");const{X:O,Y:G,Z:J,T:nt}=C,ut=d(O*O),ot=d(G*G),q=d(J*J),Q=d(q*q),Z=d(ut*F),X=d(q*d(Z+ot)),m=d(Q+d(z*d(ut*ot)));if(X!==m)throw new Error("bad point: equation left != right (1)");const a=d(O*G),l=d(J*nt);if(a!==l)throw new Error("bad point: equation left != right (2)");return!0});class M{constructor(F,z,O,G){this.X=_("x",F),this.Y=_("y",z),this.Z=_("z",O,!0),this.T=_("t",G),Object.freeze(this)}static CURVE(){return i}static fromAffine(F){if(F instanceof M)throw new Error("extended point not allowed");const{x:z,y:O}=F||{};return _("x",z),_("y",O),new M(z,O,ae,d(z*O))}static fromBytes(F,z=!1){const O=n.BYTES,{a:G,d:J}=i;F=ms(Ue(F,O,"point")),mn(z,"zip215");const nt=ms(F),ut=F[O-1];nt[O-1]=ut&-129;const ot=jn(nt),q=z?c:n.ORDER;Bi("point.y",ot,en,q);const Q=d(ot*ot),Z=d(Q-ae),X=d(J*Q-G);let{isValid:m,value:a}=v(Z,X);if(!m)throw new Error("bad point: invalid y coordinate");const l=(a&ae)===ae,p=(ut&128)!==0;if(!z&&a===en&&p)throw new Error("bad point: x=0 and x_0=1");return p!==l&&(a=d(-a)),M.fromAffine({x:a,y:ot})}static fromHex(F,z=!1){return M.fromBytes(Pt("point",F),z)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(F=8,z=!0){return T.createCache(this,F),z||this.multiply(ui),this}assertValidity(){B(this)}equals(F){I(F);const{X:z,Y:O,Z:G}=this,{X:J,Y:nt,Z:ut}=F,ot=d(z*ut),q=d(J*G),Q=d(O*ut),Z=d(nt*G);return ot===q&&Q===Z}is0(){return this.equals(M.ZERO)}negate(){return new M(d(-this.X),this.Y,this.Z,d(-this.T))}double(){const{a:F}=i,{X:z,Y:O,Z:G}=this,J=d(z*z),nt=d(O*O),ut=d(ui*d(G*G)),ot=d(F*J),q=z+O,Q=d(d(q*q)-J-nt),Z=ot+nt,X=Z-ut,m=ot-nt,a=d(Q*X),l=d(Z*m),p=d(Q*m),w=d(X*Z);return new M(a,l,w,p)}add(F){I(F);const{a:z,d:O}=i,{X:G,Y:J,Z:nt,T:ut}=this,{X:ot,Y:q,Z:Q,T:Z}=F,X=d(G*ot),m=d(J*q),a=d(ut*O*Z),l=d(nt*Q),p=d((G+J)*(ot+q)-X-m),w=l-a,x=l+a,S=d(m-z*X),k=d(p*w),y=d(x*S),f=d(p*S),E=d(w*x);return new M(k,y,E,f)}subtract(F){return this.add(F.negate())}multiply(F){if(!s.isValidNot0(F))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:z,f:O}=T.cached(this,F,G=>dn(M,G));return dn(M,[z,O])[0]}multiplyUnsafe(F,z=M.ZERO){if(!s.isValid(F))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return F===en?M.ZERO:this.is0()||F===ae?this:T.unsafe(this,F,O=>dn(M,O),z)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return T.unsafe(this,i.n).is0()}toAffine(F){return A(this,F)}clearCofactor(){return o===ae?this:this.multiplyUnsafe(o)}toBytes(){const{x:F,y:z}=this.toAffine(),O=n.toBytes(z);return O[O.length-1]|=F&ae?128:0,O}toHex(){return pn(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(F){return dn(M,F)}static msm(F,z){return po(M,s,F,z)}_setWindowSize(F){this.precompute(F)}toRawBytes(){return this.toBytes()}}M.BASE=new M(i.Gx,i.Gy,ae,d(i.Gx*i.Gy)),M.ZERO=new M(en,ae,ae,en),M.Fp=n,M.Fn=s;const T=new lo(M,s.BITS);return M.BASE.precompute(8),M}function Ec(r,t,e={}){if(typeof t!="function")throw new Error('"hash" function param is required');Xn(e,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:n}=e,{BASE:s,Fp:i,Fn:o}=r,c=e.randomBytes||Fi,d=e.adjustScalarBytes||(q=>q),v=e.domain||((q,Q,Z)=>{if(mn(Z,"phflag"),Q.length||Z)throw new Error("Contexts/pre-hash are not supported");return q});function _(q){return o.create(jn(q))}function I(q){const Q=O.secretKey;q=Pt("private key",q,Q);const Z=Pt("hashed private key",t(q),2*Q),X=d(Z.slice(0,Q)),m=Z.slice(Q,2*Q),a=_(X);return{head:X,prefix:m,scalar:a}}function A(q){const{head:Q,prefix:Z,scalar:X}=I(q),m=s.multiply(X),a=m.toBytes();return{head:Q,prefix:Z,scalar:X,point:m,pointBytes:a}}function B(q){return A(q).pointBytes}function M(q=Uint8Array.of(),...Q){const Z=De(...Q);return _(t(v(Z,Pt("context",q),!!n)))}function T(q,Q,Z={}){q=Pt("message",q),n&&(q=n(q));const{prefix:X,scalar:m,pointBytes:a}=A(Q),l=M(Z.context,X,q),p=s.multiply(l).toBytes(),w=M(Z.context,p,a,q),x=o.create(l+w*m);if(!o.isValid(x))throw new Error("sign failed: invalid s");const S=De(p,o.toBytes(x));return Ue(S,O.signature,"result")}const C={zip215:!0};function F(q,Q,Z,X=C){const{context:m,zip215:a}=X,l=O.signature;q=Pt("signature",q,l),Q=Pt("message",Q),Z=Pt("publicKey",Z,O.publicKey),a!==void 0&&mn(a,"zip215"),n&&(Q=n(Q));const p=l/2,w=q.subarray(0,p),x=jn(q.subarray(p,l));let S,k,y;try{S=r.fromBytes(Z,a),k=r.fromBytes(w,a),y=s.multiplyUnsafe(x)}catch{return!1}if(!a&&S.isSmallOrder())return!1;const f=M(m,k.toBytes(),S.toBytes(),Q);return k.add(S.multiplyUnsafe(f)).subtract(y).clearCofactor().is0()}const z=i.BYTES,O={secretKey:z,publicKey:z,signature:2*z,seed:z};function G(q=c(O.seed)){return Ue(q,O.seed,"seed")}function J(q){const Q=ot.randomSecretKey(q);return{secretKey:Q,publicKey:B(Q)}}function nt(q){return Zn(q)&&q.length===o.BYTES}function ut(q,Q){try{return!!r.fromBytes(q,Q)}catch{return!1}}const ot={getExtendedPublicKey:A,randomSecretKey:G,isValidSecretKey:nt,isValidPublicKey:ut,toMontgomery(q){const{y:Q}=r.fromBytes(q),Z=O.publicKey,X=Z===32;if(!X&&Z!==57)throw new Error("only defined for 25519 and 448");const m=X?i.div(ae+Q,ae-Q):i.div(Q-ae,Q+ae);return i.toBytes(m)},toMontgomerySecret(q){const Q=O.secretKey;Ue(q,Q);const Z=t(q.subarray(0,Q));return d(Z).subarray(0,Q)},randomPrivateKey:G,precompute(q=8,Q=r.BASE){return Q.precompute(q,!1)}};return Object.freeze({keygen:J,getPublicKey:B,sign:T,verify:F,utils:ot,Point:r,lengths:O})}function Sc(r){const t={a:r.a,d:r.d,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=wn(t.n,r.nBitLength,!0),s={Fp:e,Fn:n,uvRatio:r.uvRatio},i={randomBytes:r.randomBytes,adjustScalarBytes:r.adjustScalarBytes,domain:r.domain,prehash:r.prehash,mapToCurve:r.mapToCurve};return{CURVE:t,curveOpts:s,hash:r.hash,eddsaOpts:i}}function Bc(r,t){const e=t.Point;return Object.assign({},t,{ExtendedPoint:e,CURVE:r,nBitLength:e.Fn.BITS,nByteLength:e.Fn.BYTES})}function _c(r){const{CURVE:t,curveOpts:e,hash:n,eddsaOpts:s}=Sc(r),i=xc(t,e),o=Ec(i,n,s);return Bc(r,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ac=BigInt(1),Es=BigInt(2);BigInt(3);const Ic=BigInt(5),kc=BigInt(8),qi=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),mo={p:qi,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:kc,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Mc(r){const t=BigInt(10),e=BigInt(20),n=BigInt(40),s=BigInt(80),i=qi,c=r*r%i*r%i,d=Ot(c,Es,i)*c%i,v=Ot(d,Ac,i)*r%i,_=Ot(v,Ic,i)*v%i,I=Ot(_,t,i)*_%i,A=Ot(I,e,i)*I%i,B=Ot(A,n,i)*A%i,M=Ot(B,s,i)*B%i,T=Ot(M,s,i)*B%i,C=Ot(T,t,i)*_%i;return{pow_p_5_8:Ot(C,Es,i)*r%i,b2:c}}function Rc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}const Ss=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Tc(r,t){const e=qi,n=oe(t*t*t,e),s=oe(n*n*t,e),i=Mc(r*s).pow_p_5_8;let o=oe(r*n*i,e);const c=oe(t*o*o,e),d=o,v=oe(o*Ss,e),_=c===r,I=c===oe(-r,e),A=c===oe(-r*Ss,e);return _&&(o=d),(I||A)&&(o=v),hc(o,e)&&(o=oe(-o,e)),{isValid:_||I,value:o}}const Cc=wn(mo.p,{isLE:!0}),Lc={...mo,Fp:Cc,hash:rc,adjustScalarBytes:Rc,uvRatio:Tc},Jn=_c(Lc);var Di={exports:{}};Di.exports;(function(r){(function(t,e){function n(m,a){if(!m)throw new Error(a||"Assertion failed")}function s(m,a){m.super_=a;var l=function(){};l.prototype=a.prototype,m.prototype=new l,m.prototype.constructor=m}function i(m,a,l){if(i.isBN(m))return m;this.negative=0,this.words=null,this.length=0,this.red=null,m!==null&&((a==="le"||a==="be")&&(l=a,a=10),this._init(m||0,a||10,l||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Ma.Buffer}catch{}i.isBN=function(a){return a instanceof i?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===i.wordSize&&Array.isArray(a.words)},i.max=function(a,l){return a.cmp(l)>0?a:l},i.min=function(a,l){return a.cmp(l)<0?a:l},i.prototype._init=function(a,l,p){if(typeof a=="number")return this._initNumber(a,l,p);if(typeof a=="object")return this._initArray(a,l,p);l==="hex"&&(l=16),n(l===(l|0)&&l>=2&&l<=36),a=a.toString().replace(/\s+/g,"");var w=0;a[0]==="-"&&(w++,this.negative=1),w<a.length&&(l===16?this._parseHex(a,w,p):(this._parseBase(a,l,w),p==="le"&&this._initArray(this.toArray(),l,p)))},i.prototype._initNumber=function(a,l,p){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(n(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),p==="le"&&this._initArray(this.toArray(),l,p)},i.prototype._initArray=function(a,l,p){if(n(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var x,S,k=0;if(p==="be")for(w=a.length-1,x=0;w>=0;w-=3)S=a[w]|a[w-1]<<8|a[w-2]<<16,this.words[x]|=S<<k&67108863,this.words[x+1]=S>>>26-k&67108863,k+=24,k>=26&&(k-=26,x++);else if(p==="le")for(w=0,x=0;w<a.length;w+=3)S=a[w]|a[w+1]<<8|a[w+2]<<16,this.words[x]|=S<<k&67108863,this.words[x+1]=S>>>26-k&67108863,k+=24,k>=26&&(k-=26,x++);return this._strip()};function c(m,a){var l=m.charCodeAt(a);if(l>=48&&l<=57)return l-48;if(l>=65&&l<=70)return l-55;if(l>=97&&l<=102)return l-87;n(!1,"Invalid character in "+m)}function d(m,a,l){var p=c(m,l);return l-1>=a&&(p|=c(m,l-1)<<4),p}i.prototype._parseHex=function(a,l,p){this.length=Math.ceil((a.length-l)/6),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var x=0,S=0,k;if(p==="be")for(w=a.length-1;w>=l;w-=2)k=d(a,l,w)<<x,this.words[S]|=k&67108863,x>=18?(x-=18,S+=1,this.words[S]|=k>>>26):x+=8;else{var y=a.length-l;for(w=y%2===0?l+1:l;w<a.length;w+=2)k=d(a,l,w)<<x,this.words[S]|=k&67108863,x>=18?(x-=18,S+=1,this.words[S]|=k>>>26):x+=8}this._strip()};function v(m,a,l,p){for(var w=0,x=0,S=Math.min(m.length,l),k=a;k<S;k++){var y=m.charCodeAt(k)-48;w*=p,y>=49?x=y-49+10:y>=17?x=y-17+10:x=y,n(y>=0&&x<p,"Invalid character"),w+=x}return w}i.prototype._parseBase=function(a,l,p){this.words=[0],this.length=1;for(var w=0,x=1;x<=67108863;x*=l)w++;w--,x=x/l|0;for(var S=a.length-p,k=S%w,y=Math.min(S,S-k)+p,f=0,E=p;E<y;E+=w)f=v(a,E,E+w,l),this.imuln(x),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(k!==0){var V=1;for(f=v(a,E,a.length,l),E=0;E<k;E++)V*=l;this.imuln(V),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},i.prototype.copy=function(a){a.words=new Array(this.length);for(var l=0;l<this.length;l++)a.words[l]=this.words[l];a.length=this.length,a.negative=this.negative,a.red=this.red};function _(m,a){m.words=a.words,m.length=a.length,m.negative=a.negative,m.red=a.red}if(i.prototype._move=function(a){_(a,this)},i.prototype.clone=function(){var a=new i(null);return this.copy(a),a},i.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=I}catch{i.prototype.inspect=I}else i.prototype.inspect=I;function I(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var A=["","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"],B=[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],M=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(a,l){a=a||10,l=l|0||1;var p;if(a===16||a==="hex"){p="";for(var w=0,x=0,S=0;S<this.length;S++){var k=this.words[S],y=((k<<w|x)&16777215).toString(16);x=k>>>24-w&16777215,w+=2,w>=26&&(w-=26,S--),x!==0||S!==this.length-1?p=A[6-y.length]+y+p:p=y+p}for(x!==0&&(p=x.toString(16)+p);p.length%l!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(a===(a|0)&&a>=2&&a<=36){var f=B[a],E=M[a];p="";var V=this.clone();for(V.negative=0;!V.isZero();){var $=V.modrn(E).toString(a);V=V.idivn(E),V.isZero()?p=$+p:p=A[f-$.length]+$+p}for(this.isZero()&&(p="0"+p);p.length%l!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}n(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(a,l){return this.toArrayLike(o,a,l)}),i.prototype.toArray=function(a,l){return this.toArrayLike(Array,a,l)};var T=function(a,l){return a.allocUnsafe?a.allocUnsafe(l):new a(l)};i.prototype.toArrayLike=function(a,l,p){this._strip();var w=this.byteLength(),x=p||Math.max(1,w);n(w<=x,"byte array longer than desired length"),n(x>0,"Requested array length <= 0");var S=T(a,x),k=l==="le"?"LE":"BE";return this["_toArrayLike"+k](S,w),S},i.prototype._toArrayLikeLE=function(a,l){for(var p=0,w=0,x=0,S=0;x<this.length;x++){var k=this.words[x]<<S|w;a[p++]=k&255,p<a.length&&(a[p++]=k>>8&255),p<a.length&&(a[p++]=k>>16&255),S===6?(p<a.length&&(a[p++]=k>>24&255),w=0,S=0):(w=k>>>24,S+=2)}if(p<a.length)for(a[p++]=w;p<a.length;)a[p++]=0},i.prototype._toArrayLikeBE=function(a,l){for(var p=a.length-1,w=0,x=0,S=0;x<this.length;x++){var k=this.words[x]<<S|w;a[p--]=k&255,p>=0&&(a[p--]=k>>8&255),p>=0&&(a[p--]=k>>16&255),S===6?(p>=0&&(a[p--]=k>>24&255),w=0,S=0):(w=k>>>24,S+=2)}if(p>=0)for(a[p--]=w;p>=0;)a[p--]=0},Math.clz32?i.prototype._countBits=function(a){return 32-Math.clz32(a)}:i.prototype._countBits=function(a){var l=a,p=0;return l>=4096&&(p+=13,l>>>=13),l>=64&&(p+=7,l>>>=7),l>=8&&(p+=4,l>>>=4),l>=2&&(p+=2,l>>>=2),p+l},i.prototype._zeroBits=function(a){if(a===0)return 26;var l=a,p=0;return l&8191||(p+=13,l>>>=13),l&127||(p+=7,l>>>=7),l&15||(p+=4,l>>>=4),l&3||(p+=2,l>>>=2),l&1||p++,p},i.prototype.bitLength=function(){var a=this.words[this.length-1],l=this._countBits(a);return(this.length-1)*26+l};function C(m){for(var a=new Array(m.bitLength()),l=0;l<a.length;l++){var p=l/26|0,w=l%26;a[l]=m.words[p]>>>w&1}return a}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,l=0;l<this.length;l++){var p=this._zeroBits(this.words[l]);if(a+=p,p!==26)break}return a},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},i.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var l=0;l<a.length;l++)this.words[l]=this.words[l]|a.words[l];return this._strip()},i.prototype.ior=function(a){return n((this.negative|a.negative)===0),this.iuor(a)},i.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},i.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},i.prototype.iuand=function(a){var l;this.length>a.length?l=a:l=this;for(var p=0;p<l.length;p++)this.words[p]=this.words[p]&a.words[p];return this.length=l.length,this._strip()},i.prototype.iand=function(a){return n((this.negative|a.negative)===0),this.iuand(a)},i.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},i.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},i.prototype.iuxor=function(a){var l,p;this.length>a.length?(l=this,p=a):(l=a,p=this);for(var w=0;w<p.length;w++)this.words[w]=l.words[w]^p.words[w];if(this!==l)for(;w<l.length;w++)this.words[w]=l.words[w];return this.length=l.length,this._strip()},i.prototype.ixor=function(a){return n((this.negative|a.negative)===0),this.iuxor(a)},i.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},i.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},i.prototype.inotn=function(a){n(typeof a=="number"&&a>=0);var l=Math.ceil(a/26)|0,p=a%26;this._expand(l),p>0&&l--;for(var w=0;w<l;w++)this.words[w]=~this.words[w]&67108863;return p>0&&(this.words[w]=~this.words[w]&67108863>>26-p),this._strip()},i.prototype.notn=function(a){return this.clone().inotn(a)},i.prototype.setn=function(a,l){n(typeof a=="number"&&a>=0);var p=a/26|0,w=a%26;return this._expand(p+1),l?this.words[p]=this.words[p]|1<<w:this.words[p]=this.words[p]&~(1<<w),this._strip()},i.prototype.iadd=function(a){var l;if(this.negative!==0&&a.negative===0)return this.negative=0,l=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,l=this.isub(a),a.negative=1,l._normSign();var p,w;this.length>a.length?(p=this,w=a):(p=a,w=this);for(var x=0,S=0;S<w.length;S++)l=(p.words[S]|0)+(w.words[S]|0)+x,this.words[S]=l&67108863,x=l>>>26;for(;x!==0&&S<p.length;S++)l=(p.words[S]|0)+x,this.words[S]=l&67108863,x=l>>>26;if(this.length=p.length,x!==0)this.words[this.length]=x,this.length++;else if(p!==this)for(;S<p.length;S++)this.words[S]=p.words[S];return this},i.prototype.add=function(a){var l;return a.negative!==0&&this.negative===0?(a.negative=0,l=this.sub(a),a.negative^=1,l):a.negative===0&&this.negative!==0?(this.negative=0,l=a.sub(this),this.negative=1,l):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},i.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var l=this.iadd(a);return a.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var p=this.cmp(a);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var w,x;p>0?(w=this,x=a):(w=a,x=this);for(var S=0,k=0;k<x.length;k++)l=(w.words[k]|0)-(x.words[k]|0)+S,S=l>>26,this.words[k]=l&67108863;for(;S!==0&&k<w.length;k++)l=(w.words[k]|0)+S,S=l>>26,this.words[k]=l&67108863;if(S===0&&k<w.length&&w!==this)for(;k<w.length;k++)this.words[k]=w.words[k];return this.length=Math.max(this.length,k),w!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(a){return this.clone().isub(a)};function F(m,a,l){l.negative=a.negative^m.negative;var p=m.length+a.length|0;l.length=p,p=p-1|0;var w=m.words[0]|0,x=a.words[0]|0,S=w*x,k=S&67108863,y=S/67108864|0;l.words[0]=k;for(var f=1;f<p;f++){for(var E=y>>>26,V=y&67108863,$=Math.min(f,a.length-1),Y=Math.max(0,f-m.length+1);Y<=$;Y++){var mt=f-Y|0;w=m.words[mt]|0,x=a.words[Y]|0,S=w*x+V,E+=S/67108864|0,V=S&67108863}l.words[f]=V|0,y=E|0}return y!==0?l.words[f]=y|0:l.length--,l._strip()}var z=function(a,l,p){var w=a.words,x=l.words,S=p.words,k=0,y,f,E,V=w[0]|0,$=V&8191,Y=V>>>13,mt=w[1]|0,ft=mt&8191,st=mt>>>13,Ct=w[2]|0,xt=Ct&8191,Et=Ct>>>13,Ae=w[3]|0,St=Ae&8191,Lt=Ae>>>13,nr=w[4]|0,It=nr&8191,Ut=nr>>>13,rr=w[5]|0,Mt=rr&8191,_t=rr>>>13,Se=w[6]|0,kt=Se&8191,Ft=Se>>>13,Le=w[7]|0,Nt=Le&8191,g=Le>>>13,u=w[8]|0,h=u&8191,b=u>>>13,R=w[9]|0,L=R&8191,P=R>>>13,pt=x[0]|0,lt=pt&8191,ht=pt>>>13,At=x[1]|0,at=At&8191,zt=At>>>13,is=x[2]|0,Kt=is&8191,$t=is>>>13,ss=x[3]|0,Ht=ss&8191,Vt=ss>>>13,os=x[4]|0,jt=os&8191,Wt=os>>>13,as=x[5]|0,Gt=as&8191,Zt=as>>>13,cs=x[6]|0,Yt=cs&8191,Xt=cs>>>13,us=x[7]|0,Jt=us&8191,Qt=us>>>13,fs=x[8]|0,te=fs&8191,ee=fs>>>13,hs=x[9]|0,ne=hs&8191,re=hs>>>13;p.negative=a.negative^l.negative,p.length=19,y=Math.imul($,lt),f=Math.imul($,ht),f=f+Math.imul(Y,lt)|0,E=Math.imul(Y,ht);var Pr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,y=Math.imul(ft,lt),f=Math.imul(ft,ht),f=f+Math.imul(st,lt)|0,E=Math.imul(st,ht),y=y+Math.imul($,at)|0,f=f+Math.imul($,zt)|0,f=f+Math.imul(Y,at)|0,E=E+Math.imul(Y,zt)|0;var qr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(qr>>>26)|0,qr&=67108863,y=Math.imul(xt,lt),f=Math.imul(xt,ht),f=f+Math.imul(Et,lt)|0,E=Math.imul(Et,ht),y=y+Math.imul(ft,at)|0,f=f+Math.imul(ft,zt)|0,f=f+Math.imul(st,at)|0,E=E+Math.imul(st,zt)|0,y=y+Math.imul($,Kt)|0,f=f+Math.imul($,$t)|0,f=f+Math.imul(Y,Kt)|0,E=E+Math.imul(Y,$t)|0;var Dr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Dr>>>26)|0,Dr&=67108863,y=Math.imul(St,lt),f=Math.imul(St,ht),f=f+Math.imul(Lt,lt)|0,E=Math.imul(Lt,ht),y=y+Math.imul(xt,at)|0,f=f+Math.imul(xt,zt)|0,f=f+Math.imul(Et,at)|0,E=E+Math.imul(Et,zt)|0,y=y+Math.imul(ft,Kt)|0,f=f+Math.imul(ft,$t)|0,f=f+Math.imul(st,Kt)|0,E=E+Math.imul(st,$t)|0,y=y+Math.imul($,Ht)|0,f=f+Math.imul($,Vt)|0,f=f+Math.imul(Y,Ht)|0,E=E+Math.imul(Y,Vt)|0;var zr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(zr>>>26)|0,zr&=67108863,y=Math.imul(It,lt),f=Math.imul(It,ht),f=f+Math.imul(Ut,lt)|0,E=Math.imul(Ut,ht),y=y+Math.imul(St,at)|0,f=f+Math.imul(St,zt)|0,f=f+Math.imul(Lt,at)|0,E=E+Math.imul(Lt,zt)|0,y=y+Math.imul(xt,Kt)|0,f=f+Math.imul(xt,$t)|0,f=f+Math.imul(Et,Kt)|0,E=E+Math.imul(Et,$t)|0,y=y+Math.imul(ft,Ht)|0,f=f+Math.imul(ft,Vt)|0,f=f+Math.imul(st,Ht)|0,E=E+Math.imul(st,Vt)|0,y=y+Math.imul($,jt)|0,f=f+Math.imul($,Wt)|0,f=f+Math.imul(Y,jt)|0,E=E+Math.imul(Y,Wt)|0;var Kr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Kr>>>26)|0,Kr&=67108863,y=Math.imul(Mt,lt),f=Math.imul(Mt,ht),f=f+Math.imul(_t,lt)|0,E=Math.imul(_t,ht),y=y+Math.imul(It,at)|0,f=f+Math.imul(It,zt)|0,f=f+Math.imul(Ut,at)|0,E=E+Math.imul(Ut,zt)|0,y=y+Math.imul(St,Kt)|0,f=f+Math.imul(St,$t)|0,f=f+Math.imul(Lt,Kt)|0,E=E+Math.imul(Lt,$t)|0,y=y+Math.imul(xt,Ht)|0,f=f+Math.imul(xt,Vt)|0,f=f+Math.imul(Et,Ht)|0,E=E+Math.imul(Et,Vt)|0,y=y+Math.imul(ft,jt)|0,f=f+Math.imul(ft,Wt)|0,f=f+Math.imul(st,jt)|0,E=E+Math.imul(st,Wt)|0,y=y+Math.imul($,Gt)|0,f=f+Math.imul($,Zt)|0,f=f+Math.imul(Y,Gt)|0,E=E+Math.imul(Y,Zt)|0;var $r=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+($r>>>26)|0,$r&=67108863,y=Math.imul(kt,lt),f=Math.imul(kt,ht),f=f+Math.imul(Ft,lt)|0,E=Math.imul(Ft,ht),y=y+Math.imul(Mt,at)|0,f=f+Math.imul(Mt,zt)|0,f=f+Math.imul(_t,at)|0,E=E+Math.imul(_t,zt)|0,y=y+Math.imul(It,Kt)|0,f=f+Math.imul(It,$t)|0,f=f+Math.imul(Ut,Kt)|0,E=E+Math.imul(Ut,$t)|0,y=y+Math.imul(St,Ht)|0,f=f+Math.imul(St,Vt)|0,f=f+Math.imul(Lt,Ht)|0,E=E+Math.imul(Lt,Vt)|0,y=y+Math.imul(xt,jt)|0,f=f+Math.imul(xt,Wt)|0,f=f+Math.imul(Et,jt)|0,E=E+Math.imul(Et,Wt)|0,y=y+Math.imul(ft,Gt)|0,f=f+Math.imul(ft,Zt)|0,f=f+Math.imul(st,Gt)|0,E=E+Math.imul(st,Zt)|0,y=y+Math.imul($,Yt)|0,f=f+Math.imul($,Xt)|0,f=f+Math.imul(Y,Yt)|0,E=E+Math.imul(Y,Xt)|0;var Hr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,y=Math.imul(Nt,lt),f=Math.imul(Nt,ht),f=f+Math.imul(g,lt)|0,E=Math.imul(g,ht),y=y+Math.imul(kt,at)|0,f=f+Math.imul(kt,zt)|0,f=f+Math.imul(Ft,at)|0,E=E+Math.imul(Ft,zt)|0,y=y+Math.imul(Mt,Kt)|0,f=f+Math.imul(Mt,$t)|0,f=f+Math.imul(_t,Kt)|0,E=E+Math.imul(_t,$t)|0,y=y+Math.imul(It,Ht)|0,f=f+Math.imul(It,Vt)|0,f=f+Math.imul(Ut,Ht)|0,E=E+Math.imul(Ut,Vt)|0,y=y+Math.imul(St,jt)|0,f=f+Math.imul(St,Wt)|0,f=f+Math.imul(Lt,jt)|0,E=E+Math.imul(Lt,Wt)|0,y=y+Math.imul(xt,Gt)|0,f=f+Math.imul(xt,Zt)|0,f=f+Math.imul(Et,Gt)|0,E=E+Math.imul(Et,Zt)|0,y=y+Math.imul(ft,Yt)|0,f=f+Math.imul(ft,Xt)|0,f=f+Math.imul(st,Yt)|0,E=E+Math.imul(st,Xt)|0,y=y+Math.imul($,Jt)|0,f=f+Math.imul($,Qt)|0,f=f+Math.imul(Y,Jt)|0,E=E+Math.imul(Y,Qt)|0;var Vr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Vr>>>26)|0,Vr&=67108863,y=Math.imul(h,lt),f=Math.imul(h,ht),f=f+Math.imul(b,lt)|0,E=Math.imul(b,ht),y=y+Math.imul(Nt,at)|0,f=f+Math.imul(Nt,zt)|0,f=f+Math.imul(g,at)|0,E=E+Math.imul(g,zt)|0,y=y+Math.imul(kt,Kt)|0,f=f+Math.imul(kt,$t)|0,f=f+Math.imul(Ft,Kt)|0,E=E+Math.imul(Ft,$t)|0,y=y+Math.imul(Mt,Ht)|0,f=f+Math.imul(Mt,Vt)|0,f=f+Math.imul(_t,Ht)|0,E=E+Math.imul(_t,Vt)|0,y=y+Math.imul(It,jt)|0,f=f+Math.imul(It,Wt)|0,f=f+Math.imul(Ut,jt)|0,E=E+Math.imul(Ut,Wt)|0,y=y+Math.imul(St,Gt)|0,f=f+Math.imul(St,Zt)|0,f=f+Math.imul(Lt,Gt)|0,E=E+Math.imul(Lt,Zt)|0,y=y+Math.imul(xt,Yt)|0,f=f+Math.imul(xt,Xt)|0,f=f+Math.imul(Et,Yt)|0,E=E+Math.imul(Et,Xt)|0,y=y+Math.imul(ft,Jt)|0,f=f+Math.imul(ft,Qt)|0,f=f+Math.imul(st,Jt)|0,E=E+Math.imul(st,Qt)|0,y=y+Math.imul($,te)|0,f=f+Math.imul($,ee)|0,f=f+Math.imul(Y,te)|0,E=E+Math.imul(Y,ee)|0;var jr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(jr>>>26)|0,jr&=67108863,y=Math.imul(L,lt),f=Math.imul(L,ht),f=f+Math.imul(P,lt)|0,E=Math.imul(P,ht),y=y+Math.imul(h,at)|0,f=f+Math.imul(h,zt)|0,f=f+Math.imul(b,at)|0,E=E+Math.imul(b,zt)|0,y=y+Math.imul(Nt,Kt)|0,f=f+Math.imul(Nt,$t)|0,f=f+Math.imul(g,Kt)|0,E=E+Math.imul(g,$t)|0,y=y+Math.imul(kt,Ht)|0,f=f+Math.imul(kt,Vt)|0,f=f+Math.imul(Ft,Ht)|0,E=E+Math.imul(Ft,Vt)|0,y=y+Math.imul(Mt,jt)|0,f=f+Math.imul(Mt,Wt)|0,f=f+Math.imul(_t,jt)|0,E=E+Math.imul(_t,Wt)|0,y=y+Math.imul(It,Gt)|0,f=f+Math.imul(It,Zt)|0,f=f+Math.imul(Ut,Gt)|0,E=E+Math.imul(Ut,Zt)|0,y=y+Math.imul(St,Yt)|0,f=f+Math.imul(St,Xt)|0,f=f+Math.imul(Lt,Yt)|0,E=E+Math.imul(Lt,Xt)|0,y=y+Math.imul(xt,Jt)|0,f=f+Math.imul(xt,Qt)|0,f=f+Math.imul(Et,Jt)|0,E=E+Math.imul(Et,Qt)|0,y=y+Math.imul(ft,te)|0,f=f+Math.imul(ft,ee)|0,f=f+Math.imul(st,te)|0,E=E+Math.imul(st,ee)|0,y=y+Math.imul($,ne)|0,f=f+Math.imul($,re)|0,f=f+Math.imul(Y,ne)|0,E=E+Math.imul(Y,re)|0;var Wr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,y=Math.imul(L,at),f=Math.imul(L,zt),f=f+Math.imul(P,at)|0,E=Math.imul(P,zt),y=y+Math.imul(h,Kt)|0,f=f+Math.imul(h,$t)|0,f=f+Math.imul(b,Kt)|0,E=E+Math.imul(b,$t)|0,y=y+Math.imul(Nt,Ht)|0,f=f+Math.imul(Nt,Vt)|0,f=f+Math.imul(g,Ht)|0,E=E+Math.imul(g,Vt)|0,y=y+Math.imul(kt,jt)|0,f=f+Math.imul(kt,Wt)|0,f=f+Math.imul(Ft,jt)|0,E=E+Math.imul(Ft,Wt)|0,y=y+Math.imul(Mt,Gt)|0,f=f+Math.imul(Mt,Zt)|0,f=f+Math.imul(_t,Gt)|0,E=E+Math.imul(_t,Zt)|0,y=y+Math.imul(It,Yt)|0,f=f+Math.imul(It,Xt)|0,f=f+Math.imul(Ut,Yt)|0,E=E+Math.imul(Ut,Xt)|0,y=y+Math.imul(St,Jt)|0,f=f+Math.imul(St,Qt)|0,f=f+Math.imul(Lt,Jt)|0,E=E+Math.imul(Lt,Qt)|0,y=y+Math.imul(xt,te)|0,f=f+Math.imul(xt,ee)|0,f=f+Math.imul(Et,te)|0,E=E+Math.imul(Et,ee)|0,y=y+Math.imul(ft,ne)|0,f=f+Math.imul(ft,re)|0,f=f+Math.imul(st,ne)|0,E=E+Math.imul(st,re)|0;var Gr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,y=Math.imul(L,Kt),f=Math.imul(L,$t),f=f+Math.imul(P,Kt)|0,E=Math.imul(P,$t),y=y+Math.imul(h,Ht)|0,f=f+Math.imul(h,Vt)|0,f=f+Math.imul(b,Ht)|0,E=E+Math.imul(b,Vt)|0,y=y+Math.imul(Nt,jt)|0,f=f+Math.imul(Nt,Wt)|0,f=f+Math.imul(g,jt)|0,E=E+Math.imul(g,Wt)|0,y=y+Math.imul(kt,Gt)|0,f=f+Math.imul(kt,Zt)|0,f=f+Math.imul(Ft,Gt)|0,E=E+Math.imul(Ft,Zt)|0,y=y+Math.imul(Mt,Yt)|0,f=f+Math.imul(Mt,Xt)|0,f=f+Math.imul(_t,Yt)|0,E=E+Math.imul(_t,Xt)|0,y=y+Math.imul(It,Jt)|0,f=f+Math.imul(It,Qt)|0,f=f+Math.imul(Ut,Jt)|0,E=E+Math.imul(Ut,Qt)|0,y=y+Math.imul(St,te)|0,f=f+Math.imul(St,ee)|0,f=f+Math.imul(Lt,te)|0,E=E+Math.imul(Lt,ee)|0,y=y+Math.imul(xt,ne)|0,f=f+Math.imul(xt,re)|0,f=f+Math.imul(Et,ne)|0,E=E+Math.imul(Et,re)|0;var Zr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,y=Math.imul(L,Ht),f=Math.imul(L,Vt),f=f+Math.imul(P,Ht)|0,E=Math.imul(P,Vt),y=y+Math.imul(h,jt)|0,f=f+Math.imul(h,Wt)|0,f=f+Math.imul(b,jt)|0,E=E+Math.imul(b,Wt)|0,y=y+Math.imul(Nt,Gt)|0,f=f+Math.imul(Nt,Zt)|0,f=f+Math.imul(g,Gt)|0,E=E+Math.imul(g,Zt)|0,y=y+Math.imul(kt,Yt)|0,f=f+Math.imul(kt,Xt)|0,f=f+Math.imul(Ft,Yt)|0,E=E+Math.imul(Ft,Xt)|0,y=y+Math.imul(Mt,Jt)|0,f=f+Math.imul(Mt,Qt)|0,f=f+Math.imul(_t,Jt)|0,E=E+Math.imul(_t,Qt)|0,y=y+Math.imul(It,te)|0,f=f+Math.imul(It,ee)|0,f=f+Math.imul(Ut,te)|0,E=E+Math.imul(Ut,ee)|0,y=y+Math.imul(St,ne)|0,f=f+Math.imul(St,re)|0,f=f+Math.imul(Lt,ne)|0,E=E+Math.imul(Lt,re)|0;var Yr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,y=Math.imul(L,jt),f=Math.imul(L,Wt),f=f+Math.imul(P,jt)|0,E=Math.imul(P,Wt),y=y+Math.imul(h,Gt)|0,f=f+Math.imul(h,Zt)|0,f=f+Math.imul(b,Gt)|0,E=E+Math.imul(b,Zt)|0,y=y+Math.imul(Nt,Yt)|0,f=f+Math.imul(Nt,Xt)|0,f=f+Math.imul(g,Yt)|0,E=E+Math.imul(g,Xt)|0,y=y+Math.imul(kt,Jt)|0,f=f+Math.imul(kt,Qt)|0,f=f+Math.imul(Ft,Jt)|0,E=E+Math.imul(Ft,Qt)|0,y=y+Math.imul(Mt,te)|0,f=f+Math.imul(Mt,ee)|0,f=f+Math.imul(_t,te)|0,E=E+Math.imul(_t,ee)|0,y=y+Math.imul(It,ne)|0,f=f+Math.imul(It,re)|0,f=f+Math.imul(Ut,ne)|0,E=E+Math.imul(Ut,re)|0;var Xr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,y=Math.imul(L,Gt),f=Math.imul(L,Zt),f=f+Math.imul(P,Gt)|0,E=Math.imul(P,Zt),y=y+Math.imul(h,Yt)|0,f=f+Math.imul(h,Xt)|0,f=f+Math.imul(b,Yt)|0,E=E+Math.imul(b,Xt)|0,y=y+Math.imul(Nt,Jt)|0,f=f+Math.imul(Nt,Qt)|0,f=f+Math.imul(g,Jt)|0,E=E+Math.imul(g,Qt)|0,y=y+Math.imul(kt,te)|0,f=f+Math.imul(kt,ee)|0,f=f+Math.imul(Ft,te)|0,E=E+Math.imul(Ft,ee)|0,y=y+Math.imul(Mt,ne)|0,f=f+Math.imul(Mt,re)|0,f=f+Math.imul(_t,ne)|0,E=E+Math.imul(_t,re)|0;var Jr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Jr>>>26)|0,Jr&=67108863,y=Math.imul(L,Yt),f=Math.imul(L,Xt),f=f+Math.imul(P,Yt)|0,E=Math.imul(P,Xt),y=y+Math.imul(h,Jt)|0,f=f+Math.imul(h,Qt)|0,f=f+Math.imul(b,Jt)|0,E=E+Math.imul(b,Qt)|0,y=y+Math.imul(Nt,te)|0,f=f+Math.imul(Nt,ee)|0,f=f+Math.imul(g,te)|0,E=E+Math.imul(g,ee)|0,y=y+Math.imul(kt,ne)|0,f=f+Math.imul(kt,re)|0,f=f+Math.imul(Ft,ne)|0,E=E+Math.imul(Ft,re)|0;var Qr=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(Qr>>>26)|0,Qr&=67108863,y=Math.imul(L,Jt),f=Math.imul(L,Qt),f=f+Math.imul(P,Jt)|0,E=Math.imul(P,Qt),y=y+Math.imul(h,te)|0,f=f+Math.imul(h,ee)|0,f=f+Math.imul(b,te)|0,E=E+Math.imul(b,ee)|0,y=y+Math.imul(Nt,ne)|0,f=f+Math.imul(Nt,re)|0,f=f+Math.imul(g,ne)|0,E=E+Math.imul(g,re)|0;var ti=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(ti>>>26)|0,ti&=67108863,y=Math.imul(L,te),f=Math.imul(L,ee),f=f+Math.imul(P,te)|0,E=Math.imul(P,ee),y=y+Math.imul(h,ne)|0,f=f+Math.imul(h,re)|0,f=f+Math.imul(b,ne)|0,E=E+Math.imul(b,re)|0;var ei=(k+y|0)+((f&8191)<<13)|0;k=(E+(f>>>13)|0)+(ei>>>26)|0,ei&=67108863,y=Math.imul(L,ne),f=Math.imul(L,re),f=f+Math.imul(P,ne)|0,E=Math.imul(P,re);var ni=(k+y|0)+((f&8191)<<13)|0;return k=(E+(f>>>13)|0)+(ni>>>26)|0,ni&=67108863,S[0]=Pr,S[1]=qr,S[2]=Dr,S[3]=zr,S[4]=Kr,S[5]=$r,S[6]=Hr,S[7]=Vr,S[8]=jr,S[9]=Wr,S[10]=Gr,S[11]=Zr,S[12]=Yr,S[13]=Xr,S[14]=Jr,S[15]=Qr,S[16]=ti,S[17]=ei,S[18]=ni,k!==0&&(S[19]=k,p.length++),p};Math.imul||(z=F);function O(m,a,l){l.negative=a.negative^m.negative,l.length=m.length+a.length;for(var p=0,w=0,x=0;x<l.length-1;x++){var S=w;w=0;for(var k=p&67108863,y=Math.min(x,a.length-1),f=Math.max(0,x-m.length+1);f<=y;f++){var E=x-f,V=m.words[E]|0,$=a.words[f]|0,Y=V*$,mt=Y&67108863;S=S+(Y/67108864|0)|0,mt=mt+k|0,k=mt&67108863,S=S+(mt>>>26)|0,w+=S>>>26,S&=67108863}l.words[x]=k,p=S,S=w}return p!==0?l.words[x]=p:l.length--,l._strip()}function G(m,a,l){return O(m,a,l)}i.prototype.mulTo=function(a,l){var p,w=this.length+a.length;return this.length===10&&a.length===10?p=z(this,a,l):w<63?p=F(this,a,l):w<1024?p=O(this,a,l):p=G(this,a,l),p},i.prototype.mul=function(a){var l=new i(null);return l.words=new Array(this.length+a.length),this.mulTo(a,l)},i.prototype.mulf=function(a){var l=new i(null);return l.words=new Array(this.length+a.length),G(this,a,l)},i.prototype.imul=function(a){return this.clone().mulTo(a,this)},i.prototype.imuln=function(a){var l=a<0;l&&(a=-a),n(typeof a=="number"),n(a<67108864);for(var p=0,w=0;w<this.length;w++){var x=(this.words[w]|0)*a,S=(x&67108863)+(p&67108863);p>>=26,p+=x/67108864|0,p+=S>>>26,this.words[w]=S&67108863}return p!==0&&(this.words[w]=p,this.length++),this.length=a===0?1:this.length,l?this.ineg():this},i.prototype.muln=function(a){return this.clone().imuln(a)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(a){var l=C(a);if(l.length===0)return new i(1);for(var p=this,w=0;w<l.length&&l[w]===0;w++,p=p.sqr());if(++w<l.length)for(var x=p.sqr();w<l.length;w++,x=x.sqr())l[w]!==0&&(p=p.mul(x));return p},i.prototype.iushln=function(a){n(typeof a=="number"&&a>=0);var l=a%26,p=(a-l)/26,w=67108863>>>26-l<<26-l,x;if(l!==0){var S=0;for(x=0;x<this.length;x++){var k=this.words[x]&w,y=(this.words[x]|0)-k<<l;this.words[x]=y|S,S=k>>>26-l}S&&(this.words[x]=S,this.length++)}if(p!==0){for(x=this.length-1;x>=0;x--)this.words[x+p]=this.words[x];for(x=0;x<p;x++)this.words[x]=0;this.length+=p}return this._strip()},i.prototype.ishln=function(a){return n(this.negative===0),this.iushln(a)},i.prototype.iushrn=function(a,l,p){n(typeof a=="number"&&a>=0);var w;l?w=(l-l%26)/26:w=0;var x=a%26,S=Math.min((a-x)/26,this.length),k=67108863^67108863>>>x<<x,y=p;if(w-=S,w=Math.max(0,w),y){for(var f=0;f<S;f++)y.words[f]=this.words[f];y.length=S}if(S!==0)if(this.length>S)for(this.length-=S,f=0;f<this.length;f++)this.words[f]=this.words[f+S];else this.words[0]=0,this.length=1;var E=0;for(f=this.length-1;f>=0&&(E!==0||f>=w);f--){var V=this.words[f]|0;this.words[f]=E<<26-x|V>>>x,E=V&k}return y&&E!==0&&(y.words[y.length++]=E),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(a,l,p){return n(this.negative===0),this.iushrn(a,l,p)},i.prototype.shln=function(a){return this.clone().ishln(a)},i.prototype.ushln=function(a){return this.clone().iushln(a)},i.prototype.shrn=function(a){return this.clone().ishrn(a)},i.prototype.ushrn=function(a){return this.clone().iushrn(a)},i.prototype.testn=function(a){n(typeof a=="number"&&a>=0);var l=a%26,p=(a-l)/26,w=1<<l;if(this.length<=p)return!1;var x=this.words[p];return!!(x&w)},i.prototype.imaskn=function(a){n(typeof a=="number"&&a>=0);var l=a%26,p=(a-l)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(l!==0&&p++,this.length=Math.min(p,this.length),l!==0){var w=67108863^67108863>>>l<<l;this.words[this.length-1]&=w}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(a){return this.clone().imaskn(a)},i.prototype.iaddn=function(a){return n(typeof a=="number"),n(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},i.prototype._iaddn=function(a){this.words[0]+=a;for(var l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},i.prototype.isubn=function(a){if(n(typeof a=="number"),n(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+1]-=1;return this._strip()},i.prototype.addn=function(a){return this.clone().iaddn(a)},i.prototype.subn=function(a){return this.clone().isubn(a)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(a,l,p){var w=a.length+p,x;this._expand(w);var S,k=0;for(x=0;x<a.length;x++){S=(this.words[x+p]|0)+k;var y=(a.words[x]|0)*l;S-=y&67108863,k=(S>>26)-(y/67108864|0),this.words[x+p]=S&67108863}for(;x<this.length-p;x++)S=(this.words[x+p]|0)+k,k=S>>26,this.words[x+p]=S&67108863;if(k===0)return this._strip();for(n(k===-1),k=0,x=0;x<this.length;x++)S=-(this.words[x]|0)+k,k=S>>26,this.words[x]=S&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(a,l){var p=this.length-a.length,w=this.clone(),x=a,S=x.words[x.length-1]|0,k=this._countBits(S);p=26-k,p!==0&&(x=x.ushln(p),w.iushln(p),S=x.words[x.length-1]|0);var y=w.length-x.length,f;if(l!=="mod"){f=new i(null),f.length=y+1,f.words=new Array(f.length);for(var E=0;E<f.length;E++)f.words[E]=0}var V=w.clone()._ishlnsubmul(x,1,y);V.negative===0&&(w=V,f&&(f.words[y]=1));for(var $=y-1;$>=0;$--){var Y=(w.words[x.length+$]|0)*67108864+(w.words[x.length+$-1]|0);for(Y=Math.min(Y/S|0,67108863),w._ishlnsubmul(x,Y,$);w.negative!==0;)Y--,w.negative=0,w._ishlnsubmul(x,1,$),w.isZero()||(w.negative^=1);f&&(f.words[$]=Y)}return f&&f._strip(),w._strip(),l!=="div"&&p!==0&&w.iushrn(p),{div:f||null,mod:w}},i.prototype.divmod=function(a,l,p){if(n(!a.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var w,x,S;return this.negative!==0&&a.negative===0?(S=this.neg().divmod(a,l),l!=="mod"&&(w=S.div.neg()),l!=="div"&&(x=S.mod.neg(),p&&x.negative!==0&&x.iadd(a)),{div:w,mod:x}):this.negative===0&&a.negative!==0?(S=this.divmod(a.neg(),l),l!=="mod"&&(w=S.div.neg()),{div:w,mod:S.mod}):this.negative&a.negative?(S=this.neg().divmod(a.neg(),l),l!=="div"&&(x=S.mod.neg(),p&&x.negative!==0&&x.isub(a)),{div:S.div,mod:x}):a.length>this.length||this.cmp(a)<0?{div:new i(0),mod:this}:a.length===1?l==="div"?{div:this.divn(a.words[0]),mod:null}:l==="mod"?{div:null,mod:new i(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new i(this.modrn(a.words[0]))}:this._wordDiv(a,l)},i.prototype.div=function(a){return this.divmod(a,"div",!1).div},i.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},i.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},i.prototype.divRound=function(a){var l=this.divmod(a);if(l.mod.isZero())return l.div;var p=l.div.negative!==0?l.mod.isub(a):l.mod,w=a.ushrn(1),x=a.andln(1),S=p.cmp(w);return S<0||x===1&&S===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},i.prototype.modrn=function(a){var l=a<0;l&&(a=-a),n(a<=67108863);for(var p=(1<<26)%a,w=0,x=this.length-1;x>=0;x--)w=(p*w+(this.words[x]|0))%a;return l?-w:w},i.prototype.modn=function(a){return this.modrn(a)},i.prototype.idivn=function(a){var l=a<0;l&&(a=-a),n(a<=67108863);for(var p=0,w=this.length-1;w>=0;w--){var x=(this.words[w]|0)+p*67108864;this.words[w]=x/a|0,p=x%a}return this._strip(),l?this.ineg():this},i.prototype.divn=function(a){return this.clone().idivn(a)},i.prototype.egcd=function(a){n(a.negative===0),n(!a.isZero());var l=this,p=a.clone();l.negative!==0?l=l.umod(a):l=l.clone();for(var w=new i(1),x=new i(0),S=new i(0),k=new i(1),y=0;l.isEven()&&p.isEven();)l.iushrn(1),p.iushrn(1),++y;for(var f=p.clone(),E=l.clone();!l.isZero();){for(var V=0,$=1;!(l.words[0]&$)&&V<26;++V,$<<=1);if(V>0)for(l.iushrn(V);V-- >0;)(w.isOdd()||x.isOdd())&&(w.iadd(f),x.isub(E)),w.iushrn(1),x.iushrn(1);for(var Y=0,mt=1;!(p.words[0]&mt)&&Y<26;++Y,mt<<=1);if(Y>0)for(p.iushrn(Y);Y-- >0;)(S.isOdd()||k.isOdd())&&(S.iadd(f),k.isub(E)),S.iushrn(1),k.iushrn(1);l.cmp(p)>=0?(l.isub(p),w.isub(S),x.isub(k)):(p.isub(l),S.isub(w),k.isub(x))}return{a:S,b:k,gcd:p.iushln(y)}},i.prototype._invmp=function(a){n(a.negative===0),n(!a.isZero());var l=this,p=a.clone();l.negative!==0?l=l.umod(a):l=l.clone();for(var w=new i(1),x=new i(0),S=p.clone();l.cmpn(1)>0&&p.cmpn(1)>0;){for(var k=0,y=1;!(l.words[0]&y)&&k<26;++k,y<<=1);if(k>0)for(l.iushrn(k);k-- >0;)w.isOdd()&&w.iadd(S),w.iushrn(1);for(var f=0,E=1;!(p.words[0]&E)&&f<26;++f,E<<=1);if(f>0)for(p.iushrn(f);f-- >0;)x.isOdd()&&x.iadd(S),x.iushrn(1);l.cmp(p)>=0?(l.isub(p),w.isub(x)):(p.isub(l),x.isub(w))}var V;return l.cmpn(1)===0?V=w:V=x,V.cmpn(0)<0&&V.iadd(a),V},i.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var l=this.clone(),p=a.clone();l.negative=0,p.negative=0;for(var w=0;l.isEven()&&p.isEven();w++)l.iushrn(1),p.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;p.isEven();)p.iushrn(1);var x=l.cmp(p);if(x<0){var S=l;l=p,p=S}else if(x===0||p.cmpn(1)===0)break;l.isub(p)}while(!0);return p.iushln(w)},i.prototype.invm=function(a){return this.egcd(a).a.umod(a)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(a){return this.words[0]&a},i.prototype.bincn=function(a){n(typeof a=="number");var l=a%26,p=(a-l)/26,w=1<<l;if(this.length<=p)return this._expand(p+1),this.words[p]|=w,this;for(var x=w,S=p;x!==0&&S<this.length;S++){var k=this.words[S]|0;k+=x,x=k>>>26,k&=67108863,this.words[S]=k}return x!==0&&(this.words[S]=x,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(a){var l=a<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this._strip();var p;if(this.length>1)p=1;else{l&&(a=-a),n(a<=67108863,"Number is too big");var w=this.words[0]|0;p=w===a?0:w<a?-1:1}return this.negative!==0?-p|0:p},i.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var l=this.ucmp(a);return this.negative!==0?-l|0:l},i.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var l=0,p=this.length-1;p>=0;p--){var w=this.words[p]|0,x=a.words[p]|0;if(w!==x){w<x?l=-1:w>x&&(l=1);break}}return l},i.prototype.gtn=function(a){return this.cmpn(a)===1},i.prototype.gt=function(a){return this.cmp(a)===1},i.prototype.gten=function(a){return this.cmpn(a)>=0},i.prototype.gte=function(a){return this.cmp(a)>=0},i.prototype.ltn=function(a){return this.cmpn(a)===-1},i.prototype.lt=function(a){return this.cmp(a)===-1},i.prototype.lten=function(a){return this.cmpn(a)<=0},i.prototype.lte=function(a){return this.cmp(a)<=0},i.prototype.eqn=function(a){return this.cmpn(a)===0},i.prototype.eq=function(a){return this.cmp(a)===0},i.red=function(a){return new Z(a)},i.prototype.toRed=function(a){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},i.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(a){return this.red=a,this},i.prototype.forceRed=function(a){return n(!this.red,"Already a number in reduction context"),this._forceRed(a)},i.prototype.redAdd=function(a){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},i.prototype.redIAdd=function(a){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},i.prototype.redSub=function(a){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},i.prototype.redISub=function(a){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},i.prototype.redShl=function(a){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},i.prototype.redMul=function(a){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},i.prototype.redIMul=function(a){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},i.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(a){return n(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var J={k256:null,p224:null,p192:null,p25519:null};function nt(m,a){this.name=m,this.p=new i(a,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}nt.prototype._tmp=function(){var a=new i(null);return a.words=new Array(Math.ceil(this.n/13)),a},nt.prototype.ireduce=function(a){var l=a,p;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),p=l.bitLength();while(p>this.n);var w=p<this.n?-1:l.ucmp(this.p);return w===0?(l.words[0]=0,l.length=1):w>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},nt.prototype.split=function(a,l){a.iushrn(this.n,0,l)},nt.prototype.imulK=function(a){return a.imul(this.k)};function ut(){nt.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(ut,nt),ut.prototype.split=function(a,l){for(var p=4194303,w=Math.min(a.length,9),x=0;x<w;x++)l.words[x]=a.words[x];if(l.length=w,a.length<=9){a.words[0]=0,a.length=1;return}var S=a.words[9];for(l.words[l.length++]=S&p,x=10;x<a.length;x++){var k=a.words[x]|0;a.words[x-10]=(k&p)<<4|S>>>22,S=k}S>>>=22,a.words[x-10]=S,S===0&&a.length>10?a.length-=10:a.length-=9},ut.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var l=0,p=0;p<a.length;p++){var w=a.words[p]|0;l+=w*977,a.words[p]=l&67108863,l=w*64+(l/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function ot(){nt.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(ot,nt);function q(){nt.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(q,nt);function Q(){nt.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(Q,nt),Q.prototype.imulK=function(a){for(var l=0,p=0;p<a.length;p++){var w=(a.words[p]|0)*19+l,x=w&67108863;w>>>=26,a.words[p]=x,l=w}return l!==0&&(a.words[a.length++]=l),a},i._prime=function(a){if(J[a])return J[a];var l;if(a==="k256")l=new ut;else if(a==="p224")l=new ot;else if(a==="p192")l=new q;else if(a==="p25519")l=new Q;else throw new Error("Unknown prime "+a);return J[a]=l,l};function Z(m){if(typeof m=="string"){var a=i._prime(m);this.m=a.p,this.prime=a}else n(m.gtn(1),"modulus must be greater than 1"),this.m=m,this.prime=null}Z.prototype._verify1=function(a){n(a.negative===0,"red works only with positives"),n(a.red,"red works only with red numbers")},Z.prototype._verify2=function(a,l){n((a.negative|l.negative)===0,"red works only with positives"),n(a.red&&a.red===l.red,"red works only with red numbers")},Z.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(_(a,a.umod(this.m)._forceRed(this)),a)},Z.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},Z.prototype.add=function(a,l){this._verify2(a,l);var p=a.add(l);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},Z.prototype.iadd=function(a,l){this._verify2(a,l);var p=a.iadd(l);return p.cmp(this.m)>=0&&p.isub(this.m),p},Z.prototype.sub=function(a,l){this._verify2(a,l);var p=a.sub(l);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},Z.prototype.isub=function(a,l){this._verify2(a,l);var p=a.isub(l);return p.cmpn(0)<0&&p.iadd(this.m),p},Z.prototype.shl=function(a,l){return this._verify1(a),this.imod(a.ushln(l))},Z.prototype.imul=function(a,l){return this._verify2(a,l),this.imod(a.imul(l))},Z.prototype.mul=function(a,l){return this._verify2(a,l),this.imod(a.mul(l))},Z.prototype.isqr=function(a){return this.imul(a,a.clone())},Z.prototype.sqr=function(a){return this.mul(a,a)},Z.prototype.sqrt=function(a){if(a.isZero())return a.clone();var l=this.m.andln(3);if(n(l%2===1),l===3){var p=this.m.add(new i(1)).iushrn(2);return this.pow(a,p)}for(var w=this.m.subn(1),x=0;!w.isZero()&&w.andln(1)===0;)x++,w.iushrn(1);n(!w.isZero());var S=new i(1).toRed(this),k=S.redNeg(),y=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);this.pow(f,y).cmp(k)!==0;)f.redIAdd(k);for(var E=this.pow(f,w),V=this.pow(a,w.addn(1).iushrn(1)),$=this.pow(a,w),Y=x;$.cmp(S)!==0;){for(var mt=$,ft=0;mt.cmp(S)!==0;ft++)mt=mt.redSqr();n(ft<Y);var st=this.pow(E,new i(1).iushln(Y-ft-1));V=V.redMul(st),E=st.redSqr(),$=$.redMul(E),Y=ft}return V},Z.prototype.invm=function(a){var l=a._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},Z.prototype.pow=function(a,l){if(l.isZero())return new i(1).toRed(this);if(l.cmpn(1)===0)return a.clone();var p=4,w=new Array(1<<p);w[0]=new i(1).toRed(this),w[1]=a;for(var x=2;x<w.length;x++)w[x]=this.mul(w[x-1],a);var S=w[0],k=0,y=0,f=l.bitLength()%26;for(f===0&&(f=26),x=l.length-1;x>=0;x--){for(var E=l.words[x],V=f-1;V>=0;V--){var $=E>>V&1;if(S!==w[0]&&(S=this.sqr(S)),$===0&&k===0){y=0;continue}k<<=1,k|=$,y++,!(y!==p&&(x!==0||V!==0))&&(S=this.mul(S,w[k]),y=0,k=0)}f=26}return S},Z.prototype.convertTo=function(a){var l=a.umod(this.m);return l===a?l.clone():l},Z.prototype.convertFrom=function(a){var l=a.clone();return l.red=null,l},i.mont=function(a){return new X(a)};function X(m){Z.call(this,m),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}s(X,Z),X.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},X.prototype.convertFrom=function(a){var l=this.imod(a.mul(this.rinv));return l.red=null,l},X.prototype.imul=function(a,l){if(a.isZero()||l.isZero())return a.words[0]=0,a.length=1,a;var p=a.imul(l),w=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=p.isub(w).iushrn(this.shift),S=x;return x.cmp(this.m)>=0?S=x.isub(this.m):x.cmpn(0)<0&&(S=x.iadd(this.m)),S._forceRed(this)},X.prototype.mul=function(a,l){if(a.isZero()||l.isZero())return new i(0)._forceRed(this);var p=a.mul(l),w=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=p.isub(w).iushrn(this.shift),S=x;return x.cmp(this.m)>=0?S=x.isub(this.m):x.cmpn(0)<0&&(S=x.iadd(this.m)),S._forceRed(this)},X.prototype.invm=function(a){var l=this.imod(a._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(r,Ne)})(Di);var yo=Di.exports;const Bs=Ar(yo);var _i={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,t){var e=dt,n=e.Buffer;function s(o,c){for(var d in o)c[d]=o[d]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?r.exports=e:(s(e,t),t.Buffer=i);function i(o,c,d){return n(o,c,d)}i.prototype=Object.create(n.prototype),s(n,i),i.from=function(o,c,d){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,c,d)},i.alloc=function(o,c,d){if(typeof o!="number")throw new TypeError("Argument must be a number");var v=n(o);return c!==void 0?typeof d=="string"?v.fill(c,d):v.fill(c):v.fill(0),v},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(_i,_i.exports);var Uc=_i.exports,cr=Uc.Buffer;function Fc(r){if(r.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<r.length;n++){var s=r.charAt(n),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=n}var o=r.length,c=r.charAt(0),d=Math.log(o)/Math.log(256),v=Math.log(256)/Math.log(o);function _(B){if((Array.isArray(B)||B instanceof Uint8Array)&&(B=cr.from(B)),!cr.isBuffer(B))throw new TypeError("Expected Buffer");if(B.length===0)return"";for(var M=0,T=0,C=0,F=B.length;C!==F&&B[C]===0;)C++,M++;for(var z=(F-C)*v+1>>>0,O=new Uint8Array(z);C!==F;){for(var G=B[C],J=0,nt=z-1;(G!==0||J<T)&&nt!==-1;nt--,J++)G+=256*O[nt]>>>0,O[nt]=G%o>>>0,G=G/o>>>0;if(G!==0)throw new Error("Non-zero carry");T=J,C++}for(var ut=z-T;ut!==z&&O[ut]===0;)ut++;for(var ot=c.repeat(M);ut<z;++ut)ot+=r.charAt(O[ut]);return ot}function I(B){if(typeof B!="string")throw new TypeError("Expected String");if(B.length===0)return cr.alloc(0);for(var M=0,T=0,C=0;B[M]===c;)T++,M++;for(var F=(B.length-M)*d+1>>>0,z=new Uint8Array(F);M<B.length;){var O=B.charCodeAt(M);if(O>255)return;var G=t[O];if(G===255)return;for(var J=0,nt=F-1;(G!==0||J<C)&&nt!==-1;nt--,J++)G+=o*z[nt]>>>0,z[nt]=G%256>>>0,G=G/256>>>0;if(G!==0)throw new Error("Non-zero carry");C=J,M++}for(var ut=F-C;ut!==F&&z[ut]===0;)ut++;var ot=cr.allocUnsafe(T+(F-ut));ot.fill(0,0,T);for(var q=T;ut!==F;)ot[q++]=z[ut++];return ot}function A(B){var M=I(B);if(M)return M;throw new Error("Non-base"+o+" character")}return{encode:_,decodeUnsafe:I,decode:A}}var Nc=Fc,Oc=Nc,Pc="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",wo=Oc(Pc);const he=Ar(wo),_s=Zs;var fe={};function Ge(r,t,e){return t<=r&&r<=e}function Mr(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function qc(r){for(var t=String(r),e=t.length,n=0,s=[];n<e;){var i=t.charCodeAt(n);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(n===e-1)s.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var c=i&1023,d=o&1023;s.push(65536+(c<<10)+d),n+=1}else s.push(65533)}n+=1}return s}function Dc(r){for(var t="",e=0;e<r.length;++e){var n=r[e];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return t}var yr=-1;function zi(r){this.tokens=[].slice.call(r)}zi.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():yr},prepend:function(r){if(Array.isArray(r))for(var t=r;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var t=r;t.length;)this.tokens.push(t.shift());else this.tokens.push(r)}};var On=-1;function fi(r,t){if(r)throw TypeError("Decoder error");return t||65533}var wr="utf-8";function br(r,t){if(!(this instanceof br))return new br(r,t);if(r=r!==void 0?String(r).toLowerCase():wr,r!==wr)throw new Error("Encoding not supported. Only utf-8 is supported");t=Mr(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})}br.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=Mr(e),this._streaming||(this._decoder=new zc({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new zi(n),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==On);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===On)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),Dc(i)}};function vr(r,t){if(!(this instanceof vr))return new vr(r,t);if(r=r!==void 0?String(r).toLowerCase():wr,r!==wr)throw new Error("Encoding not supported. Only utf-8 is supported");t=Mr(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}vr.prototype={encode:function(t,e){t=t?String(t):"",e=Mr(e),this._streaming||(this._encoder=new Kc(this._options)),this._streaming=!!e.stream;for(var n=[],s=new zi(qc(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==On);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==On;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}};function zc(r){var t=r.fatal,e=0,n=0,s=0,i=128,o=191;this.handler=function(c,d){if(d===yr&&s!==0)return s=0,fi(t);if(d===yr)return On;if(s===0){if(Ge(d,0,127))return d;if(Ge(d,194,223))s=1,e=d-192;else if(Ge(d,224,239))d===224&&(i=160),d===237&&(o=159),s=2,e=d-224;else if(Ge(d,240,244))d===240&&(i=144),d===244&&(o=143),s=3,e=d-240;else return fi(t);return e=e<<6*s,null}if(!Ge(d,i,o))return e=s=n=0,i=128,o=191,c.prepend(d),fi(t);if(i=128,o=191,n+=1,e+=d-128<<6*(s-n),n!==s)return null;var v=e;return e=s=n=0,v}}function Kc(r){r.fatal,this.handler=function(t,e){if(e===yr)return On;if(Ge(e,0,127))return e;var n,s;Ge(e,128,2047)?(n=1,s=192):Ge(e,2048,65535)?(n=2,s=224):Ge(e,65536,1114111)&&(n=3,s=240);for(var i=[(e>>6*n)+s];n>0;){var o=e>>6*(n-1);i.push(128|o&63),n-=1}return i}}const $c=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:br,TextEncoder:vr},Symbol.toStringTag,{value:"Module"})),Hc=Ci($c);var Vc=Ne&&Ne.__createBinding||(Object.create?function(r,t,e,n){n===void 0&&(n=e),Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[e]}})}:function(r,t,e,n){n===void 0&&(n=e),r[n]=t[e]}),jc=Ne&&Ne.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),Ke=Ne&&Ne.__decorate||function(r,t,e,n){var s=arguments.length,i=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,t,e,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(i=(s<3?o(i):s>3?o(t,e,i):o(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i},Wc=Ne&&Ne.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)e!=="default"&&Object.hasOwnProperty.call(r,e)&&Vc(t,r,e);return jc(t,r),t},bo=Ne&&Ne.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(fe,"__esModule",{value:!0});var vo=fe.deserializeUnchecked=Ao=fe.deserialize=_o=fe.serialize=fe.BinaryReader=fe.BinaryWriter=fe.BorshError=fe.baseDecode=fe.baseEncode=void 0;const sn=bo(yo),xo=bo(wo),Gc=Wc(Hc),Zc=typeof TextDecoder!="function"?Gc.TextDecoder:TextDecoder,Yc=new Zc("utf-8",{fatal:!0});function Xc(r){return typeof r=="string"&&(r=Buffer.from(r,"utf8")),xo.default.encode(Buffer.from(r))}fe.baseEncode=Xc;function Jc(r){return Buffer.from(xo.default.decode(r))}fe.baseDecode=Jc;const hi=1024;class we 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(".")}}fe.BorshError=we;class Eo{constructor(){this.buf=Buffer.alloc(hi),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(hi)]))}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 sn.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new sn.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new sn.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new sn.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(hi)]),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)}}fe.BinaryWriter=Eo;function $e(r,t,e){const n=e.value;e.value=function(...s){try{return n.apply(this,s)}catch(i){if(i instanceof RangeError){const o=i.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new we("Reached the end of buffer when deserializing")}throw i}}}class _e{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 sn.default(t,"le")}readU128(){const t=this.readBuffer(16);return new sn.default(t,"le")}readU256(){const t=this.readBuffer(32);return new sn.default(t,"le")}readU512(){const t=this.readBuffer(64);return new sn.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new we(`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 Yc.decode(e)}catch(n){throw new we(`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}}Ke([$e],_e.prototype,"readU8",null);Ke([$e],_e.prototype,"readU16",null);Ke([$e],_e.prototype,"readU32",null);Ke([$e],_e.prototype,"readU64",null);Ke([$e],_e.prototype,"readU128",null);Ke([$e],_e.prototype,"readU256",null);Ke([$e],_e.prototype,"readU512",null);Ke([$e],_e.prototype,"readString",null);Ke([$e],_e.prototype,"readFixedArray",null);Ke([$e],_e.prototype,"readArray",null);fe.BinaryReader=_e;function So(r){return r.charAt(0).toUpperCase()+r.slice(1)}function un(r,t,e,n,s){try{if(typeof n=="string")s[`write${So(n)}`](e);else if(n instanceof Array)if(typeof n[0]=="number"){if(e.length!==n[0])throw new we(`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 we(`Expecting byte array of length ${n[1]}, but got ${e.length} bytes`);for(let i=0;i<n[1];i++)un(r,null,e[i],n[0],s)}else s.writeArray(e,i=>{un(r,t,i,n[0],s)});else if(n.kind!==void 0)switch(n.kind){case"option":{e==null?s.writeU8(0):(s.writeU8(1),un(r,t,e,n.type,s));break}case"map":{s.writeU32(e.size),e.forEach((i,o)=>{un(r,t,o,n.key,s),un(r,t,i,n.value,s)});break}default:throw new we(`FieldType ${n} unrecognized`)}else Bo(r,e,s)}catch(i){throw i instanceof we&&i.addToFieldPath(t),i}}function Bo(r,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const n=r.get(t.constructor);if(!n)throw new we(`Class ${t.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([s,i])=>{un(r,s,t[s],i,e)});else if(n.kind==="enum"){const s=t[n.field];for(let i=0;i<n.values.length;++i){const[o,c]=n.values[i];if(o===s){e.writeU8(i),un(r,o,t[o],c,e);break}}}else throw new we(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function Qc(r,t,e=Eo){const n=new e;return Bo(r,t,n),n.toArray()}var _o=fe.serialize=Qc;function fn(r,t,e,n){try{if(typeof e=="string")return n[`read${So(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return n.readFixedArray(e[0]);if(typeof e[1]=="number"){const s=[];for(let i=0;i<e[1];i++)s.push(fn(r,null,e[0],n));return s}else return n.readArray(()=>fn(r,t,e[0],n))}if(e.kind==="option")return n.readU8()?fn(r,t,e.type,n):void 0;if(e.kind==="map"){let s=new Map;const i=n.readU32();for(let o=0;o<i;o++){const c=fn(r,t,e.key,n),d=fn(r,t,e.value,n);s.set(c,d)}return s}return Ki(r,e,n)}catch(s){throw s instanceof we&&s.addToFieldPath(t),s}}function Ki(r,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const n=r.get(t);if(!n)throw new we(`Class ${t.name} is missing in schema`);if(n.kind==="struct"){const s={};for(const[i,o]of r.get(t).fields)s[i]=fn(r,i,o,e);return new t(s)}if(n.kind==="enum"){const s=e.readU8();if(s>=n.values.length)throw new we(`Enum index: ${s} is out of range`);const[i,o]=n.values[s],c=fn(r,i,o,e);return new t({[i]:c})}throw new we(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function tu(r,t,e,n=_e){const s=new n(e),i=Ki(r,t,s);if(s.offset<e.length)throw new we(`Unexpected ${e.length-s.offset} bytes after deserialized data`);return i}var Ao=fe.deserialize=tu;function eu(r,t,e,n=_e){const s=new n(e);return Ki(r,t,s)}vo=fe.deserializeUnchecked=eu;var N={};Object.defineProperty(N,"__esModule",{value:!0});N.s16=N.s8=N.nu64be=N.u48be=N.u40be=N.u32be=N.u24be=N.u16be=ue=N.nu64=N.u48=N.u40=it=N.u32=N.u24=ke=N.u16=bt=N.u8=gn=N.offset=N.greedy=N.Constant=N.UTF8=N.CString=N.Blob=N.Boolean=N.BitField=N.BitStructure=N.VariantLayout=N.Union=N.UnionLayoutDiscriminator=N.UnionDiscriminator=N.Structure=N.Sequence=N.DoubleBE=N.Double=N.FloatBE=N.Float=N.NearInt64BE=N.NearInt64=N.NearUInt64BE=N.NearUInt64=N.IntBE=N.Int=N.UIntBE=N.UInt=N.OffsetLayout=N.GreedyCount=N.ExternalLayout=N.bindConstructorLayout=N.nameWithProperty=N.Layout=N.uint8ArrayToBuffer=N.checkUint8Array=void 0;N.constant=N.utf8=N.cstr=qt=N.blob=N.unionLayoutDiscriminator=N.union=be=N.seq=N.bits=tt=N.struct=N.f64be=N.f64=N.f32be=N.f32=N.ns64be=N.s48be=N.s40be=N.s32be=N.s24be=N.s16be=Be=N.ns64=N.s48=N.s40=N.s32=N.s24=void 0;const $i=dt;function Dn(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}N.checkUint8Array=Dn;function wt(r){return Dn(r),$i.Buffer.from(r.buffer,r.byteOffset,r.length)}N.uint8ArrayToBuffer=wt;class vt{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){}}N.Layout=vt;function Hi(r,t){return t.property?r+"["+t.property+"]":r}N.nameWithProperty=Hi;function nu(r,t){if(typeof r!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(r,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof vt))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");r.layout_=t,t.boundConstructor_=r,t.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(r,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}N.bindConstructorLayout=nu;class xe extends vt{isCount(){throw new Error("ExternalLayout is abstract")}}N.ExternalLayout=xe;class Io extends xe{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){Dn(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}N.GreedyCount=Io;class Vi extends xe{constructor(t,e=0,n){if(!(t instanceof vt))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 Ce||this.layout instanceof Fe}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)}}N.OffsetLayout=Vi;class Ce extends vt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return wt(t).readUIntLE(e,this.span)}encode(t,e,n=0){return wt(e).writeUIntLE(t,n,this.span),this.span}}N.UInt=Ce;class Fe extends vt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return wt(t).readUIntBE(e,this.span)}encode(t,e,n=0){return wt(e).writeUIntBE(t,n,this.span),this.span}}N.UIntBE=Fe;class bn extends vt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return wt(t).readIntLE(e,this.span)}encode(t,e,n=0){return wt(e).writeIntLE(t,n,this.span),this.span}}N.Int=bn;class zn extends vt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return wt(t).readIntBE(e,this.span)}encode(t,e,n=0){return wt(e).writeIntBE(t,n,this.span),this.span}}N.IntBE=zn;const Ai=Math.pow(2,32);function Rr(r){const t=Math.floor(r/Ai),e=r-t*Ai;return{hi32:t,lo32:e}}function Tr(r,t){return r*Ai+t}class ko extends vt{constructor(t){super(8,t)}decode(t,e=0){const n=wt(t),s=n.readUInt32LE(e),i=n.readUInt32LE(e+4);return Tr(i,s)}encode(t,e,n=0){const s=Rr(t),i=wt(e);return i.writeUInt32LE(s.lo32,n),i.writeUInt32LE(s.hi32,n+4),8}}N.NearUInt64=ko;class Mo extends vt{constructor(t){super(8,t)}decode(t,e=0){const n=wt(t),s=n.readUInt32BE(e),i=n.readUInt32BE(e+4);return Tr(s,i)}encode(t,e,n=0){const s=Rr(t),i=wt(e);return i.writeUInt32BE(s.hi32,n),i.writeUInt32BE(s.lo32,n+4),8}}N.NearUInt64BE=Mo;class Ro extends vt{constructor(t){super(8,t)}decode(t,e=0){const n=wt(t),s=n.readUInt32LE(e),i=n.readInt32LE(e+4);return Tr(i,s)}encode(t,e,n=0){const s=Rr(t),i=wt(e);return i.writeUInt32LE(s.lo32,n),i.writeInt32LE(s.hi32,n+4),8}}N.NearInt64=Ro;class To extends vt{constructor(t){super(8,t)}decode(t,e=0){const n=wt(t),s=n.readInt32BE(e),i=n.readUInt32BE(e+4);return Tr(s,i)}encode(t,e,n=0){const s=Rr(t),i=wt(e);return i.writeInt32BE(s.hi32,n),i.writeUInt32BE(s.lo32,n+4),8}}N.NearInt64BE=To;class Co extends vt{constructor(t){super(4,t)}decode(t,e=0){return wt(t).readFloatLE(e)}encode(t,e,n=0){return wt(e).writeFloatLE(t,n),4}}N.Float=Co;class Lo extends vt{constructor(t){super(4,t)}decode(t,e=0){return wt(t).readFloatBE(e)}encode(t,e,n=0){return wt(e).writeFloatBE(t,n),4}}N.FloatBE=Lo;class Uo extends vt{constructor(t){super(8,t)}decode(t,e=0){return wt(t).readDoubleLE(e)}encode(t,e,n=0){return wt(e).writeDoubleLE(t,n),8}}N.Double=Uo;class Fo extends vt{constructor(t){super(8,t)}decode(t,e=0){return wt(t).readDoubleBE(e)}encode(t,e,n=0){return wt(e).writeDoubleBE(t,n),8}}N.DoubleBE=Fo;class No extends vt{constructor(t,e,n){if(!(t instanceof vt))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof xe&&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 xe)&&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 xe&&(s=s.decode(t,e)),0<this.elementLayout.span)n=s*this.elementLayout.span;else{let i=0;for(;i<s;)n+=this.elementLayout.getSpan(t,e+n),++i}return n}decode(t,e=0){const n=[];let s=0,i=this.count;for(i instanceof xe&&(i=i.decode(t,e));s<i;)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,i=t.reduce((o,c)=>o+s.encode(c,e,n+o),0);return this.count instanceof xe&&this.count.encode(t.length,e,n),i}}N.Sequence=No;class Oo extends vt{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((i,o)=>i&&o instanceof vt,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(const i of t)if(0>i.span&&i.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let s=-1;try{s=t.reduce((i,o)=>i+o.getSpan(),0)}catch{}super(s,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((s,i)=>{const o=i.getSpan(t,e);return e+=o,s+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e=0){Dn(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 i=0,o=0;for(const c of this.fields){let d=c.span;if(o=0<d?d:0,c.property!==void 0){const v=t[c.property];v!==void 0&&(o=c.encode(v,e,n),0>d&&(d=c.getSpan(e,n)))}i=n,n+=d}return i+o-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)}}}N.Structure=Oo;class ji{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}N.UnionDiscriminator=ji;class xr extends ji{constructor(t,e){if(!(t instanceof xe&&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)}}N.UnionLayoutDiscriminator=xr;class Wi extends vt{constructor(t,e,n){let s;if(t instanceof Ce||t instanceof Fe)s=new xr(new Vi(t));else if(t instanceof xe&&t.isCount())s=new xr(t);else if(t instanceof ji)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 vt))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&(t instanceof Ce||t instanceof Fe)&&(i+=s.layout.span)),super(i,n),this.discriminator=s,this.usesPrefixDiscriminator=t instanceof Ce||t instanceof Fe,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.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,i=s.decode(t,e),o=this.registry[i];if(o===void 0){const c=this.defaultLayout;let d=0;this.usesPrefixDiscriminator&&(d=s.layout.span),n=this.makeDestinationObject(),n[s.property]=i,n[c.property]=c.decode(t,e+d)}else n=o.decode(t,e);return n}encode(t,e,n=0){const s=this.getSourceVariant(t);if(s===void 0){const i=this.discriminator,o=this.defaultLayout;let c=0;return this.usesPrefixDiscriminator&&(c=i.layout.span),i.encode(t[i.property],e,n),c+o.encode(t[o.property],e,n+c)}return s.encode(t,e,n)}addVariant(t,e,n){const s=new Po(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]}}N.Union=Wi;class Po extends vt{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 vt))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 i=t.span;0>t.span&&(i=n?n.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,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 i=s;if(this.layout&&(this.layout.encode(t[this.property],e,n+s),i+=this.layout.getSpan(e,n+s),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}N.VariantLayout=Po;function kn(r){return 0>r&&(r+=4294967296),r}class Gi extends vt{constructor(t,e,n){if(!(t instanceof Ce||t instanceof Fe))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(i){return s=kn(i),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 i of this.fields)i.property!==void 0&&(n[i.property]=i.decode(t));return n}encode(t,e,n=0){const s=this.word.decode(e,n);this._packedSetValue(s);for(const i of this.fields)if(i.property!==void 0){const o=t[i.property];o!==void 0&&i.encode(o)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){const n=new Zi(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new qo(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}}N.BitStructure=Gi;class Zi{constructor(t,e,n){if(!(t instanceof Gi))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const s=8*t.span,i=t.fields.reduce((o,c)=>o+c.bits,0);if(e+i>s)throw new Error("bits too long for span remainder ("+(s-i)+" of "+s+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=s-i-e),this.wordMask=kn(this.valueMask<<this.start),this.property=n}decode(t,e){const n=this.container._packedGetValue();return kn(n&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==kn(t&this.valueMask))throw new TypeError(Hi("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=kn(t<<this.start);this.container._packedSetValue(kn(e&~this.wordMask)|n)}}N.BitField=Zi;let qo=class extends Zi{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)}};N.Boolean=qo;class Do extends vt{constructor(t,e){if(!(t instanceof xe&&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 xe||(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)),wt(t).slice(e,e+n)}encode(t,e,n){let s=this.length;if(this.length instanceof xe&&(s=t.length),!(t instanceof Uint8Array&&s===t.length))throw new TypeError(Hi("Blob.encode",this)+" requires (length "+s+") Uint8Array as src");if(n+s>e.length)throw new RangeError("encoding overruns Uint8Array");const i=wt(t);return wt(e).write(i.toString("hex"),n,s,"hex"),this.length instanceof xe&&this.length.encode(s,e,n),s}}N.Blob=Do;class zo extends vt{constructor(t){super(-1,t)}getSpan(t,e=0){Dn(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 wt(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const s=$i.Buffer.from(t,"utf8"),i=s.length;if(n+i>e.length)throw new RangeError("encoding overruns Buffer");const o=wt(e);return s.copy(o,n),o[n+i]=0,i+1}}N.CString=zo;class Ko extends vt{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 Dn(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 wt(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const s=$i.Buffer.from(t,"utf8"),i=s.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(n+i>e.length)throw new RangeError("encoding overruns Buffer");return s.copy(wt(e),n),i}}N.UTF8=Ko;class $o extends vt{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}N.Constant=$o;N.greedy=(r,t)=>new Io(r,t);var gn=N.offset=(r,t,e)=>new Vi(r,t,e),bt=N.u8=r=>new Ce(1,r),ke=N.u16=r=>new Ce(2,r);N.u24=r=>new Ce(3,r);var it=N.u32=r=>new Ce(4,r);N.u40=r=>new Ce(5,r);N.u48=r=>new Ce(6,r);var ue=N.nu64=r=>new ko(r);N.u16be=r=>new Fe(2,r);N.u24be=r=>new Fe(3,r);N.u32be=r=>new Fe(4,r);N.u40be=r=>new Fe(5,r);N.u48be=r=>new Fe(6,r);N.nu64be=r=>new Mo(r);N.s8=r=>new bn(1,r);N.s16=r=>new bn(2,r);N.s24=r=>new bn(3,r);N.s32=r=>new bn(4,r);N.s40=r=>new bn(5,r);N.s48=r=>new bn(6,r);var Be=N.ns64=r=>new Ro(r);N.s16be=r=>new zn(2,r);N.s24be=r=>new zn(3,r);N.s32be=r=>new zn(4,r);N.s40be=r=>new zn(5,r);N.s48be=r=>new zn(6,r);N.ns64be=r=>new To(r);N.f32=r=>new Co(r);N.f32be=r=>new Lo(r);N.f64=r=>new Uo(r);N.f64be=r=>new Fo(r);var tt=N.struct=(r,t,e)=>new Oo(r,t,e);N.bits=(r,t,e)=>new Gi(r,t,e);var be=N.seq=(r,t,e)=>new No(r,t,e);N.union=(r,t,e)=>new Wi(r,t,e);N.unionLayoutDiscriminator=(r,t)=>new xr(r,t);var qt=N.blob=(r,t)=>new Do(r,t);N.cstr=r=>new zo(r);N.utf8=(r,t)=>new Ko(r,t);N.constant=(r,t)=>new $o(r,t);var ru=8078e3,iu=8078001,su=8078004,ou=8078005,au=8078006,cu=8078011;function Ho(r){return Array.isArray(r)?"%5B"+r.map(Ho).join("%2C%20")+"%5D":typeof r=="bigint"?`${r}n`:encodeURIComponent(String(r!=null&&Object.getPrototypeOf(r)===null?{...r}:r))}function uu([r,t]){return`${r}=${Ho(t)}`}function fu(r){const t=Object.entries(r).map(uu).join("&");return btoa(t)}function hu(r,t={}){{let e=`Solana error #${r}; Decode this error by running \`npx @solana/errors decode -- ${r}`;return Object.keys(t).length&&(e+=` '${fu(t)}'`),`${e}\``}}var Cn=class extends Error{constructor(...[t,e]){let n,s;if(e){const{cause:o,...c}=e;o&&(s={cause:o}),Object.keys(c).length>0&&(n=c)}const i=hu(t,n);super(i,s);ie(this,"cause",this.cause);ie(this,"context");this.context={__code:t,...n},this.name="SolanaError"}};function lu(r,t){return"fixedSize"in t?t.fixedSize:t.getSizeFromValue(r)}function du(r){return Object.freeze({...r,encode:t=>{const e=new Uint8Array(lu(t,r));return r.write(t,e,0),e}})}function pu(r){return Object.freeze({...r,decode:(t,e=0)=>r.read(t,e)[0]})}function In(r){return"fixedSize"in r&&typeof r.fixedSize=="number"}function gu(r,t){if(In(r)!==In(t))throw new Cn(su);if(In(r)&&In(t)&&r.fixedSize!==t.fixedSize)throw new Cn(ou,{decoderFixedSize:t.fixedSize,encoderFixedSize:r.fixedSize});if(!In(r)&&!In(t)&&r.maxSize!==t.maxSize)throw new Cn(au,{decoderMaxSize:t.maxSize,encoderMaxSize:r.maxSize});return{...t,...r,decode:t.decode,encode:r.encode,read:t.read,write:r.write}}function mu(r,t,e=0){if(t.length-e<=0)throw new Cn(ru,{codecDescription:r})}function yu(r,t,e,n=0){const s=e.length-n;if(s<t)throw new Cn(iu,{bytesLength:s,codecDescription:r,expected:t})}function wu(r,t,e,n){if(n<t||n>e)throw new Cn(cu,{codecDescription:r,max:e,min:t,value:n})}function Vo(r){return(r==null?void 0:r.endian)!==1}function bu(r){return du({fixedSize:r.size,write(t,e,n){r.range&&wu(r.name,r.range[0],r.range[1],t);const s=new ArrayBuffer(r.size);return r.set(new DataView(s),t,Vo(r.config)),e.set(new Uint8Array(s),n),n+r.size}})}function vu(r){return pu({fixedSize:r.size,read(t,e=0){mu(r.name,t,e),yu(r.name,r.size,t,e);const n=new DataView(xu(t,e,r.size));return[r.get(n,Vo(r.config)),e+r.size]}})}function xu(r,t,e){const n=r.byteOffset+(t??0),s=e??r.byteLength;return r.buffer.slice(n,n+s)}var Eu=(r={})=>bu({config:r,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,e,n)=>t.setBigUint64(0,BigInt(e),n),size:8}),Su=(r={})=>vu({config:r,get:(t,e)=>t.getBigUint64(0,e),name:"u64",size:8}),Bu=(r={})=>gu(Eu(r),Su(r));class _u extends TypeError{constructor(t,e){let n;const{message:s,explanation:i,...o}=t,{path:c}=t,d=c.length===0?s:`At path: ${c.join(".")} -- ${s}`;super(i??d),i!=null&&(this.cause=d),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function Au(r){return Qn(r)&&typeof r[Symbol.iterator]=="function"}function Qn(r){return typeof r=="object"&&r!=null}function Er(r){return Qn(r)&&!Array.isArray(r)}function Oe(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function Iu(r){const{done:t,value:e}=r.next();return t?void 0:e}function ku(r,t,e,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:s,branch:i}=t,{type:o}=e,{refinement:c,message:d=`Expected a value of type \`${o}\`${c?` with refinement \`${c}\``:""}, but received: \`${Oe(n)}\``}=r;return{value:n,type:o,refinement:c,key:s[s.length-1],path:s,branch:i,...r,message:d}}function*As(r,t,e,n){Au(r)||(r=[r]);for(const s of r){const i=ku(s,t,e,n);i&&(yield i)}}function*Yi(r,t,e={}){const{path:n=[],branch:s=[r],coerce:i=!1,mask:o=!1}=e,c={path:n,branch:s,mask:o};i&&(r=t.coercer(r,c));let d="valid";for(const v of t.validator(r,c))v.explanation=e.message,d="not_valid",yield[v,void 0];for(let[v,_,I]of t.entries(r,c)){const A=Yi(_,I,{path:v===void 0?n:[...n,v],branch:v===void 0?s:[...s,_],coerce:i,mask:o,message:e.message});for(const B of A)B[0]?(d=B[0].refinement!=null?"not_refined":"not_valid",yield[B[0],void 0]):i&&(_=B[1],v===void 0?r=_:r instanceof Map?r.set(v,_):r instanceof Set?r.add(_):Qn(r)&&(_!==void 0||v in r)&&(r[v]=_))}if(d!=="not_valid")for(const v of t.refiner(r,c))v.explanation=e.message,d="not_refined",yield[v,void 0];d==="valid"&&(yield[void 0,r])}let He=class{constructor(t){const{type:e,schema:n,validator:s,refiner:i,coercer:o=d=>d,entries:c=function*(){}}=t;this.type=e,this.schema=n,this.entries=c,this.coercer=o,s?this.validator=(d,v)=>{const _=s(d,v);return As(_,v,this,d)}:this.validator=()=>[],i?this.refiner=(d,v)=>{const _=i(d,v);return As(_,v,this,d)}:this.refiner=()=>[]}assert(t,e){return Mu(t,this,e)}create(t,e){return H(t,this,e)}is(t){return jo(t,this)}mask(t,e){return Ru(t,this,e)}validate(t,e={}){return tr(t,this,e)}};function Mu(r,t,e){const n=tr(r,t,{message:e});if(n[0])throw n[0]}function H(r,t,e){const n=tr(r,t,{coerce:!0,message:e});if(n[0])throw n[0];return n[1]}function Ru(r,t,e){const n=tr(r,t,{coerce:!0,mask:!0,message:e});if(n[0])throw n[0];return n[1]}function jo(r,t){return!tr(r,t)[0]}function tr(r,t,e={}){const n=Yi(r,t,e),s=Iu(n);return s[0]?[new _u(s[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function vn(r,t){return new He({type:r,schema:null,validator:t})}function Tu(){return vn("any",()=>!0)}function j(r){return new He({type:"array",schema:r,*entries(t){if(r&&Array.isArray(t))for(const[e,n]of t.entries())yield[e,n,r]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${Oe(t)}`}})}function ze(){return vn("boolean",r=>typeof r=="boolean")}function Xi(r){return vn("instance",t=>t instanceof r||`Expected a \`${r.name}\` instance, but received: ${Oe(t)}`)}function Rt(r){const t=Oe(r),e=typeof r;return new He({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${t}\`, but received: ${Oe(n)}`}})}function Cu(){return vn("never",()=>!1)}function W(r){return new He({...r,validator:(t,e)=>t===null||r.validator(t,e),refiner:(t,e)=>t===null||r.refiner(t,e)})}function U(){return vn("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${Oe(r)}`)}function rt(r){return new He({...r,validator:(t,e)=>t===void 0||r.validator(t,e),refiner:(t,e)=>t===void 0||r.refiner(t,e)})}function Wo(r,t){return new He({type:"record",schema:null,*entries(e){if(Qn(e))for(const n in e){const s=e[n];yield[n,n,r],yield[n,s,t]}},validator(e){return Er(e)||`Expected an object, but received: ${Oe(e)}`},coercer(e){return Er(e)?{...e}:e}})}function K(){return vn("string",r=>typeof r=="string"||`Expected a string, but received: ${Oe(r)}`)}function Ji(r){const t=Cu();return new He({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const n=Math.max(r.length,e.length);for(let s=0;s<n;s++)yield[s,e[s],r[s]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Oe(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function D(r){const t=Object.keys(r);return new He({type:"type",schema:r,*entries(e){if(Qn(e))for(const n of t)yield[n,e[n],r[n]]},validator(e){return Er(e)||`Expected an object, but received: ${Oe(e)}`},coercer(e){return Er(e)?{...e}:e}})}function ve(r){const t=r.map(e=>e.type).join(" | ");return new He({type:"union",schema:null,coercer(e,n){for(const s of r){const[i,o]=s.validate(e,{coerce:!0,mask:n.mask});if(!i)return o}return e},validator(e,n){const s=[];for(const i of r){const[...o]=Yi(e,i,n),[c]=o;if(c[0])for(const[d]of o)d&&s.push(d);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Oe(e)}`,...s]}})}function Kn(){return vn("unknown",()=>!0)}function er(r,t,e){return new He({...r,coercer:(n,s)=>jo(n,t)?r.coercer(e(n,s),s):r.coercer(n,s)})}var ur,Lu=new Uint8Array(16);function Go(){if(!ur&&(ur=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ur))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ur(Lu)}const Uu=/^(?:[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 Cr(r){return typeof r=="string"&&Uu.test(r)}var ce=[];for(var li=0;li<256;++li)ce.push((li+256).toString(16).substr(1));function Lr(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(ce[r[t+0]]+ce[r[t+1]]+ce[r[t+2]]+ce[r[t+3]]+"-"+ce[r[t+4]]+ce[r[t+5]]+"-"+ce[r[t+6]]+ce[r[t+7]]+"-"+ce[r[t+8]]+ce[r[t+9]]+"-"+ce[r[t+10]]+ce[r[t+11]]+ce[r[t+12]]+ce[r[t+13]]+ce[r[t+14]]+ce[r[t+15]]).toLowerCase();if(!Cr(e))throw TypeError("Stringified UUID is invalid");return e}var Is,di,pi=0,gi=0;function Fu(r,t,e){var n=t&&e||0,s=t||new Array(16);r=r||{};var i=r.node||Is,o=r.clockseq!==void 0?r.clockseq:di;if(i==null||o==null){var c=r.random||(r.rng||Go)();i==null&&(i=Is=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),o==null&&(o=di=(c[6]<<8|c[7])&16383)}var d=r.msecs!==void 0?r.msecs:Date.now(),v=r.nsecs!==void 0?r.nsecs:gi+1,_=d-pi+(v-gi)/1e4;if(_<0&&r.clockseq===void 0&&(o=o+1&16383),(_<0||d>pi)&&r.nsecs===void 0&&(v=0),v>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");pi=d,gi=v,di=o,d+=122192928e5;var I=((d&268435455)*1e4+v)%4294967296;s[n++]=I>>>24&255,s[n++]=I>>>16&255,s[n++]=I>>>8&255,s[n++]=I&255;var A=d/4294967296*1e4&268435455;s[n++]=A>>>8&255,s[n++]=A&255,s[n++]=A>>>24&15|16,s[n++]=A>>>16&255,s[n++]=o>>>8|128,s[n++]=o&255;for(var B=0;B<6;++B)s[n+B]=i[B];return t||Lr(s)}function Zo(r){if(!Cr(r))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(r.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(r.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(r.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(r.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(r.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 Nu(r){r=unescape(encodeURIComponent(r));for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e));return t}var Ou="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Pu="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Yo(r,t,e){function n(s,i,o,c){if(typeof s=="string"&&(s=Nu(s)),typeof i=="string"&&(i=Zo(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var d=new Uint8Array(16+s.length);if(d.set(i),d.set(s,i.length),d=e(d),d[6]=d[6]&15|t,d[8]=d[8]&63|128,o){c=c||0;for(var v=0;v<16;++v)o[c+v]=d[v];return o}return Lr(d)}try{n.name=r}catch{}return n.DNS=Ou,n.URL=Pu,n}function qu(r){if(typeof r=="string"){var t=unescape(encodeURIComponent(r));r=new Uint8Array(t.length);for(var e=0;e<t.length;++e)r[e]=t.charCodeAt(e)}return Du(zu(Ku(r),r.length*8))}function Du(r){for(var t=[],e=r.length*32,n="0123456789abcdef",s=0;s<e;s+=8){var i=r[s>>5]>>>s%32&255,o=parseInt(n.charAt(i>>>4&15)+n.charAt(i&15),16);t.push(o)}return t}function Xo(r){return(r+64>>>9<<4)+14+1}function zu(r,t){r[t>>5]|=128<<t%32,r[Xo(t)-1]=t;for(var e=1732584193,n=-271733879,s=-1732584194,i=271733878,o=0;o<r.length;o+=16){var c=e,d=n,v=s,_=i;e=pe(e,n,s,i,r[o],7,-680876936),i=pe(i,e,n,s,r[o+1],12,-389564586),s=pe(s,i,e,n,r[o+2],17,606105819),n=pe(n,s,i,e,r[o+3],22,-1044525330),e=pe(e,n,s,i,r[o+4],7,-176418897),i=pe(i,e,n,s,r[o+5],12,1200080426),s=pe(s,i,e,n,r[o+6],17,-1473231341),n=pe(n,s,i,e,r[o+7],22,-45705983),e=pe(e,n,s,i,r[o+8],7,1770035416),i=pe(i,e,n,s,r[o+9],12,-1958414417),s=pe(s,i,e,n,r[o+10],17,-42063),n=pe(n,s,i,e,r[o+11],22,-1990404162),e=pe(e,n,s,i,r[o+12],7,1804603682),i=pe(i,e,n,s,r[o+13],12,-40341101),s=pe(s,i,e,n,r[o+14],17,-1502002290),n=pe(n,s,i,e,r[o+15],22,1236535329),e=ge(e,n,s,i,r[o+1],5,-165796510),i=ge(i,e,n,s,r[o+6],9,-1069501632),s=ge(s,i,e,n,r[o+11],14,643717713),n=ge(n,s,i,e,r[o],20,-373897302),e=ge(e,n,s,i,r[o+5],5,-701558691),i=ge(i,e,n,s,r[o+10],9,38016083),s=ge(s,i,e,n,r[o+15],14,-660478335),n=ge(n,s,i,e,r[o+4],20,-405537848),e=ge(e,n,s,i,r[o+9],5,568446438),i=ge(i,e,n,s,r[o+14],9,-1019803690),s=ge(s,i,e,n,r[o+3],14,-187363961),n=ge(n,s,i,e,r[o+8],20,1163531501),e=ge(e,n,s,i,r[o+13],5,-1444681467),i=ge(i,e,n,s,r[o+2],9,-51403784),s=ge(s,i,e,n,r[o+7],14,1735328473),n=ge(n,s,i,e,r[o+12],20,-1926607734),e=me(e,n,s,i,r[o+5],4,-378558),i=me(i,e,n,s,r[o+8],11,-2022574463),s=me(s,i,e,n,r[o+11],16,1839030562),n=me(n,s,i,e,r[o+14],23,-35309556),e=me(e,n,s,i,r[o+1],4,-1530992060),i=me(i,e,n,s,r[o+4],11,1272893353),s=me(s,i,e,n,r[o+7],16,-155497632),n=me(n,s,i,e,r[o+10],23,-1094730640),e=me(e,n,s,i,r[o+13],4,681279174),i=me(i,e,n,s,r[o],11,-358537222),s=me(s,i,e,n,r[o+3],16,-722521979),n=me(n,s,i,e,r[o+6],23,76029189),e=me(e,n,s,i,r[o+9],4,-640364487),i=me(i,e,n,s,r[o+12],11,-421815835),s=me(s,i,e,n,r[o+15],16,530742520),n=me(n,s,i,e,r[o+2],23,-995338651),e=ye(e,n,s,i,r[o],6,-198630844),i=ye(i,e,n,s,r[o+7],10,1126891415),s=ye(s,i,e,n,r[o+14],15,-1416354905),n=ye(n,s,i,e,r[o+5],21,-57434055),e=ye(e,n,s,i,r[o+12],6,1700485571),i=ye(i,e,n,s,r[o+3],10,-1894986606),s=ye(s,i,e,n,r[o+10],15,-1051523),n=ye(n,s,i,e,r[o+1],21,-2054922799),e=ye(e,n,s,i,r[o+8],6,1873313359),i=ye(i,e,n,s,r[o+15],10,-30611744),s=ye(s,i,e,n,r[o+6],15,-1560198380),n=ye(n,s,i,e,r[o+13],21,1309151649),e=ye(e,n,s,i,r[o+4],6,-145523070),i=ye(i,e,n,s,r[o+11],10,-1120210379),s=ye(s,i,e,n,r[o+2],15,718787259),n=ye(n,s,i,e,r[o+9],21,-343485551),e=on(e,c),n=on(n,d),s=on(s,v),i=on(i,_)}return[e,n,s,i]}function Ku(r){if(r.length===0)return[];for(var t=r.length*8,e=new Uint32Array(Xo(t)),n=0;n<t;n+=8)e[n>>5]|=(r[n/8]&255)<<n%32;return e}function on(r,t){var e=(r&65535)+(t&65535),n=(r>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function $u(r,t){return r<<t|r>>>32-t}function Ur(r,t,e,n,s,i){return on($u(on(on(t,r),on(n,i)),s),e)}function pe(r,t,e,n,s,i,o){return Ur(t&e|~t&n,r,t,s,i,o)}function ge(r,t,e,n,s,i,o){return Ur(t&n|e&~n,r,t,s,i,o)}function me(r,t,e,n,s,i,o){return Ur(t^e^n,r,t,s,i,o)}function ye(r,t,e,n,s,i,o){return Ur(e^(t|~n),r,t,s,i,o)}var Hu=Yo("v3",48,qu);function Vu(r,t,e){r=r||{};var n=r.random||(r.rng||Go)();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 Lr(n)}function ju(r,t,e,n){switch(r){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 mi(r,t){return r<<t|r>>>32-t}function Wu(r){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var s=0;s<n.length;++s)r.push(n.charCodeAt(s))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var i=r.length/4+2,o=Math.ceil(i/16),c=new Array(o),d=0;d<o;++d){for(var v=new Uint32Array(16),_=0;_<16;++_)v[_]=r[d*64+_*4]<<24|r[d*64+_*4+1]<<16|r[d*64+_*4+2]<<8|r[d*64+_*4+3];c[d]=v}c[o-1][14]=(r.length-1)*8/Math.pow(2,32),c[o-1][14]=Math.floor(c[o-1][14]),c[o-1][15]=(r.length-1)*8&4294967295;for(var I=0;I<o;++I){for(var A=new Uint32Array(80),B=0;B<16;++B)A[B]=c[I][B];for(var M=16;M<80;++M)A[M]=mi(A[M-3]^A[M-8]^A[M-14]^A[M-16],1);for(var T=e[0],C=e[1],F=e[2],z=e[3],O=e[4],G=0;G<80;++G){var J=Math.floor(G/20),nt=mi(T,5)+ju(J,C,F,z)+O+t[J]+A[G]>>>0;O=z,z=F,F=mi(C,30)>>>0,C=T,T=nt}e[0]=e[0]+T>>>0,e[1]=e[1]+C>>>0,e[2]=e[2]+F>>>0,e[3]=e[3]+z>>>0,e[4]=e[4]+O>>>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 Gu=Yo("v5",80,Wu);const Zu="00000000-0000-0000-0000-000000000000";function Yu(r){if(!Cr(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}const Xu=Object.freeze(Object.defineProperty({__proto__:null,NIL:Zu,parse:Zo,stringify:Lr,v1:Fu,v3:Hu,v4:Vu,v5:Gu,validate:Cr,version:Yu},Symbol.toStringTag,{value:"Module"})),Jo=Ci(Xu),Ju=Jo.v4,Qu=function(r,t,e,n){if(typeof r!="string")throw new TypeError(r+" 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 i={method:r};if(s===2&&(i.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");i.params=t}if(typeof e>"u"){const o=typeof n.generator=="function"?n.generator:function(){return Ju()};i.id=o(i,n)}else s===2&&e===null?n.notificationIdNull&&(i.id=null):i.id=e;return i};var tf=Qu;const ef=Jo.v4,nf=tf,Wn=function(r,t){if(!(this instanceof Wn))return new Wn(r,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 ef()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=r};var rf=Wn;Wn.prototype.request=function(r,t,e,n){const s=this;let i=null;const o=Array.isArray(r)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&r&&typeof r=="object"&&typeof t=="function")n=t,i=r;else{typeof e=="function"&&(n=e,e=void 0);const v=typeof n=="function";try{i=nf(r,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(_){if(v){n(_);return}throw _}if(!v)return i}let d;try{d=JSON.stringify(i,this.options.replacer)}catch(v){n(v);return}return this.callServer(d,function(v,_){s._parseResponse(v,_,n)}),i};Wn.prototype._parseResponse=function(r,t,e){if(r){e(r);return}if(!t){e();return}let n;try{n=JSON.parse(t,this.options.reviver)}catch(s){e(s);return}if(e.length===3)if(Array.isArray(n)){const s=function(o){return typeof o.error<"u"},i=function(o){return!s(o)};e(null,n.filter(s),n.filter(i));return}else{e(null,n.error,n.result);return}e(null,n)};const sf=Ar(rf);var Qo={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(e=!1));function s(d,v,_){this.fn=d,this.context=v,this.once=_||!1}function i(d,v,_,I,A){if(typeof _!="function")throw new TypeError("The listener must be a function");var B=new s(_,I||d,A),M=e?e+v:v;return d._events[M]?d._events[M].fn?d._events[M]=[d._events[M],B]:d._events[M].push(B):(d._events[M]=B,d._eventsCount++),d}function o(d,v){--d._eventsCount===0?d._events=new n:delete d._events[v]}function c(){this._events=new n,this._eventsCount=0}c.prototype.eventNames=function(){var v=[],_,I;if(this._eventsCount===0)return v;for(I in _=this._events)t.call(_,I)&&v.push(e?I.slice(1):I);return Object.getOwnPropertySymbols?v.concat(Object.getOwnPropertySymbols(_)):v},c.prototype.listeners=function(v){var _=e?e+v:v,I=this._events[_];if(!I)return[];if(I.fn)return[I.fn];for(var A=0,B=I.length,M=new Array(B);A<B;A++)M[A]=I[A].fn;return M},c.prototype.listenerCount=function(v){var _=e?e+v:v,I=this._events[_];return I?I.fn?1:I.length:0},c.prototype.emit=function(v,_,I,A,B,M){var T=e?e+v:v;if(!this._events[T])return!1;var C=this._events[T],F=arguments.length,z,O;if(C.fn){switch(C.once&&this.removeListener(v,C.fn,void 0,!0),F){case 1:return C.fn.call(C.context),!0;case 2:return C.fn.call(C.context,_),!0;case 3:return C.fn.call(C.context,_,I),!0;case 4:return C.fn.call(C.context,_,I,A),!0;case 5:return C.fn.call(C.context,_,I,A,B),!0;case 6:return C.fn.call(C.context,_,I,A,B,M),!0}for(O=1,z=new Array(F-1);O<F;O++)z[O-1]=arguments[O];C.fn.apply(C.context,z)}else{var G=C.length,J;for(O=0;O<G;O++)switch(C[O].once&&this.removeListener(v,C[O].fn,void 0,!0),F){case 1:C[O].fn.call(C[O].context);break;case 2:C[O].fn.call(C[O].context,_);break;case 3:C[O].fn.call(C[O].context,_,I);break;case 4:C[O].fn.call(C[O].context,_,I,A);break;default:if(!z)for(J=1,z=new Array(F-1);J<F;J++)z[J-1]=arguments[J];C[O].fn.apply(C[O].context,z)}}return!0},c.prototype.on=function(v,_,I){return i(this,v,_,I,!1)},c.prototype.once=function(v,_,I){return i(this,v,_,I,!0)},c.prototype.removeListener=function(v,_,I,A){var B=e?e+v:v;if(!this._events[B])return this;if(!_)return o(this,B),this;var M=this._events[B];if(M.fn)M.fn===_&&(!A||M.once)&&(!I||M.context===I)&&o(this,B);else{for(var T=0,C=[],F=M.length;T<F;T++)(M[T].fn!==_||A&&!M[T].once||I&&M[T].context!==I)&&C.push(M[T]);C.length?this._events[B]=C.length===1?C[0]:C:o(this,B)}return this},c.prototype.removeAllListeners=function(v){var _;return v?(_=e?e+v:v,this._events[_]&&o(this,_)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=e,c.EventEmitter=c,r.exports=c})(Qo);var of=Qo.exports;const ta=Ar(of);var af=class extends ta{constructor(t,e){super();ie(this,"socket");this.socket=new window.WebSocket(t,e.protocols),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=n=>this.emit("message",n.data),this.socket.onerror=n=>this.emit("error",n),this.socket.onclose=n=>{this.emit("close",n.code,n.reason)}}send(t,e,n){const s=n||e;try{this.socket.send(t),s()}catch(i){s(i)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,n){this.socket.addEventListener(t,e,n)}};function cf(r,t){return new af(r,t)}var uf=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},ff=class extends ta{constructor(t,e="ws://localhost:8080",{autoconnect:n=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...c}={},d,v){super();ie(this,"address");ie(this,"rpc_id");ie(this,"queue");ie(this,"options");ie(this,"autoconnect");ie(this,"ready");ie(this,"reconnect");ie(this,"reconnect_timer_id");ie(this,"reconnect_interval");ie(this,"max_reconnects");ie(this,"rest_options");ie(this,"current_reconnects");ie(this,"generate_request_id");ie(this,"socket");ie(this,"webSocketFactory");ie(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=i,this.max_reconnects=o,this.rest_options=c,this.current_reconnects=0,this.generate_request_id=d||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),v?this.dataPack=v:this.dataPack=new uf,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((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const c=this.generate_request_id(t,e),d={jsonrpc:"2.0",method:t,params:e||void 0,id:c};this.socket.send(this.dataPack.encode(d),s,v=>{if(v)return o(v);this.queue[c]={promise:[i,o]},n&&(this.queue[c].timeout=setTimeout(()=>{delete this.queue[c],o(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 i={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(i),o=>{if(o)return s(o);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&&this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_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=dt.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 i=0;i<n.params.length;i++)s.push(n.params[i]);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):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit("max_reconnects_reached",n,s),1))})}};class ea extends Vs{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,$s(t);const n=Ui(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?t.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Fn(i)}update(t){return dr(this),this.iHash.update(t),this}digestInto(t){dr(this),yn(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:i,blockLen:o,outputLen:c}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=o,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const na=(r,t,e)=>new ea(r,t).update(e).digest();na.create=(r,t)=>new ea(r,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ks=(r,t)=>(r+(r>=0?t:-t)/ra)/t;function hf(r,t,e){const[[n,s],[i,o]]=t,c=ks(o*r,e),d=ks(-s*r,e);let v=r-c*n-d*i,_=-c*s-d*o;const I=v<Ye,A=_<Ye;I&&(v=-v),A&&(_=-_);const B=Yn(Math.ceil(Js(e)/2))+Ln;if(v<Ye||v>=B||_<Ye||_>=B)throw new Error("splitScalar (endomorphism): failed, k="+r);return{k1neg:I,k1:v,k2neg:A,k2:_}}function Ii(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function yi(r,t){const e={};for(let n of Object.keys(t))e[n]=r[n]===void 0?t[n]:r[n];return mn(e.lowS,"lowS"),mn(e.prehash,"prehash"),e.format!==void 0&&Ii(e.format),e}class lf extends Error{constructor(t=""){super(t)}}const We={Err:lf,_tlv:{encode:(r,t)=>{const{Err:e}=We;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");const n=t.length/2,s=ar(n);if(s.length/2&128)throw new e("tlv.encode: long form length too big");const i=n>127?ar(s.length/2|128):"";return ar(r)+i+s+t},decode(r,t){const{Err:e}=We;let n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");const s=t[n++],i=!!(s&128);let o=0;if(!i)o=s;else{const d=s&127;if(!d)throw new e("tlv.decode(long): indefinite length not supported");if(d>4)throw new e("tlv.decode(long): byte length is too big");const v=t.subarray(n,n+d);if(v.length!==d)throw new e("tlv.decode: length bytes not complete");if(v[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(const _ of v)o=o<<8|_;if(n+=d,o<128)throw new e("tlv.decode(long): not minimal encoding")}const c=t.subarray(n,n+o);if(c.length!==o)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+o)}}},_int:{encode(r){const{Err:t}=We;if(r<Ye)throw new t("integer: negative integers are not allowed");let e=ar(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){const{Err:t}=We;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return kr(r)}},toSig(r){const{Err:t,_int:e,_tlv:n}=We,s=Pt("signature",r),{v:i,l:o}=n.decode(48,s);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:d}=n.decode(2,i),{v,l:_}=n.decode(2,d);if(_.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(v)}},hexFromSig(r){const{_tlv:t,_int:e}=We,n=t.encode(2,e.encode(r.r)),s=t.encode(2,e.encode(r.s)),i=n+s;return t.encode(48,i)}},Ye=BigInt(0),Ln=BigInt(1),ra=BigInt(2),fr=BigInt(3),df=BigInt(4);function Rn(r,t){const{BYTES:e}=r;let n;if(typeof t=="bigint")n=t;else{let s=Pt("private key",t);try{n=r.fromBytes(s)}catch{throw new Error(`invalid private key: expected ui8a of size ${e}, got ${typeof t}`)}}if(!r.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function pf(r,t={}){const e=go("weierstrass",r,t),{Fp:n,Fn:s}=e;let i=e.CURVE;const{h:o,n:c}=i;Xn(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:d}=t;if(d&&(!n.is0(i.a)||typeof d.beta!="bigint"||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const v=sa(n,s);function _(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function I(X,m,a){const{x:l,y:p}=m.toAffine(),w=n.toBytes(l);if(mn(a,"isCompressed"),a){_();const x=!n.isOdd(p);return De(ia(x),w)}else return De(Uint8Array.of(4),w,n.toBytes(p))}function A(X){Ue(X,void 0,"Point");const{publicKey:m,publicKeyUncompressed:a}=v,l=X.length,p=X[0],w=X.subarray(1);if(l===m&&(p===2||p===3)){const x=n.fromBytes(w);if(!n.isValid(x))throw new Error("bad point: is not on curve, wrong x");const S=T(x);let k;try{k=n.sqrt(S)}catch(E){const V=E instanceof Error?": "+E.message:"";throw new Error("bad point: is not on curve, sqrt error"+V)}_();const y=n.isOdd(k);return(p&1)===1!==y&&(k=n.neg(k)),{x,y:k}}else if(l===a&&p===4){const x=n.BYTES,S=n.fromBytes(w.subarray(0,x)),k=n.fromBytes(w.subarray(x,x*2));if(!C(S,k))throw new Error("bad point: is not on curve");return{x:S,y:k}}else throw new Error(`bad point: got length ${l}, expected compressed=${m} or uncompressed=${a}`)}const B=t.toBytes||I,M=t.fromBytes||A;function T(X){const m=n.sqr(X),a=n.mul(m,X);return n.add(n.add(a,n.mul(X,i.a)),i.b)}function C(X,m){const a=n.sqr(m),l=T(X);return n.eql(a,l)}if(!C(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const F=n.mul(n.pow(i.a,fr),df),z=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(F,z)))throw new Error("bad curve params: a or b");function O(X,m,a=!1){if(!n.isValid(m)||a&&n.is0(m))throw new Error(`bad point coordinate ${X}`);return m}function G(X){if(!(X instanceof q))throw new Error("ProjectivePoint expected")}function J(X){if(!d||!d.basises)throw new Error("no endo");return hf(X,d.basises,s.ORDER)}const nt=gr((X,m)=>{const{X:a,Y:l,Z:p}=X;if(n.eql(p,n.ONE))return{x:a,y:l};const w=X.is0();m==null&&(m=w?n.ONE:n.inv(p));const x=n.mul(a,m),S=n.mul(l,m),k=n.mul(p,m);if(w)return{x:n.ZERO,y:n.ZERO};if(!n.eql(k,n.ONE))throw new Error("invZ was invalid");return{x,y:S}}),ut=gr(X=>{if(X.is0()){if(t.allowInfinityPoint&&!n.is0(X.Y))return;throw new Error("bad point: ZERO")}const{x:m,y:a}=X.toAffine();if(!n.isValid(m)||!n.isValid(a))throw new Error("bad point: x or y not field elements");if(!C(m,a))throw new Error("bad point: equation left != right");if(!X.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function ot(X,m,a,l,p){return a=new q(n.mul(a.X,X),a.Y,a.Z),m=mr(l,m),a=mr(p,a),m.add(a)}class q{constructor(m,a,l){this.X=O("x",m),this.Y=O("y",a,!0),this.Z=O("z",l),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){const{x:a,y:l}=m||{};if(!m||!n.isValid(a)||!n.isValid(l))throw new Error("invalid affine point");if(m instanceof q)throw new Error("projective point not allowed");return n.is0(a)&&n.is0(l)?q.ZERO:new q(a,l,n.ONE)}static fromBytes(m){const a=q.fromAffine(M(Ue(m,void 0,"point")));return a.assertValidity(),a}static fromHex(m){return q.fromBytes(Pt("pointHex",m))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,a=!0){return Z.createCache(this,m),a||this.multiply(fr),this}assertValidity(){ut(this)}hasEvenY(){const{y:m}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(m)}equals(m){G(m);const{X:a,Y:l,Z:p}=this,{X:w,Y:x,Z:S}=m,k=n.eql(n.mul(a,S),n.mul(w,p)),y=n.eql(n.mul(l,S),n.mul(x,p));return k&&y}negate(){return new q(this.X,n.neg(this.Y),this.Z)}double(){const{a:m,b:a}=i,l=n.mul(a,fr),{X:p,Y:w,Z:x}=this;let S=n.ZERO,k=n.ZERO,y=n.ZERO,f=n.mul(p,p),E=n.mul(w,w),V=n.mul(x,x),$=n.mul(p,w);return $=n.add($,$),y=n.mul(p,x),y=n.add(y,y),S=n.mul(m,y),k=n.mul(l,V),k=n.add(S,k),S=n.sub(E,k),k=n.add(E,k),k=n.mul(S,k),S=n.mul($,S),y=n.mul(l,y),V=n.mul(m,V),$=n.sub(f,V),$=n.mul(m,$),$=n.add($,y),y=n.add(f,f),f=n.add(y,f),f=n.add(f,V),f=n.mul(f,$),k=n.add(k,f),V=n.mul(w,x),V=n.add(V,V),f=n.mul(V,$),S=n.sub(S,f),y=n.mul(V,E),y=n.add(y,y),y=n.add(y,y),new q(S,k,y)}add(m){G(m);const{X:a,Y:l,Z:p}=this,{X:w,Y:x,Z:S}=m;let k=n.ZERO,y=n.ZERO,f=n.ZERO;const E=i.a,V=n.mul(i.b,fr);let $=n.mul(a,w),Y=n.mul(l,x),mt=n.mul(p,S),ft=n.add(a,l),st=n.add(w,x);ft=n.mul(ft,st),st=n.add($,Y),ft=n.sub(ft,st),st=n.add(a,p);let Ct=n.add(w,S);return st=n.mul(st,Ct),Ct=n.add($,mt),st=n.sub(st,Ct),Ct=n.add(l,p),k=n.add(x,S),Ct=n.mul(Ct,k),k=n.add(Y,mt),Ct=n.sub(Ct,k),f=n.mul(E,st),k=n.mul(V,mt),f=n.add(k,f),k=n.sub(Y,f),f=n.add(Y,f),y=n.mul(k,f),Y=n.add($,$),Y=n.add(Y,$),mt=n.mul(E,mt),st=n.mul(V,st),Y=n.add(Y,mt),mt=n.sub($,mt),mt=n.mul(E,mt),st=n.add(st,mt),$=n.mul(Y,st),y=n.add(y,$),$=n.mul(Ct,st),k=n.mul(ft,k),k=n.sub(k,$),$=n.mul(ft,Y),f=n.mul(Ct,f),f=n.add(f,$),new q(k,y,f)}subtract(m){return this.add(m.negate())}is0(){return this.equals(q.ZERO)}multiply(m){const{endo:a}=t;if(!s.isValidNot0(m))throw new Error("invalid scalar: out of range");let l,p;const w=x=>Z.cached(this,x,S=>dn(q,S));if(a){const{k1neg:x,k1:S,k2neg:k,k2:y}=J(m),{p:f,f:E}=w(S),{p:V,f:$}=w(y);p=E.add($),l=ot(a.beta,f,V,x,k)}else{const{p:x,f:S}=w(m);l=x,p=S}return dn(q,[l,p])[0]}multiplyUnsafe(m){const{endo:a}=t,l=this;if(!s.isValid(m))throw new Error("invalid scalar: out of range");if(m===Ye||l.is0())return q.ZERO;if(m===Ln)return l;if(Z.hasCache(this))return this.multiply(m);if(a){const{k1neg:p,k1:w,k2neg:x,k2:S}=J(m),{p1:k,p2:y}=wc(q,l,w,S);return ot(a.beta,k,y,p,x)}else return Z.unsafe(l,m)}multiplyAndAddUnsafe(m,a,l){const p=this.multiplyUnsafe(a).add(m.multiplyUnsafe(l));return p.is0()?void 0:p}toAffine(m){return nt(this,m)}isTorsionFree(){const{isTorsionFree:m}=t;return o===Ln?!0:m?m(q,this):Z.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:m}=t;return o===Ln?this:m?m(q,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(m=!0){return mn(m,"isCompressed"),this.assertValidity(),B(q,this,m)}toHex(m=!0){return pn(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(m=!0){return this.toBytes(m)}_setWindowSize(m){this.precompute(m)}static normalizeZ(m){return dn(q,m)}static msm(m,a){return po(q,s,m,a)}static fromPrivateKey(m){return q.BASE.multiply(Rn(s,m))}}q.BASE=new q(i.Gx,i.Gy,n.ONE),q.ZERO=new q(n.ZERO,n.ONE,n.ZERO),q.Fp=n,q.Fn=s;const Q=s.BITS,Z=new lo(q,t.endo?Math.ceil(Q/2):Q);return q.BASE.precompute(8),q}function ia(r){return Uint8Array.of(r?2:3)}function sa(r,t){return{secretKey:t.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function gf(r,t={}){const{Fn:e}=r,n=t.randomBytes||Fi,s=Object.assign(sa(r.Fp,e),{seed:uo(e.ORDER)});function i(B){try{return!!Rn(e,B)}catch{return!1}}function o(B,M){const{publicKey:T,publicKeyUncompressed:C}=s;try{const F=B.length;return M===!0&&F!==T||M===!1&&F!==C?!1:!!r.fromBytes(B)}catch{return!1}}function c(B=n(s.seed)){return gc(Ue(B,s.seed,"seed"),e.ORDER)}function d(B,M=!0){return r.BASE.multiply(Rn(e,B)).toBytes(M)}function v(B){const M=c(B);return{secretKey:M,publicKey:d(M)}}function _(B){if(typeof B=="bigint")return!1;if(B instanceof r)return!0;const{secretKey:M,publicKey:T,publicKeyUncompressed:C}=s;if(e.allowedLengths||M===T)return;const F=Pt("key",B).length;return F===T||F===C}function I(B,M,T=!0){if(_(B)===!0)throw new Error("first arg must be private key");if(_(M)===!1)throw new Error("second arg must be public key");const C=Rn(e,B);return r.fromHex(M).multiply(C).toBytes(T)}return Object.freeze({getPublicKey:d,getSharedSecret:I,keygen:v,Point:r,utils:{isValidSecretKey:i,isValidPublicKey:o,randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:B=>Rn(e,B),precompute(B=8,M=r.BASE){return M.precompute(B,!1)}},lengths:s})}function mf(r,t,e={}){$s(t),Xn(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=e.randomBytes||Fi,s=e.hmac||((a,...l)=>na(t,a,De(...l))),{Fp:i,Fn:o}=r,{ORDER:c,BITS:d}=o,{keygen:v,getPublicKey:_,getSharedSecret:I,utils:A,lengths:B}=gf(r,e),M={prehash:!1,lowS:typeof e.lowS=="boolean"?e.lowS:!1,format:void 0,extraEntropy:!1},T="compact";function C(a){const l=c>>Ln;return a>l}function F(a,l){if(!o.isValidNot0(l))throw new Error(`invalid signature ${a}: out of range 1..Point.Fn.ORDER`);return l}function z(a,l){Ii(l);const p=B.signature,w=l==="compact"?p:l==="recovered"?p+1:void 0;return Ue(a,w,`${l} signature`)}class O{constructor(l,p,w){this.r=F("r",l),this.s=F("s",p),w!=null&&(this.recovery=w),Object.freeze(this)}static fromBytes(l,p=T){z(l,p);let w;if(p==="der"){const{r:y,s:f}=We.toSig(Ue(l));return new O(y,f)}p==="recovered"&&(w=l[0],p="compact",l=l.subarray(1));const x=o.BYTES,S=l.subarray(0,x),k=l.subarray(x,x*2);return new O(o.fromBytes(S),o.fromBytes(k),w)}static fromHex(l,p){return this.fromBytes(pr(l),p)}addRecoveryBit(l){return new O(this.r,this.s,l)}recoverPublicKey(l){const p=i.ORDER,{r:w,s:x,recovery:S}=this;if(S==null||![0,1,2,3].includes(S))throw new Error("recovery id invalid");if(c*ra<p&&S>1)throw new Error("recovery id is ambiguous for h>1 curve");const y=S===2||S===3?w+c:w;if(!i.isValid(y))throw new Error("recovery id 2 or 3 invalid");const f=i.toBytes(y),E=r.fromBytes(De(ia((S&1)===0),f)),V=o.inv(y),$=J(Pt("msgHash",l)),Y=o.create(-$*V),mt=o.create(x*V),ft=r.BASE.multiplyUnsafe(Y).add(E.multiplyUnsafe(mt));if(ft.is0())throw new Error("point at infinify");return ft.assertValidity(),ft}hasHighS(){return C(this.s)}toBytes(l=T){if(Ii(l),l==="der")return pr(We.hexFromSig(this));const p=o.toBytes(this.r),w=o.toBytes(this.s);if(l==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return De(Uint8Array.of(this.recovery),p,w)}return De(p,w)}toHex(l){return pn(this.toBytes(l))}assertValidity(){}static fromCompact(l){return O.fromBytes(Pt("sig",l),"compact")}static fromDER(l){return O.fromBytes(Pt("sig",l),"der")}normalizeS(){return this.hasHighS()?new O(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return pn(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return pn(this.toBytes("compact"))}}const G=e.bits2int||function(l){if(l.length>8192)throw new Error("input is too large");const p=kr(l),w=l.length*8-d;return w>0?p>>BigInt(w):p},J=e.bits2int_modN||function(l){return o.create(G(l))},nt=Yn(d);function ut(a){return Bi("num < 2^"+d,a,Ye,nt),o.toBytes(a)}function ot(a,l){return Ue(a,void 0,"message"),l?Ue(t(a),void 0,"prehashed message"):a}function q(a,l,p){if(["recovered","canonical"].some(Y=>Y in p))throw new Error("sign() legacy options not supported");const{lowS:w,prehash:x,extraEntropy:S}=yi(p,M);a=ot(a,x);const k=J(a),y=Rn(o,l),f=[ut(y),ut(k)];if(S!=null&&S!==!1){const Y=S===!0?n(B.secretKey):S;f.push(Pt("extraEntropy",Y))}const E=De(...f),V=k;function $(Y){const mt=G(Y);if(!o.isValidNot0(mt))return;const ft=o.inv(mt),st=r.BASE.multiply(mt).toAffine(),Ct=o.create(st.x);if(Ct===Ye)return;const xt=o.create(ft*o.create(V+Ct*y));if(xt===Ye)return;let Et=(st.x===Ct?0:2)|Number(st.y&Ln),Ae=xt;return w&&C(xt)&&(Ae=o.neg(xt),Et^=1),new O(Ct,Ae,Et)}return{seed:E,k2sig:$}}function Q(a,l,p={}){a=Pt("message",a);const{seed:w,k2sig:x}=q(a,l,p);return sc(t.outputLen,o.BYTES,s)(w,x)}function Z(a){let l;const p=typeof a=="string"||Zn(a),w=!p&&a!==null&&typeof a=="object"&&typeof a.r=="bigint"&&typeof a.s=="bigint";if(!p&&!w)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(w)l=new O(a.r,a.s);else if(p){try{l=O.fromBytes(Pt("sig",a),"der")}catch(x){if(!(x instanceof We.Err))throw x}if(!l)try{l=O.fromBytes(Pt("sig",a),"compact")}catch{return!1}}return l||!1}function X(a,l,p,w={}){const{lowS:x,prehash:S,format:k}=yi(w,M);if(p=Pt("publicKey",p),l=ot(Pt("message",l),S),"strict"in w)throw new Error("options.strict was renamed to lowS");const y=k===void 0?Z(a):O.fromBytes(Pt("sig",a),k);if(y===!1)return!1;try{const f=r.fromBytes(p);if(x&&y.hasHighS())return!1;const{r:E,s:V}=y,$=J(l),Y=o.inv(V),mt=o.create($*Y),ft=o.create(E*Y),st=r.BASE.multiplyUnsafe(mt).add(f.multiplyUnsafe(ft));return st.is0()?!1:o.create(st.x)===E}catch{return!1}}function m(a,l,p={}){const{prehash:w}=yi(p,M);return l=ot(l,w),O.fromBytes(a,"recovered").recoverPublicKey(l).toBytes()}return Object.freeze({keygen:v,getPublicKey:_,getSharedSecret:I,utils:A,lengths:B,Point:r,sign:Q,verify:X,recoverPublicKey:m,Signature:O,hash:t})}function yf(r){const t={a:r.a,b:r.b,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp;let n=r.allowedPrivateKeyLengths?Array.from(new Set(r.allowedPrivateKeyLengths.map(o=>Math.ceil(o/2)))):void 0;const s=wn(t.n,{BITS:r.nBitLength,allowedLengths:n,modFromBytes:r.wrapPrivateKey}),i={Fp:e,Fn:s,allowInfinityPoint:r.allowInfinityPoint,endo:r.endo,isTorsionFree:r.isTorsionFree,clearCofactor:r.clearCofactor,fromBytes:r.fromBytes,toBytes:r.toBytes};return{CURVE:t,curveOpts:i}}function wf(r){const{CURVE:t,curveOpts:e}=yf(r),n={hmac:r.hmac,randomBytes:r.randomBytes,lowS:r.lowS,bits2int:r.bits2int,bits2int_modN:r.bits2int_modN};return{CURVE:t,curveOpts:e,hash:r.hash,ecdsaOpts:n}}function bf(r,t){const e=t.Point;return Object.assign({},t,{ProjectivePoint:e,CURVE:Object.assign({},r,ao(e.Fn.ORDER,e.Fn.BITS))})}function vf(r){const{CURVE:t,curveOpts:e,hash:n,ecdsaOpts:s}=wf(r),i=pf(t,e),o=mf(i,n,s);return bf(r,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function xf(r,t){const e=n=>vf({...r,hash:n});return{...e(t),create:e}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Ef={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Ms=BigInt(2);function Sf(r){const t=Qi.p,e=BigInt(3),n=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),c=BigInt(44),d=BigInt(88),v=r*r*r%t,_=v*v*r%t,I=Ot(_,e,t)*_%t,A=Ot(I,e,t)*_%t,B=Ot(A,Ms,t)*v%t,M=Ot(B,s,t)*B%t,T=Ot(M,i,t)*M%t,C=Ot(T,c,t)*T%t,F=Ot(C,d,t)*C%t,z=Ot(F,c,t)*T%t,O=Ot(z,e,t)*_%t,G=Ot(O,o,t)*M%t,J=Ot(G,n,t)*v%t,nt=Ot(J,Ms,t);if(!ki.eql(ki.sqr(nt),r))throw new Error("Cannot find square root");return nt}const ki=wn(Qi.p,{sqrt:Sf}),Bf=xf({...Qi,Fp:ki,lowS:!0,endo:Ef},Zs);Jn.utils.randomPrivateKey;Jn.getPublicKey;function Rs(r){try{return Jn.ExtendedPoint.fromHex(r),!0}catch{return!1}}const _f=(r,t)=>Jn.sign(r,t.slice(0,32)),Af=Jn.verify,Pn=r=>dt.Buffer.isBuffer(r)?r:r instanceof Uint8Array?dt.Buffer.from(r.buffer,r.byteOffset,r.byteLength):dt.Buffer.from(r);class If{constructor(t){Object.assign(this,t)}encode(){return dt.Buffer.from(_o(lr,this))}static decode(t){return Ao(lr,this,t)}static decodeUnchecked(t){return vo(lr,this,t)}}const lr=new Map;var oa;const kf=32,an=32;function Mf(r){return r._bn!==void 0}let Ts=1;class ct extends If{constructor(t){if(super({}),this._bn=void 0,Mf(t))this._bn=t._bn;else{if(typeof t=="string"){const e=he.decode(t);if(e.length!=an)throw new Error("Invalid public key input");this._bn=new Bs(e)}else this._bn=new Bs(t);if(this._bn.byteLength()>an)throw new Error("Invalid public key input")}}static unique(){const t=new ct(Ts);return Ts+=1,new ct(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return he.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(dt.Buffer);if(t.length===an)return t;const e=dt.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=dt.Buffer.concat([t.toBuffer(),dt.Buffer.from(e),n.toBuffer()]),i=_s(s);return new ct(i)}static createProgramAddressSync(t,e){let n=dt.Buffer.alloc(0);t.forEach(function(i){if(i.length>kf)throw new TypeError("Max seed length exceeded");n=dt.Buffer.concat([n,Pn(i)])}),n=dt.Buffer.concat([n,e.toBuffer(),dt.Buffer.from("ProgramDerivedAddress")]);const s=_s(n);if(Rs(s))throw new Error("Invalid seeds, address must fall off the curve");return new ct(s)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n=255,s;for(;n!=0;){try{const i=t.concat(dt.Buffer.from([n]));s=this.createProgramAddressSync(i,e)}catch(i){if(i instanceof TypeError)throw i;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 ct(t);return Rs(e.toBytes())}}oa=ct;ct.default=new oa("11111111111111111111111111111111");lr.set(ct,{kind:"struct",fields:[["_bn","u256"]]});new ct("BPFLoader1111111111111111111111111111111111");const Un=1232,aa=127,ca=64;class ua extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(ua.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class fa 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(fa.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Vn extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Vn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Sr{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((i,o)=>{n.set(i.toBase58(),o)});const s=i=>{const o=n.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const yt=(r="publicKey")=>qt(32,r),Tn=(r="string")=>{const t=tt([it("length"),it("lengthPadding"),qt(gn(it(),-8),"chars")],r),e=t.decode.bind(t),n=t.encode.bind(t),s=t;return s.decode=(i,o)=>e(i,o).chars.toString(),s.encode=(i,o,c)=>{const d={chars:dt.Buffer.from(i,"utf8")};return n(d,o,c)},s.alloc=i=>it().span+it().span+dt.Buffer.from(i,"utf8").length,s},Rf=(r="authorized")=>tt([yt("staker"),yt("withdrawer")],r),Tf=(r="lockup")=>tt([Be("unixTimestamp"),Be("epoch"),yt("custodian")],r),Cf=(r="voteInit")=>tt([yt("nodePubkey"),yt("authorizedVoter"),yt("authorizedWithdrawer"),bt("commission")],r),Lf=(r="voteAuthorizeWithSeedArgs")=>tt([it("voteAuthorizationType"),yt("currentAuthorityDerivedKeyOwnerPubkey"),Tn("currentAuthorityDerivedKeySeed"),yt("newAuthorized")],r);function Me(r){let t=0,e=0;for(;;){let n=r.shift();if(t|=(n&127)<<e*7,e+=1,!(n&128))break}return t}function Re(r,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){r.push(n);break}else n|=128,r.push(n)}}function se(r,t){if(!r)throw new Error(t||"Assertion failed")}class Fr{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=o=>{const c=o.toBase58();let d=n.get(c);return d===void 0&&(d={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(c,d)),d},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const c of o.keys){const d=s(c.pubkey);d.isSigner||(d.isSigner=c.isSigner),d.isWritable||(d.isWritable=c.isWritable)}}return new Fr(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];se(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,d])=>d.isSigner&&d.isWritable),n=t.filter(([,d])=>d.isSigner&&!d.isWritable),s=t.filter(([,d])=>!d.isSigner&&d.isWritable),i=t.filter(([,d])=>!d.isSigner&&!d.isWritable),o={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{se(e.length>0,"Expected at least one writable signer key");const[d]=e[0];se(d===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const c=[...e.map(([d])=>new ct(d)),...n.map(([d])=>new ct(d)),...s.map(([d])=>new ct(d)),...i.map(([d])=>new ct(d))];return[o,c]}extractTableLookup(t){const[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&s.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:s},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(t,e){const n=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const c=new ct(i),d=t.findIndex(v=>v.equals(c));d>=0&&(se(d<256,"Max lookup table index exceeded"),n.push(d),s.push(c),this.keyMetaMap.delete(i))}return[n,s]}}const ha="Reached end of buffer unexpectedly";function Ze(r){if(r.length===0)throw new Error(ha);return r.shift()}function Te(r,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>r.length:e>=r.length)throw new Error(ha);return r.splice(...t)}class cn{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 ct(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:he.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Sr(this.staticAccountKeys)}static compile(t){const e=Fr.compile(t.instructions,t.payerKey),[n,s]=e.getMessageComponents(),o=new Sr(s).compileInstructions(t.instructions).map(c=>({programIdIndex:c.programIdIndex,accounts:c.accountKeyIndexes,data:he.encode(c.data)}));return new cn({header:n,accountKeys:s,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const n=t-e,i=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<i}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=[];Re(e,t);const n=this.instructions.map(I=>{const{accounts:A,programIdIndex:B}=I,M=Array.from(he.decode(I.data));let T=[];Re(T,A.length);let C=[];return Re(C,M.length),{programIdIndex:B,keyIndicesCount:dt.Buffer.from(T),keyIndices:A,dataLength:dt.Buffer.from(C),data:M}});let s=[];Re(s,n.length);let i=dt.Buffer.alloc(Un);dt.Buffer.from(s).copy(i);let o=s.length;n.forEach(I=>{const B=tt([bt("programIdIndex"),qt(I.keyIndicesCount.length,"keyIndicesCount"),be(bt("keyIndex"),I.keyIndices.length,"keyIndices"),qt(I.dataLength.length,"dataLength"),be(bt("userdatum"),I.data.length,"data")]).encode(I,i,o);o+=B}),i=i.slice(0,o);const c=tt([qt(1,"numRequiredSignatures"),qt(1,"numReadonlySignedAccounts"),qt(1,"numReadonlyUnsignedAccounts"),qt(e.length,"keyCount"),be(yt("key"),t,"keys"),yt("recentBlockhash")]),d={numRequiredSignatures:dt.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:dt.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:dt.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:dt.Buffer.from(e),keys:this.accountKeys.map(I=>Pn(I.toBytes())),recentBlockhash:he.decode(this.recentBlockhash)};let v=dt.Buffer.alloc(2048);const _=c.encode(d,v);return i.copy(v,_),v.slice(0,_+i.length)}static from(t){let e=[...t];const n=Ze(e);if(n!==(n&aa))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Ze(e),i=Ze(e),o=Me(e);let c=[];for(let A=0;A<o;A++){const B=Te(e,0,an);c.push(new ct(dt.Buffer.from(B)))}const d=Te(e,0,an),v=Me(e);let _=[];for(let A=0;A<v;A++){const B=Ze(e),M=Me(e),T=Te(e,0,M),C=Me(e),F=Te(e,0,C),z=he.encode(dt.Buffer.from(F));_.push({programIdIndex:B,accounts:T,data:z})}const I={header:{numRequiredSignatures:n,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:he.encode(dt.Buffer.from(d)),accountKeys:c,instructions:_};return new cn(I)}}class Br{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 Sr(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,i=this.addressTableLookups.reduce((o,c)=>o+c.writableIndexes.length,0);return s<i}else if(t>=this.header.numRequiredSignatures){const s=t-e,o=n-e-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=e-this.header.numReadonlySignedAccounts;return t<s}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const n of this.addressTableLookups){const s=t.find(i=>i.key.equals(n.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const i of n.writableIndexes)if(i<s.state.addresses.length)e.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${n.accountKey.toBase58()}`);for(const i of n.readonlyIndexes)if(i<s.state.addresses.length)e.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${n.accountKey.toBase58()}`)}return e}static compile(t){const e=Fr.compile(t.instructions,t.payerKey),n=new Array,s={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const _ of i){const I=e.extractTableLookup(_);if(I!==void 0){const[A,{writable:B,readonly:M}]=I;n.push(A),s.writable.push(...B),s.readonly.push(...M)}}const[o,c]=e.getMessageComponents(),v=new Sr(c,s).compileInstructions(t.instructions);return new Br({header:o,staticAccountKeys:c,recentBlockhash:t.recentBlockhash,compiledInstructions:v,addressTableLookups:n})}serialize(){const t=Array();Re(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();Re(n,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Re(i,this.addressTableLookups.length);const o=tt([bt("prefix"),tt([bt("numRequiredSignatures"),bt("numReadonlySignedAccounts"),bt("numReadonlyUnsignedAccounts")],"header"),qt(t.length,"staticAccountKeysLength"),be(yt(),this.staticAccountKeys.length,"staticAccountKeys"),yt("recentBlockhash"),qt(n.length,"instructionsLength"),qt(e.length,"serializedInstructions"),qt(i.length,"addressTableLookupsLength"),qt(s.length,"serializedAddressTableLookups")]),c=new Uint8Array(Un),v=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(_=>_.toBytes()),recentBlockhash:he.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},c);return c.slice(0,v)}serializeInstructions(){let t=0;const e=new Uint8Array(Un);for(const n of this.compiledInstructions){const s=Array();Re(s,n.accountKeyIndexes.length);const i=Array();Re(i,n.data.length);const o=tt([bt("programIdIndex"),qt(s.length,"encodedAccountKeyIndexesLength"),be(bt(),n.accountKeyIndexes.length,"accountKeyIndexes"),qt(i.length,"encodedDataLength"),qt(n.data.length,"data")]);t+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(Un);for(const n of this.addressTableLookups){const s=Array();Re(s,n.writableIndexes.length);const i=Array();Re(i,n.readonlyIndexes.length);const o=tt([yt("accountKey"),qt(s.length,"encodedWritableIndexesLength"),be(bt(),n.writableIndexes.length,"writableIndexes"),qt(i.length,"encodedReadonlyIndexesLength"),be(bt(),n.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const n=Ze(e),s=n&aa;se(n!==s,"Expected versioned message but received legacy message");const i=s;se(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Ze(e),numReadonlySignedAccounts:Ze(e),numReadonlyUnsignedAccounts:Ze(e)},c=[],d=Me(e);for(let M=0;M<d;M++)c.push(new ct(Te(e,0,an)));const v=he.encode(Te(e,0,an)),_=Me(e),I=[];for(let M=0;M<_;M++){const T=Ze(e),C=Me(e),F=Te(e,0,C),z=Me(e),O=new Uint8Array(Te(e,0,z));I.push({programIdIndex:T,accountKeyIndexes:F,data:O})}const A=Me(e),B=[];for(let M=0;M<A;M++){const T=new ct(Te(e,0,an)),C=Me(e),F=Te(e,0,C),z=Me(e),O=Te(e,0,z);B.push({accountKey:T,writableIndexes:F,readonlyIndexes:O})}return new Br({header:o,staticAccountKeys:c,recentBlockhash:v,compiledInstructions:I,addressTableLookups:B})}}let nn=function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r}({});const Uf=dt.Buffer.alloc(ca).fill(0);class Cs{constructor(t){this.keys=void 0,this.programId=void 0,this.data=dt.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 rn{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 Cs(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 T=0;T<e.length;T++)if(e[T].programId===void 0)throw new Error(`Transaction instruction index ${T} has undefined program id`);const s=[],i=[];e.forEach(T=>{T.keys.forEach(F=>{i.push({...F})});const C=T.programId.toString();s.includes(C)||s.push(C)}),s.forEach(T=>{i.push({pubkey:new ct(T),isSigner:!1,isWritable:!1})});const o=[];i.forEach(T=>{const C=T.pubkey.toString(),F=o.findIndex(z=>z.pubkey.toString()===C);F>-1?(o[F].isWritable=o[F].isWritable||T.isWritable,o[F].isSigner=o[F].isSigner||T.isSigner):o.push(T)}),o.sort(function(T,C){if(T.isSigner!==C.isSigner)return T.isSigner?-1:1;if(T.isWritable!==C.isWritable)return T.isWritable?-1:1;const F={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return T.pubkey.toBase58().localeCompare(C.pubkey.toBase58(),"en",F)});const c=o.findIndex(T=>T.pubkey.equals(n));if(c>-1){const[T]=o.splice(c,1);T.isSigner=!0,T.isWritable=!0,o.unshift(T)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const T of this.signatures){const C=o.findIndex(F=>F.pubkey.equals(T.publicKey));if(C>-1)o[C].isSigner||(o[C].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: ${T.publicKey.toString()}`)}let d=0,v=0,_=0;const I=[],A=[];o.forEach(({pubkey:T,isSigner:C,isWritable:F})=>{C?(I.push(T.toString()),d+=1,F||(v+=1)):(A.push(T.toString()),F||(_+=1))});const B=I.concat(A),M=e.map(T=>{const{data:C,programId:F}=T;return{programIdIndex:B.indexOf(F.toString()),accounts:T.keys.map(z=>B.indexOf(z.pubkey.toString())),data:he.encode(C)}});return M.forEach(T=>{se(T.programIdIndex>=0),T.accounts.forEach(C=>se(C>=0))}),new cn({header:{numRequiredSignatures:d,numReadonlySignedAccounts:v,numReadonlyUnsignedAccounts:_},accountKeys:B,recentBlockhash:t,instructions:M})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((s,i)=>e[i].equals(s.publicKey))||(this.signatures=e.map(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 i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),n.push(i))}this.signatures=n.map(i=>({signature:null,publicKey:i.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 i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),n.push(i))}const s=this._compile();this._partialSign(s,...n)}_partialSign(t,...e){const n=t.serialize();e.forEach(s=>{const i=_f(n,s.secretKey);this._addSignature(s.publicKey,Pn(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){se(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=dt.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const n={};for(const{signature:s,publicKey:i}of this.signatures)s===null?e&&(n.missing||(n.missing=[])).push(i):Af(s,t,i.toBytes())||(n.invalid||(n.invalid=[])).push(i);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 i=this._getMessageSignednessErrors(s,e);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
|
|
7
|
+
Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(c=>c.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
|
|
8
|
+
Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(c=>c.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(t){const{signatures:e}=this,n=[];Re(n,e.length);const s=n.length+e.length*64+t.length,i=dt.Buffer.alloc(s);return se(e.length<256),dt.Buffer.from(n).copy(i,0),e.forEach(({signature:o},c)=>{o!==null&&(se(o.length===64,"signature has invalid length"),dt.Buffer.from(o).copy(i,n.length+c*64))}),t.copy(i,n.length+e.length*64),se(i.length<=Un,`Transaction too large: ${i.length} > ${Un}`),i}get keys(){return se(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return se(this.instructions.length===1),this.instructions[0].programId}get data(){return se(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const n=Me(e);let s=[];for(let i=0;i<n;i++){const o=Te(e,0,ca);s.push(he.encode(dt.Buffer.from(o)))}return rn.populate(cn.from(e),s)}static populate(t,e=[]){const n=new rn;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((s,i)=>{const o={signature:s==he.encode(Uf)?null:he.decode(s),publicKey:t.accountKeys[i]};n.signatures.push(o)}),t.instructions.forEach(s=>{const i=s.accounts.map(o=>{const c=t.accountKeys[o];return{pubkey:c,isSigner:n.signatures.some(d=>d.publicKey.toString()===c.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});n.instructions.push(new Cs({keys:i,programId:t.accountKeys[s.programIdIndex],data:he.decode(s.data)}))}),n._message=t,n._json=n.toJSON(),n}}const Ff=160,Nf=64,Of=Ff/Nf,Pf=1e3/Of;new ct("SysvarC1ock11111111111111111111111111111111");new ct("SysvarEpochSchedu1e111111111111111111111111");new ct("Sysvar1nstructions1111111111111111111111111");new ct("SysvarRecentB1ockHashes11111111111111111111");new ct("SysvarRent111111111111111111111111111111111");new ct("SysvarRewards111111111111111111111111111111");new ct("SysvarS1otHashes111111111111111111111111111");new ct("SysvarS1otHistory11111111111111111111111111");new ct("SysvarStakeHistory1111111111111111111111111");class Ls extends Error{constructor({action:t,signature:e,transactionMessage:n,logs:s}){const i=s?`Logs:
|
|
9
|
+
${JSON.stringify(s.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let c;switch(t){case"send":c=`Transaction ${e} resulted in an error.
|
|
10
|
+
${n}. `+i+o;break;case"simulate":c=`Simulation failed.
|
|
11
|
+
Message: ${n}.
|
|
12
|
+
`+i+o;break;default:c=`Unknown action '${(d=>d)(t)}'`}super(c),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 i=s.meta.logMessages;this.transactionLogs=i,e(i)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}class et 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"}}function Mn(r){return new Promise(t=>setTimeout(t,r))}const qf=ue("lamportsPerSignature"),la=tt([it("version"),it("state"),yt("authorizedPubkey"),yt("nonce"),tt([qf],"feeCalculator")]);la.span;class ts{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=la.decode(Pn(t),0);return new ts({authorizedPubkey:new ct(e.authorizedPubkey),nonce:new ct(e.nonce).toString(),feeCalculator:e.feeCalculator})}}function qn(r){const t=qt(8,r),e=t.decode.bind(t),n=t.encode.bind(t),s=t,i=Bu();return s.decode=(o,c)=>{const d=e(o,c);return i.decode(d)},s.encode=(o,c,d)=>{const v=i.encode(o);return n(v,c,d)},s}Object.freeze({Create:{index:0,layout:tt([it("instruction"),Be("lamports"),Be("space"),yt("programId")])},Assign:{index:1,layout:tt([it("instruction"),yt("programId")])},Transfer:{index:2,layout:tt([it("instruction"),qn("lamports")])},CreateWithSeed:{index:3,layout:tt([it("instruction"),yt("base"),Tn("seed"),Be("lamports"),Be("space"),yt("programId")])},AdvanceNonceAccount:{index:4,layout:tt([it("instruction")])},WithdrawNonceAccount:{index:5,layout:tt([it("instruction"),Be("lamports")])},InitializeNonceAccount:{index:6,layout:tt([it("instruction"),yt("authorized")])},AuthorizeNonceAccount:{index:7,layout:tt([it("instruction"),yt("authorized")])},Allocate:{index:8,layout:tt([it("instruction"),Be("space")])},AllocateWithSeed:{index:9,layout:tt([it("instruction"),yt("base"),Tn("seed"),Be("space"),yt("programId")])},AssignWithSeed:{index:10,layout:tt([it("instruction"),yt("base"),Tn("seed"),yt("programId")])},TransferWithSeed:{index:11,layout:tt([it("instruction"),qn("lamports"),Tn("seed"),yt("programId")])},UpgradeNonceAccount:{index:12,layout:tt([it("instruction")])}});new ct("11111111111111111111111111111111");new ct("BPFLoader2111111111111111111111111111111111");function Df(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var wi,Us;function zf(){if(Us)return wi;Us=1;var r=Object.prototype.toString,t=Object.keys||function(n){var s=[];for(var i in n)s.push(i);return s};function e(n,s){var i,o,c,d,v,_,I;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return e(n.toJSON(),s);if(I=r.call(n),I==="[object Array]"){for(c="[",o=n.length-1,i=0;i<o;i++)c+=e(n[i],!0)+",";return o>-1&&(c+=e(n[i],!0)),c+"]"}else if(I==="[object Object]"){for(d=t(n).sort(),o=d.length,c="",i=0;i<o;)v=d[i],_=e(n[v],!1),_!==void 0&&(c&&(c+=","),c+=JSON.stringify(v)+":"+_),i++;return"{"+c+"}"}else return JSON.stringify(n);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return wi=function(n){var s=e(n,!1);if(s!==void 0)return""+s},wi}var Kf=zf(),Fs=Df(Kf);const Hn=32;function bi(r){let t=0;for(;r>1;)r/=2,t++;return t}function $f(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}class Hf{constructor(t,e,n,s,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=bi($f(t+Hn+1))-bi(Hn)-1,n=this.getSlotsInEpoch(e),s=t-(n-Hn);return[e,s]}else{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch),s=this.firstNormalEpoch+n,i=e%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*Hn:(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+bi(Hn)):this.slotsPerEpoch}}var Vf=globalThis.fetch;class jf extends ff{constructor(t,e,n){const s=i=>{const o=cf(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,t,e,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 Wf(r,t){let e;try{e=r.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${r.index}`);return e}const Ns=56;class Os{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=Wf(Gf,t),n=t.length-Ns;se(n>=0,"lookup table is invalid"),se(n%32===0,"lookup table is invalid");const s=n/32,{addresses:i}=tt([be(yt(),s,"addresses")]).decode(t.slice(Ns));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new ct(e.authority[0]):void 0,addresses:i.map(o=>new ct(o))}}}const Gf={index:1,layout:tt([it("typeIndex"),qn("deactivationSlot"),ue("lastExtendedSlot"),bt("lastExtendedStartIndex"),bt(),be(yt(),gn(bt(),-1),"authority")])},Zf=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Yf(r){const t=r.match(Zf);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);const[e,n,s,i]=t,o=r.startsWith("https:")?"wss:":"ws:",c=s==null?null:parseInt(s.slice(1),10),d=c==null?"":`:${c+1}`;return`${o}//${n}${d}${i}`}const Tt=er(Xi(ct),K(),r=>new ct(r)),da=Ji([K(),Rt("base64")]),es=er(Xi(dt.Buffer),da,r=>dt.Buffer.from(r[0],"base64")),Xf=30*1e3;function Jf(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function Bt(r){let t,e;if(typeof r=="string")t=r;else if(r){const{commitment:n,...s}=r;t=n,e=s}return{commitment:t,config:e}}function Ps(r){return r.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function pa(r){return ve([D({jsonrpc:Rt("2.0"),id:K(),result:r}),D({jsonrpc:Rt("2.0"),id:K(),error:D({code:Kn(),message:K(),data:rt(Tu())})})])}const Qf=pa(Kn());function gt(r){return er(pa(r),Qf,t=>"error"in t?t:{...t,result:H(t.result,r)})}function Dt(r){return gt(D({context:D({slot:U()}),value:r}))}function Nr(r){return D({context:D({slot:U()}),value:r})}function vi(r,t){return r===0?new Br({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new ct(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:he.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new cn(t)}const th=D({foundation:U(),foundationTerm:U(),initial:U(),taper:U(),terminal:U()}),eh=gt(j(W(D({epoch:U(),effectiveSlot:U(),amount:U(),postBalance:U(),commission:rt(W(U()))})))),nh=j(D({slot:U(),prioritizationFee:U()})),rh=D({total:U(),validator:U(),foundation:U(),epoch:U()}),ih=D({epoch:U(),slotIndex:U(),slotsInEpoch:U(),absoluteSlot:U(),blockHeight:rt(U()),transactionCount:rt(U())}),sh=D({slotsPerEpoch:U(),leaderScheduleSlotOffset:U(),warmup:ze(),firstNormalEpoch:U(),firstNormalSlot:U()}),oh=Wo(K(),j(U())),xn=W(ve([D({}),K()])),ah=D({err:xn}),ch=Rt("receivedSignature"),uh=D({"solana-core":K(),"feature-set":rt(U())}),fh=D({program:K(),programId:Tt,parsed:Kn()}),hh=D({programId:Tt,accounts:j(Tt),data:K()}),qs=Dt(D({err:W(ve([D({}),K()])),logs:W(j(K())),accounts:rt(W(j(W(D({executable:ze(),owner:K(),lamports:U(),data:j(K()),rentEpoch:rt(U())}))))),unitsConsumed:rt(U()),returnData:rt(W(D({programId:K(),data:Ji([K(),Rt("base64")])}))),innerInstructions:rt(W(j(D({index:U(),instructions:j(ve([fh,hh]))}))))})),lh=Dt(D({byIdentity:Wo(K(),j(U())),range:D({firstSlot:U(),lastSlot:U()})}));function dh(r,t,e,n,s,i){const o=e||Vf;let c;i!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let d;return n&&(d=async(_,I)=>{const A=await new Promise((B,M)=>{try{n(_,I,(T,C)=>B([T,C]))}catch(T){M(T)}});return await o(...A)}),new sf(async(_,I)=>{const A={method:"POST",body:_,agent:c,headers:Object.assign({"Content-Type":"application/json"},t||{},dl)};try{let B=5,M,T=500;for(;d?M=await d(r,A):M=await o(r,A),!(M.status!==429||s===!0||(B-=1,B===0));)console.error(`Server responded with ${M.status} ${M.statusText}. Retrying after ${T}ms delay...`),await Mn(T),T*=2;const C=await M.text();M.ok?I(null,C):I(new Error(`${M.status} ${M.statusText}: ${C}`))}catch(B){B instanceof Error&&I(B)}},{})}function ph(r){return(t,e)=>new Promise((n,s)=>{r.request(t,e,(i,o)=>{if(i){s(i);return}n(o)})})}function gh(r){return t=>new Promise((e,n)=>{t.length===0&&e([]);const s=t.map(i=>r.request(i.methodName,i.args));r.request(s,(i,o)=>{if(i){n(i);return}e(o)})})}const mh=gt(th),yh=gt(rh),wh=gt(nh),bh=gt(ih),vh=gt(sh),xh=gt(oh),Eh=gt(U()),Sh=Dt(D({total:U(),circulating:U(),nonCirculating:U(),nonCirculatingAccounts:j(Tt)})),Mi=D({amount:K(),uiAmount:W(U()),decimals:U(),uiAmountString:rt(K())}),Bh=Dt(j(D({address:Tt,amount:K(),uiAmount:W(U()),decimals:U(),uiAmountString:rt(K())}))),_h=Dt(j(D({pubkey:Tt,account:D({executable:ze(),owner:Tt,lamports:U(),data:es,rentEpoch:U()})}))),Ri=D({program:K(),parsed:Kn(),space:U()}),Ah=Dt(j(D({pubkey:Tt,account:D({executable:ze(),owner:Tt,lamports:U(),data:Ri,rentEpoch:U()})}))),Ih=Dt(j(D({lamports:U(),address:Tt}))),Gn=D({executable:ze(),owner:Tt,lamports:U(),data:es,rentEpoch:U()}),kh=D({pubkey:Tt,account:Gn}),Mh=er(ve([Xi(dt.Buffer),Ri]),ve([da,Ri]),r=>Array.isArray(r)?H(r,es):r),Ti=D({executable:ze(),owner:Tt,lamports:U(),data:Mh,rentEpoch:U()}),Rh=D({pubkey:Tt,account:Ti}),Th=D({state:ve([Rt("active"),Rt("inactive"),Rt("activating"),Rt("deactivating")]),active:U(),inactive:U()}),Ch=gt(j(D({signature:K(),slot:U(),err:xn,memo:W(K()),blockTime:rt(W(U()))}))),Lh=gt(j(D({signature:K(),slot:U(),err:xn,memo:W(K()),blockTime:rt(W(U()))}))),Uh=D({subscription:U(),result:Nr(Gn)}),Fh=D({pubkey:Tt,account:Gn}),Nh=D({subscription:U(),result:Nr(Fh)}),Oh=D({parent:U(),slot:U(),root:U()}),Ph=D({subscription:U(),result:Oh}),qh=ve([D({type:ve([Rt("firstShredReceived"),Rt("completed"),Rt("optimisticConfirmation"),Rt("root")]),slot:U(),timestamp:U()}),D({type:Rt("createdBank"),parent:U(),slot:U(),timestamp:U()}),D({type:Rt("frozen"),slot:U(),timestamp:U(),stats:D({numTransactionEntries:U(),numSuccessfulTransactions:U(),numFailedTransactions:U(),maxTransactionsPerEntry:U()})}),D({type:Rt("dead"),slot:U(),timestamp:U(),err:K()})]),Dh=D({subscription:U(),result:qh}),zh=D({subscription:U(),result:Nr(ve([ah,ch]))}),Kh=D({subscription:U(),result:U()}),$h=D({pubkey:K(),gossip:W(K()),tpu:W(K()),rpc:W(K()),version:W(K())}),Ds=D({votePubkey:K(),nodePubkey:K(),activatedStake:U(),epochVoteAccount:ze(),epochCredits:j(Ji([U(),U(),U()])),commission:U(),lastVote:U(),rootSlot:W(U())}),Hh=gt(D({current:j(Ds),delinquent:j(Ds)})),Vh=ve([Rt("processed"),Rt("confirmed"),Rt("finalized")]),jh=D({slot:U(),confirmations:W(U()),err:xn,confirmationStatus:rt(Vh)}),Wh=Dt(j(W(jh))),Gh=gt(U()),ga=D({accountKey:Tt,writableIndexes:j(U()),readonlyIndexes:j(U())}),ns=D({signatures:j(K()),message:D({accountKeys:j(K()),header:D({numRequiredSignatures:U(),numReadonlySignedAccounts:U(),numReadonlyUnsignedAccounts:U()}),instructions:j(D({accounts:j(U()),data:K(),programIdIndex:U()})),recentBlockhash:K(),addressTableLookups:rt(j(ga))})}),ma=D({pubkey:Tt,signer:ze(),writable:ze(),source:rt(ve([Rt("transaction"),Rt("lookupTable")]))}),ya=D({accountKeys:j(ma),signatures:j(K())}),wa=D({parsed:Kn(),program:K(),programId:Tt}),ba=D({accounts:j(Tt),data:K(),programId:Tt}),Zh=ve([ba,wa]),Yh=ve([D({parsed:Kn(),program:K(),programId:K()}),D({accounts:j(K()),data:K(),programId:K()})]),va=er(Zh,Yh,r=>"accounts"in r?H(r,ba):H(r,wa)),xa=D({signatures:j(K()),message:D({accountKeys:j(ma),instructions:j(va),recentBlockhash:K(),addressTableLookups:rt(W(j(ga)))})}),_r=D({accountIndex:U(),mint:K(),owner:rt(K()),programId:rt(K()),uiTokenAmount:Mi}),Ea=D({writable:j(Tt),readonly:j(Tt)}),Or=D({err:xn,fee:U(),innerInstructions:rt(W(j(D({index:U(),instructions:j(D({accounts:j(U()),data:K(),programIdIndex:U()}))})))),preBalances:j(U()),postBalances:j(U()),logMessages:rt(W(j(K()))),preTokenBalances:rt(W(j(_r))),postTokenBalances:rt(W(j(_r))),loadedAddresses:rt(Ea),computeUnitsConsumed:rt(U()),costUnits:rt(U())}),rs=D({err:xn,fee:U(),innerInstructions:rt(W(j(D({index:U(),instructions:j(va)})))),preBalances:j(U()),postBalances:j(U()),logMessages:rt(W(j(K()))),preTokenBalances:rt(W(j(_r))),postTokenBalances:rt(W(j(_r))),loadedAddresses:rt(Ea),computeUnitsConsumed:rt(U()),costUnits:rt(U())}),$n=ve([Rt(0),Rt("legacy")]),En=D({pubkey:K(),lamports:U(),postBalance:W(U()),rewardType:W(K()),commission:rt(W(U()))}),Xh=gt(W(D({blockhash:K(),previousBlockhash:K(),parentSlot:U(),transactions:j(D({transaction:ns,meta:W(Or),version:rt($n)})),rewards:rt(j(En)),blockTime:W(U()),blockHeight:W(U())}))),Jh=gt(W(D({blockhash:K(),previousBlockhash:K(),parentSlot:U(),rewards:rt(j(En)),blockTime:W(U()),blockHeight:W(U())}))),Qh=gt(W(D({blockhash:K(),previousBlockhash:K(),parentSlot:U(),transactions:j(D({transaction:ya,meta:W(Or),version:rt($n)})),rewards:rt(j(En)),blockTime:W(U()),blockHeight:W(U())}))),tl=gt(W(D({blockhash:K(),previousBlockhash:K(),parentSlot:U(),transactions:j(D({transaction:xa,meta:W(rs),version:rt($n)})),rewards:rt(j(En)),blockTime:W(U()),blockHeight:W(U())}))),el=gt(W(D({blockhash:K(),previousBlockhash:K(),parentSlot:U(),transactions:j(D({transaction:ya,meta:W(rs),version:rt($n)})),rewards:rt(j(En)),blockTime:W(U()),blockHeight:W(U())}))),nl=gt(W(D({blockhash:K(),previousBlockhash:K(),parentSlot:U(),rewards:rt(j(En)),blockTime:W(U()),blockHeight:W(U())}))),rl=gt(W(D({blockhash:K(),previousBlockhash:K(),parentSlot:U(),transactions:j(D({transaction:ns,meta:W(Or)})),rewards:rt(j(En)),blockTime:W(U())}))),zs=gt(W(D({blockhash:K(),previousBlockhash:K(),parentSlot:U(),signatures:j(K()),blockTime:W(U())}))),xi=gt(W(D({slot:U(),meta:W(Or),blockTime:rt(W(U())),transaction:ns,version:rt($n)}))),hr=gt(W(D({slot:U(),transaction:xa,meta:W(rs),blockTime:rt(W(U())),version:rt($n)}))),il=Dt(D({blockhash:K(),lastValidBlockHeight:U()})),sl=Dt(ze()),ol=D({slot:U(),numTransactions:U(),numSlots:U(),samplePeriodSecs:U()}),al=gt(j(ol)),cl=Dt(W(D({feeCalculator:D({lamportsPerSignature:U()})}))),ul=gt(K()),fl=gt(K()),hl=D({err:xn,logs:j(K()),signature:K()}),ll=D({result:Nr(hl),subscription:U()}),dl={"solana-client":"js/1.0.0-maintenance"};class wl{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 v={};return async _=>{const{commitment:I,config:A}=Bt(_),B=this._buildArgs([],I,void 0,A),M=Fs(B);return v[M]=v[M]??(async()=>{try{const T=await this._rpcRequest("getBlockHeight",B),C=H(T,gt(U()));if("error"in C)throw new et(C.error,"failed to get block height information");return C.result}finally{delete v[M]}})(),await v[M]}})();let n,s,i,o,c,d;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,s=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,c=e.disableRetryOnRateLimit,d=e.httpAgent),this._rpcEndpoint=Jf(t),this._rpcWsEndpoint=n||Yf(t),this._rpcClient=dh(t,s,i,o,c,d),this._rpcRequest=ph(this._rpcClient),this._rpcBatchRequest=gh(this._rpcClient),this._rpcWebSocket=new jf(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}=Bt(e),i=this._buildArgs([t.toBase58()],n,void 0,s),o=await this._rpcRequest("getBalance",i),c=H(o,Dt(U()));if("error"in c)throw new et(c.error,`failed to get balance for ${t.toBase58()}`);return c.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=H(e,gt(W(U())));if("error"in n)throw new et(n.error,`failed to get block time for slot ${t}`);return n.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=H(t,gt(U()));if("error"in e)throw new et(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=H(t,Eh);if("error"in e)throw new et(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=H(n,Sh);if("error"in s)throw new et(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),i=H(s,Dt(Mi));if("error"in i)throw new et(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(t,e){const n=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenAccountBalance",n),i=H(s,Dt(Mi));if("error"in i)throw new et(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(t,e,n){const{commitment:s,config:i}=Bt(n);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const c=this._buildArgs(o,s,"base64",i),d=await this._rpcRequest("getTokenAccountsByOwner",c),v=H(d,_h);if("error"in v)throw new et(v.error,`failed to get token accounts owned by account ${t.toBase58()}`);return v.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 i=this._buildArgs(s,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),c=H(o,Ah);if("error"in c)throw new et(c.error,`failed to get token accounts owned by account ${t.toBase58()}`);return c.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),i=H(s,Ih);if("error"in i)throw new et(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(t,e){const n=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenLargestAccounts",n),i=H(s,Bh);if("error"in i)throw new et(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:s}=Bt(e),i=this._buildArgs([t.toBase58()],n,"base64",s),o=await this._rpcRequest("getAccountInfo",i),c=H(o,Dt(W(Gn)));if("error"in c)throw new et(c.error,`failed to get info about account ${t.toBase58()}`);return c.result}async getParsedAccountInfo(t,e){const{commitment:n,config:s}=Bt(e),i=this._buildArgs([t.toBase58()],n,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),c=H(o,Dt(W(Ti)));if("error"in c)throw new et(c.error,`failed to get info about account ${t.toBase58()}`);return c.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}=Bt(e),i=t.map(v=>v.toBase58()),o=this._buildArgs([i],n,"jsonParsed",s),c=await this._rpcRequest("getMultipleAccounts",o),d=H(c,Dt(j(W(Ti))));if("error"in d)throw new et(d.error,`failed to get info for accounts ${i}`);return d.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:s}=Bt(e),i=t.map(v=>v.toBase58()),o=this._buildArgs([i],n,"base64",s),c=await this._rpcRequest("getMultipleAccounts",o),d=H(c,Dt(j(W(Gn))));if("error"in d)throw new et(d.error,`failed to get info for accounts ${i}`);return d.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:s,config:i}=Bt(e),o=this._buildArgs([t.toBase58()],s,void 0,{...i,epoch:n??(i==null?void 0:i.epoch)}),c=await this._rpcRequest("getStakeActivation",o),d=H(c,gt(Th));if("error"in d)throw new et(d.error,`failed to get Stake Activation ${t.toBase58()}`);return d.result}async getProgramAccounts(t,e){const{commitment:n,config:s}=Bt(e),{encoding:i,...o}=s||{},c=this._buildArgs([t.toBase58()],n,i||"base64",{...o,...o.filters?{filters:Ps(o.filters)}:null}),d=await this._rpcRequest("getProgramAccounts",c),v=j(kh),_=o.withContext===!0?H(d,Dt(v)):H(d,gt(v));if("error"in _)throw new et(_.error,`failed to get accounts owned by program ${t.toBase58()}`);return _.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:s}=Bt(e),i=this._buildArgs([t.toBase58()],n,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),c=H(o,gt(j(Rh)));if("error"in c)throw new et(c.error,`failed to get accounts owned by program ${t.toBase58()}`);return c.result}async confirmTransaction(t,e){var i;let n;if(typeof t=="string")n=t;else{const o=t;if((i=o.abortSignal)!=null&&i.aborted)return Promise.reject(o.abortSignal.reason);n=o.signature}let s;try{s=he.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return se(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,i=!1;const o=new Promise((d,v)=>{try{n=this.onSignature(e,(I,A)=>{n=void 0;const B={context:A,value:I};d({__type:nn.PROCESSED,response:B})},t);const _=new Promise(I=>{n==null?I():s=this._onSubscriptionStateChange(n,A=>{A==="subscribed"&&I()})});(async()=>{if(await _,i)return;const I=await this.getSignatureStatus(e);if(i||I==null)return;const{context:A,value:B}=I;if(B!=null)if(B!=null&&B.err)v(B.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(B.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(B.confirmationStatus==="processed"||B.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,d({__type:nn.PROCESSED,response:{context:A,value:B}})}})()}catch(_){v(_)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:s}}){let i=!1;const o=new Promise(I=>{const A=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let B=await A();if(!i){for(;B<=n;)if(await Mn(1e3),i||(B=await A(),i))return;I({__type:nn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:c,confirmationPromise:d}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),v=this.getCancellationPromise(e);let _;try{const I=await Promise.race([v,d,o]);if(I.__type===nn.PROCESSED)_=I.response;else throw new ua(s)}finally{i=!0,c()}return _}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let c=!1;const d=new Promise(B=>{let M=i,T=null;const C=async()=>{try{const{context:F,value:z}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:n});return T=F.slot,z==null?void 0:z.nonce}catch{return M}};(async()=>{if(M=await C(),!c)for(;;){if(i!==M){B({__type:nn.NONCE_INVALID,slotInWhichNonceDidAdvance:T});return}if(await Mn(2e3),c||(M=await C(),c))return}})()}),{abortConfirmation:v,confirmationPromise:_}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),I=this.getCancellationPromise(e);let A;try{const B=await Promise.race([I,_,d]);if(B.__type===nn.PROCESSED)A=B.response;else{let M;for(;;){const T=await this.getSignatureStatus(o);if(T==null)break;if(T.context.slot<(B.slotInWhichNonceDidAdvance??n)){await Mn(400);continue}M=T;break}if(M!=null&&M.value){const T=t||"finalized",{confirmationStatus:C}=M.value;switch(T){case"processed":case"recent":if(C!=="processed"&&C!=="confirmed"&&C!=="finalized")throw new Vn(o);break;case"confirmed":case"single":case"singleGossip":if(C!=="confirmed"&&C!=="finalized")throw new Vn(o);break;case"finalized":case"max":case"root":if(C!=="finalized")throw new Vn(o);break;default:}A={context:M.context,value:{err:M.value.err}}}else throw new Vn(o)}}finally{c=!0,v()}return A}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const s=new Promise(d=>{let v=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{v=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>d({__type:nn.TIMED_OUT,timeoutMs:v}),v)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let c;try{const d=await Promise.race([o,s]);if(d.__type===nn.PROCESSED)c=d.response;else throw new fa(e,d.timeoutMs/1e3)}finally{clearTimeout(n),i()}return c}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=H(t,gt(j($h)));if("error"in e)throw new et(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=H(n,Hh);if("error"in s)throw new et(s.error,"failed to get vote accounts");return s.result}async getSlot(t){const{commitment:e,config:n}=Bt(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getSlot",s),o=H(i,gt(U()));if("error"in o)throw new et(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:n}=Bt(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getSlotLeader",s),o=H(i,gt(K()));if("error"in o)throw new et(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const n=[t,e],s=await this._rpcRequest("getSlotLeaders",n),i=H(s,gt(j(Tt)));if("error"in i)throw new et(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(t,e){const{context:n,value:s}=await this.getSignatureStatuses([t],e);se(s.length===1);const i=s[0];return{context:n,value:i}}async getSignatureStatuses(t,e){const n=[t];e&&n.push(e);const s=await this._rpcRequest("getSignatureStatuses",n),i=H(s,Wh);if("error"in i)throw new et(i.error,"failed to get signature status");return i.result}async getTransactionCount(t){const{commitment:e,config:n}=Bt(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getTransactionCount",s),o=H(i,gt(U()));if("error"in o)throw new et(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getInflationGovernor",e),s=H(n,mh);if("error"in s)throw new et(s.error,"failed to get inflation");return s.result}async getInflationReward(t,e,n){const{commitment:s,config:i}=Bt(n),o=this._buildArgs([t.map(v=>v.toBase58())],s,void 0,{...i,epoch:e??(i==null?void 0:i.epoch)}),c=await this._rpcRequest("getInflationReward",o),d=H(c,eh);if("error"in d)throw new et(d.error,"failed to get inflation reward");return d.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=H(t,yh);if("error"in e)throw new et(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:n}=Bt(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getEpochInfo",s),o=H(i,bh);if("error"in o)throw new et(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=H(t,vh);if("error"in e)throw new et(e.error,"failed to get epoch schedule");const n=e.result;return new Hf(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=H(t,xh);if("error"in e)throw new et(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),i=H(s,Gh);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),n=H(e,al);if("error"in n)throw new et(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),i=H(s,cl);if("error"in i)throw new et(i.error,"failed to get fee calculator");const{context:o,value:c}=i.result;return{context:o,value:c!==null?c.feeCalculator:null}}async getFeeForMessage(t,e){const n=Pn(t.serialize()).toString("base64"),s=this._buildArgs([n],e),i=await this._rpcRequest("getFeeForMessage",s),o=H(i,Dt(W(U())));if("error"in o)throw new et(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(c=>c.toBase58()),n=e!=null&&e.length?[e]:[],s=await this._rpcRequest("getRecentPrioritizationFees",n),i=H(s,wh);if("error"in i)throw new et(i.error,"failed to get recent prioritization fees");return i.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:n}=Bt(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getLatestBlockhash",s),o=H(i,il);if("error"in o)throw new et(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:n,config:s}=Bt(e),i=this._buildArgs([t],n,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),c=H(o,sl);if("error"in c)throw new et(c.error,"failed to determine if the blockhash `"+t+"`is valid");return c.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=H(t,gt(uh));if("error"in e)throw new et(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=H(t,gt(K()));if("error"in e)throw new et(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:n,config:s}=Bt(e),i=this._buildArgsAtLeastConfirmed([t],n,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const c=H(o,Qh);if("error"in c)throw c.error;return c.result}case"none":{const c=H(o,Jh);if("error"in c)throw c.error;return c.result}default:{const c=H(o,Xh);if("error"in c)throw c.error;const{result:d}=c;return d?{...d,transactions:d.transactions.map(({transaction:v,meta:_,version:I})=>({meta:_,transaction:{...v,message:vi(I,v.message)},version:I}))}:null}}}catch(c){throw new et(c,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:s}=Bt(e),i=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const c=H(o,el);if("error"in c)throw c.error;return c.result}case"none":{const c=H(o,nl);if("error"in c)throw c.error;return c.result}default:{const c=H(o,tl);if("error"in c)throw c.error;return c.result}}}catch(c){throw new et(c,"failed to get block")}}async getBlockProduction(t){let e,n;if(typeof t=="string")n=t;else if(t){const{commitment:c,...d}=t;n=c,e=d}const s=this._buildArgs([],n,"base64",e),i=await this._rpcRequest("getBlockProduction",s),o=H(i,lh);if("error"in o)throw new et(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:n,config:s}=Bt(e),i=this._buildArgsAtLeastConfirmed([t],n,void 0,s),o=await this._rpcRequest("getTransaction",i),c=H(o,xi);if("error"in c)throw new et(c.error,"failed to get transaction");const d=c.result;return d&&{...d,transaction:{...d.transaction,message:vi(d.version,d.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:n,config:s}=Bt(e),i=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),c=H(o,hr);if("error"in c)throw new et(c.error,"failed to get transaction");return c.result}async getParsedTransactions(t,e){const{commitment:n,config:s}=Bt(e),i=t.map(d=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([d],n,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(d=>{const v=H(d,hr);if("error"in v)throw new et(v.error,"failed to get transactions");return v.result})}async getTransactions(t,e){const{commitment:n,config:s}=Bt(e),i=t.map(d=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([d],n,void 0,s)}));return(await this._rpcBatchRequest(i)).map(d=>{const v=H(d,xi);if("error"in v)throw new et(v.error,"failed to get transactions");const _=v.result;return _&&{..._,transaction:{..._.transaction,message:vi(_.version,_.transaction.message)}}})}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getBlock",n),i=H(s,rl);if("error"in i)throw new et(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");const c={...o,transactions:o.transactions.map(({transaction:d,meta:v})=>{const _=new cn(d.message);return{meta:v,transaction:{...d,message:_}}})};return{...c,transactions:c.transactions.map(({transaction:d,meta:v})=>({meta:v,transaction:rn.populate(d.message,d.signatures)}))}}async getBlocks(t,e,n){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),i=await this._rpcRequest("getBlocks",s),o=H(i,gt(j(U())));if("error"in o)throw new et(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",n),i=H(s,zs);if("error"in i)throw new et(i.error,"failed to get block");const o=i.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",n),i=H(s,zs);if("error"in i)throw new et(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getTransaction",n),i=H(s,xi);if("error"in i)throw new et(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const c=new cn(o.transaction.message),d=o.transaction.signatures;return{...o,transaction:rn.populate(c,d)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getTransaction",n),i=H(s,hr);if("error"in i)throw new et(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(t,e){const n=t.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(o=>{const c=H(o,hr);if("error"in c)throw new et(c.error,"failed to get confirmed transactions");return c.result})}async getConfirmedSignaturesForAddress(t,e,n){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const d=await this.getConfirmedBlockSignatures(e,"finalized");d.signatures.length>0&&(s.until=d.signatures[d.signatures.length-1].toString())}catch(d){if(d instanceof Error&&d.message.includes("skipped"))continue;throw d}let o=await this.getSlot("finalized");for(;!("before"in s)&&(n++,!(n>o));)try{const d=await this.getConfirmedBlockSignatures(n);d.signatures.length>0&&(s.before=d.signatures[d.signatures.length-1].toString())}catch(d){if(d instanceof Error&&d.message.includes("skipped"))continue;throw d}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(d=>d.signature)}async getConfirmedSignaturesForAddress2(t,e,n){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=H(i,Ch);if("error"in o)throw new et(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,n){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),i=await this._rpcRequest("getSignaturesForAddress",s),o=H(i,Lh);if("error"in o)throw new et(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:n,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=new Os({key:t,state:Os.deserialize(s.data)})),{context:n,value:i}}async getNonceAndContext(t,e){const{context:n,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=ts.fromAccountData(s.data)),{context:n,value:i}}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=H(n,ul);if("error"in s)throw new et(s.error,`airdrop to ${t.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Mn(100);const n=Date.now()-this._blockhashInfo.lastFetch>=Xf;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 i=await this.getLatestBlockhash("finalized");if(n!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await Mn(Pf/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}=Bt(t),s=this._buildArgs([],e,"base64",n),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=H(i,Dt(U()));if("error"in o)throw new et(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,n){if("message"in t){const T=t.serialize(),C=dt.Buffer.from(T).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const F=e||{};F.encoding="base64","commitment"in F||(F.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(F.innerInstructions=e.innerInstructions);const z=[C,F],O=await this._rpcRequest("simulateTransaction",z),G=H(O,qs);if("error"in G)throw new Error("failed to simulate transaction: "+G.error.message);return G.result}let s;if(t instanceof rn){let M=t;s=new rn,s.feePayer=M.feePayer,s.instructions=t.instructions,s.nonceInfo=M.nonceInfo,s.signatures=M.signatures}else s=rn.populate(t),s._message=s._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(s.nonceInfo&&i)s.sign(...i);else{let M=this._disableBlockhashCaching;for(;;){const T=await this._blockhashWithExpiryBlockHeight(M);if(s.lastValidBlockHeight=T.lastValidBlockHeight,s.recentBlockhash=T.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const C=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(C)&&!this._blockhashInfo.transactionSignatures.includes(C)){this._blockhashInfo.simulatedSignatures.push(C);break}else M=!0}}const o=s._compile(),c=o.serialize(),v=s._serialize(c).toString("base64"),_={encoding:"base64",commitment:this.commitment};if(n){const M=(Array.isArray(n)?n:o.nonProgramIds()).map(T=>T.toBase58());_.accounts={encoding:"base64",addresses:M}}i&&(_.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(_.innerInstructions=e.innerInstructions);const I=[v,_],A=await this._rpcRequest("simulateTransaction",I),B=H(A,qs);if("error"in B){let M;if("data"in B.error&&(M=B.error.data.logs,M&&Array.isArray(M))){const T=`
|
|
13
|
+
`,C=T+M.join(T);console.error(B.error.message,C)}throw new Ls({action:"simulate",signature:"",transactionMessage:B.error.message,logs:M})}return B.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(t.nonceInfo)t.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const c=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=c.lastValidBlockHeight,t.recentBlockhash=c.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const d=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(d))o=!0;else{this._blockhashInfo.transactionSignatures.push(d);break}}}const i=t.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(t,e){const n=Pn(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},s=e&&e.skipPreflight,i=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),i&&(n.preflightCommitment=i);const o=[t,n],c=await this._rpcRequest("sendTransaction",o),d=H(c,fl);if("error"in d){let v;throw"data"in d.error&&(v=d.error.data.logs),new Ls({action:s?"send":"simulate",signature:"",transactionMessage:d.error.message,logs:v})}return d.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 i=this._subscriptionStateChangeCallbacksByHash[t];i&&i.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var i;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const s=(i=this._subscriptionStateChangeCallbacksByHash)[n]||(i[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:i,method:o}=s;try{this._setSubscription(n,{...s,state:"subscribing"});const c=await this._rpcWebSocket.call(o,i);this._setSubscription(n,{...s,serverSubscriptionId:c,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[c]=s.callbacks,await this._updateSubscriptions()}catch(c){if(console.error(`Received ${c instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:c}),!e())return;this._setSubscription(n,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(n,{...s,state:"unsubscribing"}),this._setSubscription(n,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(c){if(c instanceof Error&&console.error(`${o} error:`,c.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(i){console.error(i)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=H(t,Uh);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,s=Fs([t.method,e]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const o=this._subscriptionsByHash[s];se(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const{commitment:s,config:i}=Bt(n),o=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=H(t,Nh);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,s){const{commitment:i,config:o}=Bt(n),c=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:Ps(s)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},c)}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}=H(t,ll);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=H(t,Ph);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}=H(t,Dh);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 i=e||this._commitment;if(i||n||s){let o={};n&&(o.encoding=n),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,n,s){const i=e||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,s)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=H(t,zh);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"),i=this._makeSubscription({callback:(o,c)=>{if(o.type==="status"){e(o.result,c);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(t,e,n){const{commitment:s,...i}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([t],s,void 0,i),c=this._makeSubscription({callback:(d,v)=>{e(d,v);try{this.removeSignatureListener(c)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return c}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=H(t,Kh);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}Object.freeze({CreateLookupTable:{index:0,layout:tt([it("instruction"),qn("recentSlot"),bt("bumpSeed")])},FreezeLookupTable:{index:1,layout:tt([it("instruction")])},ExtendLookupTable:{index:2,layout:tt([it("instruction"),qn(),be(yt(),gn(it(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:tt([it("instruction")])},CloseLookupTable:{index:4,layout:tt([it("instruction")])}});new ct("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:tt([bt("instruction"),it("units"),it("additionalFee")])},RequestHeapFrame:{index:1,layout:tt([bt("instruction"),it("bytes")])},SetComputeUnitLimit:{index:2,layout:tt([bt("instruction"),it("units")])},SetComputeUnitPrice:{index:3,layout:tt([bt("instruction"),qn("microLamports")])}});new ct("ComputeBudget111111111111111111111111111111");tt([bt("numSignatures"),bt("padding"),ke("signatureOffset"),ke("signatureInstructionIndex"),ke("publicKeyOffset"),ke("publicKeyInstructionIndex"),ke("messageDataOffset"),ke("messageDataSize"),ke("messageInstructionIndex")]);new ct("Ed25519SigVerify111111111111111111111111111");Bf.utils.isValidPrivateKey;tt([bt("numSignatures"),ke("signatureOffset"),bt("signatureInstructionIndex"),ke("ethAddressOffset"),bt("ethAddressInstructionIndex"),ke("messageDataOffset"),ke("messageDataSize"),bt("messageInstructionIndex"),qt(20,"ethAddress"),qt(64,"signature"),bt("recoveryId")]);new ct("KeccakSecp256k11111111111111111111111111111");var Sa;new ct("StakeConfig11111111111111111111111111111111");class Ba{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}}Sa=Ba;Ba.default=new Sa(0,0,ct.default);Object.freeze({Initialize:{index:0,layout:tt([it("instruction"),Rf(),Tf()])},Authorize:{index:1,layout:tt([it("instruction"),yt("newAuthorized"),it("stakeAuthorizationType")])},Delegate:{index:2,layout:tt([it("instruction")])},Split:{index:3,layout:tt([it("instruction"),Be("lamports")])},Withdraw:{index:4,layout:tt([it("instruction"),Be("lamports")])},Deactivate:{index:5,layout:tt([it("instruction")])},Merge:{index:7,layout:tt([it("instruction")])},AuthorizeWithSeed:{index:8,layout:tt([it("instruction"),yt("newAuthorized"),it("stakeAuthorizationType"),Tn("authoritySeed"),yt("authorityOwner")])}});new ct("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:tt([it("instruction"),Cf()])},Authorize:{index:1,layout:tt([it("instruction"),yt("newAuthorized"),it("voteAuthorizationType")])},Withdraw:{index:3,layout:tt([it("instruction"),Be("lamports")])},UpdateValidatorIdentity:{index:4,layout:tt([it("instruction")])},AuthorizeWithSeed:{index:10,layout:tt([it("instruction"),Lf()])}});new ct("Vote111111111111111111111111111111111111111");new ct("Va1idator1nfo111111111111111111111111111111");D({name:K(),website:rt(K()),details:rt(K()),iconUrl:rt(K()),keybaseUsername:rt(K())});new ct("Vote111111111111111111111111111111111111111");tt([yt("nodePubkey"),yt("authorizedWithdrawer"),bt("commission"),ue(),be(tt([ue("slot"),it("confirmationCount")]),gn(it(),-8),"votes"),bt("rootSlotValid"),ue("rootSlot"),ue(),be(tt([ue("epoch"),yt("authorizedVoter")]),gn(it(),-8),"authorizedVoters"),tt([be(tt([yt("authorizedPubkey"),ue("epochOfLastAuthorizedSwitch"),ue("targetEpoch")]),32,"buf"),ue("idx"),bt("isEmpty")],"priorVoters"),ue(),be(tt([ue("epoch"),ue("credits"),ue("prevCredits")]),gn(it(),-8),"epochCredits"),tt([ue("slot"),ue("timestamp")],"lastTimestamp")]);export{wl as C,ct as P,rn as T,Cs as a,Ar as g,Ma as r};
|