PageSourceSearch

https://quiqrpay.com/assets/CryptoSender-C-5GqRVJ.js

js quiqrpay.com collected 2026-09-24 14:51:03 UTC 312,001 bytes, 21 lines download raw bytes

1var Tc=Object.defineProperty;var Uc=(r,t,e)=>t in r?Tc(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var le=(r,t,e)=>Uc(r,typeof t!="symbol"?t+"":t,e);import{h as ps,k as Xr,m as Ge,R as de,r as Tt,j as $}from"./index-zb99FpKi.js";var bt={},Jr={};Jr.byteLength=Oc;Jr.toByteArray=zc;Jr.fromByteArray=$c;var Je=[],ze=[],Pc=typeof Uint8Array<"u"?Uint8Array:Array,Ii="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var zn=0,Fc=Ii.length;zn<Fc;++zn)Je[zn]=Ii[zn],ze[Ii.charCodeAt(zn)]=zn;ze[45]=62;ze[95]=63;function Uo(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 Oc(r){var t=Uo(r),e=t[0],n=t[1];return(e+n)*3/4-n}function Dc(r,t,e){return(t+e)*3/4-e}function zc(r){var t,e=Uo(r),n=e[0],s=e[1],i=new Pc(Dc(r,n,s)),o=0,u=s>0?n-4:n,c;for(c=0;c<u;c+=4)t=ze[r.charCodeAt(c)]<<18|ze[r.charCodeAt(c+1)]<<12|ze[r.charCodeAt(c+2)]<<6|ze[r.charCodeAt(c+3)],i[o++]=t>>16&255,i[o++]=t>>8&255,i[o++]=t&255;return s===2&&(t=ze[r.charCodeAt(c)]<<2|ze[r.charCodeAt(c+1)]>>4,i[o++]=t&255),s===1&&(t=ze[r.charCodeAt(c)]<<10|ze[r.charCodeAt(c+1)]<<4|ze[r.charCodeAt(c+2)]>>2,i[o++]=t>>8&255,i[o++]=t&255),i}function qc(r){return Je[r>>18&63]+Je[r>>12&63]+Je[r>>6&63]+Je[r&63]}function Kc(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(qc(n));return s.join("")}function $c(r){for(var t,e=r.length,n=e%3,s=[],i=16383,o=0,u=e-n;o<u;o+=i)s.push(Kc(r,o,o+i>u?u:o+i));return n===1?(t=r[e-1],s.push(Je[t>>2]+Je[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],s.push(Je[t>>10]+Je[t>>4&63]+Je[t<<2&63]+"=")),s.join("")}var gs={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */gs.read=function(r,t,e,n,s){var i,o,u=s*8-n-1,c=(1<<u)-1,p=c>>1,g=-7,v=e?s-1:0,S=e?-1:1,A=r[t+v];for(v+=S,i=A&(1<<-g)-1,A>>=-g,g+=u;g>0;i=i*256+r[t+v],v+=S,g-=8);for(o=i&(1<<-g)-1,i>>=-g,g+=n;g>0;o=o*256+r[t+v],v+=S,g-=8);if(i===0)i=1-p;else{if(i===c)return o?NaN:(A?-1:1)*(1/0);o=o+Math.pow(2,n),i=i-p}return(A?-1:1)*o*Math.pow(2,i-n)};gs.write=function(r,t,e,n,s,i){var o,u,c,p=i*8-s-1,g=(1<<p)-1,v=g>>1,S=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=n?0:i-1,_=n?1:-1,C=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,o=g):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+v>=1?t+=S/c:t+=S*Math.pow(2,1-v),t*c>=2&&(o++,c/=2),o+v>=g?(u=0,o=g):o+v>=1?(u=(t*c-1)*Math.pow(2,s),o=o+v):(u=t*Math.pow(2,v-1)*Math.pow(2,s),o=0));s>=8;r[e+A]=u&255,A+=_,u/=256,s-=8);for(o=o<<s|u,p+=s;p>0;r[e+A]=o&255,A+=_,o/=256,p-=8);r[e+A-_]|=C*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=Jr,e=gs,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=u,r.SlowBuffer=D,r.INSPECT_MAX_BYTES=50;const s=2147483647;r.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=i(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const y=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(y,l),y.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function o(y){if(y>s)throw new RangeError('The value "'+y+'" is invalid for option "size"');const l=new Uint8Array(y);return Object.setPrototypeOf(l,u.prototype),l}function u(y,l,d){if(typeof y=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(y)}return c(y,l,d)}u.poolSize=8192;function c(y,l,d){if(typeof y=="string")return S(y,l);if(ArrayBuffer.isView(y))return _(y);if(y==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y);if(Dt(y,ArrayBuffer)||y&&Dt(y.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Dt(y,SharedArrayBuffer)||y&&Dt(y.buffer,SharedArrayBuffer)))return C(y,l,d);if(typeof y=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const B=y.valueOf&&y.valueOf();if(B!=null&&B!==y)return u.from(B,l,d);const L=M(y);if(L)return L;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof y[Symbol.toPrimitive]=="function")return u.from(y[Symbol.toPrimitive]("string"),l,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y)}u.from=function(y,l,d){return c(y,l,d)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function p(y){if(typeof y!="number")throw new TypeError('"size" argument must be of type number');
6if(y<0)throw new RangeError('The value "'+y+'" is invalid for option "size"')}function g(y,l,d){return p(y),y<=0?o(y):l!==void 0?typeof d=="string"?o(y).fill(l,d):o(y).fill(l):o(y)}u.alloc=function(y,l,d){return g(y,l,d)};function v(y){return p(y),o(y<0?0:U(y)|0)}u.allocUnsafe=function(y){return v(y)},u.allocUnsafeSlow=function(y){return v(y)};function S(y,l){if((typeof l!="string"||l==="")&&(l="utf8"),!u.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const d=N(y,l)|0;let B=o(d);const L=B.write(y,l);return L!==d&&(B=B.slice(0,L)),B}function A(y){const l=y.length<0?0:U(y.length)|0,d=o(l);for(let B=0;B<l;B+=1)d[B]=y[B]&255;return d}function _(y){if(Dt(y,Uint8Array)){const l=new Uint8Array(y);return C(l.buffer,l.byteOffset,l.byteLength)}return A(y)}function C(y,l,d){if(l<0||y.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(y.byteLength<l+(d||0))throw new RangeError('"length" is outside of buffer bounds');let B;return l===void 0&&d===void 0?B=new Uint8Array(y):d===void 0?B=new Uint8Array(y,l):B=new Uint8Array(y,l,d),Object.setPrototypeOf(B,u.prototype),B}function M(y){if(u.isBuffer(y)){const l=U(y.length)|0,d=o(l);return d.length===0||y.copy(d,0,0,l),d}if(y.length!==void 0)return typeof y.length!="number"||kt(y.length)?o(0):A(y);if(y.type==="Buffer"&&Array.isArray(y.data))return A(y.data)}function U(y){if(y>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return y|0}function D(y){return+y!=y&&(y=0),u.alloc(+y)}u.isBuffer=function(l){return l!=null&&l._isBuffer===!0&&l!==u.prototype},u.compare=function(l,d){if(Dt(l,Uint8Array)&&(l=u.from(l,l.offset,l.byteLength)),Dt(d,Uint8Array)&&(d=u.from(d,d.offset,d.byteLength)),!u.isBuffer(l)||!u.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(l===d)return 0;let B=l.length,L=d.length;for(let T=0,O=Math.min(B,L);T<O;++T)if(l[T]!==d[T]){B=l[T],L=d[T];break}return B<L?-1:L<B?1:0},u.isEncoding=function(l){switch(String(l).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(l,d){if(!Array.isArray(l))throw new TypeError('"list" argument must be an Array of Buffers');if(l.length===0)return u.alloc(0);let B;if(d===void 0)for(d=0,B=0;B<l.length;++B)d+=l[B].length;const L=u.allocUnsafe(d);let T=0;for(B=0;B<l.length;++B){let O=l[B];if(Dt(O,Uint8Array))T+O.length>L.length?(u.isBuffer(O)||(O=u.from(O)),O.copy(L,T)):Uint8Array.prototype.set.call(L,O,T);else if(u.isBuffer(O))O.copy(L,T);else throw new TypeError('"list" argument must be an Array of Buffers');T+=O.length}return L};function N(y,l){if(u.isBuffer(y))return y.length;if(ArrayBuffer.isView(y)||Dt(y,ArrayBuffer))return y.byteLength;if(typeof y!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof y);const d=y.length,B=arguments.length>2&&arguments[2]===!0;if(!B&&d===0)return 0;let L=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return dt(y).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return wt(y).length;default:if(L)return B?-1:dt(y).length;l=(""+l).toLowerCase(),L=!0}}u.byteLength=N;function K(y,l,d){let B=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,l>>>=0,d<=l))return"";for(y||(y="utf8");;)switch(y){case"hex":return I(this,l,d);case"utf8":case"utf-8":return a(this,l,d);case"ascii":return x(this,l,d);case"latin1":case"binary":return E(this,l,d);case"base64":return w(this,l,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,l,d);default:if(B)throw new TypeError("Unknown encoding: "+y);y=(y+"").toLowerCase(),B=!0}}u.prototype._isBuffer=!0;function V(y,l,d){const B=y[l];y[l]=y[d],y[d]=B}u.prototype.swap16=function(){const l=this.length;if(l%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<l;d+=2)V(this,d,d+1);return this},u.prototype.swap32=function(){const l=this.length;if(l%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<l;d+=4)V(this,d,d+3),V(this,d+1,d+2);return this},u.prototype.swap64=function(){const l=this.length;if(l%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<l;d+=8)V(this,d,d+7),V(this,d+1,d+6),V(this,d+2,d+5),V(this,d+3,d+4);return this},u.prototype.toString=function(){const l=this.length;return l===0?"":arguments.length===0?a(this,0,l):K.apply(this,arguments)}
6,u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(l){if(!u.isBuffer(l))throw new TypeError("Argument must be a Buffer");return this===l?!0:u.compare(this,l)===0},u.prototype.inspect=function(){let l="";const d=r.INSPECT_MAX_BYTES;return l=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(l+=" ... "),"<Buffer "+l+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(l,d,B,L,T){if(Dt(l,Uint8Array)&&(l=u.from(l,l.offset,l.byteLength)),!u.isBuffer(l))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof l);if(d===void 0&&(d=0),B===void 0&&(B=l?l.length:0),L===void 0&&(L=0),T===void 0&&(T=this.length),d<0||B>l.length||L<0||T>this.length)throw new RangeError("out of range index");if(L>=T&&d>=B)return 0;if(L>=T)return-1;if(d>=B)return 1;if(d>>>=0,B>>>=0,L>>>=0,T>>>=0,this===l)return 0;let O=T-L,vt=B-d;const xt=Math.min(O,vt),mt=this.slice(L,T),Ft=l.slice(d,B);for(let pt=0;pt<xt;++pt)if(mt[pt]!==Ft[pt]){O=mt[pt],vt=Ft[pt];break}return O<vt?-1:vt<O?1:0};function nt(y,l,d,B,L){if(y.length===0)return-1;if(typeof d=="string"?(B=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,kt(d)&&(d=L?0:y.length-1),d<0&&(d=y.length+d),d>=y.length){if(L)return-1;d=y.length-1}else if(d<0)if(L)d=0;else return-1;if(typeof l=="string"&&(l=u.from(l,B)),u.isBuffer(l))return l.length===0?-1:lt(y,l,d,B,L);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?L?Uint8Array.prototype.indexOf.call(y,l,d):Uint8Array.prototype.lastIndexOf.call(y,l,d):lt(y,[l],d,B,L);throw new TypeError("val must be string, number or Buffer")}function lt(y,l,d,B,L){let T=1,O=y.length,vt=l.length;if(B!==void 0&&(B=String(B).toLowerCase(),B==="ucs2"||B==="ucs-2"||B==="utf16le"||B==="utf-16le")){if(y.length<2||l.length<2)return-1;T=2,O/=2,vt/=2,d/=2}function xt(Ft,pt){return T===1?Ft[pt]:Ft.readUInt16BE(pt*T)}let mt;if(L){let Ft=-1;for(mt=d;mt<O;mt++)if(xt(y,mt)===xt(l,Ft===-1?0:mt-Ft)){if(Ft===-1&&(Ft=mt),mt-Ft+1===vt)return Ft*T}else Ft!==-1&&(mt-=mt-Ft),Ft=-1}else for(d+vt>O&&(d=O-vt),mt=d;mt>=0;mt--){let Ft=!0;for(let pt=0;pt<vt;pt++)if(xt(y,mt+pt)!==xt(l,pt)){Ft=!1;break}if(Ft)return mt}return-1}u.prototype.includes=function(l,d,B){return this.indexOf(l,d,B)!==-1},u.prototype.indexOf=function(l,d,B){return nt(this,l,d,B,!0)},u.prototype.lastIndexOf=function(l,d,B){return nt(this,l,d,B,!1)};function st(y,l,d,B){d=Number(d)||0;const L=y.length-d;B?(B=Number(B),B>L&&(B=L)):B=L;const T=l.length;B>T/2&&(B=T/2);let O;for(O=0;O<B;++O){const vt=parseInt(l.substr(O*2,2),16);if(kt(vt))return O;y[d+O]=vt}return O}function z(y,l,d,B){return _t(dt(l,y.length-d),y,d,B)}function et(y,l,d,B){return _t(Mt(l),y,d,B)}function W(y,l,d,B){return _t(wt(l),y,d,B)}function Q(y,l,d,B){return _t(Fe(l,y.length-d),y,d,B)}u.prototype.write=function(l,d,B,L){if(d===void 0)L="utf8",B=this.length,d=0;else if(B===void 0&&typeof d=="string")L=d,B=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(B)?(B=B>>>0,L===void 0&&(L="utf8")):(L=B,B=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const T=this.length-d;if((B===void 0||B>T)&&(B=T),l.length>0&&(B<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");L||(L="utf8");let O=!1;for(;;)switch(L){case"hex":return st(this,l,d,B);case"utf8":case"utf-8":return z(this,l,d,B);case"ascii":case"latin1":case"binary":return et(this,l,d,B);case"base64":return W(this,l,d,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,l,d,B);default:if(O)throw new TypeError("Unknown encoding: "+L);L=(""+L).toLowerCase(),O=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function w(y,l,d){return l===0&&d===y.length?t.fromByteArray(y):t.fromByteArray(y.slice(l,d))}function a(y,l,d){d=Math.min(y.length,d);const B=[];let L=l;for(;L<d;){const T=y[L];let O=null,vt=T>239?4:T>223?3:T>191?2:1;if(L+vt<=d){let xt,mt,Ft,pt;switch(vt){case 1:T<128&&(O=T);break;case 2:xt=y[L+1],(xt&192)===128&&(pt=(T&31)<<6|xt&63,pt>127&&(O=pt));break;case 3:xt=y[L+1],mt=y[L+2],(xt&192)===128&&(mt&192)===128&&(pt=(T&15)<<12|(xt&63)<<6|mt&63,pt>2047&&(pt<55296||pt>57343)&&(O=pt));break;case 4:xt=y[L+1],mt=y[L+2],Ft=y[L+3],(xt&192)===128&&(mt&192)===128&&(Ft&192)===128&&(pt=(T&15)<<18|(xt&63)<<12|(mt&63)<<6|Ft&63,pt>65535&&pt<1114112&&(O=pt))}}O===null?(O=65533,vt=1):O>65535&&(O-=65536,B.push(O>>>10&1023|55296),O=56320|O&1023),B.push(O),L+=vt}return m(B)}const f=4096;function m(y){const l=y.length;if(l<=f)return String.fromCharCode.apply(String,y);let d="",B=0;for(;B<l;)d+=String.fromCharCode.apply(String,y.slice(B,B+=f));return d}function x(y,l,d){let B="";d=Math.min(y.length,d);for(let L=l;L<d;++L)B+=String.fromCharCode(y[L]&127);return B}function E(y,l,d){let B="";d=Math.min(y.length,d);for(let L=l;L<d;++L)B+=String.fromCharCode(y[L]);return B}function I(y,l,d){const B=y.length;(!l||l<0)&&(l=0),(!d||d<0||d>B)&&(d=B);let L="";for(let T=l;T<d;++T)L+=Nt[y[T]];return L}function R(y,l,d){const B=y.slice(l,d);let L="";for(let T=0;T<B.length-1;T+=2)L+=String.fromCharCode(B[T]+B[T+1]*256);return L}u.prototype.slice=function(l,d){const B=this.length;l=~~l,d=d===void 0?B:~~d,l<0?(l+=B,l<0&&(l=0)):l>B&&(l=B),d<0?(d+=B,d<0&&(d=0)):d>B&&(d=B),d<l&&(d=l);const L=this.subarray(l,d);return Object.setPrototypeOf(L,u.prototype),L};function b(y,l,d){if(y%1!==0||y<0)throw new RangeError("offset is not uint");if(y+l>d)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(l,d,B){l=l>>>0,d=d>>>0,B||b(l,d,this.length);let L=this[l],T=1,O=0;for(;++O<d&&(T*=256);)L+=this[l+O]*T;return L},u.prototype.readUintBE=u.prototype.readUIntBE=function(l,d,B){l=l>>>0,d=d>>>0,B||b(l,d,this.length);let L=this[l+--d],T=1;for(;d>0&&(T*=256);)L+=this[l+--d]*T;return L},u.prototype.readUint8=u.prototype.readUInt8=function(l,d){return l=l>>>0,d||b(l,1,this.length),this[l]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(l,d){return l=l>>>0,d||b(l,2,this.length),this[l]|this[l+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(l,d){return l=l>>>0,d||b(l,2,this.length),this[l]<<8|this[l+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(l,d){return l=l>>>0,d||b(l,4,this.length),(this[l]|this[l+1]<<8|this[l+2]<<16)+this[l+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(l,d){return l=l>>>0,d||b(l,4,this.length),this[l]*16777216+(this[l+1]<<16|this[l+2]<<8|this[l+3])},u.prototype.readBigUInt64LE=Ne(function(l){l=l>>>0,Re(l,"offset");const d=this[l],B=this[l+7];(d===void 0||B===void 0)&&tt(l,this.length-8);const L=d+this[++l]*2**8+this[++l]*2**16+this[++l]*2**24,T=this[++l]+this[++l]*2**8+this[++l]*2**16+B*2**24;return BigInt(L)+(BigInt(T)<<BigInt(32))}),u.prototype.readBigUInt64BE=Ne(function(l){l=l>>>0,Re(l,"offset");const d=this[l],B=this[l+7];(d===void 0||B===void 0)&&tt(l,this.length-8);const L=d*2**24+this[++l]*2**16+this[++l]*2**8+this[++l],T=this[++l]*2**24+this[++l]*2**16+this[++l]*2**8+
6B;return(BigInt(L)<<BigInt(32))+BigInt(T)}),u.prototype.readIntLE=function(l,d,B){l=l>>>0,d=d>>>0,B||b(l,d,this.length);let L=this[l],T=1,O=0;for(;++O<d&&(T*=256);)L+=this[l+O]*T;return T*=128,L>=T&&(L-=Math.pow(2,8*d)),L},u.prototype.readIntBE=function(l,d,B){l=l>>>0,d=d>>>0,B||b(l,d,this.length);let L=d,T=1,O=this[l+--L];for(;L>0&&(T*=256);)O+=this[l+--L]*T;return T*=128,O>=T&&(O-=Math.pow(2,8*d)),O},u.prototype.readInt8=function(l,d){return l=l>>>0,d||b(l,1,this.length),this[l]&128?(255-this[l]+1)*-1:this[l]},u.prototype.readInt16LE=function(l,d){l=l>>>0,d||b(l,2,this.length);const B=this[l]|this[l+1]<<8;return B&32768?B|4294901760:B},u.prototype.readInt16BE=function(l,d){l=l>>>0,d||b(l,2,this.length);const B=this[l+1]|this[l]<<8;return B&32768?B|4294901760:B},u.prototype.readInt32LE=function(l,d){return l=l>>>0,d||b(l,4,this.length),this[l]|this[l+1]<<8|this[l+2]<<16|this[l+3]<<24},u.prototype.readInt32BE=function(l,d){return l=l>>>0,d||b(l,4,this.length),this[l]<<24|this[l+1]<<16|this[l+2]<<8|this[l+3]},u.prototype.readBigInt64LE=Ne(function(l){l=l>>>0,Re(l,"offset");const d=this[l],B=this[l+7];(d===void 0||B===void 0)&&tt(l,this.length-8);const L=this[l+4]+this[l+5]*2**8+this[l+6]*2**16+(B<<24);return(BigInt(L)<<BigInt(32))+BigInt(d+this[++l]*2**8+this[++l]*2**16+this[++l]*2**24)}),u.prototype.readBigInt64BE=Ne(function(l){l=l>>>0,Re(l,"offset");const d=this[l],B=this[l+7];(d===void 0||B===void 0)&&tt(l,this.length-8);const L=(d<<24)+this[++l]*2**16+this[++l]*2**8+this[++l];return(BigInt(L)<<BigInt(32))+BigInt(this[++l]*2**24+this[++l]*2**16+this[++l]*2**8+B)}),u.prototype.readFloatLE=function(l,d){return l=l>>>0,d||b(l,4,this.length),e.read(this,l,!0,23,4)},u.prototype.readFloatBE=function(l,d){return l=l>>>0,d||b(l,4,this.length),e.read(this,l,!1,23,4)},u.prototype.readDoubleLE=function(l,d){return l=l>>>0,d||b(l,8,this.length),e.read(this,l,!0,52,8)},u.prototype.readDoubleBE=function(l,d){return l=l>>>0,d||b(l,8,this.length),e.read(this,l,!1,52,8)};function h(y,l,d,B,L,T){if(!u.isBuffer(y))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>L||l<T)throw new RangeError('"value" argument is out of bounds');if(d+B>y.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(l,d,B,L){if(l=+l,d=d>>>0,B=B>>>0,!L){const vt=Math.pow(2,8*B)-1;h(this,l,d,B,vt,0)}let T=1,O=0;for(this[d]=l&255;++O<B&&(T*=256);)this[d+O]=l/T&255;return d+B},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(l,d,B,L){if(l=+l,d=d>>>0,B=B>>>0,!L){const vt=Math.pow(2,8*B)-1;h(this,l,d,B,vt,0)}let T=B-1,O=1;for(this[d+T]=l&255;--T>=0&&(O*=256);)this[d+T]=l/O&255;return d+B},u.prototype.writeUint8=u.prototype.writeUInt8=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,1,255,0),this[d]=l&255,d+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,2,65535,0),this[d]=l&255,this[d+1]=l>>>8,d+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,2,65535,0),this[d]=l>>>8,this[d+1]=l&255,d+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,4,4294967295,0),this[d+3]=l>>>24,this[d+2]=l>>>16,this[d+1]=l>>>8,this[d]=l&255,d+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,4,4294967295,0),this[d]=l>>>24,this[d+1]=l>>>16,this[d+2]=l>>>8,this[d+3]=l&255,d+4};function k(y,l,d,B,L){Lt(l,B,L,y,d,7);let T=Number(l&BigInt(4294967295));y[d++]=T,T=T>>8,y[d++]=T,T=T>>8,y[d++]=T,T=T>>8,y[d++]=T;let O=Number(l>>BigInt(32)&BigInt(4294967295));return y[d++]=O,O=O>>8,y[d++]=O,O=O>>8,y[d++]=O,O=O>>8,y[d++]=O,d}function G(y,l,d,B,L){Lt(l,B,L,y,d,7);let T=Number(l&BigInt(4294967295));y[d+7]=T,T=T>>8,y[d+6]=T,T=T>>8,y[d+5]=T,T=T>>8,y[d+4]=T;let O=Number(l>>BigInt(32)&BigInt(4294967295));return y[d+3]=O,O=O>>8,y[d+2]=O,O=O>>8,y[d+1]=O,O=O>>8,y[d]=O,d+8}u.prototype.writeBigUInt64LE=Ne(function(l,d=0){return k(this,l,d,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Ne(function(l,d=0){return G(this,l,d,BigInt(0),BigInt("0xffffffffffffffff"))}
6),u.prototype.writeIntLE=function(l,d,B,L){if(l=+l,d=d>>>0,!L){const xt=Math.pow(2,8*B-1);h(this,l,d,B,xt-1,-xt)}let T=0,O=1,vt=0;for(this[d]=l&255;++T<B&&(O*=256);)l<0&&vt===0&&this[d+T-1]!==0&&(vt=1),this[d+T]=(l/O>>0)-vt&255;return d+B},u.prototype.writeIntBE=function(l,d,B,L){if(l=+l,d=d>>>0,!L){const xt=Math.pow(2,8*B-1);h(this,l,d,B,xt-1,-xt)}let T=B-1,O=1,vt=0;for(this[d+T]=l&255;--T>=0&&(O*=256);)l<0&&vt===0&&this[d+T+1]!==0&&(vt=1),this[d+T]=(l/O>>0)-vt&255;return d+B},u.prototype.writeInt8=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,1,127,-128),l<0&&(l=255+l+1),this[d]=l&255,d+1},u.prototype.writeInt16LE=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,2,32767,-32768),this[d]=l&255,this[d+1]=l>>>8,d+2},u.prototype.writeInt16BE=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,2,32767,-32768),this[d]=l>>>8,this[d+1]=l&255,d+2},u.prototype.writeInt32LE=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,4,2147483647,-2147483648),this[d]=l&255,this[d+1]=l>>>8,this[d+2]=l>>>16,this[d+3]=l>>>24,d+4},u.prototype.writeInt32BE=function(l,d,B){return l=+l,d=d>>>0,B||h(this,l,d,4,2147483647,-2147483648),l<0&&(l=4294967295+l+1),this[d]=l>>>24,this[d+1]=l>>>16,this[d+2]=l>>>8,this[d+3]=l&255,d+4},u.prototype.writeBigInt64LE=Ne(function(l,d=0){return k(this,l,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Ne(function(l,d=0){return G(this,l,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function j(y,l,d,B,L,T){if(d+B>y.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function Y(y,l,d,B,L){return l=+l,d=d>>>0,L||j(y,l,d,4),e.write(y,l,d,B,23,4),d+4}u.prototype.writeFloatLE=function(l,d,B){return Y(this,l,d,!0,B)},u.prototype.writeFloatBE=function(l,d,B){return Y(this,l,d,!1,B)};function gt(y,l,d,B,L){return l=+l,d=d>>>0,L||j(y,l,d,8),e.write(y,l,d,B,52,8),d+8}u.prototype.writeDoubleLE=function(l,d,B){return gt(this,l,d,!0,B)},u.prototype.writeDoubleBE=function(l,d,B){return gt(this,l,d,!1,B)},u.prototype.copy=function(l,d,B,L){if(!u.isBuffer(l))throw new TypeError("argument should be a Buffer");if(B||(B=0),!L&&L!==0&&(L=this.length),d>=l.length&&(d=l.length),d||(d=0),L>0&&L<B&&(L=B),L===B||l.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(B<0||B>=this.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("sourceEnd out of bounds");L>this.length&&(L=this.length),l.length-d<L-B&&(L=l.length-d+B);const T=L-B;return this===l&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,B,L):Uint8Array.prototype.set.call(l,this.subarray(B,L),d),T},u.prototype.fill=function(l,d,B,L){if(typeof l=="string"){if(typeof d=="string"?(L=d,d=0,B=this.length):typeof B=="string"&&(L=B,B=this.length),L!==void 0&&typeof L!="string")throw new TypeError("encoding must be a string");if(typeof L=="string"&&!u.isEncoding(L))throw new TypeError("Unknown encoding: "+L);if(l.length===1){const O=l.charCodeAt(0);(L==="utf8"&&O<128||L==="latin1")&&(l=O)}}else typeof l=="number"?l=l&255:typeof l=="boolean"&&(l=Number(l));if(d<0||this.length<d||this.length<B)throw new RangeError("Out of range index");if(B<=d)return this;d=d>>>0,B=B===void 0?this.length:B>>>0,l||(l=0);let T;if(typeof l=="number")for(T=d;T<B;++T)this[T]=l;else{const O=u.isBuffer(l)?l:u.from(l,L),vt=O.length;if(vt===0)throw new TypeError('The value "'+l+'" is invalid for argument "value"');for(T=0;T<B-d;++T)this[T+d]=O[T%vt]}return this};const ht={};function ft(y,l,d){ht[y]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${y}]`,this.stack,delete this.name}get code(){return y}set code(L){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:L,writable:!0})}toString(){return`${this.name} [${y}]: ${this.message}`}}}ft("ERR_BUFFER_OUT_OF_BOUNDS",function(y){return y?`${y} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ft("ERR_INVALID_ARG_TYPE",function(y,l){return`The "${y}" argument must be of type number. Received type ${typeof l}`},TypeError),ft("ERR_OUT_OF_RANGE",function(y,l,d){let B=`The value of "${y}" is out of range.`,L=d;return Number.isInteger(d)&&Math.abs(d)>2**32?L=Ot(String(d)):typeof d=="bigint"&&(L=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(L=Ot(L)),L+="n"),B+=` It must be ${l}. Received ${L}`,B},RangeError);function Ot(y){let l="",d=y.length;const B=y[0]==="-"?1:0;for(;d>=B+4;d-=3)l=`_${y.slice(d-3,d)}${l}`;return`${y.slice(0,d)}${l}`}
6function Rt(y,l,d){Re(l,"offset"),(y[l]===void 0||y[l+d]===void 0)&&tt(l,y.length-(d+1))}function Lt(y,l,d,B,L,T){if(y>d||y<l){const O=typeof l=="bigint"?"n":"";let vt;throw l===0||l===BigInt(0)?vt=`>= 0${O} and < 2${O} ** ${(T+1)*8}${O}`:vt=`>= -(2${O} ** ${(T+1)*8-1}${O}) and < 2 ** ${(T+1)*8-1}${O}`,new ht.ERR_OUT_OF_RANGE("value",vt,y)}Rt(B,L,T)}function Re(y,l){if(typeof y!="number")throw new ht.ERR_INVALID_ARG_TYPE(l,"number",y)}function tt(y,l,d){throw Math.floor(y)!==y?(Re(y,d),new ht.ERR_OUT_OF_RANGE("offset","an integer",y)):l<0?new ht.ERR_BUFFER_OUT_OF_BOUNDS:new ht.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,y)}const ot=/[^+/0-9A-Za-z-_]/g;function yt(y){if(y=y.split("=")[0],y=y.trim().replace(ot,""),y.length<2)return"";for(;y.length%4!==0;)y=y+"=";return y}function dt(y,l){l=l||1/0;let d;const B=y.length;let L=null;const T=[];for(let O=0;O<B;++O){if(d=y.charCodeAt(O),d>55295&&d<57344){if(!L){if(d>56319){(l-=3)>-1&&T.push(239,191,189);continue}else if(O+1===B){(l-=3)>-1&&T.push(239,191,189);continue}L=d;continue}if(d<56320){(l-=3)>-1&&T.push(239,191,189),L=d;continue}d=(L-55296<<10|d-56320)+65536}else L&&(l-=3)>-1&&T.push(239,191,189);if(L=null,d<128){if((l-=1)<0)break;T.push(d)}else if(d<2048){if((l-=2)<0)break;T.push(d>>6|192,d&63|128)}else if(d<65536){if((l-=3)<0)break;T.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((l-=4)<0)break;T.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return T}function Mt(y){const l=[];for(let d=0;d<y.length;++d)l.push(y.charCodeAt(d)&255);return l}function Fe(y,l){let d,B,L;const T=[];for(let O=0;O<y.length&&!((l-=2)<0);++O)d=y.charCodeAt(O),B=d>>8,L=d%256,T.push(L),T.push(B);return T}function wt(y){return t.toByteArray(yt(y))}function _t(y,l,d,B){let L;for(L=0;L<B&&!(L+d>=l.length||L>=y.length);++L)l[L+d]=y[L];return L}function Dt(y,l){return y instanceof l||y!=null&&y.constructor!=null&&y.constructor.name!=null&&y.constructor.name===l.name}function kt(y){return y!==y}const Nt=function(){const y="0123456789abcdef",l=new Array(256);for(let d=0;d<16;++d){const B=d*16;for(let L=0;L<16;++L)l[B+L]=y[d]+y[L]}return l}();function Ne(y){return typeof BigInt>"u"?Pt:y}function Pt(){throw new Error("BigInt not supported")}})(bt);const qn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function br(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ji(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Nn(r,...t){if(!br(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 Po(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Ji(r.outputLen),Ji(r.blockLen)}function Fr(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 jc(r,t){Nn(r);const e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function nr(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function Mi(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ye(r,t){return r<<32-t|r>>>t}const Fo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Hc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Mn(r){if(Nn(r),Fo)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Hc[r[e]];return t}const on={_0:48,_9:57,A:65,F:70,a:97,f:102};function Zs(r){if(r>=on._0&&r<=on._9)return r-on._0;if(r>=on.A&&r<=on.F)return r-(on.A-10);if(r>=on.a&&r<=on.f)return r-(on.a-10)}function Or(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Fo)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=Zs(r.charCodeAt(i)),u=Zs(r.charCodeAt(i+1));if(o===void 0||u===void 0){const c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[s]=o*16+u}return n}function Wc(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function ms(r){return typeof r=="string"&&(r=Wc(r)),Nn(r),r}function Qe(...r){let t=0;for(let n=0;n<r.length;n++){const s=r[n];Nn(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 Oo{}function Do(r){const t=n=>r().update(ms(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ys(r=32){if(qn&&typeof qn.getRandomValues=="function")return qn.getRandomValues(new Uint8Array(r));if(qn&&typeof qn.randomBytes=="function")return Uint8Array.from(qn.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Vc(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),u=Number(e&i),c=n?4:0,p=n?0:4;r.setUint32(t+c,o,n),r.setUint32(t+p,u,n)}function Gc(r,t,e){return r&t^~r&e}function Zc(r,t,e){return r&t^r&e^t&e}class zo extends Oo{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=Mi(this.buffer)}update(t){Fr(this),t=ms(t),Nn(t);const{view:e,buffer:n,blockLen:s}=this,i=t.length;for(let o=0;o<i;){const u=Math.min(s-this.pos,i-o);if(u===s){const c=Mi(t);for(;s<=i-o;o+=s)this.process(c,o);continue}n.set(t.subarray(o,o+u),this.pos),this.pos+=u,o+=u,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fr(this),jc(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:s,isLE:i}=this;let{pos:o}=this;e[o++]=128,nr(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(n,0),o=0);for(let v=o;v<s;v++)e[v]=0;Vc(n,s-8,BigInt(this.length*8),i),this.process(n,0);const u=Mi(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");
6const p=c/4,g=this.get();if(p>g.length)throw new Error("_sha2: outputLen bigger than state");for(let v=0;v<p;v++)u.setUint32(4*v,g[v],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:u}=this;return t.destroyed=o,t.finished=i,t.length=s,t.pos=u,s%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const hn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ee=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),kr=BigInt(2**32-1),Ys=BigInt(32);function Yc(r,t=!1){return t?{h:Number(r&kr),l:Number(r>>Ys&kr)}:{h:Number(r>>Ys&kr)|0,l:Number(r&kr)|0}}function Xc(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:u}=Yc(r[i],t);[n[i],s[i]]=[o,u]}return[n,s]}const Xs=(r,t,e)=>r>>>e,Js=(r,t,e)=>r<<32-e|t>>>e,Kn=(r,t,e)=>r>>>e|t<<32-e,$n=(r,t,e)=>r<<32-e|t>>>e,Ir=(r,t,e)=>r<<64-e|t>>>e-32,Mr=(r,t,e)=>r>>>e-32|t<<64-e;function an(r,t,e,n){const s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}const Jc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Qc=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,tu=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),eu=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,nu=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),ru=(r,t,e,n,s,i)=>t+e+n+s+i+(r/2**32|0)|0,iu=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]),dn=new Uint32Array(64);class su extends zo{constructor(t=32){super(64,t,8,!1),this.A=hn[0]|0,this.B=hn[1]|0,this.C=hn[2]|0,this.D=hn[3]|0,this.E=hn[4]|0,this.F=hn[5]|0,this.G=hn[6]|0,this.H=hn[7]|0}get(){const{A:t,B:e,C:n,D:s,E:i,F:o,G:u,H:c}=this;return[t,e,n,s,i,o,u,c]}set(t,e,n,s,i,o,u,c){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=u|0,this.H=c|0}process(t,e){for(let v=0;v<16;v++,e+=4)dn[v]=t.getUint32(e,!1);for(let v=16;v<64;v++){const S=dn[v-15],A=dn[v-2],_=Ye(S,7)^Ye(S,18)^S>>>3,C=Ye(A,17)^Ye(A,19)^A>>>10;dn[v]=C+dn[v-7]+_+dn[v-16]|0}let{A:n,B:s,C:i,D:o,E:u,F:c,G:p,H:g}=this;for(let v=0;v<64;v++){const S=Ye(u,6)^Ye(u,11)^Ye(u,25),A=g+S+Gc(u,c,p)+iu[v]+dn[v]|0,C=(Ye(n,2)^Ye(n,13)^Ye(n,22))+Zc(n,s,i)|0;g=p,p=c,c=u,u=o+A|0,o=i,i=s,s=n,n=A+C|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,u=u+this.E|0,c=c+this.F|0,p=p+this.G|0,g=g+this.H|0,this.set(n,s,i,o,u,c,p,g)}roundClean(){nr(dn)}destroy(){this.set(0,0,0,0,0,0,0,0),nr(this.buffer)}}const qo=Xc(["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","0
6xa81a664bbc423001","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))),ou=qo[0],au=qo[1],pn=new Uint32Array(80),gn=new Uint32Array(80);class cu extends zo{constructor(t=64){super(128,t,16,!1),this.Ah=Ee[0]|0,this.Al=Ee[1]|0,this.Bh=Ee[2]|0,this.Bl=Ee[3]|0,this.Ch=Ee[4]|0,this.Cl=Ee[5]|0,this.Dh=Ee[6]|0,this.Dl=Ee[7]|0,this.Eh=Ee[8]|0,this.El=Ee[9]|0,this.Fh=Ee[10]|0,this.Fl=Ee[11]|0,this.Gh=Ee[12]|0,this.Gl=Ee[13]|0,this.Hh=Ee[14]|0,this.Hl=Ee[15]|0}get(){const{Ah:t,Al:e,Bh:n,Bl:s,Ch:i,Cl:o,Dh:u,Dl:c,Eh:p,El:g,Fh:v,Fl:S,Gh:A,Gl:_,Hh:C,Hl:M}=this;return[t,e,n,s,i,o,u,c,p,g,v,S,A,_,C,M]}set(t,e,n,s,i,o,u,c,p,g,v,S,A,_,C,M){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=u|0,this.Dl=c|0,this.Eh=p|0,this.El=g|0,this.Fh=v|0,this.Fl=S|0,this.Gh=A|0,this.Gl=_|0,this.Hh=C|0,this.Hl=M|0}process(t,e){for(let N=0;N<16;N++,e+=4)pn[N]=t.getUint32(e),gn[N]=t.getUint32(e+=4);for(let N=16;N<80;N++){const K=pn[N-15]|0,V=gn[N-15]|0,nt=Kn(K,V,1)^Kn(K,V,8)^Xs(K,V,7),lt=$n(K,V,1)^$n(K,V,8)^Js(K,V,7),st=pn[N-2]|0,z=gn[N-2]|0,et=Kn(st,z,19)^Ir(st,z,61)^Xs(st,z,6),W=$n(st,z,19)^Mr(st,z,61)^Js(st,z,6),Q=tu(lt,W,gn[N-7],gn[N-16]),w=eu(Q,nt,et,pn[N-7],pn[N-16]);pn[N]=w|0,gn[N]=Q|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:u,Cl:c,Dh:p,Dl:g,Eh:v,El:S,Fh:A,Fl:_,Gh:C,Gl:M,Hh:U,Hl:D}=this;for(let N=0;N<80;N++){const K=Kn(v,S,14)^Kn(v,S,18)^Ir(v,S,41),V=$n(v,S,14)^$n(v,S,18)^Mr(v,S,41),nt=v&A^~v&C,lt=S&_^~S&M,st=nu(D,V,lt,au[N],gn[N]),z=ru(st,U,K,nt,ou[N],pn[N]),et=st|0,W=Kn(n,s,28)^Ir(n,s,34)^Ir(n,s,39),Q=$n(n,s,28)^Mr(n,s,34)^Mr(n,s,39),w=n&i^n&u^i&u,a=s&o^s&c^o&c;U=C|0,D=M|0,C=A|0,M=_|0,A=v|0,_=S|0,{h:v,l:S}=an(p|0,g|0,z|0,et|0),p=u|0,g=c|0,u=i|0,c=o|0,i=n|0,o=s|0;const f=Jc(et,Q,a);n=Qc(f,z,W,w),s=f|0}({h:n,l:s}=an(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=an(this.Bh|0,this.Bl|0,i|0,o|0),{h:u,l:c}=an(this.Ch|0,this.Cl|0,u|0,c|0),{h:p,l:g}=an(this.Dh|0,this.Dl|0,p|0,g|0),{h:v,l:S}=an(this.Eh|0,this.El|0,v|0,S|0),{h:A,l:_}=an(this.Fh|0,this.Fl|0,A|0,_|0),{h:C,l:M}=an(this.Gh|0,this.Gl|0,C|0,M|0),{h:U,l:D}=an(this.Hh|0,this.Hl|0,U|0,D|0),this.set(n,s,i,o,u,c,p,g,v,S,A,_,C,M,U,D)}roundClean(){nr(pn,gn)}destroy(){nr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ko=Do(()=>new su),uu=Do(()=>new cu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ws=BigInt(0),Qi=BigInt(1);function Cn(r,t=""){if(typeof r!="boolean"){const e=t&&`"${t}"`;throw new Error(e+"expected boolean, got type="+typeof r)}return r}function We(r,t,e=""){const n=br(r),s=r==null?void 0:r.length,i=t!==void 0;if(!n||i&&s!==t){const o=e&&`"${e}" `,u=i?` of length ${t}`:"",c=n?`length=${s}`:`type=${typeof r}`;throw new Error(o+"expected Uint8Array"+u+", got "+c)}return r}function Rr(r){const t=r.toString(16);return t.length&1?"0"+t:t}function $o(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?ws:BigInt("0x"+r)}function Qr(r){return $o(Mn(r))}function gr(r){return Nn(r),$o(Mn(Uint8Array.from(r).reverse()))}function bs(r,t){return Or(r.toString(16).padStart(t*2,"0"))}function jo(r,t){return bs(r,t).reverse()}function Ht(r,t,e){let n;if(typeof t=="string")try{n=Or(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(br(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 Qs(r){return Uint8Array.from(r)}const Ri=r=>typeof r=="bigint"&&ws<=r;function lu(r,t,e){return Ri(r)&&Ri(t)&&Ri(e)&&t<=r&&r<e}function ts(r,t,e,n){if(!lu(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Ho(r){let t;for(t=0;r>ws;r>>=Qi,t+=1);return t}const vr=r=>(Qi<<BigInt(r))-Qi;function fu(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=A=>new Uint8Array(A),s=A=>Uint8Array.of(A);let i=n(r),o=n(r),u=0;const c=()=>{i.fill(1),o.fill(0),u=0},p=(...A)=>e(o,i,...A),g=(A=n(0))=>{o=p(s(0),A),i=p(),A.length!==0&&(o=p(s(1),A),i=p())},v=()=>{if(u++>=1e3)throw new Error("drbg: tried 1000 values");let A=0;const _=[];for(;A<t;){i=p();const C=i.slice();_.push(C),A+=i.length}return Qe(..._)};return(A,_)=>{c(),g(A);let C;for(;!(C=_(v()));)g();return c(),C}}function xr(r,t,e={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(s,i,o){const u=r[s];if(o&&u===void 0)return;const c=typeof u;if(c!==i||u===null)throw new Error(`param "${s}
6" is invalid: expected ${i}, got ${c}`)}Object.entries(t).forEach(([s,i])=>n(s,i,!1)),Object.entries(e).forEach(([s,i])=>n(s,i,!0))}function Dr(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 Le=BigInt(0),xe=BigInt(1),_n=BigInt(2),Wo=BigInt(3),Vo=BigInt(4),Go=BigInt(5),hu=BigInt(7),Zo=BigInt(8),du=BigInt(9),Yo=BigInt(16);function he(r,t){const e=r%t;return e>=Le?e:t+e}function jt(r,t,e){let n=r;for(;t-- >Le;)n*=n,n%=e;return n}function to(r,t){if(r===Le)throw new Error("invert: expected non-zero number");if(t<=Le)throw new Error("invert: expected positive modulus, got "+t);let e=he(r,t),n=t,s=Le,i=xe;for(;e!==Le;){const u=n/e,c=n%e,p=s-i*u;n=e,e=c,s=i,i=p}if(n!==xe)throw new Error("invert: does not exist");return he(s,t)}function vs(r,t,e){if(!r.eql(r.sqr(t),e))throw new Error("Cannot find square root")}function Xo(r,t){const e=(r.ORDER+xe)/Vo,n=r.pow(t,e);return vs(r,n,t),n}function pu(r,t){const e=(r.ORDER-Go)/Zo,n=r.mul(t,_n),s=r.pow(n,e),i=r.mul(t,s),o=r.mul(r.mul(i,_n),s),u=r.mul(i,r.sub(o,r.ONE));return vs(r,u,t),u}function gu(r){const t=Tn(r),e=Jo(r),n=e(t,t.neg(t.ONE)),s=e(t,n),i=e(t,t.neg(n)),o=(r+hu)/Yo;return(u,c)=>{let p=u.pow(c,o),g=u.mul(p,n);const v=u.mul(p,s),S=u.mul(p,i),A=u.eql(u.sqr(g),c),_=u.eql(u.sqr(v),c);p=u.cmov(p,g,A),g=u.cmov(S,v,_);const C=u.eql(u.sqr(g),c),M=u.cmov(p,g,C);return vs(u,M,c),M}}function Jo(r){if(r<Wo)throw new Error("sqrt is not defined for small field");let t=r-xe,e=0;for(;t%_n===Le;)t/=_n,e++;let n=_n;const s=Tn(r);for(;eo(s,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Xo;let i=s.pow(n,t);const o=(t+xe)/_n;return function(c,p){if(c.is0(p))return p;if(eo(c,p)!==1)throw new Error("Cannot find square root");let g=e,v=c.mul(c.ONE,i),S=c.pow(p,t),A=c.pow(p,o);for(;!c.eql(S,c.ONE);){if(c.is0(S))return c.ZERO;let _=1,C=c.sqr(S);for(;!c.eql(C,c.ONE);)if(_++,C=c.sqr(C),_===g)throw new Error("Cannot find square root");const M=xe<<BigInt(g-_-1),U=c.pow(v,M);g=_,v=c.sqr(U),S=c.mul(S,v),A=c.mul(A,U)}return A}}function mu(r){return r%Vo===Wo?Xo:r%Zo===Go?pu:r%Yo===du?gu(r):Jo(r)}const yu=(r,t)=>(he(r,t)&xe)===xe,wu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bu(r){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=wu.reduce((n,s)=>(n[s]="function",n),t);return xr(r,e),r}function vu(r,t,e){if(e<Le)throw new Error("invalid exponent, negatives unsupported");if(e===Le)return r.ONE;if(e===xe)return t;let n=r.ONE,s=t;for(;e>Le;)e&xe&&(n=r.mul(n,s)),s=r.sqr(s),e>>=xe;return n}function Qo(r,t,e=!1){const n=new Array(t.length).fill(e?r.ZERO:void 0),s=t.reduce((o,u,c)=>r.is0(u)?o:(n[c]=o,r.mul(o,u)),r.ONE),i=r.inv(s);return t.reduceRight((o,u,c)=>r.is0(u)?o:(n[c]=r.mul(o,n[c]),r.mul(o,u)),i),n}function eo(r,t){const e=(r.ORDER-xe)/_n,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 ta(r,t){t!==void 0&&Ji(t);const e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Tn(r,t,e=!1,n={}){if(r<=Le)throw new Error("invalid field: expected ORDER > 0, got "+r);let s,i,o=!1,u;if(typeof t=="object"&&t!=null){if(n.sqrt||e)throw new Error("cannot specify opts in two arguments");const S=t;S.BITS&&(s=S.BITS),S.sqrt&&(i=S.sqrt),typeof S.isLE=="boolean"&&(e=S.isLE),typeof S.modFromBytes=="boolean"&&(o=S.modFromBytes),u=S.allowedLengths}else typeof t=="number"&&(s=t),n.sqrt&&(i=n.sqrt);const{nBitLength:c,nByteLength:p}=ta(r,s);if(p>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let g;const v=Object.freeze({ORDER:r,isLE:e,BITS:c,BYTES:p,MASK:vr(c),ZERO:Le,ONE:xe,allowedLengths:u,create:S=>he(S,r),isValid:S=>{if(typeof S!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof S);return Le<=S&&S<r},is0:S=>S===Le,isValidNot0:S=>!v.is0(S)&&v.isValid(S),isOdd:S=>(S&xe)===xe,neg:S=>he(-S,r),eql:(S,A)=>S===A,sqr:S=>he(S*S,r),add:(S,A)=>he(S+A,r),sub:(S,A)=>he(S-A,r),mul:(S,A)=>he(S*A,r),pow:(S,A)=>vu(v,S,A),div:(S,A)=>he(S*to(A,r),r),sqrN:S=>S*S,addN:(S,A)=>S+A,subN:(S,A)=>S-A,mulN:(S,A)=>S*A,inv:S=>to(S,r),sqrt:i||(S=>(g||(g=mu(r)),g(v,S))),toBytes:S=>e?jo(S,p):bs(S,p),fromBytes:(S,A=!0)=>
6{if(u){if(!u.includes(S.length)||S.length>p)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+S.length);const C=new Uint8Array(p);C.set(S,e?0:C.length-S.length),S=C}if(S.length!==p)throw new Error("Field.fromBytes: expected "+p+" bytes, got "+S.length);let _=e?gr(S):Qr(S);if(o&&(_=he(_,r)),!A&&!v.isValid(_))throw new Error("invalid field element: outside of range 0..ORDER");return _},invertBatch:S=>Qo(v,S),cmov:(S,A,_)=>_?A:S});return Object.freeze(v)}function ea(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 na(r){const t=ea(r);return t+Math.ceil(t/2)}function xu(r,t,e=!1){const n=r.length,s=ea(t),i=na(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const o=e?gr(r):Qr(r),u=he(o,t-xe)+xe;return e?jo(u,s):bs(u,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rr=BigInt(0),kn=BigInt(1);function zr(r,t){const e=t.negate();return r?e:t}function In(r,t){const e=Qo(r.Fp,t.map(n=>n.Z));return t.map((n,s)=>r.fromAffine(n.toAffine(e[s])))}function ra(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Ci(r,t){ra(r,t);const e=Math.ceil(t/r)+1,n=2**(r-1),s=2**r,i=vr(r),o=BigInt(r);return{windows:e,windowSize:n,mask:i,maxNumber:s,shiftBy:o}}function no(r,t,e){const{windowSize:n,mask:s,maxNumber:i,shiftBy:o}=e;let u=Number(r&s),c=r>>o;u>n&&(u-=i,c+=kn);const p=t*n,g=p+Math.abs(u)-1,v=u===0,S=u<0,A=t%2!==0;return{nextN:c,offset:g,isZero:v,isNeg:S,isNegF:A,offsetF:p}}function Eu(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 Su(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 Li=new WeakMap,ia=new WeakMap;function Ni(r){return ia.get(r)||1}function ro(r){if(r!==rr)throw new Error("invalid wNAF")}class sa{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>rr;)e&kn&&(n=n.add(s)),s=s.double(),e>>=kn;return n}precomputeWindow(t,e){const{windows:n,windowSize:s}=Ci(e,this.bits),i=[];let o=t,u=o;for(let c=0;c<n;c++){u=o,i.push(u);for(let p=1;p<s;p++)u=u.add(o),i.push(u);o=u.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=Ci(t,this.bits);for(let u=0;u<o.windows;u++){const{nextN:c,offset:p,isZero:g,isNeg:v,isNegF:S,offsetF:A}=no(n,u,o);n=c,g?i=i.add(zr(S,e[A])):s=s.add(zr(v,e[p]))}return ro(n),{p:s,f:i}}wNAFUnsafe(t,e,n,s=this.ZERO){const i=Ci(t,this.bits);for(let o=0;o<i.windows&&n!==rr;o++){const{nextN:u,offset:c,isZero:p,isNeg:g}=no(n,o,i);if(n=u,!p){const v=e[c];s=s.add(g?v.negate():v)}}return ro(n),s}getPrecomputes(t,e,n){let s=Li.get(e);return s||(s=this.precomputeWindow(e,t),t!==1&&(typeof n=="function"&&(s=n(s)),Li.set(e,s))),s}cached(t,e,n){const s=Ni(t);return this.wNAF(s,this.getPrecomputes(s,t,n),e)}unsafe(t,e,n,s){const i=Ni(t);return i===1?this._unsafeLadder(t,e,s):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),e,s)}createCache(t,e){ra(e,this.bits),ia.set(t,e),Li.delete(t)}hasCache(t){return Ni(t)!==1}}function Bu(r,t,e,n){let s=t,i=r.ZERO,o=r.ZERO;for(;e>rr||n>rr;)e&kn&&(i=i.add(s)),n&kn&&(o=o.add(s)),s=s.double(),e>>=kn,n>>=kn;return{p1:i,p2:o}}function oa(r,t,e,n){Eu(e,r),Su(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,u=Ho(BigInt(s));let c=1;u>12?c=u-3:u>4?c=u-2:u>0&&(c=2);const p=vr(c),g=new Array(Number(p)+1).fill(o),v=Math.floor((t.BITS-1)/c)*c;let S=o;for(let A=v;A>=0;A-=c){g.fill(o);for(let C=0;C<i;C++){const M=n[C],U=Number(M>>BigInt(A)&p);g[U]=g[U].add(e[C])}let _=o;for(let C=g.length-1,M=o;C>0;C--)M=M.add(g[C]),_=_.add(M);if(S=S.add(_),A!==0)for(let C=0;C<c;C++)S=S.double()}return S}function io(r,t,e){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return bu(t),t}else return Tn(r,{isLE:e})}function aa(r,t,e={}
6,n){if(n===void 0&&(n=r==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(const c of["p","n","h"]){const p=t[c];if(!(typeof p=="bigint"&&p>rr))throw new Error(`CURVE.${c} must be positive bigint`)}const s=io(t.p,e.Fp,n),i=io(t.n,e.Fn,n),u=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(const c of u)if(!s.isValid(t[c]))throw new Error(`CURVE.${c} 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 mn=BigInt(0),pe=BigInt(1),Ti=BigInt(2),Au=BigInt(8);function _u(r,t,e,n){const s=r.sqr(e),i=r.sqr(n),o=r.add(r.mul(t.a,s),i),u=r.add(r.ONE,r.mul(t.d,r.mul(s,i)));return r.eql(o,u)}function ku(r,t={}){const e=aa("edwards",r,t,t.FpFnLE),{Fp:n,Fn:s}=e;let i=e.CURVE;const{h:o}=i;xr(t,{},{uvRatio:"function"});const u=Ti<<BigInt(s.BYTES*8)-pe,c=M=>n.create(M),p=t.uvRatio||((M,U)=>{try{return{isValid:!0,value:n.sqrt(n.div(M,U))}}catch{return{isValid:!1,value:mn}}});if(!_u(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function g(M,U,D=!1){const N=D?pe:mn;return ts("coordinate "+M,U,N,u),U}function v(M){if(!(M instanceof _))throw new Error("ExtendedPoint expected")}const S=Dr((M,U)=>{const{X:D,Y:N,Z:K}=M,V=M.is0();U==null&&(U=V?Au:n.inv(K));const nt=c(D*U),lt=c(N*U),st=n.mul(K,U);if(V)return{x:mn,y:pe};if(st!==pe)throw new Error("invZ was invalid");return{x:nt,y:lt}}),A=Dr(M=>{const{a:U,d:D}=i;if(M.is0())throw new Error("bad point: ZERO");const{X:N,Y:K,Z:V,T:nt}=M,lt=c(N*N),st=c(K*K),z=c(V*V),et=c(z*z),W=c(lt*U),Q=c(z*c(W+st)),w=c(et+c(D*c(lt*st)));if(Q!==w)throw new Error("bad point: equation left != right (1)");const a=c(N*K),f=c(V*nt);if(a!==f)throw new Error("bad point: equation left != right (2)");return!0});class _{constructor(U,D,N,K){this.X=g("x",U),this.Y=g("y",D),this.Z=g("z",N,!0),this.T=g("t",K),Object.freeze(this)}static CURVE(){return i}static fromAffine(U){if(U instanceof _)throw new Error("extended point not allowed");const{x:D,y:N}=U||{};return g("x",D),g("y",N),new _(D,N,pe,c(D*N))}static fromBytes(U,D=!1){const N=n.BYTES,{a:K,d:V}=i;U=Qs(We(U,N,"point")),Cn(D,"zip215");const nt=Qs(U),lt=U[N-1];nt[N-1]=lt&-129;const st=gr(nt),z=D?u:n.ORDER;ts("point.y",st,mn,z);const et=c(st*st),W=c(et-pe),Q=c(V*et-K);let{isValid:w,value:a}=p(W,Q);if(!w)throw new Error("bad point: invalid y coordinate");const f=(a&pe)===pe,m=(lt&128)!==0;if(!D&&a===mn&&m)throw new Error("bad point: x=0 and x_0=1");return m!==f&&(a=c(-a)),_.fromAffine({x:a,y:st})}static fromHex(U,D=!1){return _.fromBytes(Ht("point",U),D)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(U=8,D=!0){return C.createCache(this,U),D||this.multiply(Ti),this}assertValidity(){A(this)}equals(U){v(U);const{X:D,Y:N,Z:K}=this,{X:V,Y:nt,Z:lt}=U,st=c(D*lt),z=c(V*K),et=c(N*lt),W=c(nt*K);return st===z&&et===W}is0(){return this.equals(_.ZERO)}negate(){return new _(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:U}=i,{X:D,Y:N,Z:K}=this,V=c(D*D),nt=c(N*N),lt=c(Ti*c(K*K)),st=c(U*V),z=D+N,et=c(c(z*z)-V-nt),W=st+nt,Q=W-lt,w=st-nt,a=c(et*Q),f=c(W*w),m=c(et*w),x=c(Q*W);return new _(a,f,x,m)}add(U){v(U);const{a:D,d:N}=i,{X:K,Y:V,Z:nt,T:lt}=this,{X:st,Y:z,Z:et,T:W}=U,Q=c(K*st),w=c(V*z),a=c(lt*N*W),f=c(nt*et),m=c((K+V)*(st+z)-Q-w),x=f-a,E=f+a,I=c(w-D*Q),R=c(m*x),b=c(E*I),h=c(m*I),k=c(x*E);return new _(R,b,k,h)}subtract(U){return this.add(U.negate())}multiply(U){if(!s.isValidNot0(U))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:D,f:N}=C.cached(this,U,K=>In(_,K));return In(_,[D,N])[0]}multiplyUnsafe(U,D=_.ZERO){if(!s.isValid(U))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return U===mn?_.ZERO:this.is0()||U===pe?this:C.unsafe(this,U,N=>In(_,N),D)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return C.unsafe(this,i.n).is0()}toAffine(U){return S(this,U)}clearCofactor(){return o===pe?this:this.multiplyUnsafe(o)}toBytes(){const{x:U,y:D}=this.toAffine(),N=n.toBytes(D);return N[N.length-1]|=U&pe?128:0,N}toHex(){return Mn(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(U){return In(_,U)}static msm(U,D){return oa(_,s,U,D)}
6_setWindowSize(U){this.precompute(U)}toRawBytes(){return this.toBytes()}}_.BASE=new _(i.Gx,i.Gy,pe,c(i.Gx*i.Gy)),_.ZERO=new _(mn,pe,pe,mn),_.Fp=n,_.Fn=s;const C=new sa(_,s.BITS);return _.BASE.precompute(8),_}function Iu(r,t,e={}){if(typeof t!="function")throw new Error('"hash" function param is required');xr(e,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:n}=e,{BASE:s,Fp:i,Fn:o}=r,u=e.randomBytes||ys,c=e.adjustScalarBytes||(z=>z),p=e.domain||((z,et,W)=>{if(Cn(W,"phflag"),et.length||W)throw new Error("Contexts/pre-hash are not supported");return z});function g(z){return o.create(gr(z))}function v(z){const et=N.secretKey;z=Ht("private key",z,et);const W=Ht("hashed private key",t(z),2*et),Q=c(W.slice(0,et)),w=W.slice(et,2*et),a=g(Q);return{head:Q,prefix:w,scalar:a}}function S(z){const{head:et,prefix:W,scalar:Q}=v(z),w=s.multiply(Q),a=w.toBytes();return{head:et,prefix:W,scalar:Q,point:w,pointBytes:a}}function A(z){return S(z).pointBytes}function _(z=Uint8Array.of(),...et){const W=Qe(...et);return g(t(p(W,Ht("context",z),!!n)))}function C(z,et,W={}){z=Ht("message",z),n&&(z=n(z));const{prefix:Q,scalar:w,pointBytes:a}=S(et),f=_(W.context,Q,z),m=s.multiply(f).toBytes(),x=_(W.context,m,a,z),E=o.create(f+x*w);if(!o.isValid(E))throw new Error("sign failed: invalid s");const I=Qe(m,o.toBytes(E));return We(I,N.signature,"result")}const M={zip215:!0};function U(z,et,W,Q=M){const{context:w,zip215:a}=Q,f=N.signature;z=Ht("signature",z,f),et=Ht("message",et),W=Ht("publicKey",W,N.publicKey),a!==void 0&&Cn(a,"zip215"),n&&(et=n(et));const m=f/2,x=z.subarray(0,m),E=gr(z.subarray(m,f));let I,R,b;try{I=r.fromBytes(W,a),R=r.fromBytes(x,a),b=s.multiplyUnsafe(E)}catch{return!1}if(!a&&I.isSmallOrder())return!1;const h=_(w,R.toBytes(),I.toBytes(),et);return R.add(I.multiplyUnsafe(h)).subtract(b).clearCofactor().is0()}const D=i.BYTES,N={secretKey:D,publicKey:D,signature:2*D,seed:D};function K(z=u(N.seed)){return We(z,N.seed,"seed")}function V(z){const et=st.randomSecretKey(z);return{secretKey:et,publicKey:A(et)}}function nt(z){return br(z)&&z.length===o.BYTES}function lt(z,et){try{return!!r.fromBytes(z,et)}catch{return!1}}const st={getExtendedPublicKey:S,randomSecretKey:K,isValidSecretKey:nt,isValidPublicKey:lt,toMontgomery(z){const{y:et}=r.fromBytes(z),W=N.publicKey,Q=W===32;if(!Q&&W!==57)throw new Error("only defined for 25519 and 448");const w=Q?i.div(pe+et,pe-et):i.div(et-pe,et+pe);return i.toBytes(w)},toMontgomerySecret(z){const et=N.secretKey;We(z,et);const W=t(z.subarray(0,et));return c(W).subarray(0,et)},randomPrivateKey:K,precompute(z=8,et=r.BASE){return et.precompute(z,!1)}};return Object.freeze({keygen:V,getPublicKey:A,sign:C,verify:U,utils:st,Point:r,lengths:N})}function Mu(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=Tn(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 Ru(r,t){const e=t.Point;return Object.assign({},t,{ExtendedPoint:e,CURVE:r,nBitLength:e.Fn.BITS,nByteLength:e.Fn.BYTES})}function Cu(r){const{CURVE:t,curveOpts:e,hash:n,eddsaOpts:s}=Mu(r),i=ku(t,e),o=Iu(i,n,s);return Ru(r,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Lu=BigInt(1),so=BigInt(2);BigInt(3);const Nu=BigInt(5),Tu=BigInt(8),xs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ca={p:xs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Tu,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Uu(r){const t=BigInt(10),e=BigInt(20),n=BigInt(40),s=BigInt(80),i=xs,u=r*r%i*r%i,c=jt(u,so,i)*u%i,p=jt(c,Lu,i)*r%i,g=jt(p,Nu,i)*p%i,v=jt(g,t,i)*g%i,S=jt(v,e,i)*v%i,A=jt(S,n,i)*S%i,_=jt(A,s,i)*A%i,C=jt(_,s,i)*A%i,M=jt(C,t,i)*g%i;return{pow_p_5_8:jt(M,so,i)*r%i,b2:u}}function Pu(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}const oo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Fu(r,t){const e=xs,n=he(t*t*t,e),s=he(n*n*t,e),i=Uu(r*s).pow_p_5_8;let o=he(r*n*i,e);const u=he(t*o*o,e),c=o,p=he(o*oo,e),g=u===r,v=u===he(-r,e),S=u===he(-r*oo,e);return g&&(o=c),(v||S)&&(o=p),yu(o,e)&&(o=he(-o,e)),{isValid:g||v,value:o}}const Ou=Tn(ca.p,{isLE:!0}),Du={...ca,Fp:Ou,hash:uu,adjustScalarBytes:Pu,uvRatio:Fu},or=Cu(Du);var Es={exports:{}};const zu={},qu=Object.freeze(Object.defineProperty({__proto__:null,default:zu},Symbol.toStringTag,{value:"Module"})),Ku=ps(qu);Es.exports;(function(r){(function(t,e){function n(w,a){if(!w)throw new Error(a||"Assertion failed")}function s(w,a){w.super_=a;var f=function(){};f.prototype=a.prototype,w.prototype=new f,w.prototype.constructor=w}function i(w,a,f){if(i.isBN(w))return w;this.negative=0,this.words=null,this.length=0,this.red=null,w!==null&&((a==="le"||a==="be")&&(f=a,a=10),this._init(w||0,a||10,f||"be"))}
vendor: 13,692 bytes, line 6
6typeof 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=Ku.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,f){return a.cmp(f)>0?a:f},i.min=function(a,f){return a.cmp(f)<0?a:f},i.prototype._init=function(a,f,m){if(typeof a=="number")return this._initNumber(a,f,m);if(typeof a=="object")return this._initArray(a,f,m);f==="hex"&&(f=16),n(f===(f|0)&&f>=2&&f<=36),a=a.toString().replace(/\s+/g,"");var x=0;a[0]==="-"&&(x++,this.negative=1),x<a.length&&(f===16?this._parseHex(a,x,m):(this._parseBase(a,f,x),m==="le"&&this._initArray(this.toArray(),f,m)))},i.prototype._initNumber=function(a,f,m){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),m==="le"&&this._initArray(this.toArray(),f,m)},i.prototype._initArray=function(a,f,m){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 x=0;x<this.length;x++)this.words[x]=0;var E,I,R=0;if(m==="be")for(x=a.length-1,E=0;x>=0;x-=3)I=a[x]|a[x-1]<<8|a[x-2]<<16,this.words[E]|=I<<R&67108863,this.words[E+1]=I>>>26-R&67108863,R+=24,R>=26&&(R-=26,E++);else if(m==="le")for(x=0,E=0;x<a.length;x+=3)I=a[x]|a[x+1]<<8|a[x+2]<<16,this.words[E]|=I<<R&67108863,this.words[E+1]=I>>>26-R&67108863,R+=24,R>=26&&(R-=26,E++);return this._strip()};function u(w,a){var f=w.charCodeAt(a);if(f>=48&&f<=57)return f-48;if(f>=65&&f<=70)return f-55;if(f>=97&&f<=102)return f-87;n(!1,"Invalid character in "+w)}function c(w,a,f){var m=u(w,f);return f-1>=a&&(m|=u(w,f-1)<<4),m}i.prototype._parseHex=function(a,f,m){this.length=Math.ceil((a.length-f)/6),this.words=new Array(this.length);for(var x=0;x<this.length;x++)this.words[x]=0;var E=0,I=0,R;if(m==="be")for(x=a.length-1;x>=f;x-=2)R=c(a,f,x)<<E,this.words[I]|=R&67108863,E>=18?(E-=18,I+=1,this.words[I]|=R>>>26):E+=8;else{var b=a.length-f;for(x=b%2===0?f+1:f;x<a.length;x+=2)R=c(a,f,x)<<E,this.words[I]|=R&67108863,E>=18?(E-=18,I+=1,this.words[I]|=R>>>26):E+=8}this._strip()};function p(w,a,f,m){for(var x=0,E=0,I=Math.min(w.length,f),R=a;R<I;R++){var b=w.charCodeAt(R)-48;x*=m,b>=49?E=b-49+10:b>=17?E=b-17+10:E=b,n(b>=0&&E<m,"Invalid character"),x+=E}return x}i.prototype._parseBase=function(a,f,m){this.words=[0],this.length=1;for(var x=0,E=1;E<=67108863;E*=f)x++;x--,E=E/f|0;for(var I=a.length-m,R=I%x,b=Math.min(I,I-R)+m,h=0,k=m;k<b;k+=x)h=p(a,k,k+x,f),this.imuln(E),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(R!==0){var G=1;for(h=p(a,k,a.length,f),k=0;k<R;k++)G*=f;this.imuln(G),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this._strip()},i.prototype.copy=function(a){a.words=new Array(this.length);for(var f=0;f<this.length;f++)a.words[f]=this.words[f];a.length=this.length,a.negative=this.negative,a.red=this.red};function g(w,a){w.words=a.words,w.length=a.length,w.negative=a.negative,w.red=a.red}if(i.prototype._move=function(a){g(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")]=v}catch{i.prototype.inspect=v}else i.prototype.inspect=v;function v(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var S=["","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"],A=[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],_=[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,f){a=a||10,f=f|0||1;var m;if(a===16||a==="hex"){m="";for(var x=0,E=0,I=0;I<this.length;I++){var R=this.words[I],b=((R<<x|E)&16777215).toString(16);E=R>>>24-x&16777215,x+=2,x>=26&&(x-=26,I--),E!==0||I!==this.length-1?m=S[6-b.length]+b+m:m=b+m}for(E!==0&&(m=E.toString(16)+m);m.length%f!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(a===(a|0)&&a>=2&&a<=36){var h=A[a],k=_[a];m="";var G=this.clone();for(G.negative=0;!G.isZero();){var j=G.modrn(k).toString(a);G=G.idivn(k),G.isZero()?m=j+m:m=S[h-j.length]+j+m}for(this.isZero()&&(m="0"+m);m.length%f!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}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,f){return this.toArrayLike(o,a,f)}),i.prototype.toArray=function(a,f){return this.toArrayLike(Array,a,f)};var C=function(a,f){return a.allocUnsafe?a.allocUnsafe(f):new a(f)};i.prototype.toArrayLike=function(a,f,m){this._strip();var x=this.byteLength(),E=m||Math.max(1,x);n(x<=E,"byte array longer than desired length"),n(E>0,"Requested array length <= 0");var I=C(a,E),R=f==="le"?"LE":"BE";return this["_toArrayLike"+R](I,x),I},i.prototype._toArrayLikeLE=function(a,f){for(var m=0,x=0,E=0,I=0;E<this.length;E++){var R=this.words[E]<<I|x;a[m++]=R&255,m<a.length&&(a[m++]=R>>8&255),m<a.length&&(a[m++]=R>>16&255),I===6?(m<a.length&&(a[m++]=R>>24&255),x=0,I=0):(x=R>>>24,I+=2)}if(m<a.length)for(a[m++]=x;m<a.length;)a[m++]=0},i.prototype._toArrayLikeBE=function(a,f){for(var m=a.length-1,x=0,E=0,I=0;E<this.length;E++){var R=this.words[E]<<I|x;a[m--]=R&255,m>=0&&(a[m--]=R>>8&255),m>=0&&(a[m--]=R>>16&255),I===6?(m>=0&&(a[m--]=R>>24&255),x=0,I=0):(x=R>>>24,I+=2)}if(m>=0)for(a[m--]=x;m>=0;)a[m--]=0},Math.clz32?i.prototype._countBits=function(a){return 32-Math.clz32(a)}:i.prototype._countBits=function(a){var f=a,m=0;return f>=4096&&(m+=13,f>>>=13),f>=64&&(m+=7,f>>>=7),f>=8&&(m+=4,f>>>=4),f>=2&&(m+=2,f>>>=2),m+f},i.prototype._zeroBits=function(a){if(a===0)return 26;var f=a,m=0;return f&8191||(m+=13,f>>>=13),f&127||(m+=7,f>>>=7),f&15||(m+=4,f>>>=4),f&3||(m+=2,f>>>=2),f&1||m++,m},i.prototype.bitLength=function(){var a=this.words[this.length-1],f=this._countBits(a);return(this.length-1)*26+f};function M(w){for(var a=new Array(w.bitLength()),f=0;f<a.length;f++){var m=f/26|0,x=f%26;a[f]=w.words[m]>>>x&1}return a}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,f=0;f<this.length;f++){var m=this._zeroBits(this.words[f]);if(a+=m,m!==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 f=0;f<a.length;f++)this.words[f]=this.words[f]|a.words[f];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 f;this.length>a.length?f=a:f=this;for(var m=0;m<f.length;m++)this.words[m]=this.words[m]&a.words[m];return this.length=f.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 f,m;this.length>a.length?(f=this,m=a):(f=a,m=this);for(var x=0;x<m.length;x++)this.words[x]=f.words[x]^m.words[x];if(this!==f)for(;x<f.length;x++)this.words[x]=f.words[x];return this.length=f.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 f=Math.ceil(a/26)|0,m=a%26;this._expand(f),m>0&&f--;for(var x=0;x<f;x++)this.words[x]=~this.words[x]&67108863;return m>0&&(this.words[x]=~this.words[x]&67108863>>26-m),this._strip()},i.prototype.notn=function(a){return this.clone().inotn(a)},i.prototype.setn=function(a,f){n(typeof a=="number"&&a>=0);var m=a/26|0,x=a%26;return this._expand(m+1),f?this.words[m]=this.words[m]|1<<x:this.words[m]=this.words[m]&~(1<<x),this._strip()},i.prototype.iadd=function(a){var f;if(this.negative!==0&&a.negative===0)return this.negative=0,f=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,f=this.isub(a),a.negative=1,f._normSign();var m,x;this.length>a.length?(m=this,x=a):(m=a,x=this);for(var E=0,I=0;I<x.length;I++)f=(m.words[I]|0)+(x.words[I]|0)+E,this.words[I]=f&67108863,E=f>>>26;for(;E!==0&&I<m.length;I++)f=(m.words[I]|0)+E,this.words[I]=f&67108863,E=f>>>26;if(this.length=m.length,E!==0)this.words[this.length]=E,this.length++;else if(m!==this)for(;I<m.length;I++)this.words[I]=m.words[I];return this},i.prototype.add=function(a){var f;return a.negative!==0&&this.negative===0?(a.negative=0,f=this.sub(a),a.negative^=1,f):a.negative===0&&this.negative!==0?(this.negative=0,f=a.sub(this),this.negative=1,f):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 f=this.iadd(a);return a.negative=1,f._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var m=this.cmp(a);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var x,E;m>0?(x=this,E=a):(x=a,E=this);for(var I=0,R=0;R<E.length;R++)f=(x.words[R]|0)-(E.words[R]|0)+I,I=f>>26,this.words[R]=f&67108863;for(;I!==0&&R<x.length;R++)f=(x.words[R]|0)+I,I=f>>26,this.words[R]=f&67108863;if(I===0&&R<x.length&&x!==this)for(;R<x.length;R++)this.words[R]=x.words[R];return this.length=Math.max(this.length,R),x!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(a){return this.clone().isub(a)};function U(w,a,f){f.negative=a.negative^w.negative;var m=w.length+a.length|0;f.length=m,m=m-1|0;var x=w.words[0]|0,E=a.words[0]|0,I=x*E,R=I&67108863,b=I/67108864|0;f.words[0]=R;for(var h=1;h<m;h++){for(var k=b>>>26,G=b&67108863,j=Math.min(h,a.length-1),Y=Math.max(0,h-w.length+1);Y<=j;Y++){var gt=h-Y|0;x=w.words[gt]|0,E=a.words[Y]|0,I=x*E+G,k+=I/67108864|0,G=I&67108863}f.words[h]=G|0,b=k|0}return b!==0?f.words[h]=b|0:f.length--,f._strip()}var D=function(a,f,m){var x=a.words,E=f.words,I=m.words,R=0,b,h,k,G=x[0]|0,j=G&8191,Y=G>>>13,gt=x[1]|0,ht=gt&8191,ft=gt>>>13,Ot=x[2]|0,Rt=Ot&8191,Lt=Ot>>>13,Re=x[3]|0,tt=Re&8191,ot=Re>>>13,yt=x[4]|0,dt=yt&8191,Mt=yt>>>13,Fe=x[5]|0,wt=Fe&8191,_t=Fe>>>13,Dt=x[6]|0,kt=Dt&8191,Nt=Dt>>>13,Ne=x[7]|0,Pt=Ne&8191,y=Ne>>>13,l=x[8]|0,d=l&8191,B=l>>>13,L=x[9]|0,T=L&8191,O=L>>>13,vt=E[0]|0,xt=vt&8191,mt=vt>>>13,Ft=E[1]|0,pt=Ft&8191,Vt=Ft>>>13,qs=E[2]|0,Gt=qs&8191,Zt=qs>>>13,Ks=E[3]|0,Yt=Ks&8191,Xt=Ks>>>13,$s=E[4]|0,Jt=$s&8191,Qt=$s>>>13,js=E[5]|0,te=js&8191,ee=js>>>13,Hs=E[6]|0,ne=Hs&8191,re=Hs>>>13,Ws=E[7]|0,ie=Ws&8191,se=Ws>>>13,Vs=E[8]|0,oe=Vs&8191,ae=Vs>>>13,Gs=E[9]|0,ce=Gs&8191,ue=Gs>>>13;m.negative=a.negative^f.negative,m.length=19,b=Math.imul(j,xt),h=Math.imul(j,mt),h=h+Math.imul(Y,xt)|0,k=Math.imul(Y,mt);var ui=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(ui>>>26)|0,ui&=67108863,b=Math.imul(ht,xt),h=Math.imul(ht,mt),h=h+Math.imul(ft,xt)|0,k=Math.imul(ft,mt),b=b+Math.imul(j,pt)|0,h=h+Math.imul(j,Vt)|0,h=h+Math.imul(Y,pt)|0,k=k+Math.imul(Y,Vt)|0;var li=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(li>>>26)|0,li&=67108863,b=Math.imul(Rt,xt),h=Math.imul(Rt,mt),h=h+Math.imul(Lt,xt)|0,k=Math.imul(Lt,mt),b=b+Math.imul(ht,pt)|0,h=h+Math.imul(ht,Vt)|0,h=h+Math.imul(ft,pt)|0,k=k+Math.imul(ft,Vt)|0,b=b+Math.imul(j,Gt)|0,h=h+Math.imul(j,Zt)|0,h=h+Math.imul(Y,Gt)|0,k=k+Math.imul(Y,Zt)|0;var fi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(fi>>>26)|0,fi&=67108863,b=Math.imul(tt,xt),h=Math.imul(tt,mt),h=h+Math.imul(ot,xt)|0,k=Math.imul(ot,mt),b=b+Math.imul(Rt,pt)|0,h=h+Math.imul(Rt,Vt)|0,h=h+Math.imul(Lt,pt)|0,k=k+Math.imul(Lt,Vt)|0,b=b+Math.imul(ht,Gt)|0,h=h+Math.imul(ht,Zt)|0,h=h+Math.imul(ft,Gt)|0,k=k+Math.imul(ft,Zt)|0,b=b+Math.imul(j,Yt)|0,h=h+Math.imul(j,
6Xt)|0,h=h+Math.imul(Y,Yt)|0,k=k+Math.imul(Y,Xt)|0;var hi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(hi>>>26)|0,hi&=67108863,b=Math.imul(dt,xt),h=Math.imul(dt,mt),h=h+Math.imul(Mt,xt)|0,k=Math.imul(Mt,mt),b=b+Math.imul(tt,pt)|0,h=h+Math.imul(tt,Vt)|0,h=h+Math.imul(ot,pt)|0,k=k+Math.imul(ot,Vt)|0,b=b+Math.imul(Rt,Gt)|0,h=h+Math.imul(Rt,Zt)|0,h=h+Math.imul(Lt,Gt)|0,k=k+Math.imul(Lt,Zt)|0,b=b+Math.imul(ht,Yt)|0,h=h+Math.imul(ht,Xt)|0,h=h+Math.imul(ft,Yt)|0,k=k+Math.imul(ft,Xt)|0,b=b+Math.imul(j,Jt)|0,h=h+Math.imul(j,Qt)|0,h=h+Math.imul(Y,Jt)|0,k=k+Math.imul(Y,Qt)|0;var di=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(di>>>26)|0,di&=67108863,b=Math.imul(wt,xt),h=Math.imul(wt,mt),h=h+Math.imul(_t,xt)|0,k=Math.imul(_t,mt),b=b+Math.imul(dt,pt)|0,h=h+Math.imul(dt,Vt)|0,h=h+Math.imul(Mt,pt)|0,k=k+Math.imul(Mt,Vt)|0,b=b+Math.imul(tt,Gt)|0,h=h+Math.imul(tt,Zt)|0,h=h+Math.imul(ot,Gt)|0,k=k+Math.imul(ot,Zt)|0,b=b+Math.imul(Rt,Yt)|0,h=h+Math.imul(Rt,Xt)|0,h=h+Math.imul(Lt,Yt)|0,k=k+Math.imul(Lt,Xt)|0,b=b+Math.imul(ht,Jt)|0,h=h+Math.imul(ht,Qt)|0,h=h+Math.imul(ft,Jt)|0,k=k+Math.imul(ft,Qt)|0,b=b+Math.imul(j,te)|0,h=h+Math.imul(j,ee)|0,h=h+Math.imul(Y,te)|0,k=k+Math.imul(Y,ee)|0;var pi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(pi>>>26)|0,pi&=67108863,b=Math.imul(kt,xt),h=Math.imul(kt,mt),h=h+Math.imul(Nt,xt)|0,k=Math.imul(Nt,mt),b=b+Math.imul(wt,pt)|0,h=h+Math.imul(wt,Vt)|0,h=h+Math.imul(_t,pt)|0,k=k+Math.imul(_t,Vt)|0,b=b+Math.imul(dt,Gt)|0,h=h+Math.imul(dt,Zt)|0,h=h+Math.imul(Mt,Gt)|0,k=k+Math.imul(Mt,Zt)|0,b=b+Math.imul(tt,Yt)|0,h=h+Math.imul(tt,Xt)|0,h=h+Math.imul(ot,Yt)|0,k=k+Math.imul(ot,Xt)|0,b=b+Math.imul(Rt,Jt)|0,h=h+Math.imul(Rt,Qt)|0,h=h+Math.imul(Lt,Jt)|0,k=k+Math.imul(Lt,Qt)|0,b=b+Math.imul(ht,te)|0,h=h+Math.imul(ht,ee)|0,h=h+Math.imul(ft,te)|0,k=k+Math.imul(ft,ee)|0,b=b+Math.imul(j,ne)|0,h=h+Math.imul(j,re)|0,h=h+Math.imul(Y,ne)|0,k=k+Math.imul(Y,re)|0;var gi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(gi>>>26)|0,gi&=67108863,b=Math.imul(Pt,xt),h=Math.imul(Pt,mt),h=h+Math.imul(y,xt)|0,k=Math.imul(y,mt),b=b+Math.imul(kt,pt)|0,h=h+Math.imul(kt,Vt)|0,h=h+Math.imul(Nt,pt)|0,k=k+Math.imul(Nt,Vt)|0,b=b+Math.imul(wt,Gt)|0,h=h+Math.imul(wt,Zt)|0,h=h+Math.imul(_t,Gt)|0,k=k+Math.imul(_t,Zt)|0,b=b+Math.imul(dt,Yt)|0,h=h+Math.imul(dt,Xt)|0,h=h+Math.imul(Mt,Yt)|0,k=k+Math.imul(Mt,Xt)|0,b=b+Math.imul(tt,Jt)|0,h=h+Math.imul(tt,Qt)|0,h=h+Math.imul(ot,Jt)|0,k=k+Math.imul(ot,Qt)|0,b=b+Math.imul(Rt,te)|0,h=h+Math.imul(Rt,ee)|0,h=h+Math.imul(Lt,te)|0,k=k+Math.imul(Lt,ee)|0,b=b+Math.imul(ht,ne)|0,h=h+Math.imul(ht,re)|0,h=h+Math.imul(ft,ne)|0,k=k+Math.imul(ft,re)|0,b=b+Math.imul(j,ie)|0,h=h+Math.imul(j,se)|0,h=h+Math.imul(Y,ie)|0,k=k+Math.imul(Y,se)|0;var mi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(mi>>>26)|0,mi&=67108863,b=Math.imul(d,xt),h=Math.imul(d,mt),h=h+Math.imul(B,xt)|0,k=Math.imul(B,mt),b=b+Math.imul(Pt,pt)|0,h=h+Math.imul(Pt,Vt)|0,h=h+Math.imul(y,pt)|0,k=k+Math.imul(y,Vt)|0,b=b+Math.imul(kt,Gt)|0,h=h+Math.imul(kt,Zt)|0,h=h+Math.imul(Nt,Gt)|0,k=k+Math.imul(Nt,Zt)|0,b=b+Math.imul(wt,Yt)|0,h=h+Math.imul(wt,Xt)|0,h=h+Math.imul(_t,Yt)|0,k=k+Math.imul(_t,Xt)|0,b=b+Math.imul(dt,Jt)|0,h=h+Math.imul(dt,Qt)|0,h=h+Math.imul(Mt,Jt)|0,k=k+Math.imul(Mt,Qt)|0,b=b+Math.imul(tt,te)|0,h=h+Math.imul(tt,ee)|0,h=h+Math.imul(ot,te)|0,k=k+Math.imul(ot,ee)|0,b=b+Math.imul(Rt,ne)|0,h=h+Math.imul(Rt,re)|0,h=h+Math.imul(Lt,ne)|0,k=k+Math.imul(Lt,re)|0,b=b+Math.imul(ht,ie)|0,h=h+Math.imul(ht,se)|0,h=h+Math.imul(ft,ie)|0,k=k+Math.imul(ft,se)|0,b=b+Math.imul(j,oe)|0,h=h+Math.imul(j,ae)|0,h=h+Math.imul(Y,oe)|0,k=k+Math.imul(Y,ae)|0;var yi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(yi>>>26)|0,yi&=67108863,b=Math.imul(T,xt),h=Math.imul(T,mt),h=h+Math.imul(O,xt)|0,k=Math.imul(O,mt),b=b+Math.imul(d,pt)|0,h=h+Math.imul(d,Vt)|0,h=h+Math.imul(B,pt)|0,k=k+Math.imul(B,Vt)|0,b=b+Math.imul(Pt,Gt)|0,h=h+Math.imul(Pt,Zt)|0,h=h+Math.imul(y,Gt)|0,k=k+Math.imul(y,Zt)|0,b=b+Math.imul(kt,Yt)|0,h=h+Math.imul(kt,Xt)|0,h=h+Math.imul(Nt,Yt)|0,k=k+Math.imul(Nt,Xt)|0,b=b+Math.imul(wt,Jt)|0,h=h+Math.imul(wt,Qt)|0,h=h+Math.imul(_t,Jt)|0,k=k+Math.imul(_t,Qt)|0,b=b+Math.imul(dt,te)|0,h=h+Math.imul(dt,ee)|0,h=h+Math.imul(Mt,te)|0,k=k+Math.imul(Mt,ee)|0,b=b+Math.imul(tt,ne)|0,h=h+Math.imul(tt,re)|0,h=h+Math.imul(ot,ne)|0,k=k+Math.imul(ot,re)|0,b=b+Math.imul(Rt,ie)|0,h=h+Math.imul(Rt,se)|0,h=h+Math.imul(Lt,ie)|0,k=k+Math.imul(Lt,se)|0,b=b+Math.imul(ht,oe)|0,h=h+Math.imul(ht,ae)|0,h=h+Math.imul(ft,oe)|0,k=k+Math.imul(ft,ae)|0,b=b+Math.imul(j,ce)|0,h=h+Math.imul(j,ue)|0,h=h+Math.imul(Y,ce)|0,k=k+Math.imul(Y,ue)|0;var wi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(wi>>>26)|0,wi&=67108863,b=Math.imul(T,pt),h=Math.imul(T,Vt),h=h+Math.imul(O,pt)|0,k=Math.imul(O,Vt),b=b+Math.imul(d,Gt)|0,h=h+Math.imul(d,Zt)|0,h=h+Math.imul(B,Gt)|0,k=k+Math.imul(B,Zt)|0,b=b+Math.imul(Pt,Yt)|0,h=h+Math.imul(Pt,Xt)|0,h=h+Math.imul(y,Yt)|0,k=k+Math.imul(y,Xt)|0,b=b+Math.imul(kt,Jt)|0,h=h+Math.imul(kt,Qt)|0,h=h+Math.imul(Nt,Jt)|0,k=k+Math.imul(Nt,Qt)|0,b=b+Math.imul(wt,te)|0,h=h+Math.imul(wt,ee)|0,h=h+Math.imul(_t,te)|0,
vendor: 29,680 bytes, line 6
6k=k+Math.imul(_t,ee)|0,b=b+Math.imul(dt,ne)|0,h=h+Math.imul(dt,re)|0,h=h+Math.imul(Mt,ne)|0,k=k+Math.imul(Mt,re)|0,b=b+Math.imul(tt,ie)|0,h=h+Math.imul(tt,se)|0,h=h+Math.imul(ot,ie)|0,k=k+Math.imul(ot,se)|0,b=b+Math.imul(Rt,oe)|0,h=h+Math.imul(Rt,ae)|0,h=h+Math.imul(Lt,oe)|0,k=k+Math.imul(Lt,ae)|0,b=b+Math.imul(ht,ce)|0,h=h+Math.imul(ht,ue)|0,h=h+Math.imul(ft,ce)|0,k=k+Math.imul(ft,ue)|0;var bi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(bi>>>26)|0,bi&=67108863,b=Math.imul(T,Gt),h=Math.imul(T,Zt),h=h+Math.imul(O,Gt)|0,k=Math.imul(O,Zt),b=b+Math.imul(d,Yt)|0,h=h+Math.imul(d,Xt)|0,h=h+Math.imul(B,Yt)|0,k=k+Math.imul(B,Xt)|0,b=b+Math.imul(Pt,Jt)|0,h=h+Math.imul(Pt,Qt)|0,h=h+Math.imul(y,Jt)|0,k=k+Math.imul(y,Qt)|0,b=b+Math.imul(kt,te)|0,h=h+Math.imul(kt,ee)|0,h=h+Math.imul(Nt,te)|0,k=k+Math.imul(Nt,ee)|0,b=b+Math.imul(wt,ne)|0,h=h+Math.imul(wt,re)|0,h=h+Math.imul(_t,ne)|0,k=k+Math.imul(_t,re)|0,b=b+Math.imul(dt,ie)|0,h=h+Math.imul(dt,se)|0,h=h+Math.imul(Mt,ie)|0,k=k+Math.imul(Mt,se)|0,b=b+Math.imul(tt,oe)|0,h=h+Math.imul(tt,ae)|0,h=h+Math.imul(ot,oe)|0,k=k+Math.imul(ot,ae)|0,b=b+Math.imul(Rt,ce)|0,h=h+Math.imul(Rt,ue)|0,h=h+Math.imul(Lt,ce)|0,k=k+Math.imul(Lt,ue)|0;var vi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(vi>>>26)|0,vi&=67108863,b=Math.imul(T,Yt),h=Math.imul(T,Xt),h=h+Math.imul(O,Yt)|0,k=Math.imul(O,Xt),b=b+Math.imul(d,Jt)|0,h=h+Math.imul(d,Qt)|0,h=h+Math.imul(B,Jt)|0,k=k+Math.imul(B,Qt)|0,b=b+Math.imul(Pt,te)|0,h=h+Math.imul(Pt,ee)|0,h=h+Math.imul(y,te)|0,k=k+Math.imul(y,ee)|0,b=b+Math.imul(kt,ne)|0,h=h+Math.imul(kt,re)|0,h=h+Math.imul(Nt,ne)|0,k=k+Math.imul(Nt,re)|0,b=b+Math.imul(wt,ie)|0,h=h+Math.imul(wt,se)|0,h=h+Math.imul(_t,ie)|0,k=k+Math.imul(_t,se)|0,b=b+Math.imul(dt,oe)|0,h=h+Math.imul(dt,ae)|0,h=h+Math.imul(Mt,oe)|0,k=k+Math.imul(Mt,ae)|0,b=b+Math.imul(tt,ce)|0,h=h+Math.imul(tt,ue)|0,h=h+Math.imul(ot,ce)|0,k=k+Math.imul(ot,ue)|0;var xi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(xi>>>26)|0,xi&=67108863,b=Math.imul(T,Jt),h=Math.imul(T,Qt),h=h+Math.imul(O,Jt)|0,k=Math.imul(O,Qt),b=b+Math.imul(d,te)|0,h=h+Math.imul(d,ee)|0,h=h+Math.imul(B,te)|0,k=k+Math.imul(B,ee)|0,b=b+Math.imul(Pt,ne)|0,h=h+Math.imul(Pt,re)|0,h=h+Math.imul(y,ne)|0,k=k+Math.imul(y,re)|0,b=b+Math.imul(kt,ie)|0,h=h+Math.imul(kt,se)|0,h=h+Math.imul(Nt,ie)|0,k=k+Math.imul(Nt,se)|0,b=b+Math.imul(wt,oe)|0,h=h+Math.imul(wt,ae)|0,h=h+Math.imul(_t,oe)|0,k=k+Math.imul(_t,ae)|0,b=b+Math.imul(dt,ce)|0,h=h+Math.imul(dt,ue)|0,h=h+Math.imul(Mt,ce)|0,k=k+Math.imul(Mt,ue)|0;var Ei=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,b=Math.imul(T,te),h=Math.imul(T,ee),h=h+Math.imul(O,te)|0,k=Math.imul(O,ee),b=b+Math.imul(d,ne)|0,h=h+Math.imul(d,re)|0,h=h+Math.imul(B,ne)|0,k=k+Math.imul(B,re)|0,b=b+Math.imul(Pt,ie)|0,h=h+Math.imul(Pt,se)|0,h=h+Math.imul(y,ie)|0,k=k+Math.imul(y,se)|0,b=b+Math.imul(kt,oe)|0,h=h+Math.imul(kt,ae)|0,h=h+Math.imul(Nt,oe)|0,k=k+Math.imul(Nt,ae)|0,b=b+Math.imul(wt,ce)|0,h=h+Math.imul(wt,ue)|0,h=h+Math.imul(_t,ce)|0,k=k+Math.imul(_t,ue)|0;var Si=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(Si>>>26)|0,Si&=67108863,b=Math.imul(T,ne),h=Math.imul(T,re),h=h+Math.imul(O,ne)|0,k=Math.imul(O,re),b=b+Math.imul(d,ie)|0,h=h+Math.imul(d,se)|0,h=h+Math.imul(B,ie)|0,k=k+Math.imul(B,se)|0,b=b+Math.imul(Pt,oe)|0,h=h+Math.imul(Pt,ae)|0,h=h+Math.imul(y,oe)|0,k=k+Math.imul(y,ae)|0,b=b+Math.imul(kt,ce)|0,h=h+Math.imul(kt,ue)|0,h=h+Math.imul(Nt,ce)|0,k=k+Math.imul(Nt,ue)|0;var Bi=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(Bi>>>26)|0,Bi&=67108863,b=Math.imul(T,ie),h=Math.imul(T,se),h=h+Math.imul(O,ie)|0,k=Math.imul(O,se),b=b+Math.imul(d,oe)|0,h=h+Math.imul(d,ae)|0,h=h+Math.imul(B,oe)|0,k=k+Math.imul(B,ae)|0,b=b+Math.imul(Pt,ce)|0,h=h+Math.imul(Pt,ue)|0,h=h+Math.imul(y,ce)|0,k=k+Math.imul(y,ue)|0;var Ai=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,b=Math.imul(T,oe),h=Math.imul(T,ae),h=h+Math.imul(O,oe)|0,k=Math.imul(O,ae),b=b+Math.imul(d,ce)|0,h=h+Math.imul(d,ue)|0,h=h+Math.imul(B,ce)|0,k=k+Math.imul(B,ue)|0;var _i=(R+b|0)+((h&8191)<<13)|0;R=(k+(h>>>13)|0)+(_i>>>26)|0,_i&=67108863,b=Math.imul(T,ce),h=Math.imul(T,ue),h=h+Math.imul(O,ce)|0,k=Math.imul(O,ue);var ki=(R+b|0)+((h&8191)<<13)|0;return R=(k+(h>>>13)|0)+(ki>>>26)|0,ki&=67108863,I[0]=ui,I[1]=li,I[2]=fi,I[3]=hi,I[4]=di,I[5]=pi,I[6]=gi,I[7]=mi,I[8]=yi,I[9]=wi,I[10]=bi,I[11]=vi,I[12]=xi,I[13]=Ei,I[14]=Si,I[15]=Bi,I[16]=Ai,I[17]=_i,I[18]=ki,R!==0&&(I[19]=R,m.length++),m};Math.imul||(D=U);function N(w,a,f){f.negative=a.negative^w.negative,f.length=w.length+a.length;for(var m=0,x=0,E=0;E<f.length-1;E++){var I=x;x=0;for(var R=m&67108863,b=Math.min(E,a.length-1),h=Math.max(0,E-w.length+1);h<=b;h++){var k=E-h,G=w.words[k]|0,j=a.words[h]|0,Y=G*j,gt=Y&67108863;I=I+(Y/67108864|0)|0,gt=gt+R|0,R=gt&67108863,I=I+(gt>>>26)|0,x+=I>>>26,I&=67108863}f.words[E]=R,m=I,I=x}return m!==0?f.words[E]=m:f.length--,f._strip()}function K(w,a,f){return N(w,a,f)}i.prototype.mulTo=function(a,f){var m,x=this.length+a.length;return this.length===10&&a.length===10?m=D(this,a,f):x<63?m=U(this,a,f):x<1024?m=N(this,a,f):m=K(this,a,f),m},i.prototype.mul=function(a){var f=new i(null);return f.words=new Array(this.length+a.length),this.mulTo(a,f)},i.prototype.mulf=function(a){var f=new i(null);return f.words=new Array(this.length+a.length),K(this,a,f)},i.prototype.imul=function(a){return this.clone().mulTo(a,this)},i.prototype.imuln=function(a){var f=a<0;f&&(a=-a),n(typeof a=="number"),n(a<67108864);for(var m=0,x=0;x<this.length;x++){var E=(this.words[x]|0)*a,I=(E&67108863)+(m&67108863);m>>=26,m+=E/67108864|0,m+=I>>>26,this.words[x]=I&67108863}return m!==0&&(this.words[x]=m,this.length++),this.length=a===0?1:this.length,f?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 f=M(a);if(f.length===0)return new i(1);for(var m=this,x=0;x<f.length&&f[x]===0;x++,m=m.sqr());if(++x<f.length)for(var E=m.sqr();x<f.length;x++,E=E.sqr())f[x]!==0&&(m=m.mul(E));return m},i.prototype.iushln=function(a){n(typeof a=="number"&&a>=0);var f=a%26,m=(a-f)/26,x=67108863>>>26-f<<26-f,E;if(f!==0){var I=0;for(E=0;E<this.length;E++){var R=this.words[E]&x,b=(this.words[E]|0)-R<<f;this.words[E]=b|I,I=R>>>26-f}I&&(this.words[E]=I,this.length++)}if(m!==0){for(E=this.length-1;E>=0;E--)this.words[E+m]=this.words[E];for(E=0;E<m;E++)this.words[E]=0;this.length+=m}return this._strip()},i.prototype.ishln=function(a){return n(this.negative===0),this.iushln(a)},i.prototype.iushrn=function(a,f,m){n(typeof a=="number"&&a>=0);var x;f?x=(f-f%26)/26:x=0;var E=a%26,I=Math.min((a-E)/26,this.length),R=67108863^67108863>>>E<<E,b=m;if(x-=I,x=Math.max(0,x),b){for(var h=0;h<I;h++)b.words[h]=this.words[h];b.length=I}if(I!==0)if(this.length>I)for(this.length-=I,h=0;h<this.length;h++)this.words[h]=this.words[h+I];else this.words[0]=0,this.length=1;var k=0;for(h=this.length-1;h>=0&&(k!==0||h>=x);h--){var G=this.words[h]|0;this.words[h]=k<<26-E|G>>>E,k=G&R}return b&&k!==0&&(b.words[b.length++]=k),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(a,f,m){return n(this.negative===0),this.iushrn(a,f,m)},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 f=a%26,m=(a-f)/26,x=1<<f;if(this.length<=m)return!1;var E=this.words[m];return!!(E&x)},i.prototype.imaskn=function(a){n(typeof a=="number"&&a>=0);var f=a%26,m=(a-f)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(f!==0&&m++,this.length=Math.min(m,this.length),f!==0){var x=67108863^67108863>>>f<<f;this.words[this.length-1]&=x}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 f=0;f<this.length&&this.words[f]>=67108864;f++)this.words[f]-=67108864,f===this.length-1?this.words[f+1]=1:this.words[f+1]++;return this.length=Math.max(this.length,f+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 f=0;f<this.length&&this.words[f]<0;f++)this.words[f]+=67108864,this.words[f+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,f,m){var x=a.length+m,E;this._expand(x);var I,R=0;for(E=0;E<a.length;E++){I=(this.words[E+m]|0)+R;var b=(a.words[E]|0)*f;I-=b&67108863,R=(I>>26)-(b/67108864|0),this.words[E+m]=I&67108863}for(;E<this.length-m;E++)I=(this.words[E+m]|0)+R,R=I>>26,this.words[E+m]=I&67108863;if(R===0)return this._strip();for(n(R===-1),R=0,E=0;E<this.length;E++)I=-(this.words[E]|0)+R,R=I>>26,this.words[E]=I&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(a,f){var m=this.length-a.length,x=this.clone(),E=a,I=E.words[E.length-1]|0,R=this._countBits(I);m=26-R,m!==0&&(E=E.ushln(m),x.iushln(m),I=E.words[E.length-1]|0);var b=x.length-E.length,h;if(f!=="mod"){h=new i(null),h.length=b+1,h.words=new Array(h.length);for(var k=0;k<h.length;k++)h.words[k]=0}var G=x.clone()._ishlnsubmul(E,1,b);G.negative===0&&(x=G,h&&(h.words[b]=1));for(var j=b-1;j>=0;j--){var Y=(x.words[E.length+j]|0)*67108864+(x.words[E.length+j-1]|0);for(Y=Math.min(Y/I|0,67108863),x._ishlnsubmul(E,Y,j);x.negative!==0;)Y--,x.negative=0,x._ishlnsubmul(E,1,j),x.isZero()||(x.negative^=1);h&&(h.words[j]=Y)}return h&&h._strip(),x._strip(),f!=="div"&&m!==0&&x.iushrn(m),{div:h||null,mod:x}},i.prototype.divmod=function(a,f,m){if(n(!a.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var x,E,I;return this.negative!==0&&a.negative===0?(I=this.neg().divmod(a,f),f!=="mod"&&(x=I.div.neg()),f!=="div"&&(E=I.mod.neg(),m&&E.negative!==0&&E.iadd(a)),{div:x,mod:E}):this.negative===0&&a.negative!==0?(I=this.divmod(a.neg(),f),f!=="mod"&&(x=I.div.neg()),{div:x,mod:I.mod}):this.negative&a.negative?(I=this.neg().divmod(a.neg(),f),f!=="div"&&(E=I.mod.neg(),m&&E.negative!==0&&E.isub(a)),{div:I.div,mod:E}):a.length>this.length||this.cmp(a)<0?{div:new i(0),mod:this}:a.length===1?f==="div"?{div:this.divn(a.words[0]),mod:null}:f==="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,f)},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 f=this.divmod(a);if(f.mod.isZero())return f.div;var m=f.div.negative!==0?f.mod.isub(a):f.mod,x=a.ushrn(1),E=a.andln(1),I=m.cmp(x);return I<0||E===1&&I===0?f.div:f.div.negative!==0?f.div.isubn(1):f.div.iaddn(1)},i.prototype.modrn=function(a){var f=a<0;f&&(a=-a),n(a<=67108863);for(var m=(1<<26)%a,x=0,E=this.length-1;E>=0;E--)x=(m*x+(this.words[E]|0))%a;return f?-x:x},i.prototype.modn=function(a){return this.modrn(a)},i.prototype.idivn=function(a){var f=a<0;f&&(a=-a),n(a<=67108863);for(var m=0,x=this.length-1;x>=0;x--){var E=(this.words[x]|0)+m*67108864;this.words[x]=E/a|0,m=E%a}return this._strip(),f?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 f=this,m=a.clone();f.negative!==0?f=f.umod(a):f=f.clone();for(var x=new i(1),E=new i(0),I=new i(0),R=new i(1),b=0;f.isEven()&&m.isEven();)f.iushrn(1),m.iushrn(1),++b;for(var h=m.clone(),k=f.clone();!f.isZero();){for(var G=0,j=1;!(f.words[0]&j)&&G<26;++G,j<<=1);if(G>0)for(f.iushrn(G);G-- >0;)(x.isOdd()||E.isOdd())&&(x.iadd(h),E.isub(k)),x.iushrn(1),E.iushrn(1);for(var Y=0,gt=1;!(m.words[0]&gt)&&Y<26;++Y,gt<<=1);if(Y>0)for(m.iushrn(Y);Y-- >0;)(I.isOdd()||R.isOdd())&&(I.iadd(h),R.isub(k)),I.iushrn(1),R.iushrn(1);f.cmp(m)>=0?(f.isub(m),x.isub(I),E.isub(R)):(m.isub(f),I.isub(x),R.isub(E))}return{a:I,b:R,gcd:m.iushln(b)}},i.prototype._invmp=function(a){n(a.negative===0),n(!a.isZero());var f=this,m=a.clone();f.negative!==0?f=f.umod(a):f=f.clone();for(var x=new i(1),E=new i(0),I=m.clone();f.cmpn(1)>0&&m.cmpn(1)>0;){for(var R=0,b=1;!(f.words[0]&b)&&R<26;++R,b<<=1);if(R>0)for(f.iushrn(R);R-- >0;)x.isOdd()&&x.iadd(I),x.iushrn(1);for(var h=0,k=1;!(m.words[0]&k)&&h<26;++h,k<<=1);if(h>0)for(m.iushrn(h);h-- >0;)E.isOdd()&&E.iadd(I),E.iushrn(1);f.cmp(m)>=0?(f.isub(m),x.isub(E)):(m.isub(f),E.isub(x))}var G;return f.cmpn(1)===0?G=x:G=E,G.cmpn(0)<0&&G.iadd(a),G},i.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var f=this.clone(),m=a.clone();f.negative=0,m.negative=0;for(var x=0;f.isEven()&&m.isEven();x++)f.iushrn(1),m.iushrn(1);do{for(;f.isEven();)f.iushrn(1);for(;m.isEven();)m.iushrn(1);var E=f.cmp(m);if(E<0){var I=f;f=m,m=I}else if(E===0||m.cmpn(1)===0)break;f.isub(m)}while(!0);return m.iushln(x)},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 f=a%26,m=(a-f)/26,x=1<<f;if(this.length<=m)return this._expand(m+1),this.words[m]|=x,this;for(var E=x,I=m;E!==0&&I<this.length;I++){var R=this.words[I]|0;R+=E,E=R>>>26,R&=67108863,this.words[I]=R}return E!==0&&(this.words[I]=E,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(a){var f=a<0;if(this.negative!==0&&!f)return-1;if(this.negative===0&&f)return 1;this._strip();var m;if(this.length>1)m=1;else{f&&(a=-a),n(a<=67108863,"Number is too big");var x=this.words[0]|0;m=x===a?0:x<a?-1:1}return this.negative!==0?-m|0:m},i.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var f=this.ucmp(a);return this.negative!==0?-f|0:f},i.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var f=0,m=this.length-1;m>=0;m--){var x=this.words[m]|0,E=a.words[m]|0;if(x!==E){x<E?f=-1:x>E&&(f=1);break}}return f},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 W(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 V={k256:null,p224:null,p192:null,p25519:null};function nt(w,a){this.name=w,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 f=a,m;do this.split(f,this.tmp),f=this.imulK(f),f=f.iadd(this.tmp),m=f.bitLength();while(m>this.n);var x=m<this.n?-1:f.ucmp(this.p);return x===0?(f.words[0]=0,f.length=1):x>0?f.isub(this.p):f.strip!==void 0?f.strip():f._strip(),f},nt.prototype.split=function(a,f){a.iushrn(this.n,0,f)},nt.prototype.imulK=function(a){return a.imul(this.k)};function lt(){nt.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(lt,nt),lt.prototype.split=function(a,f){for(var m=4194303,x=Math.min(a.length,9),E=0;E<x;E++)f.words[E]=a.words[E];if(f.length=x,a.length<=9){a.words[0]=0,a.length=1;return}var I=a.words[9];for(f.words[f.length++]=I&m,E=10;E<a.length;E++){var R=a.words[E]|0;a.words[E-10]=(R&m)<<4|I>>>22,I=R}I>>>=22,a.words[E-10]=I,I===0&&a.length>10?a.length-=10:a.length-=9},lt.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var f=0,m=0;m<a.length;m++){var x=a.words[m]|0;f+=x*977,a.words[m]=f&67108863,f=x*64+(f/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function st(){nt.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(st,nt);function z(){nt.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(z,nt);function et(){nt.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(et,nt),et.prototype.imulK=function(a){for(var f=0,m=0;m<a.length;m++){var x=(a.words[m]|0)*19+f,E=x&67108863;x>>>=26,a.words[m]=E,f=x}return f!==0&&(a.words[a.length++]=f),a},i._prime=function(a){if(V[a])return V[a];var f;if(a==="k256")f=new lt;else if(a==="p224")f=new st;else if(a==="p192")f=new z;else if(a==="p25519")f=new et;else throw new Error("Unknown prime "+a);return V[a]=f,f};function W(w){if(typeof w=="string"){var a=i._prime(w);this.m=a.p,this.prime=a}else n(w.gtn(1),"modulus must be greater than 1"),this.m=w,this.prime=null}W.prototype._verify1=function(a){n(a.negative===0,"red works only with positives"),n(a.red,"red works only with red numbers")},W.prototype._verify2=function(a,f){n((a.negative|f.negative)===0,"red works only with positives"),n(a.red&&a.red===f.red,"red works only with red numbers")},W.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(g(a,a.umod(this.m)._forceRed(this)),a)},W.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},W.prototype.add=function(a,f){this._verify2(a,f);var m=a.add(f);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},W.prototype.iadd=function(a,f){this._verify2(a,f);var m=a.iadd(f);return m.cmp(this.m)>=0&&m.isub(this.m),m},W.prototype.sub=function(a,f){this._verify2(a,f);var m=a.sub(f);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},W.prototype.isub=function(a,f){this._verify2(a,f);var m=a.isub(f);return m.cmpn(0)<0&&m.iadd(this.m),m},W.prototype.shl=function(a,f){return this._verify1(a),this.imod(a.ushln(f))},W.prototype.imul=function(a,f){return this._verify2(a,f),this.imod(a.imul(f))},W.prototype.mul=function(a,f){return this._verify2(a,f),this.imod(a.mul(f))},W.prototype.isqr=function(a){return this.imul(a,a.clone())},W.prototype.sqr=function(a){return this.mul(a,a)},W.prototype.sqrt=function(a){if(a.isZero())return a.clone();var f=this.m.andln(3);if(n(f%2===1),f===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(a,m)}for(var x=this.m.subn(1),E=0;!x.isZero()&&x.andln(1)===0;)E++,x.iushrn(1);n(!x.isZero());var I=new i(1).toRed(this),R=I.redNeg(),b=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);this.pow(h,b).cmp(R)!==0;)h.redIAdd(R);for(var k=this.pow(h,x),G=this.pow(a,x.addn(1).iushrn(1)),j=this.pow(a,x),Y=E;j.cmp(I)!==0;){for(var gt=j,ht=0;gt.cmp(I)!==0;ht++)gt=gt.redSqr();n(ht<Y);var ft=this.pow(k,new i(1).iushln(Y-ht-1));G=G.redMul(ft),k=ft.redSqr(),j=j.redMul(k),Y=ht}return G},W.prototype.invm=function(a){var f=a._invmp(this.m);return f.negative!==0?(f.negative=0,this.imod(f).redNeg()):this.imod(f)},W.prototype.pow=function(a,f){if(f.isZero())return new i(1).toRed(this);if(f.cmpn(1)===0)return a.clone();var m=4,x=new Array(1<<m);x[0]=new i(1).toRed(this),x[1]=a;for(var E=2;E<x.length;E++)x[E]=this.mul(x[E-1],a);var I=x[0],R=0,b=0,h=f.bitLength()%26;for(h===0&&(h=26),E=f.length-1;E>=0;E--){for(var k=f.words[E],G=h-1;G>=0;G--){var j=k>>G&1;if(I!==x[0]&&(I=this.sqr(I)),j===0&&R===0){b=0;continue}R<<=1,R|=j,b++,!(b!==m&&(E!==0||G!==0))&&(I=this.mul(I,x[R]),b=0,R=0)}h=26}return I},W.prototype.convertTo=function(a){var f=a.umod(this.m);return f===a?f.clone():f},W.prototype.convertFrom=function(a){var f=a.clone();return f.red=null,f},i.mont=function(a){return new Q(a)};function Q(w){W.call(this,w),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(Q,W),Q.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},Q.prototype.convertFrom=function(a){var f=this.imod(a.mul(this.rinv));return f.red=null,f},Q.prototype.imul=function(a,f){if(a.isZero()||f.isZero())return a.words[0]=0,a.length=1,a;var m=a.imul(f),x=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=m.isub(x).iushrn(this.shift),I=E;return E.cmp(this.m)>=0?I=E.isub(this.m):E.cmpn(0)<0&&(I=E.iadd(this.m)),I._forceRed(this)},Q.prototype.mul=function(a,f){if(a.isZero()||f.isZero())return new i(0)._forceRed(this);var m=a.mul(f),x=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=m.isub(x).iushrn(this.shift),I=E;return E.cmp(this.m)>=0?I=E.isub(this.m):E.cmpn(0)<0&&(I=E.iadd(this.m)),I._forceRed(this)},Q.prototype.invm=function(a){var f=this.imod(a._invmp(this.m).mul(this.r2));return f._forceRed(this)}})(r,Ge)})(Es);var ua=Es.exports;const ao=Xr(ua);var es={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,t){var e=bt,n=e.Buffer;function s(o,u){for(var c in o)u[c]=o[c]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?r.exports=e:(s(e,t),t.Buffer=i);function i(o,u,c){return n(o,u,c)}i.prototype=Object.create(n.prototype),s(n,i),i.from=function(o,u,c){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,u,c)},i.alloc=function(o,u,c){if(typeof o!="number")throw new TypeError("Argument must be a number");var p=n(o);return u!==void 0?typeof c=="string"?p.fill(u,c):p.fill(u):p.fill(0),p},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)}})(es,es.exports);var $u=es.exports,Cr=$u.Buffer;function ju(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,u=r.charAt(0),c=Math.log(o)/Math.log(256),p=Math.log(256)/Math.log(o);function g(A){if((Array.isArray(A)||A instanceof Uint8Array)&&(A=Cr.from(A)),!Cr.isBuffer(A))throw new TypeError("Expected Buffer");if(A.length===0)return"";for(var _=0,C=0,M=0,U=A.length;M!==U&&A[M]===0;)M++,_++;for(var D=(U-M)*p+1>>>0,N=new Uint8Array(D);M!==U;){for(var K=A[M],V=0,nt=D-1;(K!==0||V<C)&&nt!==-1;nt--,V++)K+=256*N[nt]>>>0,N[nt]=K%o>>>0,K=K/o>>>0;if(K!==0)throw new Error("Non-zero carry");C=V,M++}for(var lt=D-C;lt!==D&&N[lt]===0;)lt++;for(var st=u.repeat(_);lt<D;++lt)st+=r.charAt(N[lt]);return st}function v(A){if(typeof A!="string")throw new TypeError("Expected String");if(A.length===0)return Cr.alloc(0);for(var _=0,C=0,M=0;A[_]===u;)C++,_++;for(var U=(A.length-_)*c+1>>>0,D=new Uint8Array(U);_<A.length;){var N=A.charCodeAt(_);if(N>255)return;var K=t[N];if(K===255)return;for(var V=0,nt=U-1;(K!==0||V<M)&&nt!==-1;nt--,V++)K+=o*D[nt]>>>0,D[nt]=K%256>>>0,K=K/256>>>0;if(K!==0)throw new Error("Non-zero carry");M=V,_++}for(var lt=U-M;lt!==U&&D[lt]===0;)lt++;var st=Cr.allocUnsafe(C+(U-lt));st.fill(0,0,C);for(var z=C;lt!==U;)st[z++]=D[lt++];return st}function S(A){var _=v(A);if(_)return _;throw new Error("Non-base"+o+" character")}return{encode:g,decodeUnsafe:v,decode:S}}var Hu=ju,Wu=Hu,Vu="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",la=Wu(Vu);const ve=Xr(la),co=Ko;var be={};function un(r,t,e){return t<=r&&r<=e}function ti(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function Gu(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 u=i&1023,c=o&1023;s.push(65536+(u<<10)+c),n+=1}else s.push(65533)}n+=1}return s}function Zu(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 qr=-1;function Ss(r){this.tokens=[].slice.call(r)}Ss.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():qr},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 ir=-1;function Ui(r,t){if(r)throw TypeError("Decoder error");return t||65533}var Kr="utf-8";function $r(r,t){if(!(this instanceof $r))return new $r(r,t);if(r=r!==void 0?String(r).toLowerCase():Kr,r!==Kr)throw new Error("Encoding not supported. Only utf-8 is supported");t=ti(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}$r.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=ti(e),this._streaming||(this._decoder=new Yu({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new Ss(n),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==ir);)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===ir)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),Zu(i)}};function jr(r,t){if(!(this instanceof jr))return new jr(r,t);if(r=r!==void 0?String(r).toLowerCase():Kr,r!==Kr)throw new Error("Encoding not supported. Only utf-8 is supported");t=ti(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}jr.prototype={encode:function(t,e){t=t?String(t):"",e=ti(e),this._streaming||(this._encoder=new Xu(this._options)),this._streaming=!!e.stream;for(var n=[],s=new Ss(Gu(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==ir);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==ir;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}};function Yu(r){var t=r.fatal,e=0,n=0,s=0,i=128,o=191;
6this.handler=function(u,c){if(c===qr&&s!==0)return s=0,Ui(t);if(c===qr)return ir;if(s===0){if(un(c,0,127))return c;if(un(c,194,223))s=1,e=c-192;else if(un(c,224,239))c===224&&(i=160),c===237&&(o=159),s=2,e=c-224;else if(un(c,240,244))c===240&&(i=144),c===244&&(o=143),s=3,e=c-240;else return Ui(t);return e=e<<6*s,null}if(!un(c,i,o))return e=s=n=0,i=128,o=191,u.prepend(c),Ui(t);if(i=128,o=191,n+=1,e+=c-128<<6*(s-n),n!==s)return null;var p=e;return e=s=n=0,p}}function Xu(r){r.fatal,this.handler=function(t,e){if(e===qr)return ir;if(un(e,0,127))return e;var n,s;un(e,128,2047)?(n=1,s=192):un(e,2048,65535)?(n=2,s=224):un(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 Ju=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:$r,TextEncoder:jr},Symbol.toStringTag,{value:"Module"})),Qu=ps(Ju);var tl=Ge&&Ge.__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]}),el=Ge&&Ge.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),nn=Ge&&Ge.__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 u=r.length-1;u>=0;u--)(o=r[u])&&(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},nl=Ge&&Ge.__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)&&tl(t,r,e);return el(t,r),t},fa=Ge&&Ge.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(be,"__esModule",{value:!0});var ha=be.deserializeUnchecked=wa=be.deserialize=ya=be.serialize=be.BinaryReader=be.BinaryWriter=be.BorshError=be.baseDecode=be.baseEncode=void 0;const bn=fa(ua),da=fa(la),rl=nl(Qu),il=typeof TextDecoder!="function"?rl.TextDecoder:TextDecoder,sl=new il("utf-8",{fatal:!0});function ol(r){return typeof r=="string"&&(r=Buffer.from(r,"utf8")),da.default.encode(Buffer.from(r))}be.baseEncode=ol;function al(r){return Buffer.from(da.default.decode(r))}be.baseDecode=al;const Pi=1024;class ke 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(".")}}be.BorshError=ke;class pa{constructor(){this.buf=Buffer.alloc(Pi),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Pi)]))}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 bn.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new bn.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new bn.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new bn.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(Pi)]),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)}}be.BinaryWriter=pa;function rn(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 ke("Reached the end of buffer when deserializing")}throw i}}}class Pe{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 bn.default(t,"le")}readU128(){const t=this.readBuffer(16);return new bn.default(t,"le")}readU256(){const t=this.readBuffer(32);return new bn.default(t,"le")}readU512(){const t=this.readBuffer(64);return new bn.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new ke(`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 sl.decode(e)}catch(n){throw new ke(`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}}nn([rn],Pe.prototype,"readU8",null);nn([rn],Pe.prototype,"readU16",null);nn([rn],Pe.prototype,"readU32",null);nn([rn],Pe.prototype,"readU64",null);nn([rn],Pe.prototype,"readU128",null);nn([rn],Pe.prototype,"readU256",null);nn([rn],Pe.prototype,"readU512",null);nn([rn],Pe.prototype,"readString",null);nn([rn],Pe.prototype,"readFixedArray",null);nn([rn],Pe.prototype,"readArray",null);be.BinaryReader=Pe;function ga(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Bn(r,t,e,n,s){try{if(typeof n=="string")s[`write${ga(n)}`](e);else if(n instanceof Array)if(typeof n[0]=="number"){if(e.length!==n[0])throw new ke(`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 ke(`Expecting byte array of length ${n[1]}, but got ${e.length} bytes`);for(let i=0;i<n[1];i++)Bn(r,null,e[i],n[0],s)}else s.writeArray(e,i=>{Bn(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),Bn(r,t,e,n.type,s));break}case"map":{s.writeU32(e.size),e.forEach((i,o)=>{Bn(r,t,o,n.key,s),Bn(r,t,i,n.value,s)});break}default:throw new ke(`FieldType ${n} unrecognized`)}else ma(r,e,s)}catch(i){throw i instanceof ke&&i.addToFieldPath(t),i}}function ma(r,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const n=r.get(t.constructor);if(!n)throw new ke(`Class ${t.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([s,i])=>{Bn(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,u]=n.values[i];if(o===s){e.writeU8(i),Bn(r,o,t[o],u,e);break}}}else throw new ke(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function cl(r,t,e=pa){const n=new e;return ma(r,t,n),n.toArray()}var ya=be.serialize=cl;function An(r,t,e,n){try{if(typeof e=="string")return n[`read${ga(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(An(r,null,e[0],n));return s}else return n.readArray(()=>An(r,t,e[0],n))}if(e.kind==="option")return n.readU8()?An(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 u=An(r,t,e.key,n),c=An(r,t,e.value,n);s.set(u,c)}return s}return Bs(r,e,n)}catch(s){throw s instanceof ke&&s.addToFieldPath(t),s}}function Bs(r,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const n=r.get(t);if(!n)throw new ke(`Class ${t.name} is missing in schema`);if(n.kind==="struct"){const s={};for(const[i,o]of r.get(t).fields)s[i]=An(r,i,o,e);return new t(s)}if(n.kind==="enum"){const s=e.readU8();if(s>=n.values.length)throw new ke(`Enum index: ${s} is out of range`);const[i,o]=n.values[s],u=An(r,i,o,e);return new t({[i]:u})}throw new ke(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function ul(r,t,e,n=Pe){const s=new n(e),i=Bs(r,t,s);if(s.offset<e.length)throw new ke(`Unexpected ${e.length-s.offset} bytes after deserialized data`);return i}var wa=be.deserialize=ul;function ll(r,t,e,n=Pe){const s=new n(e);return Bs(r,t,s)}ha=be.deserializeUnchecked=ll;var F={};Object.defineProperty(F,"__esModule",{value:!0});F.s16=F.s8=F.nu64be=F.u48be=F.u40be=F.u32be=F.u24be=F.u16be=me=F.nu64=F.u48=F.u40=ct=F.u32=F.u24=qe=F.u16=St=F.u8=Rn=F.offset=F.greedy=F.Constant=F.UTF8=F.CString=F.Blob=F.Boolean=F.BitField=F.BitStructure=F.VariantLayout=F.Union=F.UnionLayoutDiscriminator=F.UnionDiscriminator=F.Structure=F.Sequence=F.DoubleBE=F.Double=F.FloatBE=F.Float=F.NearInt64BE=F.NearInt64=F.NearUInt64BE=F.NearUInt64=F.IntBE=F.Int=F.UIntBE=F.UInt=F.OffsetLayout=F.GreedyCount=F.Exter
6nalLayout=F.bindConstructorLayout=F.nameWithProperty=F.Layout=F.uint8ArrayToBuffer=F.checkUint8Array=void 0;F.constant=F.utf8=F.cstr=zt=F.blob=F.unionLayoutDiscriminator=F.union=Ie=F.seq=F.bits=rt=F.struct=F.f64be=F.f64=F.f32be=F.f32=F.ns64be=F.s48be=F.s40be=F.s32be=F.s24be=F.s16be=Ue=F.ns64=F.s48=F.s40=F.s32=F.s24=void 0;const As=bt;function ar(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}F.checkUint8Array=ar;function It(r){return ar(r),As.Buffer.from(r.buffer,r.byteOffset,r.length)}F.uint8ArrayToBuffer=It;class Ct{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){}}F.Layout=Ct;function _s(r,t){return t.property?r+"["+t.property+"]":r}F.nameWithProperty=_s;function fl(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 Ct))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})}F.bindConstructorLayout=fl;class Ce extends Ct{isCount(){throw new Error("ExternalLayout is abstract")}}F.ExternalLayout=Ce;class ba extends Ce{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){ar(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}F.GreedyCount=ba;class ks extends Ce{constructor(t,e=0,n){if(!(t instanceof Ct))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 He||this.layout instanceof Ve}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)}}F.OffsetLayout=ks;class He extends Ct{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return It(t).readUIntLE(e,this.span)}encode(t,e,n=0){return It(e).writeUIntLE(t,n,this.span),this.span}}F.UInt=He;class Ve extends Ct{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return It(t).readUIntBE(e,this.span)}encode(t,e,n=0){return It(e).writeUIntBE(t,n,this.span),this.span}}F.UIntBE=Ve;class Un extends Ct{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return It(t).readIntLE(e,this.span)}encode(t,e,n=0){return It(e).writeIntLE(t,n,this.span),this.span}}F.Int=Un;class cr extends Ct{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return It(t).readIntBE(e,this.span)}encode(t,e,n=0){return It(e).writeIntBE(t,n,this.span),this.span}}F.IntBE=cr;const ns=Math.pow(2,32);function ei(r){const t=Math.floor(r/ns),e=r-t*ns;return{hi32:t,lo32:e}}function ni(r,t){return r*ns+t}class va extends Ct{constructor(t){super(8,t)}decode(t,e=0){const n=It(t),s=n.readUInt32LE(e),i=n.readUInt32LE(e+4);return ni(i,s)}encode(t,e,n=0){const s=ei(t),i=It(e);return i.writeUInt32LE(s.lo32,n),i.writeUInt32LE(s.hi32,n+4),8}}F.NearUInt64=va;class xa extends Ct{constructor(t){super(8,t)}decode(t,e=0){const n=It(t),s=n.readUInt32BE(e),i=n.readUInt32BE(e+4);return ni(s,i)}encode(t,e,n=0){const s=ei(t),i=It(e);return i.writeUInt32BE(s.hi32,n),i.writeUInt32BE(s.lo32,n+4),8}}F.NearUInt64BE=xa;class Ea extends Ct{constructor(t){super(8,t)}
6decode(t,e=0){const n=It(t),s=n.readUInt32LE(e),i=n.readInt32LE(e+4);return ni(i,s)}encode(t,e,n=0){const s=ei(t),i=It(e);return i.writeUInt32LE(s.lo32,n),i.writeInt32LE(s.hi32,n+4),8}}F.NearInt64=Ea;class Sa extends Ct{constructor(t){super(8,t)}decode(t,e=0){const n=It(t),s=n.readInt32BE(e),i=n.readUInt32BE(e+4);return ni(s,i)}encode(t,e,n=0){const s=ei(t),i=It(e);return i.writeInt32BE(s.hi32,n),i.writeUInt32BE(s.lo32,n+4),8}}F.NearInt64BE=Sa;class Ba extends Ct{constructor(t){super(4,t)}decode(t,e=0){return It(t).readFloatLE(e)}encode(t,e,n=0){return It(e).writeFloatLE(t,n),4}}F.Float=Ba;class Aa extends Ct{constructor(t){super(4,t)}decode(t,e=0){return It(t).readFloatBE(e)}encode(t,e,n=0){return It(e).writeFloatBE(t,n),4}}F.FloatBE=Aa;class _a extends Ct{constructor(t){super(8,t)}decode(t,e=0){return It(t).readDoubleLE(e)}encode(t,e,n=0){return It(e).writeDoubleLE(t,n),8}}F.Double=_a;class ka extends Ct{constructor(t){super(8,t)}decode(t,e=0){return It(t).readDoubleBE(e)}encode(t,e,n=0){return It(e).writeDoubleBE(t,n),8}}F.DoubleBE=ka;class Ia extends Ct{constructor(t,e,n){if(!(t instanceof Ct))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Ce&&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 Ce)&&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 Ce&&(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 Ce&&(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,u)=>o+s.encode(u,e,n+o),0);return this.count instanceof Ce&&this.count.encode(t.length,e,n),i}}F.Sequence=Ia;class Ma extends Ct{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((i,o)=>i&&o instanceof Ct,!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){ar(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 u of this.fields){let c=u.span;if(o=0<c?c:0,u.property!==void 0){const p=t[u.property];p!==void 0&&(o=u.encode(p,e,n),0>c&&(c=u.getSpan(e,n)))}i=n,n+=c}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)}}}F.Structure=Ma;class Is{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}F.UnionDiscriminator=Is;class Hr extends Is{constructor(t,e){if(!(t instanceof Ce&&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)}}F.UnionLayoutDiscriminator=Hr;class Ms extends Ct{constructor(t,e,n){let s;if(t instanceof He||t instanceof Ve)s=new Hr(new ks(t));else if(t instanceof Ce&&t.isCount())s=new Hr(t);else if(t instanceof Is)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 Ct))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 He||t instanceof Ve)&&(i+=s.layout.span)),super(i,n),this.discriminator=s,this.usesPrefixDiscriminator=t instanceof He||t instanceof Ve,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);
6this.getSourceVariant=function(u){return o(u)},this.configGetSourceVariant=function(u){o=u.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n;const s=this.discriminator,i=s.decode(t,e),o=this.registry[i];if(o===void 0){const u=this.defaultLayout;let c=0;this.usesPrefixDiscriminator&&(c=s.layout.span),n=this.makeDestinationObject(),n[s.property]=i,n[u.property]=u.decode(t,e+c)}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 u=0;return this.usesPrefixDiscriminator&&(u=i.layout.span),i.encode(t[i.property],e,n),u+o.encode(t[o.property],e,n+u)}return s.encode(t,e,n)}addVariant(t,e,n){const s=new Ra(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]}}F.Union=Ms;class Ra extends Ct{constructor(t,e,n,s){if(!(t instanceof Ms))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 Ct))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)}}F.VariantLayout=Ra;function Wn(r){return 0>r&&(r+=4294967296),r}class Rs extends Ct{constructor(t,e,n){if(!(t instanceof He||t instanceof Ve))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=Wn(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 Cs(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new Ca(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}}F.BitStructure=Rs;class Cs{constructor(t,e,n){if(!(t instanceof Rs))throw new TypeError("container must be a BitStructure");
6if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const s=8*t.span,i=t.fields.reduce((o,u)=>o+u.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=Wn(this.valueMask<<this.start),this.property=n}decode(t,e){const n=this.container._packedGetValue();return Wn(n&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==Wn(t&this.valueMask))throw new TypeError(_s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=Wn(t<<this.start);this.container._packedSetValue(Wn(e&~this.wordMask)|n)}}F.BitField=Cs;let Ca=class extends Cs{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)}};F.Boolean=Ca;class La extends Ct{constructor(t,e){if(!(t instanceof Ce&&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 Ce||(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)),It(t).slice(e,e+n)}encode(t,e,n){let s=this.length;if(this.length instanceof Ce&&(s=t.length),!(t instanceof Uint8Array&&s===t.length))throw new TypeError(_s("Blob.encode",this)+" requires (length "+s+") Uint8Array as src");if(n+s>e.length)throw new RangeError("encoding overruns Uint8Array");const i=It(t);return It(e).write(i.toString("hex"),n,s,"hex"),this.length instanceof Ce&&this.length.encode(s,e,n),s}}F.Blob=La;class Na extends Ct{constructor(t){super(-1,t)}getSpan(t,e=0){ar(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 It(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const s=As.Buffer.from(t,"utf8"),i=s.length;if(n+i>e.length)throw new RangeError("encoding overruns Buffer");const o=It(e);return s.copy(o,n),o[n+i]=0,i+1}}F.CString=Na;class Ta extends Ct{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 ar(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 It(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const s=As.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(It(e),n),i}}F.UTF8=Ta;class Ua extends Ct{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}F.Constant=Ua;F.greedy=(r,t)=>new ba(r,t);var Rn=F.offset=(r,t,e)=>new ks(r,t,e),St=F.u8=r=>new He(1,r),qe=F.u16=r=>new He(2,r);F.u24=r=>new He(3,r);var ct=F.u32=r=>new He(4,r);F.u40=r=>new He(5,r);F.u48=r=>new He(6,r);var me=F.nu64=r=>new va(r);F.u16be=r=>new Ve(2,r);F.u24be=r=>new Ve(3,r);F.u32be=r=>new Ve(4,r);F.u40be=r=>new Ve(5,r);F.u48be=r=>new Ve(6,r);F.nu64be=r=>new xa(r);F.s8=r=>new Un(1,r);F.s16=r=>new Un(2,r);F.s24=r=>new Un(3,r);F.s32=r=>new Un(4,r);F.s40=r=>new Un(5,r);F.s48=r=>new Un(6,r);var Ue=F.ns64=r=>new Ea(r);F.s16be=r=>new cr(2,r);F.s24be=r=>new cr(3,r);F.s32be=r=>new cr(4,r);F.s40be=r=>new cr(5,r);F.s48be=r=>new cr(6,r);F.ns64be=r=>new Sa(r);F.f32=r=>new Ba(r);F.f32be=r=>new Aa(r);F.f64=r=>new _a(r);F.f64be=r=>new ka(r);var rt=F.struct=(r,t,e)=>new Ma(r,t,e);F.bits=(r,t,e)=>new Rs(r,t,e);var Ie=F.seq=(r,t,e)=>new Ia(r,t,e);F.union=(r,t,e)=>new Ms(r,t,e);F.unionLayoutDiscriminator=(r,t)=>new Hr(r,t);var zt=F.blob=(r,t)=>new La(r,t);F.cstr=r=>new Na(r);F.utf8=(r,t)=>new Ta(r,t);F.constant=(r,t)=>new Ua(r,t);var hl=8078e3,dl=8078001,pl=8078004,gl=8078005,ml=8078006,yl=8078011;function Pa(r){return Array.isArray(r)?"%5B"+r.map(Pa).join("%2C%20")+"%5D":typeof r=="bigint"?`${r}n`:encodeURIComponent(String(r!=null&&Object.getPrototypeOf(r)===null?{...r}:r))}function wl([r,t]){return`${r}=${Pa(t)}`}function bl(r){const t=Object.entries(r).map(wl).join("&");return btoa(t)}function vl(r,t={}){{let e=`Solana error #${r}; Decode this error by running \`npx @solana/errors decode -- ${r}`;return Object.keys(t).length&&(e+=` '${bl(t)}'`),`${e}\``}}
6var Xn=class extends Error{constructor(...[t,e]){let n,s;if(e){const{cause:o,...u}=e;o&&(s={cause:o}),Object.keys(u).length>0&&(n=u)}const i=vl(t,n);super(i,s);le(this,"cause",this.cause);le(this,"context");this.context={__code:t,...n},this.name="SolanaError"}};function xl(r,t){return"fixedSize"in t?t.fixedSize:t.getSizeFromValue(r)}function El(r){return Object.freeze({...r,encode:t=>{const e=new Uint8Array(xl(t,r));return r.write(t,e,0),e}})}function Sl(r){return Object.freeze({...r,decode:(t,e=0)=>r.read(t,e)[0]})}function jn(r){return"fixedSize"in r&&typeof r.fixedSize=="number"}function Bl(r,t){if(jn(r)!==jn(t))throw new Xn(pl);if(jn(r)&&jn(t)&&r.fixedSize!==t.fixedSize)throw new Xn(gl,{decoderFixedSize:t.fixedSize,encoderFixedSize:r.fixedSize});if(!jn(r)&&!jn(t)&&r.maxSize!==t.maxSize)throw new Xn(ml,{decoderMaxSize:t.maxSize,encoderMaxSize:r.maxSize});return{...t,...r,decode:t.decode,encode:r.encode,read:t.read,write:r.write}}function Al(r,t,e=0){if(t.length-e<=0)throw new Xn(hl,{codecDescription:r})}function _l(r,t,e,n=0){const s=e.length-n;if(s<t)throw new Xn(dl,{bytesLength:s,codecDescription:r,expected:t})}function kl(r,t,e,n){if(n<t||n>e)throw new Xn(yl,{codecDescription:r,max:e,min:t,value:n})}function Fa(r){return(r==null?void 0:r.endian)!==1}function Il(r){return El({fixedSize:r.size,write(t,e,n){r.range&&kl(r.name,r.range[0],r.range[1],t);const s=new ArrayBuffer(r.size);return r.set(new DataView(s),t,Fa(r.config)),e.set(new Uint8Array(s),n),n+r.size}})}function Ml(r){return Sl({fixedSize:r.size,read(t,e=0){Al(r.name,t,e),_l(r.name,r.size,t,e);const n=new DataView(Rl(t,e,r.size));return[r.get(n,Fa(r.config)),e+r.size]}})}function Rl(r,t,e){const n=r.byteOffset+(t??0),s=e??r.byteLength;return r.buffer.slice(n,n+s)}var Cl=(r={})=>Il({config:r,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,e,n)=>t.setBigUint64(0,BigInt(e),n),size:8}),Ll=(r={})=>Ml({config:r,get:(t,e)=>t.getBigUint64(0,e),name:"u64",size:8}),Nl=(r={})=>Bl(Cl(r),Ll(r));class Tl extends TypeError{constructor(t,e){let n;const{message:s,explanation:i,...o}=t,{path:u}=t,c=u.length===0?s:`At path: ${u.join(".")} -- ${s}`;super(i??c),i!=null&&(this.cause=c),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function Ul(r){return Er(r)&&typeof r[Symbol.iterator]=="function"}function Er(r){return typeof r=="object"&&r!=null}function Wr(r){return Er(r)&&!Array.isArray(r)}function Ze(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function Pl(r){const{done:t,value:e}=r.next();return t?void 0:e}function Fl(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:u,message:c=`Expected a value of type \`${o}\`${u?` with refinement \`${u}\``:""}, but received: \`${Ze(n)}\``}=r;return{value:n,type:o,refinement:u,key:s[s.length-1],path:s,branch:i,...r,message:c}}function*uo(r,t,e,n){Ul(r)||(r=[r]);for(const s of r){const i=Fl(s,t,e,n);i&&(yield i)}}function*Ls(r,t,e={}){const{path:n=[],branch:s=[r],coerce:i=!1,mask:o=!1}=e,u={path:n,branch:s,mask:o};i&&(r=t.coercer(r,u));let c="valid";for(const p of t.validator(r,u))p.explanation=e.message,c="not_valid",yield[p,void 0];for(let[p,g,v]of t.entries(r,u)){const S=Ls(g,v,{path:p===void 0?n:[...n,p],branch:p===void 0?s:[...s,g],coerce:i,mask:o,message:e.message});for(const A of S)A[0]?(c=A[0].refinement!=null?"not_refined":"not_valid",yield[A[0],void 0]):i&&(g=A[1],p===void 0?r=g:r instanceof Map?r.set(p,g):r instanceof Set?r.add(g):Er(r)&&(g!==void 0||p in r)&&(r[p]=g))}
6if(c!=="not_valid")for(const p of t.refiner(r,u))p.explanation=e.message,c="not_refined",yield[p,void 0];c==="valid"&&(yield[void 0,r])}let sn=class{constructor(t){const{type:e,schema:n,validator:s,refiner:i,coercer:o=c=>c,entries:u=function*(){}}=t;this.type=e,this.schema=n,this.entries=u,this.coercer=o,s?this.validator=(c,p)=>{const g=s(c,p);return uo(g,p,this,c)}:this.validator=()=>[],i?this.refiner=(c,p)=>{const g=i(c,p);return uo(g,p,this,c)}:this.refiner=()=>[]}assert(t,e){return Ol(t,this,e)}create(t,e){return Z(t,this,e)}is(t){return Oa(t,this)}mask(t,e){return Dl(t,this,e)}validate(t,e={}){return Sr(t,this,e)}};function Ol(r,t,e){const n=Sr(r,t,{message:e});if(n[0])throw n[0]}function Z(r,t,e){const n=Sr(r,t,{coerce:!0,message:e});if(n[0])throw n[0];return n[1]}function Dl(r,t,e){const n=Sr(r,t,{coerce:!0,mask:!0,message:e});if(n[0])throw n[0];return n[1]}function Oa(r,t){return!Sr(r,t)[0]}function Sr(r,t,e={}){const n=Ls(r,t,e),s=Pl(n);return s[0]?[new Tl(s[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function Pn(r,t){return new sn({type:r,schema:null,validator:t})}function zl(){return Pn("any",()=>!0)}function X(r){return new sn({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: ${Ze(t)}`}})}function en(){return Pn("boolean",r=>typeof r=="boolean")}function Ns(r){return Pn("instance",t=>t instanceof r||`Expected a \`${r.name}\` instance, but received: ${Ze(t)}`)}function qt(r){const t=Ze(r),e=typeof r;return new sn({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${t}\`, but received: ${Ze(n)}`}})}function ql(){return Pn("never",()=>!1)}function J(r){return new sn({...r,validator:(t,e)=>t===null||r.validator(t,e),refiner:(t,e)=>t===null||r.refiner(t,e)})}function P(){return Pn("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${Ze(r)}`)}function ut(r){return new sn({...r,validator:(t,e)=>t===void 0||r.validator(t,e),refiner:(t,e)=>t===void 0||r.refiner(t,e)})}function Da(r,t){return new sn({type:"record",schema:null,*entries(e){if(Er(e))for(const n in e){const s=e[n];yield[n,n,r],yield[n,s,t]}},validator(e){return Wr(e)||`Expected an object, but received: ${Ze(e)}`},coercer(e){return Wr(e)?{...e}:e}})}function H(){return Pn("string",r=>typeof r=="string"||`Expected a string, but received: ${Ze(r)}`)}function Ts(r){const t=ql();return new sn({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: ${Ze(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function q(r){const t=Object.keys(r);return new sn({type:"type",schema:r,*entries(e){if(Er(e))for(const n of t)yield[n,e[n],r[n]]},validator(e){return Wr(e)||`Expected an object, but received: ${Ze(e)}`},coercer(e){return Wr(e)?{...e}:e}})}function Me(r){const t=r.map(e=>e.type).join(" | ");return new sn({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]=Ls(e,i,n),[u]=o;if(u[0])for(const[c]of o)c&&s.push(c);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Ze(e)}`,...s]}})}function ur(){return Pn("unknown",()=>!0)}function Br(r,t,e){return new sn({...r,coercer:(n,s)=>Oa(n,t)?r.coercer(e(n,s),s):r.coercer(n,s)})}var Lr,Kl=new Uint8Array(16);function za(){if(!Lr&&(Lr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Lr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Lr(Kl)}const $l=/^(?:[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 ri(r){return typeof r=="string"&&$l.test(r)}var ge=[];for(var Fi=0;Fi<256;++Fi)ge.push((Fi+256).toString(16).substr(1));function ii(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(ge[r[t+0]]+ge[r[t+1]]+ge[r[t+2]]+ge[r[t+3]]+"-"+ge[r[t+4]]+ge[r[t+5]]+"-"+ge[r[t+6]]+ge[r[t+7]]+"-"+ge[r[t+8]]+ge[r[t+9]]+"-"+ge[r[t+10]]+ge[r[t+11]]+ge[r[t+12]]+ge[r[t+13]]+ge[r[t+14]]+ge[r[t+15]]).toLowerCase();
vendor: 6,004 bytes, line 6
6if(!ri(e))throw TypeError("Stringified UUID is invalid");return e}var lo,Oi,Di=0,zi=0;function jl(r,t,e){var n=t&&e||0,s=t||new Array(16);r=r||{};var i=r.node||lo,o=r.clockseq!==void 0?r.clockseq:Oi;if(i==null||o==null){var u=r.random||(r.rng||za)();i==null&&(i=lo=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),o==null&&(o=Oi=(u[6]<<8|u[7])&16383)}var c=r.msecs!==void 0?r.msecs:Date.now(),p=r.nsecs!==void 0?r.nsecs:zi+1,g=c-Di+(p-zi)/1e4;if(g<0&&r.clockseq===void 0&&(o=o+1&16383),(g<0||c>Di)&&r.nsecs===void 0&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Di=c,zi=p,Oi=o,c+=122192928e5;var v=((c&268435455)*1e4+p)%4294967296;s[n++]=v>>>24&255,s[n++]=v>>>16&255,s[n++]=v>>>8&255,s[n++]=v&255;var S=c/4294967296*1e4&268435455;s[n++]=S>>>8&255,s[n++]=S&255,s[n++]=S>>>24&15|16,s[n++]=S>>>16&255,s[n++]=o>>>8|128,s[n++]=o&255;for(var A=0;A<6;++A)s[n+A]=i[A];return t||ii(s)}function qa(r){if(!ri(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 Hl(r){r=unescape(encodeURIComponent(r));for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e));return t}var Wl="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Vl="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Ka(r,t,e){function n(s,i,o,u){if(typeof s=="string"&&(s=Hl(s)),typeof i=="string"&&(i=qa(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var c=new Uint8Array(16+s.length);if(c.set(i),c.set(s,i.length),c=e(c),c[6]=c[6]&15|t,c[8]=c[8]&63|128,o){u=u||0;for(var p=0;p<16;++p)o[u+p]=c[p];return o}return ii(c)}try{n.name=r}catch{}return n.DNS=Wl,n.URL=Vl,n}function Gl(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 Zl(Yl(Xl(r),r.length*8))}function Zl(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 $a(r){return(r+64>>>9<<4)+14+1}function Yl(r,t){r[t>>5]|=128<<t%32,r[$a(t)-1]=t;for(var e=1732584193,n=-271733879,s=-1732584194,i=271733878,o=0;o<r.length;o+=16){var u=e,c=n,p=s,g=i;e=Se(e,n,s,i,r[o],7,-680876936),i=Se(i,e,n,s,r[o+1],12,-389564586),s=Se(s,i,e,n,r[o+2],17,606105819),n=Se(n,s,i,e,r[o+3],22,-1044525330),e=Se(e,n,s,i,r[o+4],7,-176418897),i=Se(i,e,n,s,r[o+5],12,1200080426),s=Se(s,i,e,n,r[o+6],17,-1473231341),n=Se(n,s,i,e,r[o+7],22,-45705983),e=Se(e,n,s,i,r[o+8],7,1770035416),i=Se(i,e,n,s,r[o+9],12,-1958414417),s=Se(s,i,e,n,r[o+10],17,-42063),n=Se(n,s,i,e,r[o+11],22,-1990404162),e=Se(e,n,s,i,r[o+12],7,1804603682),i=Se(i,e,n,s,r[o+13],12,-40341101),s=Se(s,i,e,n,r[o+14],17,-1502002290),n=Se(n,s,i,e,r[o+15],22,1236535329),e=Be(e,n,s,i,r[o+1],5,-165796510),i=Be(i,e,n,s,r[o+6],9,-1069501632),s=Be(s,i,e,n,r[o+11],14,643717713),n=Be(n,s,i,e,r[o],20,-373897302),e=Be(e,n,s,i,r[o+5],5,-701558691),i=Be(i,e,n,s,r[o+10],9,38016083),s=Be(s,i,e,n,r[o+15],14,-660478335),n=Be(n,s,i,e,r[o+4],20,-405537848),e=Be(e,n,s,i,r[o+9],5,568446438),i=Be(i,e,n,s,r[o+14],9,-1019803690),s=Be(s,i,e,n,r[o+3],14,-187363961),n=Be(n,s,i,e,r[o+8],20,1163531501),e=Be(e,n,s,i,r[o+13],5,-1444681467),i=Be(i,e,n,s,r[o+2],9,-51403784),s=Be(s,i,e,n,r[o+7],14,1735328473),n=Be(n,s,i,e,r[o+12],20,-1926607734),e=Ae(e,n,s,i,r[o+5],4,-378558),i=Ae(i,e,n,s,r[o+8],11,-2022574463),s=Ae(s,i,e,n,r[o+11],16,1839030562),n=Ae(n,s,i,e,r[o+14],23,-35309556),e=Ae(e,n,s,i,r[o+1],4,-1530992060),i=Ae(i,e,n,s,r[o+4],11,1272893353),s=Ae(s,i,e,n,r[o+7],16,-155497632),n=Ae(n,s,i,e,r[o+10],23,-1094730640),e=Ae(e,n,s,i,r[o+13],4,681279174),i=Ae(i,e,n,s,r[o],11,-358537222),s=Ae(s,i,e,n,r[o+3],16,-722521979),n=Ae(n,s,i,e,r[o+6],23,76029189),e=Ae(e,n,s,i,r[o+9],4,-640364487),i=Ae(i,e,n,s,r[o+12],11,-421815835),s=Ae(s,i,e,n,r[o+15],16,530742520),n=Ae(n,s,i,e,r[o+2],23,-995338651),e=_e(e,n,s,i,r[o],6,-198630844),i=_e(i,e,n,s,r[o+7],10,1126891415),s=_e(s,i,e,n,r[o+14],15,-1416354905),n=_e(n,s,i,e,r[o+5],21,-57434055),e=_e(e,n,s,i,r[o+12],6,1700485571),i=_e(i,e,n,s,r[o+3],10,-1894986606),s=_e(s,i,e,n,r[o+10],15,-1051523),n=_e(n,s,i,e,r[o+1],21,-2054922799),e=_e(e,n,s,i,r[o+8],6,1873313359),i=_e(i,e,n,s,r[o+15],10,-30611744),s=_e(s,i,e,n,r[o+6],15,-1560198380),n=_e(n,s,i,e,r[o+13],21,1309151649),e=_e(e,n,s,i,r[o+4],6,-145523070),i=_e(i,e,n,s,r[o+11],10,-1120210379),s=_e(s,i,e,n,r[o+2],15,718787259),n=_e(n,s,i,e,r[o+9],21,-343485551),e=vn(e,u),n=vn(n,c),s=vn(s,p),i=vn(i,g)}return[e,n,s,i]}function Xl(r){if(r.length===0)return[];for(var t=r.length*8,e=new Uint32Array($a(t)),n=0;n<t;n+=8)e[n>>5]|=(r[n/8]&255)<<n%32;return e}function vn(r,t){var e=(r&65535)+(t&65535),n=(r>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function Jl(r,t){return r<<t|r>>>32-t}function si(r,t,e,n,s,i){return vn(Jl(vn(vn(t,r),vn(n,i)),s),e)}function Se(r,t,e,n,s,i,o){return si(t&e|~t&n,r,t,s,i,o)}function Be(r,t,e,n,s,i,o){return si(t&n|e&~n,r,t,s,i,o)}function Ae(r,t,e,n,s,i,o){return si(t^e^n,r,t,s,i,o)}function _e(r,t,e,n,s,i,o){return si(e^(t|~n),r,t,s,i,o)}var Ql=Ka("v3",48,Gl);function tf(r,t,e){r=r||{};var n=r.random||(r.rng||za)();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 ii(n)}function ef(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 qi(r,t){return r<<t|r>>>32-t}function nf(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));
6r.push(128);for(var i=r.length/4+2,o=Math.ceil(i/16),u=new Array(o),c=0;c<o;++c){for(var p=new Uint32Array(16),g=0;g<16;++g)p[g]=r[c*64+g*4]<<24|r[c*64+g*4+1]<<16|r[c*64+g*4+2]<<8|r[c*64+g*4+3];u[c]=p}u[o-1][14]=(r.length-1)*8/Math.pow(2,32),u[o-1][14]=Math.floor(u[o-1][14]),u[o-1][15]=(r.length-1)*8&4294967295;for(var v=0;v<o;++v){for(var S=new Uint32Array(80),A=0;A<16;++A)S[A]=u[v][A];for(var _=16;_<80;++_)S[_]=qi(S[_-3]^S[_-8]^S[_-14]^S[_-16],1);for(var C=e[0],M=e[1],U=e[2],D=e[3],N=e[4],K=0;K<80;++K){var V=Math.floor(K/20),nt=qi(C,5)+ef(V,M,U,D)+N+t[V]+S[K]>>>0;N=D,D=U,U=qi(M,30)>>>0,M=C,C=nt}e[0]=e[0]+C>>>0,e[1]=e[1]+M>>>0,e[2]=e[2]+U>>>0,e[3]=e[3]+D>>>0,e[4]=e[4]+N>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var rf=Ka("v5",80,nf);const sf="00000000-0000-0000-0000-000000000000";function of(r){if(!ri(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}const af=Object.freeze(Object.defineProperty({__proto__:null,NIL:sf,parse:qa,stringify:ii,v1:jl,v3:Ql,v4:tf,v5:rf,validate:ri,version:of},Symbol.toStringTag,{value:"Module"})),ja=ps(af),cf=ja.v4,uf=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 cf()};i.id=o(i,n)}else s===2&&e===null?n.notificationIdNull&&(i.id=null):i.id=e;return i};var lf=uf;const ff=ja.v4,hf=lf,mr=function(r,t){if(!(this instanceof mr))return new mr(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 ff()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=r};var df=mr;mr.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 p=typeof n=="function";try{i=hf(r,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(g){if(p){n(g);return}throw g}if(!p)return i}let c;try{c=JSON.stringify(i,this.options.replacer)}catch(p){n(p);return}return this.callServer(c,function(p,g){s._parseResponse(p,g,n)}),i};mr.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 pf=Xr(df);var Ha={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(c,p,g){this.fn=c,this.context=p,this.once=g||!1}function i(c,p,g,v,S){if(typeof g!="function")throw new TypeError("The listener must be a function");var A=new s(g,v||c,S),_=e?e+p:p;return c._events[_]?c._events[_].fn?c._events[_]=[c._events[_],A]:c._events[_].push(A):(c._events[_]=A,c._eventsCount++),c}function o(c,p){--c._eventsCount===0?c._events=new n:delete c._events[p]}function u(){this._events=new n,this._eventsCount=0}u.prototype.eventNames=function(){var p=[],g,v;if(this._eventsCount===0)return p;for(v in g=this._events)t.call(g,v)&&p.push(e?v.slice(1):v);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(g)):p},u.prototype.listeners=function(p){var g=e?e+p:p,v=this._events[g];if(!v)return[];if(v.fn)return[v.fn];for(var S=0,A=v.length,_=new Array(A);S<A;S++)_[S]=v[S].fn;return _},u.prototype.listenerCount=function(p){var g=e?e+p:p,v=this._events[g];return v?v.fn?1:v.length:0},u.prototype.emit=function(p,g,v,S,A,_){var C=e?e+p:p;if(!this._events[C])return!1;var M=this._events[C],U=arguments.length,D,N;if(M.fn){switch(M.once&&this.removeListener(p,M.fn,void 0,!0),U){case 1:return M.fn.call(M.context),!0;case 2:return M.fn.call(M.context,g),!0;case 3:return M.fn.call(M.context,g,v),!0;case 4:return M.fn.call(M.context,g,v,S),!0;case 5:return M.fn.call(M.context,g,v,S,A),!0;case 6:return M.fn.call(M.context,g,v,S,A,_),!0}for(N=1,D=new Array(U-1);N<U;N++)D[N-1]=arguments[N];M.fn.apply(M.context,D)}else{var K=M.length,V;for(N=0;N<K;N++)switch(M[N].once&&this.removeListener(p,M[N].fn,void 0,!0),U){case 1:M[N].fn.call(M[N].context);break;case 2:M[N].fn.call(M[N].context,g);break;case 3:M[N].fn.call(M[N].context,g,v);break;case 4:M[N].fn.call(M[N].context,g,v,S);break;default:if(!D)for(V=1,D=new Array(U-1);V<U;V++)D[V-1]=arguments[V];M[N].fn.apply(M[N].context,D)}}return!0},u.prototype.on=function(p,g,v){return i(this,p,g,v,!1)},u.prototype.once=function(p,g,v){return i(this,p,g,v,!0)},u.prototype.removeListener=function(p,g,v,S){var A=e?e+p:p;if(!this._events[A])return this;if(!g)return o(this,A),this;var _=this._events[A];if(_.fn)_.fn===g&&(!S||_.once)&&(!v||_.context===v)&&o(this,A);else{for(var C=0,M=[],U=_.length;C<U;
6C++)(_[C].fn!==g||S&&!_[C].once||v&&_[C].context!==v)&&M.push(_[C]);M.length?this._events[A]=M.length===1?M[0]:M:o(this,A)}return this},u.prototype.removeAllListeners=function(p){var g;return p?(g=e?e+p:p,this._events[g]&&o(this,g)):(this._events=new n,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,r.exports=u})(Ha);var gf=Ha.exports;const Wa=Xr(gf);var mf=class extends Wa{constructor(t,e){super();le(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 yf(r,t){return new mf(r,t)}var wf=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},bf=class extends Wa{constructor(t,e="ws://localhost:8080",{autoconnect:n=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...u}={},c,p){super();le(this,"address");le(this,"rpc_id");le(this,"queue");le(this,"options");le(this,"autoconnect");le(this,"ready");le(this,"reconnect");le(this,"reconnect_timer_id");le(this,"reconnect_interval");le(this,"max_reconnects");le(this,"rest_options");le(this,"current_reconnects");le(this,"generate_request_id");le(this,"socket");le(this,"webSocketFactory");le(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=u,this.current_reconnects=0,this.generate_request_id=c||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),p?this.dataPack=p:this.dataPack=new wf,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)=>
6{if(!this.ready)return o(new Error("socket not ready"));const u=this.generate_request_id(t,e),c={jsonrpc:"2.0",method:t,params:e||void 0,id:u};this.socket.send(this.dataPack.encode(c),s,p=>{if(p)return o(p);this.queue[u]={promise:[i,o]},n&&(this.queue[u].timeout=setTimeout(()=>{delete this.queue[u],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=bt.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=>
6this.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 Va extends Oo{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Po(t);const n=ms(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),nr(i)}update(t){return Fr(this),this.iHash.update(t),this}digestInto(t){Fr(this),Nn(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:u}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=o,t.outputLen=u,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 Ga=(r,t,e)=>new Va(r,t).update(e).digest();Ga.create=(r,t)=>new Va(r,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fo=(r,t)=>(r+(r>=0?t:-t)/Za)/t;function vf(r,t,e){const[[n,s],[i,o]]=t,u=fo(o*r,e),c=fo(-s*r,e);let p=r-u*n-c*i,g=-u*s-c*o;const v=p<fn,S=g<fn;v&&(p=-p),S&&(g=-g);const A=vr(Math.ceil(Ho(e)/2))+Jn;if(p<fn||p>=A||g<fn||g>=A)throw new Error("splitScalar (endomorphism): failed, k="+r);return{k1neg:v,k1:p,k2neg:S,k2:g}}function rs(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function Ki(r,t){const e={};for(let n of Object.keys(t))e[n]=r[n]===void 0?t[n]:r[n];return Cn(e.lowS,"lowS"),Cn(e.prehash,"prehash"),e.format!==void 0&&rs(e.format),e}class xf extends Error{constructor(t=""){super(t)}}const cn={Err:xf,_tlv:{encode:(r,t)=>{const{Err:e}=cn;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=Rr(n);if(s.length/2&128)throw new e("tlv.encode: long form length too big");const i=n>127?Rr(s.length/2|128):"";return Rr(r)+i+s+t},decode(r,t){const{Err:e}=cn;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 c=s&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");const p=t.subarray(n,n+c);if(p.length!==c)throw new e("tlv.decode: length bytes not complete");if(p[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(const g of p)o=o<<8|g;if(n+=c,o<128)throw new e("tlv.decode(long): not minimal encoding")}const u=t.subarray(n,n+o);if(u.length!==o)throw new e("tlv.decode: wrong value length");return{v:u,l:t.subarray(n+o)}}},_int:{encode(r){const{Err:t}=cn;if(r<fn)throw new t("integer: negative integers are not allowed");let e=Rr(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}=cn;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 Qr(r)}},toSig(r){const{Err:t,_int:e,_tlv:n}=cn,s=Ht("signature",r),{v:i,l:o}=n.decode(48,s);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:u,l:c}=n.decode(2,i),{v:p,l:g}=n.decode(2,c);if(g.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(u),s:e.decode(p)}},hexFromSig(r){const{_tlv:t,_int:e}=cn,n=t.encode(2,e.encode(r.r)),s=t.encode(2,e.encode(r.s)),i=n+s;return t.encode(48,i)}},fn=BigInt(0),Jn=BigInt(1),Za=BigInt(2),Nr=BigInt(3),Ef=BigInt(4);function Gn(r,t){const{BYTES:e}=r;let n;if(typeof t=="bigint")n=t;else{let s=Ht("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 Sf(r,t={}
6){const e=aa("weierstrass",r,t),{Fp:n,Fn:s}=e;let i=e.CURVE;const{h:o,n:u}=i;xr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const p=Xa(n,s);function g(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function v(Q,w,a){const{x:f,y:m}=w.toAffine(),x=n.toBytes(f);if(Cn(a,"isCompressed"),a){g();const E=!n.isOdd(m);return Qe(Ya(E),x)}else return Qe(Uint8Array.of(4),x,n.toBytes(m))}function S(Q){We(Q,void 0,"Point");const{publicKey:w,publicKeyUncompressed:a}=p,f=Q.length,m=Q[0],x=Q.subarray(1);if(f===w&&(m===2||m===3)){const E=n.fromBytes(x);if(!n.isValid(E))throw new Error("bad point: is not on curve, wrong x");const I=C(E);let R;try{R=n.sqrt(I)}catch(k){const G=k instanceof Error?": "+k.message:"";throw new Error("bad point: is not on curve, sqrt error"+G)}g();const b=n.isOdd(R);return(m&1)===1!==b&&(R=n.neg(R)),{x:E,y:R}}else if(f===a&&m===4){const E=n.BYTES,I=n.fromBytes(x.subarray(0,E)),R=n.fromBytes(x.subarray(E,E*2));if(!M(I,R))throw new Error("bad point: is not on curve");return{x:I,y:R}}else throw new Error(`bad point: got length ${f}, expected compressed=${w} or uncompressed=${a}`)}const A=t.toBytes||v,_=t.fromBytes||S;function C(Q){const w=n.sqr(Q),a=n.mul(w,Q);return n.add(n.add(a,n.mul(Q,i.a)),i.b)}function M(Q,w){const a=n.sqr(w),f=C(Q);return n.eql(a,f)}if(!M(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const U=n.mul(n.pow(i.a,Nr),Ef),D=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(U,D)))throw new Error("bad curve params: a or b");function N(Q,w,a=!1){if(!n.isValid(w)||a&&n.is0(w))throw new Error(`bad point coordinate ${Q}`);return w}function K(Q){if(!(Q instanceof z))throw new Error("ProjectivePoint expected")}function V(Q){if(!c||!c.basises)throw new Error("no endo");return vf(Q,c.basises,s.ORDER)}const nt=Dr((Q,w)=>{const{X:a,Y:f,Z:m}=Q;if(n.eql(m,n.ONE))return{x:a,y:f};const x=Q.is0();w==null&&(w=x?n.ONE:n.inv(m));const E=n.mul(a,w),I=n.mul(f,w),R=n.mul(m,w);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(R,n.ONE))throw new Error("invZ was invalid");return{x:E,y:I}}),lt=Dr(Q=>{if(Q.is0()){if(t.allowInfinityPoint&&!n.is0(Q.Y))return;throw new Error("bad point: ZERO")}const{x:w,y:a}=Q.toAffine();if(!n.isValid(w)||!n.isValid(a))throw new Error("bad point: x or y not field elements");if(!M(w,a))throw new Error("bad point: equation left != right");if(!Q.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function st(Q,w,a,f,m){return a=new z(n.mul(a.X,Q),a.Y,a.Z),w=zr(f,w),a=zr(m,a),w.add(a)}class z{constructor(w,a,f){this.X=N("x",w),this.Y=N("y",a,!0),this.Z=N("z",f),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){const{x:a,y:f}=w||{};if(!w||!n.isValid(a)||!n.isValid(f))throw new Error("invalid affine point");if(w instanceof z)throw new Error("projective point not allowed");return n.is0(a)&&n.is0(f)?z.ZERO:new z(a,f,n.ONE)}static fromBytes(w){const a=z.fromAffine(_(We(w,void 0,"point")));return a.assertValidity(),a}static fromHex(w){return z.fromBytes(Ht("pointHex",w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,a=!0){return W.createCache(this,w),a||this.multiply(Nr),this}assertValidity(){lt(this)}hasEvenY(){const{y:w}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(w)}equals(w){K(w);const{X:a,Y:f,Z:m}=this,{X:x,Y:E,Z:I}=w,R=n.eql(n.mul(a,I),n.mul(x,m)),b=n.eql(n.mul(f,I),n.mul(E,m));return R&&b}negate(){return new z(this.X,n.neg(this.Y),this.Z)}double(){const{a:w,b:a}=i,f=n.mul(a,Nr),{X:m,Y:x,Z:E}=this;let I=n.ZERO,R=n.ZERO,b=n.ZERO,h=n.mul(m,m),k=n.mul(x,x),G=n.mul(E,E),j=n.mul(m,x);return j=n.add(j,j),b=n.mul(m,E),b=n.add(b,b),I=n.mul(w,b),R=n.mul(f,G),R=n.add(I,R),I=n.sub(k,R),R=n.add(k,R),R=n.mul(I,R),I=n.mul(j,I),b=n.mul(f,b),G=n.mul(w,G),j=n.sub(h,G),j=n.mul(w,j),j=n.add(j,b),b=n.add(h,h),h=n.add(b,h),h=n.add(h,G),h=n.mul(h,j),R=n.add(R,h),G=n.mul(x,E),G=n.add(G,G),h=n.mul(G,j),I=n.sub(I,h),b=n.mul(G,k),b=n.add(b,b),b=n.add(b,b),new z(I,R,b)}add(w){K(w);const{X:a,Y:f,Z:m}=this,{X:x,Y:E,Z:I}=w;
6let R=n.ZERO,b=n.ZERO,h=n.ZERO;const k=i.a,G=n.mul(i.b,Nr);let j=n.mul(a,x),Y=n.mul(f,E),gt=n.mul(m,I),ht=n.add(a,f),ft=n.add(x,E);ht=n.mul(ht,ft),ft=n.add(j,Y),ht=n.sub(ht,ft),ft=n.add(a,m);let Ot=n.add(x,I);return ft=n.mul(ft,Ot),Ot=n.add(j,gt),ft=n.sub(ft,Ot),Ot=n.add(f,m),R=n.add(E,I),Ot=n.mul(Ot,R),R=n.add(Y,gt),Ot=n.sub(Ot,R),h=n.mul(k,ft),R=n.mul(G,gt),h=n.add(R,h),R=n.sub(Y,h),h=n.add(Y,h),b=n.mul(R,h),Y=n.add(j,j),Y=n.add(Y,j),gt=n.mul(k,gt),ft=n.mul(G,ft),Y=n.add(Y,gt),gt=n.sub(j,gt),gt=n.mul(k,gt),ft=n.add(ft,gt),j=n.mul(Y,ft),b=n.add(b,j),j=n.mul(Ot,ft),R=n.mul(ht,R),R=n.sub(R,j),j=n.mul(ht,Y),h=n.mul(Ot,h),h=n.add(h,j),new z(R,b,h)}subtract(w){return this.add(w.negate())}is0(){return this.equals(z.ZERO)}multiply(w){const{endo:a}=t;if(!s.isValidNot0(w))throw new Error("invalid scalar: out of range");let f,m;const x=E=>W.cached(this,E,I=>In(z,I));if(a){const{k1neg:E,k1:I,k2neg:R,k2:b}=V(w),{p:h,f:k}=x(I),{p:G,f:j}=x(b);m=k.add(j),f=st(a.beta,h,G,E,R)}else{const{p:E,f:I}=x(w);f=E,m=I}return In(z,[f,m])[0]}multiplyUnsafe(w){const{endo:a}=t,f=this;if(!s.isValid(w))throw new Error("invalid scalar: out of range");if(w===fn||f.is0())return z.ZERO;if(w===Jn)return f;if(W.hasCache(this))return this.multiply(w);if(a){const{k1neg:m,k1:x,k2neg:E,k2:I}=V(w),{p1:R,p2:b}=Bu(z,f,x,I);return st(a.beta,R,b,m,E)}else return W.unsafe(f,w)}multiplyAndAddUnsafe(w,a,f){const m=this.multiplyUnsafe(a).add(w.multiplyUnsafe(f));return m.is0()?void 0:m}toAffine(w){return nt(this,w)}isTorsionFree(){const{isTorsionFree:w}=t;return o===Jn?!0:w?w(z,this):W.unsafe(this,u).is0()}clearCofactor(){const{clearCofactor:w}=t;return o===Jn?this:w?w(z,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(w=!0){return Cn(w,"isCompressed"),this.assertValidity(),A(z,this,w)}toHex(w=!0){return Mn(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(w=!0){return this.toBytes(w)}_setWindowSize(w){this.precompute(w)}static normalizeZ(w){return In(z,w)}static msm(w,a){return oa(z,s,w,a)}static fromPrivateKey(w){return z.BASE.multiply(Gn(s,w))}}z.BASE=new z(i.Gx,i.Gy,n.ONE),z.ZERO=new z(n.ZERO,n.ONE,n.ZERO),z.Fp=n,z.Fn=s;const et=s.BITS,W=new sa(z,t.endo?Math.ceil(et/2):et);return z.BASE.precompute(8),z}function Ya(r){return Uint8Array.of(r?2:3)}function Xa(r,t){return{secretKey:t.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Bf(r,t={}){const{Fn:e}=r,n=t.randomBytes||ys,s=Object.assign(Xa(r.Fp,e),{seed:na(e.ORDER)});function i(A){try{return!!Gn(e,A)}catch{return!1}}function o(A,_){const{publicKey:C,publicKeyUncompressed:M}=s;try{const U=A.length;return _===!0&&U!==C||_===!1&&U!==M?!1:!!r.fromBytes(A)}catch{return!1}}function u(A=n(s.seed)){return xu(We(A,s.seed,"seed"),e.ORDER)}function c(A,_=!0){return r.BASE.multiply(Gn(e,A)).toBytes(_)}function p(A){const _=u(A);return{secretKey:_,publicKey:c(_)}}function g(A){if(typeof A=="bigint")return!1;if(A instanceof r)return!0;const{secretKey:_,publicKey:C,publicKeyUncompressed:M}=s;if(e.allowedLengths||_===C)return;const U=Ht("key",A).length;return U===C||U===M}function v(A,_,C=!0){if(g(A)===!0)throw new Error("first arg must be private key");if(g(_)===!1)throw new Error("second arg must be public key");const M=Gn(e,A);return r.fromHex(_).multiply(M).toBytes(C)}return Object.freeze({getPublicKey:c,getSharedSecret:v,keygen:p,Point:r,utils:{isValidSecretKey:i,isValidPublicKey:o,randomSecretKey:u,isValidPrivateKey:i,randomPrivateKey:u,normPrivateKeyToScalar:A=>Gn(e,A),precompute(A=8,_=r.BASE){return _.precompute(A,!1)}},lengths:s})}function Af(r,t,e={}){Po(t),xr(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=e.randomBytes||ys,s=e.hmac||((a,...f)=>Ga(t,a,Qe(...f))),{Fp:i,Fn:o}=r,{ORDER:u,BITS:c}=o,{keygen:p,getPublicKey:g,getSharedSecret:v,utils:S,lengths:A}=Bf(r,e),_={prehash:!1,lowS:typeof e.lowS=="boolean"?e.lowS:!1,format:void 0,extraEntropy:!1},C="compact";function M(a){const f=u>>Jn;return a>f}function U(a,f){if(!o.isValidNot0(f))throw new Error(`invalid signature ${a}: out of range 1..Point.Fn.ORDER`);return f}function D(a,f){rs(f);const m=A.signature,x=f==="compact"?m:f==="recovered"?m+1:void 0;return We(a,x,`${f} signature`)}class N{constructor(f,m,x){this.r=U("r",f),this.s=U("s",m),x!=null&&(this.recovery=x),Object.freeze(this)}static fromBytes(f,m=C){D(f,m);let x;if(m==="der"){const{r:b,s:h}=cn.toSig(We(f));return new N(b,h)}m==="recovered"&&(x=f[0],m="compact",f=f.subarray(1));const E=o.BYTES,I=f.subarray(0,E),R=f.subarray(E,E*2);return new N(o.fromBytes(I),o.fromBytes(R),x)}static fromHex(f,m){return this.fromBytes(Or(f),m)}addRecoveryBit(f){return new N(this.r,this.s,f)}recoverPublicKey(f){const m=i.ORDER,{r:x,s:E,recovery:I}=this;if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");if(u*Za<m&&I>1)throw new Error("recovery id is ambiguous for h>1 curve");const b=I===2||I===3?x+u:x;if(!i.isValid(b))throw new Error("recovery id 2 or 3 invalid");const h=i.toBytes(b),k=r.fromBytes(Qe(Ya((I&1)===0),h)),G=o.inv(b),j=V(Ht("msgHash",f)),Y=o.create(-j*G),gt=o.create(E*G),ht=r.BASE.multiplyUnsafe(Y).add(k.multiplyUnsafe(gt));if(ht.is0())throw new Error("point at infinify");return ht.assertValidity(),ht}hasHighS(){return M(this.s)}toBytes(f=C){if(rs(f),f==="der")return Or(cn.hexFromSig(this));const m=o.toBytes(this.r),x=o.toBytes(this.s);if(f==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Qe(Uint8Array.of(this.recovery),m,x)}return Qe(m,x)}toHex(f){return Mn(this.toBytes(f))}assertValidity(){}static fromCompact(f){return N.fromBytes(Ht("sig",f),"compact")}static fromDER(f){return N.fromBytes(Ht("sig",f),"der")}normalizeS(){return this.hasHighS()?new N(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Mn(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Mn(this.toBytes("compact"))}}const K=e.bits2int||function(f){if(f.length>8192)throw new Error("input is too large");
6const m=Qr(f),x=f.length*8-c;return x>0?m>>BigInt(x):m},V=e.bits2int_modN||function(f){return o.create(K(f))},nt=vr(c);function lt(a){return ts("num < 2^"+c,a,fn,nt),o.toBytes(a)}function st(a,f){return We(a,void 0,"message"),f?We(t(a),void 0,"prehashed message"):a}function z(a,f,m){if(["recovered","canonical"].some(Y=>Y in m))throw new Error("sign() legacy options not supported");const{lowS:x,prehash:E,extraEntropy:I}=Ki(m,_);a=st(a,E);const R=V(a),b=Gn(o,f),h=[lt(b),lt(R)];if(I!=null&&I!==!1){const Y=I===!0?n(A.secretKey):I;h.push(Ht("extraEntropy",Y))}const k=Qe(...h),G=R;function j(Y){const gt=K(Y);if(!o.isValidNot0(gt))return;const ht=o.inv(gt),ft=r.BASE.multiply(gt).toAffine(),Ot=o.create(ft.x);if(Ot===fn)return;const Rt=o.create(ht*o.create(G+Ot*b));if(Rt===fn)return;let Lt=(ft.x===Ot?0:2)|Number(ft.y&Jn),Re=Rt;return x&&M(Rt)&&(Re=o.neg(Rt),Lt^=1),new N(Ot,Re,Lt)}return{seed:k,k2sig:j}}function et(a,f,m={}){a=Ht("message",a);const{seed:x,k2sig:E}=z(a,f,m);return fu(t.outputLen,o.BYTES,s)(x,E)}function W(a){let f;const m=typeof a=="string"||br(a),x=!m&&a!==null&&typeof a=="object"&&typeof a.r=="bigint"&&typeof a.s=="bigint";if(!m&&!x)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(x)f=new N(a.r,a.s);else if(m){try{f=N.fromBytes(Ht("sig",a),"der")}catch(E){if(!(E instanceof cn.Err))throw E}if(!f)try{f=N.fromBytes(Ht("sig",a),"compact")}catch{return!1}}return f||!1}function Q(a,f,m,x={}){const{lowS:E,prehash:I,format:R}=Ki(x,_);if(m=Ht("publicKey",m),f=st(Ht("message",f),I),"strict"in x)throw new Error("options.strict was renamed to lowS");const b=R===void 0?W(a):N.fromBytes(Ht("sig",a),R);if(b===!1)return!1;try{const h=r.fromBytes(m);if(E&&b.hasHighS())return!1;const{r:k,s:G}=b,j=V(f),Y=o.inv(G),gt=o.create(j*Y),ht=o.create(k*Y),ft=r.BASE.multiplyUnsafe(gt).add(h.multiplyUnsafe(ht));return ft.is0()?!1:o.create(ft.x)===k}catch{return!1}}function w(a,f,m={}){const{prehash:x}=Ki(m,_);return f=st(f,x),N.fromBytes(a,"recovered").recoverPublicKey(f).toBytes()}return Object.freeze({keygen:p,getPublicKey:g,getSharedSecret:v,utils:S,lengths:A,Point:r,sign:et,verify:Q,recoverPublicKey:w,Signature:N,hash:t})}function _f(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=Tn(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 kf(r){const{CURVE:t,curveOpts:e}=_f(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 If(r,t){const e=t.Point;return Object.assign({},t,{ProjectivePoint:e,CURVE:Object.assign({},r,ta(e.Fn.ORDER,e.Fn.BITS))})}function Mf(r){const{CURVE:t,curveOpts:e,hash:n,ecdsaOpts:s}=kf(r),i=Sf(t,e),o=Af(i,n,s);return If(r,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Rf(r,t){const e=n=>Mf({...r,hash:n});return{...e(t),create:e}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Us={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Cf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ho=BigInt(2);function Lf(r){const t=Us.p,e=BigInt(3),n=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),u=BigInt(44),c=BigInt(88),p=r*r*r%t,g=p*p*r%t,v=jt(g,e,t)*g%t,S=jt(v,e,t)*g%t,A=jt(S,ho,t)*p%t,_=jt(A,s,t)*A%t,C=jt(_,i,t)*_%t,M=jt(C,u,t)*C%t,U=jt(M,c,t)*M%t,D=jt(U,u,t)*C%t,N=jt(D,e,t)*g%t,K=jt(N,o,t)*_%t,V=jt(K,n,t)*p%t,nt=jt(V,ho,t);
6if(!is.eql(is.sqr(nt),r))throw new Error("Cannot find square root");return nt}const is=Tn(Us.p,{sqrt:Lf}),Nf=Rf({...Us,Fp:is,lowS:!0,endo:Cf},Ko);or.utils.randomPrivateKey;const po=()=>{const r=or.utils.randomPrivateKey(),t=ss(r),e=new Uint8Array(64);return e.set(r),e.set(t,32),{publicKey:t,secretKey:e}},ss=or.getPublicKey;function go(r){try{return or.ExtendedPoint.fromHex(r),!0}catch{return!1}}const Tf=(r,t)=>or.sign(r,t.slice(0,32)),Uf=or.verify,ye=r=>bt.Buffer.isBuffer(r)?r:r instanceof Uint8Array?bt.Buffer.from(r.buffer,r.byteOffset,r.byteLength):bt.Buffer.from(r);class Pf{constructor(t){Object.assign(this,t)}encode(){return bt.Buffer.from(ya(Pr,this))}static decode(t){return wa(Pr,this,t)}static decodeUnchecked(t){return ha(Pr,this,t)}}const Pr=new Map;var Ja;const Ff=32,xn=32;function Of(r){return r._bn!==void 0}let mo=1;class it extends Pf{constructor(t){if(super({}),this._bn=void 0,Of(t))this._bn=t._bn;else{if(typeof t=="string"){const e=ve.decode(t);if(e.length!=xn)throw new Error("Invalid public key input");this._bn=new ao(e)}else this._bn=new ao(t);if(this._bn.byteLength()>xn)throw new Error("Invalid public key input")}}static unique(){const t=new it(mo);return mo+=1,new it(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ve.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(bt.Buffer);if(t.length===xn)return t;const e=bt.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=bt.Buffer.concat([t.toBuffer(),bt.Buffer.from(e),n.toBuffer()]),i=co(s);return new it(i)}static createProgramAddressSync(t,e){let n=bt.Buffer.alloc(0);t.forEach(function(i){if(i.length>Ff)throw new TypeError("Max seed length exceeded");n=bt.Buffer.concat([n,ye(i)])}),n=bt.Buffer.concat([n,e.toBuffer(),bt.Buffer.from("ProgramDerivedAddress")]);const s=co(n);if(go(s))throw new Error("Invalid seeds, address must fall off the curve");return new it(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(bt.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 it(t);return go(e.toBytes())}}Ja=it;it.default=new Ja("11111111111111111111111111111111");Pr.set(it,{kind:"struct",fields:[["_bn","u256"]]});new it("BPFLoader1111111111111111111111111111111111");const Qn=1232,Qa=127,tc=64;class ec extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(ec.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class nc 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(nc.prototype,"name",{value:"TransactionExpiredTimeoutError"});class hr extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(hr.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Vr{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;
6this.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 At=(r="publicKey")=>zt(32,r),Zn=(r="string")=>{const t=rt([ct("length"),ct("lengthPadding"),zt(Rn(ct(),-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,u)=>{const c={chars:bt.Buffer.from(i,"utf8")};return n(c,o,u)},s.alloc=i=>ct().span+ct().span+bt.Buffer.from(i,"utf8").length,s},Df=(r="authorized")=>rt([At("staker"),At("withdrawer")],r),zf=(r="lockup")=>rt([Ue("unixTimestamp"),Ue("epoch"),At("custodian")],r),qf=(r="voteInit")=>rt([At("nodePubkey"),At("authorizedVoter"),At("authorizedWithdrawer"),St("commission")],r),Kf=(r="voteAuthorizeWithSeedArgs")=>rt([ct("voteAuthorizationType"),At("currentAuthorityDerivedKeyOwnerPubkey"),Zn("currentAuthorityDerivedKeySeed"),At("newAuthorized")],r);function rc(r,t){const e=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(t[s.property]);if("count"in s&&"elementLayout"in s){const i=t[s.property];if(Array.isArray(i))return i.length*e(s.elementLayout)}else if("fields"in s)return rc({layout:s},t[s.property]);return 0};let n=0;return r.layout.fields.forEach(s=>{n+=e(s)}),n}function Ke(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 $e(r,t){let e=t;for(;;){let n=e&127;
6if(e>>=7,e==0){r.push(n);break}else n|=128,r.push(n)}}function fe(r,t){if(!r)throw new Error(t||"Assertion failed")}class oi{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 u=o.toBase58();let c=n.get(u);return c===void 0&&(c={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(u,c)),c},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const u of o.keys){const c=s(u.pubkey);c.isSigner||(c.isSigner=u.isSigner),c.isWritable||(c.isWritable=u.isWritable)}}return new oi(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];fe(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,c])=>c.isSigner&&c.isWritable),n=t.filter(([,c])=>c.isSigner&&!c.isWritable),s=t.filter(([,c])=>!c.isSigner&&c.isWritable),i=t.filter(([,c])=>!c.isSigner&&!c.isWritable),o={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{fe(e.length>0,"Expected at least one writable signer key");const[c]=e[0];fe(c===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const u=[...e.map(([c])=>new it(c)),...n.map(([c])=>new it(c)),...s.map(([c])=>new it(c)),...i.map(([c])=>new it(c))];return[o,u]}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 u=new it(i),c=t.findIndex(p=>p.equals(u));c>=0&&(fe(c<256,"Max lookup table index exceeded"),n.push(c),s.push(u),this.keyMetaMap.delete(i))}return[n,s]}}const ic="Reached end of buffer unexpectedly";function ln(r){if(r.length===0)throw new Error(ic);return r.shift()}function je(r,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>r.length:e>=r.length)throw new Error(ic);return r.splice(...t)}class En{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 it(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:ve.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Vr(this.staticAccountKeys)}static compile(t){const e=oi.compile(t.instructions,t.payerKey),[n,s]=e.getMessageComponents(),o=new Vr(s).compileInstructions(t.instructions).map(u=>({programIdIndex:u.programIdIndex,accounts:u.accountKeyIndexes,data:ve.encode(u.data)}));return new En({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=[];$e(e,t);const n=this.instructions.map(v=>{const{accounts:S,programIdIndex:A}=v,_=Array.from(ve.decode(v.data));let C=[];$e(C,S.length);let M=[];return $e(M,_.length),{programIdIndex:A,keyIndicesCount:bt.Buffer.from(C),keyIndices:S,dataLength:bt.Buffer.from(M),data:_}});let s=[];$e(s,n.length);let i=bt.Buffer.alloc(Qn);bt.Buffer.from(s).copy(i);let o=s.length;
6n.forEach(v=>{const A=rt([St("programIdIndex"),zt(v.keyIndicesCount.length,"keyIndicesCount"),Ie(St("keyIndex"),v.keyIndices.length,"keyIndices"),zt(v.dataLength.length,"dataLength"),Ie(St("userdatum"),v.data.length,"data")]).encode(v,i,o);o+=A}),i=i.slice(0,o);const u=rt([zt(1,"numRequiredSignatures"),zt(1,"numReadonlySignedAccounts"),zt(1,"numReadonlyUnsignedAccounts"),zt(e.length,"keyCount"),Ie(At("key"),t,"keys"),At("recentBlockhash")]),c={numRequiredSignatures:bt.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:bt.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:bt.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:bt.Buffer.from(e),keys:this.accountKeys.map(v=>ye(v.toBytes())),recentBlockhash:ve.decode(this.recentBlockhash)};let p=bt.Buffer.alloc(2048);const g=u.encode(c,p);return i.copy(p,g),p.slice(0,g+i.length)}static from(t){let e=[...t];const n=ln(e);if(n!==(n&Qa))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=ln(e),i=ln(e),o=Ke(e);let u=[];for(let S=0;S<o;S++){const A=je(e,0,xn);u.push(new it(bt.Buffer.from(A)))}const c=je(e,0,xn),p=Ke(e);let g=[];for(let S=0;S<p;S++){const A=ln(e),_=Ke(e),C=je(e,0,_),M=Ke(e),U=je(e,0,M),D=ve.encode(bt.Buffer.from(U));g.push({programIdIndex:A,accounts:C,data:D})}const v={header:{numRequiredSignatures:n,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:ve.encode(bt.Buffer.from(c)),accountKeys:u,instructions:g};return new En(v)}}class Gr{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 Vr(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,u)=>o+u.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=oi.compile(t.instructions,t.payerKey),n=new Array,s={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const g of i){const v=e.extractTableLookup(g);if(v!==void 0){const[S,{writable:A,readonly:_}]=v;n.push(S),s.writable.push(...A),s.readonly.push(..._)}}const[o,u]=e.getMessageComponents(),p=new Vr(u,s).compileInstructions(t.instructions);return new Gr({header:o,staticAccountKeys:u,recentBlockhash:t.recentBlockhash,compiledInstructions:p,addressTableLookups:n})}serialize(){const t=Array();$e(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();$e(n,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();$e(i,this.addressTableLookups.length);const o=rt([St("prefix"),rt([St("numRequiredSignatures"),St("numReadonlySignedAccounts"),St("numReadonlyUnsignedAccounts")],"header"),zt(t.length,"staticAccountKeysLength"),Ie(At(),this.staticAccountKeys.length,"staticAccountKeys"),At("recentBlockhash"),zt(n.length,"instructionsLength"),zt(e.length,"serializedInstructions"),zt(i.length,"addressTableLookupsLength"),zt(s.length,"serializedAddressTableLookups")]),u=new Uint8Array(Qn),p=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(g=>g.toBytes()),recentBlockhash:ve.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},u);return u.slice(0,p)}serializeInstructions(){let t=0;const e=new Uint8Array(Qn);for(const n of this.compiledInstructions){const s=Array();$e(s,n.accountKeyIndexes.length);const i=Array();$e(i,n.data.length);const o=rt([St("programIdIndex"),zt(s.length,"encodedAccountKeyIndexesLength"),Ie(St(),n.accountKeyIndexes.length,"accountKeyIndexes"),zt(i.length,"encodedDataLength"),zt(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(Qn);for(const n of this.addressTableLookups){const s=Array();$e(s,n.writableIndexes.length);const i=Array();$e(i,n.readonlyIndexes.length);const o=rt([At("accountKey"),zt(s.length,"encodedWritableIndexesLength"),Ie(St(),n.writableIndexes.length,"writableIndexes"),zt(i.length,"encodedReadonlyIndexesLength"),Ie(St(),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=ln(e),s=n&Qa;fe(n!==s,"Expected versioned message but received legacy message");const i=s;fe(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:ln(e),numReadonlySignedAccounts:ln(e),numReadonlyUnsignedAccounts:ln(e)},u=[],c=Ke(e);for(let _=0;_<c;_++)u.push(new it(je(e,0,xn)));const p=ve.encode(je(e,0,xn)),g=Ke(e),v=[];for(let _=0;_<g;_++){const C=ln(e),M=Ke(e),U=je(e,0,M),D=Ke(e),N=new Uint8Array(je(e,0,D));v.push({programIdIndex:C,accountKeyIndexes:U,data:N})}const S=Ke(e),A=[];for(let _=0;_<S;_++){const C=new it(je(e,0,xn)),M=Ke(e),U=je(e,0,M),D=Ke(e),N=je(e,0,D);A.push({accountKey:C,writableIndexes:U,readonlyIndexes:N})}return new Gr({header:o,staticAccountKeys:u,recentBlockhash:p,compiledInstructions:v,addressTableLookups:A})}}let yn=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 $f=bt.Buffer.alloc(tc).fill(0);class Te{constructor(t){this.keys=void 0,this.programId=void 0,this.data=bt.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 tn{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,nonceInstru
6ction: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 Te(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let C=0;C<e.length;C++)if(e[C].programId===void 0)throw new Error(`Transaction instruction index ${C} has undefined program id`);const s=[],i=[];e.forEach(C=>{C.keys.forEach(U=>{i.push({...U})});const M=C.programId.toString();s.includes(M)||s.push(M)}),s.forEach(C=>{i.push({pubkey:new it(C),isSigner:!1,isWritable:!1})});const o=[];i.forEach(C=>{const M=C.pubkey.toString(),U=o.findIndex(D=>D.pubkey.toString()===M);U>-1?(o[U].isWritable=o[U].isWritable||C.isWritable,o[U].isSigner=o[U].isSigner||C.isSigner):o.push(C)}),o.sort(function(C,M){if(C.isSigner!==M.isSigner)return C.isSigner?-1:1;if(C.isWritable!==M.isWritable)return C.isWritable?-1:1;const U={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return C.pubkey.toBase58().localeCompare(M.pubkey.toBase58(),"en",U)});const u=o.findIndex(C=>C.pubkey.equals(n));if(u>-1){const[C]=o.splice(u,1);C.isSigner=!0,C.isWritable=!0,o.unshift(C)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const C of this.signatures){const M=o.findIndex(U=>U.pubkey.equals(C.publicKey));if(M>-1)o[M].isSigner||(o[M].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${C.publicKey.toString()}`)}let c=0,p=0,g=0;const v=[],S=[];o.forEach(({pubkey:C,isSigner:M,isWritable:U})=>{M?(v.push(C.toString()),c+=1,U||(p+=1)):(S.push(C.toString()),U||(g+=1))});const A=v.concat(S),_=e.map(C=>{const{data:M,programId:U}=C;return{programIdIndex:A.indexOf(U.toString()),accounts:C.keys.map(D=>A.indexOf(D.pubkey.toString())),data:ve.encode(M)}});return _.forEach(C=>{fe(C.programIdIndex>=0),C.accounts.forEach(M=>fe(M>=0))}),new En({header:{numRequiredSignatures:c,numReadonlySignedAccounts:p,numReadonlyUnsignedAccounts:g},accountKeys:A,recentBlockhash:t,instructions:_})}_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();
6e.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=Tf(n,s.secretKey);this._addSignature(s.publicKey,ye(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){fe(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=bt.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):Uf(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+=`
7Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(u=>u.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
8Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(u=>u.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(t){const{signatures:e}=this,n=[];$e(n,e.length);const s=n.length+e.length*64+t.length,i=bt.Buffer.alloc(s);return fe(e.length<256),bt.Buffer.from(n).copy(i,0),e.forEach(({signature:o},u)=>{o!==null&&(fe(o.length===64,"signature has invalid length"),bt.Buffer.from(o).copy(i,n.length+u*64))}),t.copy(i,n.length+e.length*64),fe(i.length<=Qn,`Transaction too large: ${i.length} > ${Qn}`),i}get keys(){return fe(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return fe(this.instructions.length===1),this.instructions[0].programId}get data(){return fe(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const n=Ke(e);let s=[];for(let i=0;i<n;i++){const o=je(e,0,tc);s.push(ve.encode(bt.Buffer.from(o)))}return tn.populate(En.from(e),s)}static populate(t,e=[]){const n=new tn;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((s,i)=>{const o={signature:s==ve.encode($f)?null:ve.decode(s),publicKey:t.accountKeys[i]};n.signatures.push(o)}),t.instructions.forEach(s=>{const i=s.accounts.map(o=>{const u=t.accountKeys[o];return{pubkey:u,isSigner:n.signatures.some(c=>c.publicKey.toString()===u.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});n.instructions.push(new Te({keys:i,programId:t.accountKeys[s.programIdIndex],data:ve.decode(s.data)}))}),n._message=t,n._json=n.toJSON(),n}}const jf=160,Hf=64,Wf=jf/Hf,Vf=1e3/Wf;new it("SysvarC1ock11111111111111111111111111111111");new it("SysvarEpochSchedu1e111111111111111111111111");new it("Sysvar1nstructions1111111111111111111111111");const $i=new it("SysvarRecentB1ockHashes11111111111111111111"),yo=new it("SysvarRent111111111111111111111111111111111");new it("SysvarRewards111111111111111111111111111111");new it("SysvarS1otHashes111111111111111111111111111");new it("SysvarS1otHistory11111111111111111111111111");new it("SysvarStakeHistory1111111111111111111111111");class wo 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 u;switch(t){case"send":u=`Transaction ${e} resulted in an error. 
10${n}. `+i+o;break;case"simulate":u=`Simulation failed. 
11Message: ${n}. 
12`+i+o;break;default:u=`Unknown action '${(c=>c)(t)}'`}super(u),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=n,this.transactionLogs=s||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}
12async 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 at 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 Vn(r){return new Promise(t=>setTimeout(t,r))}function Oe(r,t){const e=r.layout.span>=0?r.layout.span:rc(r,t),n=bt.Buffer.alloc(e),s=Object.assign({instruction:r.index},t);return r.layout.encode(s,n),n}const Gf=me("lamportsPerSignature"),sc=rt([ct("version"),ct("state"),At("authorizedPubkey"),At("nonce"),rt([Gf],"feeCalculator")]),bo=sc.span;class Ps{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=sc.decode(ye(t),0);return new Ps({authorizedPubkey:new it(e.authorizedPubkey),nonce:new it(e.nonce).toString(),feeCalculator:e.feeCalculator})}}function sr(r){const t=zt(8,r),e=t.decode.bind(t),n=t.encode.bind(t),s=t,i=Nl();return s.decode=(o,u)=>{const c=e(o,u);return i.decode(c)},s.encode=(o,u,c)=>{const p=i.encode(o);return n(p,u,c)},s}const De=Object.freeze({Create:{index:0,layout:rt([ct("instruction"),Ue("lamports"),Ue("space"),At("programId")])},Assign:{index:1,layout:rt([ct("instruction"),At("programId")])},Transfer:{index:2,layout:rt([ct("instruction"),sr("lamports")])},CreateWithSeed:{index:3,layout:rt([ct("instruction"),At("base"),Zn("seed"),Ue("lamports"),Ue("space"),At("programId")])},AdvanceNonceAccount:{index:4,layout:rt([ct("instruction")])},WithdrawNonceAccount:{index:5,layout:rt([ct("instruction"),Ue("lamports")])},InitializeNonceAccount:{index:6,layout:rt([ct("instruction"),At("authorized")])},AuthorizeNonceAccount:{index:7,layout:rt([ct("instruction"),At("authorized")])},Allocate:{index:8,layout:rt([ct("instruction"),Ue("space")])},AllocateWithSeed:{index:9,layout:rt([ct("instruction"),At("base"),Zn("seed"),Ue("space"),At("programId")])},AssignWithSeed:{index:10,layout:rt([ct("instruction"),At("base"),Zn("seed"),At("programId")])},TransferWithSeed:{index:11,layout:rt([ct("instruction"),sr("lamports"),Zn("seed"),At("programId")])},UpgradeNonceAccount:{index:12,layout:rt([ct("instruction")])}});class yr{constructor(){}static createAccount(t){const e=De.Create,n=Oe(e,{lamports:t.lamports,space:t.space,programId:ye(t.programId.toBuffer())});return new Te({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(t){let e,n;if("basePubkey"in t){const s=De.TransferWithSeed;e=Oe(s,{lamports:BigInt(t.lamports),seed:t.seed,programId:ye(t.programId.toBuffer())}),n=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=De.Transfer;e=Oe(s,{lamports:BigInt(t.lamports)}),n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:e})}static assign(t){let e,n;if("basePubkey"in t){const s=De.AssignWithSeed;e=Oe(s,{base:ye(t.basePubkey.toBuffer()),seed:t.seed,programId:ye(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=De.Assign;e=Oe(s,{programId:ye(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=De.CreateWithSeed,n=Oe(e,{base:ye(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:ye(t.programId.toBuffer())});let s=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||s.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Te({keys:s,programId:this.programId,data:n})}static createNonceAccount(t){const e=new tn;"basePubkey"in t&&"seed"in t?e.add(yr.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:bo,programId:this.programId})):e.add(yr.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:bo,programId:this.programId}));const n={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(n)),e}static nonceInitialize(t){const e=De.InitializeNonceAccount,n=Oe(e,{authorized:ye(t.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$i,isSigner:!1,isWritable:!1},{pubkey:yo,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Te(s)}static nonceAdvance(t){const e=De.AdvanceNonceAccount,n=Oe(e),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$i,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Te(s)}static nonceWithdraw(t){const e=De.WithdrawNonceAccount,n=Oe(e,{lamports:t.lamports});return new Te({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:$i,isSigner:!1,isWritable:!1},{pubkey:yo,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(t){const e=De.AuthorizeNonceAccount,n=Oe(e,{authorized:ye(t.newAuthorizedPubkey.toBuffer())});return new Te({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(t){let e,n;if("basePubkey"in t){const s=De.AllocateWithSeed;e=Oe(s,{base:ye(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:ye(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=De.Allocate;e=Oe(s,{space:t.space}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:e})}}yr.programId=new it("11111111111111111111111111111111");new it("BPFLoader2111111111111111111111111111111111");function Zf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ji,vo;
12function Yf(){if(vo)return ji;vo=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,u,c,p,g,v;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(v=r.call(n),v==="[object Array]"){for(u="[",o=n.length-1,i=0;i<o;i++)u+=e(n[i],!0)+",";return o>-1&&(u+=e(n[i],!0)),u+"]"}else if(v==="[object Object]"){for(c=t(n).sort(),o=c.length,u="",i=0;i<o;)p=c[i],g=e(n[p],!1),g!==void 0&&(u&&(u+=","),u+=JSON.stringify(p)+":"+g),i++;return"{"+u+"}"}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 ji=function(n){var s=e(n,!1);if(s!==void 0)return""+s},ji}var Xf=Yf(),xo=Zf(Xf);const fr=32;function Hi(r){let t=0;for(;r>1;)r/=2,t++;return t}function Jf(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 Qf{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=Hi(Jf(t+fr+1))-Hi(fr)-1,n=this.getSlotsInEpoch(e),s=t-(n-fr);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)*fr:(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+Hi(fr)):this.slotsPerEpoch}}var th=globalThis.fetch;class eh extends bf{constructor(t,e,n){const s=i=>{const o=yf(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 nh(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 Eo=56;class So{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=nh(rh,t),n=t.length-Eo;fe(n>=0,"lookup table is invalid"),fe(n%32===0,"lookup table is invalid");const s=n/32,{addresses:i}=rt([Ie(At(),s,"addresses")]).decode(t.slice(Eo));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new it(e.authority[0]):void 0,addresses:i.map(o=>new it(o))}}}const rh={index:1,layout:rt([ct("typeIndex"),sr("deactivationSlot"),me("lastExtendedSlot"),St("lastExtendedStartIndex"),St(),Ie(At(),Rn(St(),-1),"authority")])},ih=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function sh(r){const t=r.match(ih);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);const[e,n,s,i]=t,o=r.startsWith("https:")?"wss:":"ws:",u=s==null?null:parseInt(s.slice(1),10),c=u==null?"":`:${u+1}`;return`${o}//${n}${c}${i}`}const Kt=Br(Ns(it),H(),r=>new it(r)),oc=Ts([H(),qt("base64")]),Fs=Br(Ns(bt.Buffer),oc,r=>bt.Buffer.from(r[0],"base64")),oh=30*1e3;function ah(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function Ut(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 Bo(r){return r.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function ac(r){return Me([q({jsonrpc:qt("2.0"),id:H(),result:r}),q({jsonrpc:qt("2.0"),id:H(),error:q({code:ur(),message:H(),data:ut(zl())})})])}const ch=ac(ur());function Et(r){return Br(ac(r),ch,t=>"error"in t?t:{...t,result:Z(t.result,r)})}function Wt(r){return Et(q({context:q({slot:P()}),value:r}))}function ai(r){return q({context:q({slot:P()}),value:r})}function Wi(r,t){return r===0?new Gr({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new it(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:ve.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new En(t)}
vendor: 8,527 bytes, line 12
12const uh=q({foundation:P(),foundationTerm:P(),initial:P(),taper:P(),terminal:P()}),lh=Et(X(J(q({epoch:P(),effectiveSlot:P(),amount:P(),postBalance:P(),commission:ut(J(P()))})))),fh=X(q({slot:P(),prioritizationFee:P()})),hh=q({total:P(),validator:P(),foundation:P(),epoch:P()}),dh=q({epoch:P(),slotIndex:P(),slotsInEpoch:P(),absoluteSlot:P(),blockHeight:ut(P()),transactionCount:ut(P())}),ph=q({slotsPerEpoch:P(),leaderScheduleSlotOffset:P(),warmup:en(),firstNormalEpoch:P(),firstNormalSlot:P()}),gh=Da(H(),X(P())),Fn=J(Me([q({}),H()])),mh=q({err:Fn}),yh=qt("receivedSignature"),wh=q({"solana-core":H(),"feature-set":ut(P())}),bh=q({program:H(),programId:Kt,parsed:ur()}),vh=q({programId:Kt,accounts:X(Kt),data:H()}),Ao=Wt(q({err:J(Me([q({}),H()])),logs:J(X(H())),accounts:ut(J(X(J(q({executable:en(),owner:H(),lamports:P(),data:X(H()),rentEpoch:ut(P())}))))),unitsConsumed:ut(P()),returnData:ut(J(q({programId:H(),data:Ts([H(),qt("base64")])}))),innerInstructions:ut(J(X(q({index:P(),instructions:X(Me([bh,vh]))}))))})),xh=Wt(q({byIdentity:Da(H(),X(P())),range:q({firstSlot:P(),lastSlot:P()})}));function Eh(r,t,e,n,s,i){const o=e||th;let u;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 c;return n&&(c=async(g,v)=>{const S=await new Promise((A,_)=>{try{n(g,v,(C,M)=>A([C,M]))}catch(C){_(C)}});return await o(...S)}),new pf(async(g,v)=>{const S={method:"POST",body:g,agent:u,headers:Object.assign({"Content-Type":"application/json"},t||{},Ed)};try{let A=5,_,C=500;for(;c?_=await c(r,S):_=await o(r,S),!(_.status!==429||s===!0||(A-=1,A===0));)console.error(`Server responded with ${_.status} ${_.statusText}.  Retrying after ${C}ms delay...`),await Vn(C),C*=2;const M=await _.text();_.ok?v(null,M):v(new Error(`${_.status} ${_.statusText}: ${M}`))}catch(A){A instanceof Error&&v(A)}},{})}function Sh(r){return(t,e)=>new Promise((n,s)=>{r.request(t,e,(i,o)=>{if(i){s(i);return}n(o)})})}function Bh(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 Ah=Et(uh),_h=Et(hh),kh=Et(fh),Ih=Et(dh),Mh=Et(ph),Rh=Et(gh),Ch=Et(P()),Lh=Wt(q({total:P(),circulating:P(),nonCirculating:P(),nonCirculatingAccounts:X(Kt)})),os=q({amount:H(),uiAmount:J(P()),decimals:P(),uiAmountString:ut(H())}),Nh=Wt(X(q({address:Kt,amount:H(),uiAmount:J(P()),decimals:P(),uiAmountString:ut(H())}))),Th=Wt(X(q({pubkey:Kt,account:q({executable:en(),owner:Kt,lamports:P(),data:Fs,rentEpoch:P()})}))),as=q({program:H(),parsed:ur(),space:P()}),Uh=Wt(X(q({pubkey:Kt,account:q({executable:en(),owner:Kt,lamports:P(),data:as,rentEpoch:P()})}))),Ph=Wt(X(q({lamports:P(),address:Kt}))),wr=q({executable:en(),owner:Kt,lamports:P(),data:Fs,rentEpoch:P()}),Fh=q({pubkey:Kt,account:wr}),Oh=Br(Me([Ns(bt.Buffer),as]),Me([oc,as]),r=>Array.isArray(r)?Z(r,Fs):r),cs=q({executable:en(),owner:Kt,lamports:P(),data:Oh,rentEpoch:P()}),Dh=q({pubkey:Kt,account:cs}),zh=q({state:Me([qt("active"),qt("inactive"),qt("activating"),qt("deactivating")]),active:P(),inactive:P()}),qh=Et(X(q({signature:H(),slot:P(),err:Fn,memo:J(H()),blockTime:ut(J(P()))}))),Kh=Et(X(q({signature:H(),slot:P(),err:Fn,memo:J(H()),blockTime:ut(J(P()))}))),$h=q({subscription:P(),result:ai(wr)}),jh=q({pubkey:Kt,account:wr}),Hh=q({subscription:P(),result:ai(jh)}),Wh=q({parent:P(),slot:P(),root:P()}),Vh=q({subscription:P(),result:Wh}),Gh=Me([q({type:Me([qt("firstShredReceived"),qt("completed"),qt("optimisticConfirmation"),qt("root")]),slot:P(),timestamp:P()}),q({type:qt("createdBank"),parent:P(),slot:P(),timestamp:P()}),q({type:qt("frozen"),slot:P(),timestamp:P(),stats:q({numTransactionEntries:P(),numSuccessfulTransactions:P(),numFailedTransactions:P(),maxTransactionsPerEntry:P()})}),q({type:qt("dead"),slot:P(),timestamp:P(),err:H()})]),Zh=q({subscription:P(),result:Gh}),Yh=q({subscription:P(),result:ai(Me([mh,yh]))}),Xh=q({subscription:P(),result:P()}),Jh=q({pubkey:H(),gossip:J(H()),tpu:J(H()),rpc:J(H()),version:J(H())}),_o=q({votePubkey:H(),nodePubkey:H(),activatedStake:P(),epochVoteAccount:en(),epochCredits:X(Ts([P(),P(),P()])),commission:P(),lastVote:P(),rootSlot:J(P())}),Qh=Et(q({current:X(_o),delinquent:X(_o)})),td=Me([qt("processed"),qt("confirmed"),qt("finalized")]),ed=q({slot:P(),confirmations:J(P()),err:Fn,confirmationStatus:ut(td)}),nd=Wt(X(J(ed))),rd=Et(P()),cc=q({accountKey:Kt,writableIndexes:X(P()),readonlyIndexes:X(P())}),Os=q({signatures:X(H()),message:q({accountKeys:X(H()),header:q({numRequiredSignatures:P(),numReadonlySignedAccounts:P(),numReadonlyUnsignedAccounts:P()}),instructions:X(q({accounts:X(P()),data:H(),programIdIndex:P()})),recentBlockhash:H(),addressTableLookups:ut(X(cc))})}),uc=q({pubkey:Kt,signer:en(),writable:en(),source:ut(Me([qt("transaction"),qt("lookupTable")]))}),lc=q({accountKeys:X(uc),signatures:X(H())}),fc=q({parsed:ur(),program:H(),programId:Kt}),hc=q({accounts:X(Kt),data:H(),programId:Kt}),id=Me([hc,fc]),sd=Me([q({parsed:ur(),program:H(),programId:H()}),q({accounts:X(H()),data:H(),programId:H()})]),dc=Br(id,sd,r=>"accounts"in r?Z(r,hc):Z(r,fc)),pc=q({signatures:X(H()),message:q({accountKeys:X(uc),instructions:X(dc),recentBlockhash:H(),addressTableLookups:ut(J(X(cc)))})}),Zr=q({accountIndex:P(),mint:H(),owner:ut(H()),programId:ut(H()),uiTokenAmount:os}),gc=q({writable:X(Kt),readonly:X(Kt)}),ci=q({err:Fn,fee:P(),innerInstructions:ut(J(X(q({index:P(),instructions:X(q({accounts:X(P()),data:H(),programIdIndex:P()}))})))),preBalances:X(P()),postBalances:X(P()),logMessages:ut(J(X(H()))),preTokenBalances:ut(J(X(Zr))),postTokenBalances:ut(J(X(Zr))),loadedAddresses:ut(gc),computeUnitsConsumed:ut(P()),costUnits:ut(P())}),Ds=q({err:Fn,fee:P(),innerInstructions:ut(J(X(q({index:P(),instructions:X(dc)})))),preBalances:X(P()),postBalances:X(P()),logMessages:ut(J(X(H()))),preTokenBalances:ut(J(X(Zr))),postTokenBalances:ut(J(X(Zr))),loadedAddresses:ut(gc),computeUnitsConsumed:ut(P()),costUnits:ut(P())}),lr=Me([qt(0),qt("legacy")]),On=q({pubkey:H(),lamports:P(),postBalance:J(P()),rewardType:J(H()),commission:ut(J(P()))}),od=Et(J(q({blockhash:H(),previousBlockhash:H(),parentSlot:P(),transactions:X(q({transaction:Os,meta:J(ci),version:ut(lr)})),rewards:ut(X(On)),blockTime:J(P()),blockHeight:J(P())}))),ad=Et(J(q({blockhash:H(),previousBlockhash:H(),parentSlot:P(),rewards:ut(X(On)),blockTime:J(P()),blockHeight:J(P())}))),cd=Et(J(q({blockhash:H(),previousBlockhash:H(),parentSlot:P(),transactions:X(q({transaction:lc,meta:J(ci),version:ut(lr)})),rewards:ut(X(On)),blockTime:J(P()),blockHeight:J(P())}))),ud=Et(J(q({blockhash:H(),previousBlockhash:H(),parentSlot:P(),transactions:X(q({transaction:pc,meta:J(Ds),version:ut(lr)})),rewards:ut(X(On)),blockTime:J(P()),blockHeight:J(P())}))),ld=Et(J(q({blockhash:H(),previousBlockhash:H(),parentSlot:P(),transactions:X(q({transaction:lc,meta:J(Ds),version:ut(lr)})),rewards:ut(X(On)),blockTime:J(P()),blockHeight:J(P())}))),fd=Et(J(q({blockhash:H(),previousBlockhash:H(),parentSlot:P(),rewards:ut(X(On)),blockTime:J(P()),blockHeight:J(P())}))),hd=Et(J(q({blockhash:H(),previousBlockhash:H(),parentSlot:P(),transactions:X(q({transaction:Os,meta:J(ci)})),rewards:ut(X(On)),blockTime:J(P())}))),ko=Et(J(q({blockhash:H(),previousBlockhash:H(),parentSlot:P(),signatures:X(H()),blockTime:J(P())}))),Vi=Et(J(q({slot:P(),meta:J(ci),blockTime:ut(J(P())),transaction:Os,version:ut(lr)}))),Tr=Et(J(q({slot:P(),transaction:pc,meta:J(Ds),blockTime:ut(J(P())),version:ut(lr)}))),dd=Wt(q({blockhash:H(),lastValidBlockHeight:P()})),pd=Wt(en()),gd=q({slot:P(),numTransactions:P(),numSlots:P(),samplePeriodSecs:P()}),md=Et(X(gd)),yd=Wt(J(q({feeCalculator:q({lamportsPerSignature:P()})}))),wd=Et(H()),bd=Et(H()),vd=q({err:Fn,logs:X(H()),signature:H()}),xd=q({result:ai(vd),subscription:P()}),Ed={"solana-client":"js/1.0.0-maintenance"};class Io{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={}
12,this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const p={};return async g=>{const{commitment:v,config:S}=Ut(g),A=this._buildArgs([],v,void 0,S),_=xo(A);return p[_]=p[_]??(async()=>{try{const C=await this._rpcRequest("getBlockHeight",A),M=Z(C,Et(P()));if("error"in M)throw new at(M.error,"failed to get block height information");return M.result}finally{delete p[_]}})(),await p[_]}})();let n,s,i,o,u,c;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,u=e.disableRetryOnRateLimit,c=e.httpAgent),this._rpcEndpoint=ah(t),this._rpcWsEndpoint=n||sh(t),this._rpcClient=Eh(t,s,i,o,u,c),this._rpcRequest=Sh(this._rpcClient),this._rpcBatchRequest=Bh(this._rpcClient),this._rpcWebSocket=new eh(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}=Ut(e),i=this._buildArgs([t.toBase58()],n,void 0,s),o=await this._rpcRequest("getBalance",i),u=Z(o,Wt(P()));if("error"in u)throw new at(u.error,`failed to get balance for ${t.toBase58()}`);return u.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+n)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),n=Z(e,Et(J(P())));if("error"in n)throw new at(n.error,`failed to get block time for slot ${t}`);return n.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=Z(t,Et(P()));if("error"in e)throw new at(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=Z(t,Ch);if("error"in e)throw new at(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=Z(n,Lh);if("error"in s)throw new at(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=Z(s,Wt(os));if("error"in i)throw new at(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=Z(s,Wt(os));if("error"in i)throw new at(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(t,e,n){const{commitment:s,config:i}=Ut(n);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const u=this._buildArgs(o,s,"base64",i),c=await this._rpcRequest("getTokenAccountsByOwner",u),p=Z(c,Th);if("error"in p)throw new at(p.error,`failed to get token accounts owned by account ${t.toBase58()}`);return p.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),u=Z(o,Uh);if("error"in u)throw new at(u.error,`failed to get token accounts owned by account ${t.toBase58()}`);return u.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},n=e.filter||e.commitment?[e]:[],s=await this._rpcRequest("getLargestAccounts",n),i=Z(s,Ph);if("error"in i)throw new at(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=Z(s,Nh);if("error"in i)throw new at(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:s}=Ut(e),i=this._buildArgs([t.toBase58()],n,"base64",s),o=await this._rpcRequest("getAccountInfo",i),u=Z(o,Wt(J(wr)));if("error"in u)throw new at(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getParsedAccountInfo(t,e){const{commitment:n,config:s}=Ut(e),i=this._buildArgs([t.toBase58()],n,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),u=Z(o,Wt(J(cs)));if("error"in u)throw new at(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(n){throw new Error("failed to get info about account "+t.toBase58()+": "+n)}}async getMultipleParsedAccounts(t,e){const{commitment:n,config:s}=Ut(e),i=t.map(p=>
12p.toBase58()),o=this._buildArgs([i],n,"jsonParsed",s),u=await this._rpcRequest("getMultipleAccounts",o),c=Z(u,Wt(X(J(cs))));if("error"in c)throw new at(c.error,`failed to get info for accounts ${i}`);return c.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:s}=Ut(e),i=t.map(p=>p.toBase58()),o=this._buildArgs([i],n,"base64",s),u=await this._rpcRequest("getMultipleAccounts",o),c=Z(u,Wt(X(J(wr))));if("error"in c)throw new at(c.error,`failed to get info for accounts ${i}`);return c.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:s,config:i}=Ut(e),o=this._buildArgs([t.toBase58()],s,void 0,{...i,epoch:n??(i==null?void 0:i.epoch)}),u=await this._rpcRequest("getStakeActivation",o),c=Z(u,Et(zh));if("error"in c)throw new at(c.error,`failed to get Stake Activation ${t.toBase58()}`);return c.result}async getProgramAccounts(t,e){const{commitment:n,config:s}=Ut(e),{encoding:i,...o}=s||{},u=this._buildArgs([t.toBase58()],n,i||"base64",{...o,...o.filters?{filters:Bo(o.filters)}:null}),c=await this._rpcRequest("getProgramAccounts",u),p=X(Fh),g=o.withContext===!0?Z(c,Wt(p)):Z(c,Et(p));if("error"in g)throw new at(g.error,`failed to get accounts owned by program ${t.toBase58()}`);return g.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:s}=Ut(e),i=this._buildArgs([t.toBase58()],n,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),u=Z(o,Et(X(Dh)));if("error"in u)throw new at(u.error,`failed to get accounts owned by program ${t.toBase58()}`);return u.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=ve.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return fe(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((c,p)=>{try{n=this.onSignature(e,(v,S)=>{n=void 0;const A={context:S,value:v};c({__type:yn.PROCESSED,response:A})},t);const g=new Promise(v=>{n==null?v():s=this._onSubscriptionStateChange(n,S=>{S==="subscribed"&&v()})});(async()=>{if(await g,i)return;
12const v=await this.getSignatureStatus(e);if(i||v==null)return;const{context:S,value:A}=v;if(A!=null)if(A!=null&&A.err)p(A.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(A.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(A.confirmationStatus==="processed"||A.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,c({__type:yn.PROCESSED,response:{context:S,value:A}})}})()}catch(g){p(g)}});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(v=>{const S=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let A=await S();if(!i){for(;A<=n;)if(await Vn(1e3),i||(A=await S(),i))return;v({__type:yn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:u,confirmationPromise:c}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),p=this.getCancellationPromise(e);let g;try{const v=await Promise.race([p,c,o]);if(v.__type===yn.PROCESSED)g=v.response;else throw new ec(s)}finally{i=!0,u()}return g}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let u=!1;const c=new Promise(A=>{let _=i,C=null;const M=async()=>{try{const{context:U,value:D}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:n});return C=U.slot,D==null?void 0:D.nonce}catch{return _}};(async()=>{if(_=await M(),!u)for(;;){if(i!==_){A({__type:yn.NONCE_INVALID,slotInWhichNonceDidAdvance:C});return}if(await Vn(2e3),u||(_=await M(),u))return}})()}),{abortConfirmation:p,confirmationPromise:g}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),v=this.getCancellationPromise(e);let S;try{const A=await Promise.race([v,g,c]);if(A.__type===yn.PROCESSED)S=A.response;else{let _;for(;;
12){const C=await this.getSignatureStatus(o);if(C==null)break;if(C.context.slot<(A.slotInWhichNonceDidAdvance??n)){await Vn(400);continue}_=C;break}if(_!=null&&_.value){const C=t||"finalized",{confirmationStatus:M}=_.value;switch(C){case"processed":case"recent":if(M!=="processed"&&M!=="confirmed"&&M!=="finalized")throw new hr(o);break;case"confirmed":case"single":case"singleGossip":if(M!=="confirmed"&&M!=="finalized")throw new hr(o);break;case"finalized":case"max":case"root":if(M!=="finalized")throw new hr(o);break;default:}S={context:_.context,value:{err:_.value.err}}}else throw new hr(o)}}finally{u=!0,p()}return S}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const s=new Promise(c=>{let p=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{p=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>c({__type:yn.TIMED_OUT,timeoutMs:p}),p)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let u;try{const c=await Promise.race([o,s]);if(c.__type===yn.PROCESSED)u=c.response;else throw new nc(e,c.timeoutMs/1e3)}finally{clearTimeout(n),i()}return u}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=Z(t,Et(X(Jh)));if("error"in e)throw new at(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=Z(n,Qh);if("error"in s)throw new at(s.error,"failed to get vote accounts");return s.result}async getSlot(t){const{commitment:e,config:n}=Ut(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getSlot",s),o=Z(i,Et(P()));if("error"in o)throw new at(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:n}=Ut(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getSlotLeader",s),o=Z(i,Et(H()));if("error"in o)throw new at(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=Z(s,Et(X(Kt)));if("error"in i)throw new at(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(t,e){const{context:n,value:s}
12=await this.getSignatureStatuses([t],e);fe(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=Z(s,nd);if("error"in i)throw new at(i.error,"failed to get signature status");return i.result}async getTransactionCount(t){const{commitment:e,config:n}=Ut(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getTransactionCount",s),o=Z(i,Et(P()));if("error"in o)throw new at(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=Z(n,Ah);if("error"in s)throw new at(s.error,"failed to get inflation");return s.result}async getInflationReward(t,e,n){const{commitment:s,config:i}=Ut(n),o=this._buildArgs([t.map(p=>p.toBase58())],s,void 0,{...i,epoch:e??(i==null?void 0:i.epoch)}),u=await this._rpcRequest("getInflationReward",o),c=Z(u,lh);if("error"in c)throw new at(c.error,"failed to get inflation reward");return c.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=Z(t,_h);if("error"in e)throw new at(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:n}=Ut(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getEpochInfo",s),o=Z(i,Ih);if("error"in o)throw new at(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=Z(t,Mh);if("error"in e)throw new at(e.error,"failed to get epoch schedule");const n=e.result;return new Qf(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=Z(t,Rh);if("error"in e)throw new at(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=Z(s,rd);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=Z(e,md);if("error"in n)throw new at(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=Z(s,yd);if("error"in i)throw new at(i.error,"failed to get fee calculator");const{context:o,value:u}=i.result;return{context:o,value:u!==null?u.feeCalculator:null}}async getFeeForMessage(t,e){const n=ye(t.serialize()).toString("base64"),s=this._buildArgs([n],e),i=await this._rpcRequest("getFeeForMessage",s),o=Z(i,Wt(J(P())));if("error"in o)throw new at(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(u=>u.toBase58()),n=e!=null&&e.length?[e]:[],s=await this._rpcRequest("getRecentPrioritizationFees",n),i=Z(s,kh);if("error"in i)throw new at(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}=Ut(t),s=this._buildArgs([],e,void 0,n),i=await this._rpcRequest("getLatestBlockhash",s),o=Z(i,dd);if("error"in o)throw new at(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:n,config:s}=Ut(e),i=this._buildArgs([t],n,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),u=Z(o,pd);if("error"in u)throw new at(u.error,"failed to determine if the blockhash `"+t+"`is valid");return u.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=Z(t,Et(wh));if("error"in e)throw new at(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=Z(t,Et(H()));if("error"in e)throw new at(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:n,config:s}=Ut(e),i=this._buildArgsAtLeastConfirmed([t],n,void 0,s),o=await this._rpcRequest("getBlock",i);
12try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const u=Z(o,cd);if("error"in u)throw u.error;return u.result}case"none":{const u=Z(o,ad);if("error"in u)throw u.error;return u.result}default:{const u=Z(o,od);if("error"in u)throw u.error;const{result:c}=u;return c?{...c,transactions:c.transactions.map(({transaction:p,meta:g,version:v})=>({meta:g,transaction:{...p,message:Wi(v,p.message)},version:v}))}:null}}}catch(u){throw new at(u,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:s}=Ut(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 u=Z(o,ld);if("error"in u)throw u.error;return u.result}case"none":{const u=Z(o,fd);if("error"in u)throw u.error;return u.result}default:{const u=Z(o,ud);if("error"in u)throw u.error;return u.result}}}catch(u){throw new at(u,"failed to get block")}}async getBlockProduction(t){let e,n;if(typeof t=="string")n=t;else if(t){const{commitment:u,...c}=t;n=u,e=c}const s=this._buildArgs([],n,"base64",e),i=await this._rpcRequest("getBlockProduction",s),o=Z(i,xh);if("error"in o)throw new at(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:n,config:s}=Ut(e),i=this._buildArgsAtLeastConfirmed([t],n,void 0,s),o=await this._rpcRequest("getTransaction",i),u=Z(o,Vi);if("error"in u)throw new at(u.error,"failed to get transaction");const c=u.result;return c&&{...c,transaction:{...c.transaction,message:Wi(c.version,c.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:n,config:s}=Ut(e),i=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),u=Z(o,Tr);if("error"in u)throw new at(u.error,"failed to get transaction");return u.result}async getParsedTransactions(t,e){const{commitment:n,config:s}=Ut(e),i=t.map(c=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([c],n,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(c=>{const p=Z(c,Tr);if("error"in p)throw new at(p.error,"failed to get transactions");return p.result})}async getTransactions(t,e){const{commitment:n,config:s}=Ut(e),i=t.map(c=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([c],n,void 0,s)}));return(await this._rpcBatchRequest(i)).map(c=>{const p=Z(c,Vi);if("error"in p)throw new at(p.error,"failed to get transactions");const g=p.result;return g&&{...g,transaction:{...g.transaction,message:Wi(g.version,g.transaction.message)}}})}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getBlock",n),i=Z(s,hd);if("error"in i)throw new at(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");const u={...o,transactions:o.transactions.map(({transaction:c,meta:p})=>{const g=new En(c.message);return{meta:p,transaction:{...c,message:g}}})};return{...u,transactions:u.transactions.map(({transaction:c,meta:p})=>({meta:p,transaction:tn.populate(c.message,c.signatures)}))}}async getBlocks(t,e,n){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),i=await this._rpcRequest("getBlocks",s),o=Z(i,Et(X(P())));if("error"in o)throw new at(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=Z(s,ko);if("error"in i)throw new at(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=Z(s,ko);if("error"in i)throw new at(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=Z(s,Vi);if("error"in i)throw new at(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const u=new En(o.transaction.message),c=o.transaction.signatures;return{...o,transaction:tn.populate(u,c)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getTransaction",n),i=Z(s,Tr);if("error"in i)throw new at(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 u=Z(o,Tr);if("error"in u)throw new at(u.error,"failed to get confirmed transactions");return u.result})}async getConfirmedSignaturesForAddress(t,e,n){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const c=await this.getConfirmedBlockSignatures(e,"finalized");c.signatures.length>0&&(s.until=c.signatures[c.signatures.length-1].toString())}catch(c){if(c instanceof Error&&c.message.includes("skipped"))continue;throw c}
12let o=await this.getSlot("finalized");for(;!("before"in s)&&(n++,!(n>o));)try{const c=await this.getConfirmedBlockSignatures(n);c.signatures.length>0&&(s.before=c.signatures[c.signatures.length-1].toString())}catch(c){if(c instanceof Error&&c.message.includes("skipped"))continue;throw c}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(c=>c.signature)}async getConfirmedSignaturesForAddress2(t,e,n){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=Z(i,qh);if("error"in o)throw new at(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=Z(i,Kh);if("error"in o)throw new at(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 So({key:t,state:So.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=Ps.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=Z(n,wd);if("error"in s)throw new at(s.error,`airdrop to ${t.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Vn(100);const n=Date.now()-this._blockhashInfo.lastFetch>=oh;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 Vn(Vf/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}=Ut(t),s=this._buildArgs([],e,"base64",n),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=Z(i,Wt(P()));if("error"in o)throw new at(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,n){if("message"in t){const C=t.serialize(),M=bt.Buffer.from(C).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const U=e||{};U.encoding="base64","commitment"in U||(U.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(U.innerInstructions=e.innerInstructions);const D=[M,U],N=await this._rpcRequest("simulateTransaction",D),K=Z(N,Ao);if("error"in K)throw new Error("failed to simulate transaction: "+K.error.message);return K.result}let s;if(t instanceof tn){let _=t;s=new tn,s.feePayer=_.feePayer,s.instructions=t.instructions,s.nonceInfo=_.nonceInfo,s.signatures=_.signatures}else s=tn.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 _=this._disableBlockhashCaching;for(;;){const C=await this._blockhashWithExpiryBlockHeight(_);if(s.lastValidBlockHeight=C.lastValidBlockHeight,s.recentBlockhash=C.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const M=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(M)&&!this._blockhashInfo.transactionSignatures.includes(M)){this._blockhashInfo.simulatedSignatures.push(M);break}else _=!0}}const o=s._compile(),u=o.serialize(),p=s._serialize(u).toString("base64"),g={encoding:"base64",commitment:this.commitment};if(n){const _=(Array.isArray(n)?n:o.nonProgramIds()).map(C=>
12C.toBase58());g.accounts={encoding:"base64",addresses:_}}i&&(g.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(g.innerInstructions=e.innerInstructions);const v=[p,g],S=await this._rpcRequest("simulateTransaction",v),A=Z(S,Ao);if("error"in A){let _;if("data"in A.error&&(_=A.error.data.logs,_&&Array.isArray(_))){const C=`
13    `,M=C+_.join(C);console.error(A.error.message,M)}throw new wo({action:"simulate",signature:"",transactionMessage:A.error.message,logs:_})}return A.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 u=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=u.lastValidBlockHeight,t.recentBlockhash=u.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const c=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(c))o=!0;else{this._blockhashInfo.transactionSignatures.push(c);break}}}const i=t.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(t,e){const n=ye(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],u=await this._rpcRequest("sendTransaction",o),c=Z(u,bd);if("error"in c){let p;throw"data"in c.error&&(p=c.error.data.logs),new wo({action:s?"send":"simulate",signature:"",transactionMessage:c.error.message,logs:p})}return c.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 u=await this._rpcWebSocket.call(o,i);this._setSubscription(n,{...s,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=s.callbacks,await this._updateSubscriptions()}catch(u){if(console.error(`Received ${u instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:u}),!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(u){if(u instanceof Error&&console.error(`${o} error:`,u.message),!e())return;this._setSubscription(n,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}
13))}_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}=Z(t,$h);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,s=xo([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];fe(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}=Ut(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}=Z(t,Hh);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,s){const{commitment:i,config:o}=Ut(n),u=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:Bo(s)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},u)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,n){const 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}=Z(t,xd);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=Z(t,Vh);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}=Z(t,Zh);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}=Z(t,Yh);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,u)=>{if(o.type==="status"){e(o.result,u);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),u=this._makeSubscription({callback:(c,p)=>{e(c,p);try{this.removeSignatureListener(u)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return u}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=Z(t,Xh);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class tr{constructor(t){this._keypair=void 0,this._keypair=t??po()}static generate(){return new tr(po())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const n=t.slice(32,64);if(!e||!e.skipValidation){const s=t.slice(0,32),i=ss(s);for(let o=0;o<32;o++)if(n[o]!==i[o])throw new Error("provided secretKey is invali
13d")}return new tr({publicKey:n,secretKey:t})}static fromSeed(t){const e=ss(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new tr({publicKey:e,secretKey:n})}get publicKey(){return new it(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}Object.freeze({CreateLookupTable:{index:0,layout:rt([ct("instruction"),sr("recentSlot"),St("bumpSeed")])},FreezeLookupTable:{index:1,layout:rt([ct("instruction")])},ExtendLookupTable:{index:2,layout:rt([ct("instruction"),sr(),Ie(At(),Rn(ct(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:rt([ct("instruction")])},CloseLookupTable:{index:4,layout:rt([ct("instruction")])}});new it("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:rt([St("instruction"),ct("units"),ct("additionalFee")])},RequestHeapFrame:{index:1,layout:rt([St("instruction"),ct("bytes")])},SetComputeUnitLimit:{index:2,layout:rt([St("instruction"),ct("units")])},SetComputeUnitPrice:{index:3,layout:rt([St("instruction"),sr("microLamports")])}});new it("ComputeBudget111111111111111111111111111111");rt([St("numSignatures"),St("padding"),qe("signatureOffset"),qe("signatureInstructionIndex"),qe("publicKeyOffset"),qe("publicKeyInstructionIndex"),qe("messageDataOffset"),qe("messageDataSize"),qe("messageInstructionIndex")]);new it("Ed25519SigVerify111111111111111111111111111");Nf.utils.isValidPrivateKey;rt([St("numSignatures"),qe("signatureOffset"),St("signatureInstructionIndex"),qe("ethAddressOffset"),St("ethAddressInstructionIndex"),qe("messageDataOffset"),qe("messageDataSize"),St("messageInstructionIndex"),zt(20,"ethAddress"),zt(64,"signature"),St("recoveryId")]);new it("KeccakSecp256k11111111111111111111111111111");var mc;new it("StakeConfig11111111111111111111111111111111");class yc{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}}mc=yc;yc.default=new mc(0,0,it.default);Object.freeze({Initialize:{index:0,layout:rt([ct("instruction"),Df(),zf()])},Authorize:{index:1,layout:rt([ct("instruction"),At("newAuthorized"),ct("stakeAuthorizationType")])},Delegate:{index:2,layout:rt([ct("instruction")])},Split:{index:3,layout:rt([ct("instruction"),Ue("lamports")])},Withdraw:{index:4,layout:rt([ct("instruction"),Ue("lamports")])},Deactivate:{index:5,layout:rt([ct("instruction")])},Merge:{index:7,layout:rt([ct("instruction")])},AuthorizeWithSeed:{index:8,layout:rt([ct("instruction"),At("newAuthorized"),ct("stakeAuthorizationType"),Zn("authoritySeed"),At("authorityOwner")])}});new it("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:rt([ct("instruction"),qf()])},Authorize:{index:1,layout:rt([ct("instruction"),At("newAuthorized"),ct("voteAuthorizationType")])},Withdraw:{index:3,layout:rt([ct("instruction"),Ue("lamports")])},UpdateValidatorIdentity:{index:4,layout:rt([ct("instruction")])},AuthorizeWithSeed:{index:10,layout:rt([ct("instruction"),Kf()])}});new it("Vote111111111111111111111111111111111111111");new it("Va1idator1nfo111111111111111111111111111111");q({name:H(),website:ut(H()),details:ut(H()),iconUrl:ut(H()),keybaseUsername:ut(H())});new it("Vote111111111111111111111111111111111111111");rt([At("nodePubkey"),At("authorizedWithdrawer"),St("commission"),me(),Ie(rt([me("slot"),ct("confirmationCount")]),Rn(ct(),-8),"votes"),St("rootSlotValid"),me("rootSlot"),me(),Ie(rt([me("epoch"),At("authorizedVoter")]),Rn(ct(),-8),"authorizedVoters"),rt([Ie(rt([At("authorizedPubkey"),me("epochOfLastAuthorizedSwitch"),me("targetEpoch")]),32,"buf"),me("idx"),St("isEmpty")],"priorVoters"),me(),Ie(rt([me("epoch"),me("credits"),me("prevCredits")]),Rn(ct(),-8),"epochCredits"),rt([me("slot"),me("timestamp")],"lastTimestamp")]);const Dn=new it("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new it("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const er=new it("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");new it("So11111111111111111111111111111111111111112");new it("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");const zs=r=>{const t=r.decode.bind(r),e=r.encode.bind(r);return{decode:t,encode:e}};var Ar={};
13Object.defineProperty(Ar,"__esModule",{value:!0});function Sd(r){{const t=Buffer.from(r);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var Bd=Ar.toBigIntLE=Sd;function Ad(r){{const t=r.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}Ar.toBigIntBE=Ad;function _d(r,t){{const e=r.toString(16),n=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return n.reverse(),n}}var kd=Ar.toBufferLE=_d;function Id(r,t){{const e=r.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}Ar.toBufferBE=Id;const Md=r=>t=>{const e=zt(r,t),{encode:n,decode:s}=zs(e),i=e;return i.decode=(o,u)=>{const c=s(o,u);return Bd(Buffer.from(c))},i.encode=(o,u,c)=>{const p=kd(o,r);return n(p,u,c)},i},pr=Md(8),wc=r=>{const t=St(r),{encode:e,decode:n}=zs(t),s=t;return s.decode=(i,o)=>!!n(i,o),s.encode=(i,o,u)=>{const c=Number(i);return e(c,o,u)},s},we=r=>{const t=zt(32,r),{encode:e,decode:n}=zs(t),s=t;return s.decode=(i,o)=>{const u=n(i,o);return new it(u)},s.encode=(i,o,u)=>{const c=i.toBuffer();return e(c,o,u)},s};class _r extends Error{constructor(t){super(t)}}class Rd extends _r{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class Cd extends _r{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class Gi extends _r{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class Ld extends _r{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class Nd extends _r{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var us;(function(r){r[r.InitializeMint=0]="InitializeMint",r[r.InitializeAccount=1]="InitializeAccount",r[r.InitializeMultisig=2]="InitializeMultisig",r[r.Transfer=3]="Transfer",r[r.Approve=4]="Approve",r[r.Revoke=5]="Revoke",r[r.SetAuthority=6]="SetAuthority",r[r.MintTo=7]="MintTo",r[r.Burn=8]="Burn",r[r.CloseAccount=9]="CloseAccount",r[r.FreezeAccount=10]="FreezeAccount",r[r.ThawAccount=11]="ThawAccount",r[r.TransferChecked=12]="TransferChecked",r[r.ApproveChecked=13]="ApproveChecked",r[r.MintToChecked=14]="MintToChecked",r[r.BurnChecked=15]="BurnChecked",r[r.InitializeAccount2=16]="InitializeAccount2",r[r.SyncNative=17]="SyncNative",r[r.InitializeAccount3=18]="InitializeAccount3",r[r.InitializeMultisig2=19]="InitializeMultisig2",r[r.InitializeMint2=20]="InitializeMint2",r[r.GetAccountDataSize=21]="GetAccountDataSize",r[r.InitializeImmutableOwner=22]="InitializeImmutableOwner",r[r.AmountToUiAmount=23]="AmountToUiAmount",r[r.UiAmountToAmount=24]="UiAmountToAmount",r[r.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",r[r.TransferFeeExtension=26]="TransferFeeExtension",r[r.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",r[r.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",r[r.Reallocate=29]="Reallocate",r[r.MemoTransferExtension=30]="MemoTransferExtension",r[r.CreateNativeMint=31]="CreateNativeMint",r[r.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",r[r.InterestBearingMintExtension=33]="InterestBearingMintExtension",r[r.CpiGuardExtension=34]="CpiGuardExtension",r[r.InitializePermanentDelegate=35]="InitializePermanentDelegate",r[r.TransferHookExtension=36]="TransferHookExtension",r[r.MetadataPointerExtension=39]="MetadataPointerExtension",r[r.GroupPointerExtension=40]="GroupPointerExtension",r[r.GroupMemberPointerExtension=41]="GroupMemberPointerExtension",r[r.ScaledUiAmountExtension=43]="ScaledUiAmountExtension",r[r.PausableExtension=44]="PausableExtension"})(us||(us={}));var ls;(function(r){r[r.Uninitialized=0]="Uninitialized",r[r.Mint=1]="Mint",r[r.Account=2]="Account"})(ls||(ls={}));const Td=1,Ud=rt([St("m"),St("n"),wc("isInitialized"),we("signer1"),we("signer2"),we("signer3"),we("signer4"),we("signer5"),we("signer6"),we("signer7"),we("signer8"),we("signer9"),we("signer10"),we("signer11")]),Pd=Ud.span;var Mo;(function(r){r[r.Uninitialized=0]="Uninitialized",r[r.Initialized=1]="Initialized",r[r.Frozen=2]="Frozen"})(Mo||(Mo={}));const Fd=rt([we("mint"),we("owner"),pr("amount"),ct("delegateOption"),we("delegate"),St("state"),ct("isNativeOption"),pr("isNative"),pr("delegatedAmount"),ct("closeAuthorityOption"),we("closeAuthority")]),Zi=Fd.span;function Od(r,t,e){if(e.length){r.push({pubkey:t,isSigner:!1,isWritable:!1});for(const n of e)r.push({pubkey:n instanceof it?n:n.publicKey,isSigner:!0,isWritable:!1})}else r.push({pubkey:t,isSigner:!0,isWritable:!1});return r}const Ro=rt([St("instruction"),pr("amount"),St("decimals")]);function Dd(r,t,e,n,s,i,o=[],u=Dn){const c=Od([{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!1,isWritable:!0}],n,o),p=Buffer.alloc(Ro.span);return Ro.encode({instruction:us.TransferChecked,amount:BigInt(s),decimals:i},p),new Te({keys:c,programId:u,data:p})}const bc=rt([ct("mintAuthorityOption"),we("mintAuthority"),pr("supply"),St("decimals"),wc("isInitialized"),ct("freezeAuthorityOption"),we("freezeAuthority")]),Yi=bc.span;async function zd(r,t,e,n=Dn){const s=await r.getAccountInfo(t,e);return qd(t,s,n)}function qd(r,t,e=Dn){if(!t)throw new Rd;if(!t.owner.equals(e))throw new Cd;if(t.data.length<Yi)throw new Gi;const n=bc.decode(t.data.slice(0,Yi));let s=Buffer.alloc(0);if(t.data.length>Yi){if(t.data.length<=Zi)throw new Gi;if(t.data.length===Pd)throw new Gi;if(t.data[Zi]!=ls.Mint)throw new Ld;s=t.data.slice(Zi+Td)}return{address:r,mintAuthority:n.mintAuthorityOption?n.mintAuthority:null,supply:n.supply,decimals:n.decimals,isInitialized:n.isInitialized,freezeAuthority:n.freezeAuthorityOption?n.freezeAuthority:null,tlvData:s}}
13function Co(r,t,e=!1,n=Dn,s=er){if(!e&&!it.isOnCurve(t.toBuffer()))throw new Nd;const[i]=it.findProgramAddressSync([t.toBuffer(),n.toBuffer(),r.toBuffer()],s);return i}function Kd(r,t,e,n,s=Dn,i=er){return $d(r,t,e,n,Buffer.alloc(0),s,i)}function $d(r,t,e,n,s,i=Dn,o=er){const u=[{pubkey:r,isSigner:!0,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:yr.programId,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1}];return new Te({keys:u,programId:o,data:s})}var jd=Object.defineProperty,Yr=Object.getOwnPropertySymbols,vc=Object.prototype.hasOwnProperty,xc=Object.prototype.propertyIsEnumerable,Lo=(r,t,e)=>t in r?jd(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fs=(r,t)=>{for(var e in t||(t={}))vc.call(t,e)&&Lo(r,e,t[e]);if(Yr)for(var e of Yr(t))xc.call(t,e)&&Lo(r,e,t[e]);return r},hs=(r,t)=>{var e={};for(var n in r)vc.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&Yr)for(var n of Yr(r))t.indexOf(n)<0&&xc.call(r,n)&&(e[n]=r[n]);return e};/**
14 * @license QR Code generator library (TypeScript)
15 * Copyright (c) Project Nayuki.
16 * SPDX-License-Identifier: MIT
17 */var Ln;(r=>{const t=class Bt{constructor(c,p,g,v){if(this.version=c,this.errorCorrectionLevel=p,this.modules=[],this.isFunction=[],c<Bt.MIN_VERSION||c>Bt.MAX_VERSION)throw new RangeError("Version value out of range");if(v<-1||v>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let S=[];for(let _=0;_<this.size;_++)S.push(!1);for(let _=0;_<this.size;_++)this.modules.push(S.slice()),this.isFunction.push(S.slice());this.drawFunctionPatterns();const A=this.addEccAndInterleave(g);if(this.drawCodewords(A),v==-1){let _=1e9;for(let C=0;C<8;C++){this.applyMask(C),this.drawFormatBits(C);const M=this.getPenaltyScore();M<_&&(v=C,_=M),this.applyMask(C)}}s(0<=v&&v<=7),this.mask=v,this.applyMask(v),this.drawFormatBits(v),this.isFunction=[]}static encodeText(c,p){const g=r.QrSegment.makeSegments(c);return Bt.encodeSegments(g,p)}static encodeBinary(c,p){const g=r.QrSegment.makeBytes(c);return Bt.encodeSegments([g],p)}static encodeSegments(c,p,g=1,v=40,S=-1,A=!0){if(!(Bt.MIN_VERSION<=g&&g<=v&&v<=Bt.MAX_VERSION)||S<-1||S>7)throw new RangeError("Invalid value");let _,C;for(_=g;;_++){const N=Bt.getNumDataCodewords(_,p)*8,K=o.getTotalBits(c,_);if(K<=N){C=K;break}if(_>=v)throw new RangeError("Data too long")}for(const N of[Bt.Ecc.MEDIUM,Bt.Ecc.QUARTILE,Bt.Ecc.HIGH])A&&C<=Bt.getNumDataCodewords(_,N)*8&&(p=N);let M=[];for(const N of c){e(N.mode.modeBits,4,M),e(N.numChars,N.mode.numCharCountBits(_),M);for(const K of N.getData())M.push(K)}s(M.length==C);const U=Bt.getNumDataCodewords(_,p)*8;s(M.length<=U),e(0,Math.min(4,U-M.length),M),e(0,(8-M.length%8)%8,M),s(M.length%8==0);for(let N=236;M.length<U;N^=253)e(N,8,M);let D=[];for(;D.length*8<M.length;)D.push(0);return M.forEach((N,K)=>D[K>>>3]|=N<<7-(K&7)),new Bt(_,p,D,S)}getModule(c,p){return 0<=c&&c<this.size&&0<=p&&p<this.size&&this.modules[p][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let g=0;g<this.size;g++)this.setFunctionModule(6,g,g%2==0),this.setFunctionModule(g,6,g%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),p=c.length;for(let g=0;g<p;g++)for(let v=0;v<p;v++)g==0&&v==0||g==0&&v==p-1||g==p-1&&v==0||this.drawAlignmentPattern(c[g],c[v]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const p=this.errorCorrectionLevel.formatBits<<3|c;let g=p;for(let S=0;S<10;S++)g=g<<1^(g>>>9)*1335;const v=(p<<10|g)^21522;s(v>>>15==0);for(let S=0;S<=5;S++)this.setFunctionModule(8,S,n(v,S));this.setFunctionModule(8,7,n(v,6)),this.setFunctionModule(8,8,n(v,7)),this.setFunctionModule(7,8,n(v,8));for(let S=9;S<15;S++)this.setFunctionModule(14-S,8,n(v,S));for(let S=0;S<8;S++)this.setFunctionModule(this.size-1-S,8,n(v,S));for(let S=8;S<15;S++)this.setFunctionModule(8,this.size-15+S,n(v,S));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let g=0;g<12;g++)c=c<<1^(c>>>11)*7973;const p=this.version<<12|c;s(p>>>18==0);for(let g=0;g<18;g++){const v=n(p,g),S=this.size-11+g%3,A=Math.floor(g/3);this.setFunctionModule(S,A,v),this.setFunctionModule(A,S,v)}}drawFinderPattern(c,p){for(let g=-4;g<=4;g++)for(let v=-4;v<=4;v++){const S=Math.max(Math.abs(v),Math.abs(g)),A=c+v,_=p+g;0<=A&&A<this.size&&0<=_&&_<this.size&&this.setFunctionModule(A,_,S!=2&&S!=4)}}drawAlignmentPattern(c,p){for(let g=-2;g<=2;g++)for(let v=-2;v<=2;v++)this.setFunctionModule(c+v,p+g,Math.max(Math.abs(v),Math.abs(g))!=1)}setFunctionModule(c,p,g){this.modules[p][c]=g,this.isFunction[p][c]=!0}addEccAndInterleave(c){const p=this.version,g=this.errorCorrectionLevel;if(c.length!=Bt.getNumDataCodewords(p,g))throw new RangeError("Invalid argument");const v=Bt.NUM_ERROR_CORRECTION_BLOCKS[g.ordinal][p],S=Bt.ECC_CODEWORDS_PER_BLOCK[g.ordinal][p],A=Math.floor(Bt.getNumRawDataModules(p)/8),_=v-A%v,C=Math.floor(A/v);let M=[];const U=Bt.reedSolomonComputeDivisor(S);for(let N=0,K=0;N<v;N++){let V=c.slice(K,K+C-S+(N<_?0:1));K+=V.length;const nt=Bt.reedSolomonComputeRemainder(V,U);N<_&&V.push(0),M.push(V.concat(nt))}let D=[];for(let N=0;N<M[0].length;
17N++)M.forEach((K,V)=>{(N!=C-S||V>=_)&&D.push(K[N])});return s(D.length==A),D}drawCodewords(c){if(c.length!=Math.floor(Bt.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let p=0;for(let g=this.size-1;g>=1;g-=2){g==6&&(g=5);for(let v=0;v<this.size;v++)for(let S=0;S<2;S++){const A=g-S,C=(g+1&2)==0?this.size-1-v:v;!this.isFunction[C][A]&&p<c.length*8&&(this.modules[C][A]=n(c[p>>>3],7-(p&7)),p++)}}s(p==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let p=0;p<this.size;p++)for(let g=0;g<this.size;g++){let v;switch(c){case 0:v=(g+p)%2==0;break;case 1:v=p%2==0;break;case 2:v=g%3==0;break;case 3:v=(g+p)%3==0;break;case 4:v=(Math.floor(g/3)+Math.floor(p/2))%2==0;break;case 5:v=g*p%2+g*p%3==0;break;case 6:v=(g*p%2+g*p%3)%2==0;break;case 7:v=((g+p)%2+g*p%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[p][g]&&v&&(this.modules[p][g]=!this.modules[p][g])}}getPenaltyScore(){let c=0;for(let S=0;S<this.size;S++){let A=!1,_=0,C=[0,0,0,0,0,0,0];for(let M=0;M<this.size;M++)this.modules[S][M]==A?(_++,_==5?c+=Bt.PENALTY_N1:_>5&&c++):(this.finderPenaltyAddHistory(_,C),A||(c+=this.finderPenaltyCountPatterns(C)*Bt.PENALTY_N3),A=this.modules[S][M],_=1);c+=this.finderPenaltyTerminateAndCount(A,_,C)*Bt.PENALTY_N3}for(let S=0;S<this.size;S++){let A=!1,_=0,C=[0,0,0,0,0,0,0];for(let M=0;M<this.size;M++)this.modules[M][S]==A?(_++,_==5?c+=Bt.PENALTY_N1:_>5&&c++):(this.finderPenaltyAddHistory(_,C),A||(c+=this.finderPenaltyCountPatterns(C)*Bt.PENALTY_N3),A=this.modules[M][S],_=1);c+=this.finderPenaltyTerminateAndCount(A,_,C)*Bt.PENALTY_N3}for(let S=0;S<this.size-1;S++)for(let A=0;A<this.size-1;A++){const _=this.modules[S][A];_==this.modules[S][A+1]&&_==this.modules[S+1][A]&&_==this.modules[S+1][A+1]&&(c+=Bt.PENALTY_N2)}let p=0;for(const S of this.modules)p=S.reduce((A,_)=>A+(_?1:0),p);const g=this.size*this.size,v=Math.ceil(Math.abs(p*20-g*10)/g)-1;return s(0<=v&&v<=9),c+=v*Bt.PENALTY_N4,s(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,p=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let g=[6];for(let v=this.size-7;g.length<c;v-=p)g.splice(1,0,v);return g}}static getNumRawDataModules(c){if(c<Bt.MIN_VERSION||c>Bt.MAX_VERSION)throw new RangeError("Version number out of range");let p=(16*c+128)*c+64;if(c>=2){const g=Math.floor(c/7)+2;p-=(25*g-10)*g-55,c>=7&&(p-=36)}return s(208<=p&&p<=29648),p}static getNumDataCodewords(c,p){return Math.floor(Bt.getNumRawDataModules(c)/8)-Bt.ECC_CODEWORDS_PER_BLOCK[p.ordinal][c]*Bt.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let p=[];for(let v=0;v<c-1;v++)p.push(0);p.push(1);let g=1;for(let v=0;v<c;v++){for(let S=0;S<p.length;S++)p[S]=Bt.reedSolomonMultiply(p[S],g),S+1<p.length&&(p[S]^=p[S+1]);g=Bt.reedSolomonMultiply(g,2)}return p}static reedSolomonComputeRemainder(c,p){let g=p.map(v=>0);for(const v of c){const S=v^g.shift();g.push(0),p.forEach((A,_)=>g[_]^=Bt.reedSolomonMultiply(A,S))}return g}static reedSolomonMultiply(c,p){if(c>>>8||p>>>8)throw new RangeError("Byte out of range");let g=0;for(let v=7;v>=0;v--)g=g<<1^(g>>>7)*285,g^=(p>>>v&1)*c;return s(g>>>8==0),g}finderPenaltyCountPatterns(c){const p=c[1];s(p<=this.size*3);const g=p>0&&c[2]==p&&c[3]==p*3&&c[4]==p&&c[5]==p;return(g&&c[0]>=p*4&&c[6]>=p?1:0)+(g&&c[6]>=p*4&&c[0]>=p?1:0)}finderPenaltyTerminateAndCount(c,p,g){return c&&(this.finderPenaltyAddHistory(p,g),p=0),p+=this.size,this.finderPenaltyAddHistory(p,g),this.finderPenaltyCountPatterns(g)}finderPenaltyAddHistory(c,p){p[0]==0&&(c+=this.size),p.pop(),p.unshift(c)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=t;
17function e(u,c,p){if(c<0||c>31||u>>>c)throw new RangeError("Value out of range");for(let g=c-1;g>=0;g--)p.push(u>>>g&1)}function n(u,c){return(u>>>c&1)!=0}function s(u){if(!u)throw new Error("Assertion error")}const i=class $t{constructor(c,p,g){if(this.mode=c,this.numChars=p,this.bitData=g,p<0)throw new RangeError("Invalid argument");this.bitData=g.slice()}static makeBytes(c){let p=[];for(const g of c)e(g,8,p);return new $t($t.Mode.BYTE,c.length,p)}static makeNumeric(c){if(!$t.isNumeric(c))throw new RangeError("String contains non-numeric characters");let p=[];for(let g=0;g<c.length;){const v=Math.min(c.length-g,3);e(parseInt(c.substring(g,g+v),10),v*3+1,p),g+=v}return new $t($t.Mode.NUMERIC,c.length,p)}static makeAlphanumeric(c){if(!$t.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let p=[],g;for(g=0;g+2<=c.length;g+=2){let v=$t.ALPHANUMERIC_CHARSET.indexOf(c.charAt(g))*45;v+=$t.ALPHANUMERIC_CHARSET.indexOf(c.charAt(g+1)),e(v,11,p)}return g<c.length&&e($t.ALPHANUMERIC_CHARSET.indexOf(c.charAt(g)),6,p),new $t($t.Mode.ALPHANUMERIC,c.length,p)}static makeSegments(c){return c==""?[]:$t.isNumeric(c)?[$t.makeNumeric(c)]:$t.isAlphanumeric(c)?[$t.makeAlphanumeric(c)]:[$t.makeBytes($t.toUtf8ByteArray(c))]}static makeEci(c){let p=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)e(c,8,p);else if(c<16384)e(2,2,p),e(c,14,p);else if(c<1e6)e(6,3,p),e(c,21,p);else throw new RangeError("ECI assignment value out of range");return new $t($t.Mode.ECI,0,p)}static isNumeric(c){return $t.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return $t.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,p){let g=0;for(const v of c){const S=v.mode.numCharCountBits(p);if(v.numChars>=1<<S)return 1/0;g+=4+S+v.bitData.length}return g}static toUtf8ByteArray(c){c=encodeURI(c);let p=[];for(let g=0;g<c.length;g++)c.charAt(g)!="%"?p.push(c.charCodeAt(g)):(p.push(parseInt(c.substring(g+1,g+3),16)),g+=2);return p}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(Ln||(Ln={}));(r=>{(t=>{const e=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};e.LOW=new e(0,1),e.MEDIUM=new e(1,0),e.QUARTILE=new e(2,3),e.HIGH=new e(3,2),t.Ecc=e})(r.QrCode||(r.QrCode={}))})(Ln||(Ln={}));(r=>{(t=>{const e=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};e.NUMERIC=new e(1,[10,12,14]),e.ALPHANUMERIC=new e(2,[9,11,13]),e.BYTE=new e(4,[8,16,16]),e.KANJI=new e(8,[8,10,12]),e.ECI=new e(7,[0,0,0]),t.Mode=e})(r.QrSegment||(r.QrSegment={}))})(Ln||(Ln={}));var Yn=Ln;/**
18 * @license qrcode.react
19 * Copyright (c) Paul O'Shannessy
20 * SPDX-License-Identifier: ISC
21 */var Hd={L:Yn.QrCode.Ecc.LOW,M:Yn.QrCode.Ecc.MEDIUM,Q:Yn.QrCode.Ecc.QUARTILE,H:Yn.QrCode.Ecc.HIGH},Ec=128,Sc="L",Bc="#FFFFFF",Ac="#000000",_c=!1,kc=1,Wd=4,Vd=0,Gd=.1;function Ic(r,t=0){const e=[];return r.forEach(function(n,s){let i=null;
21n.forEach(function(o,u){if(!o&&i!==null){e.push(`M${i+t} ${s+t}h${u-i}v1H${i+t}z`),i=null;return}if(u===n.length-1){if(!o)return;i===null?e.push(`M${u+t},${s+t} h1v1H${u+t}z`):e.push(`M${i+t},${s+t} h${u+1-i}v1H${i+t}z`);return}o&&i===null&&(i=u)})}),e.join("")}function Mc(r,t){return r.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((s,i)=>i<t.x||i>=t.x+t.w?s:!1))}function Zd(r,t,e,n){if(n==null)return null;const s=r.length+e*2,i=Math.floor(t*Gd),o=s/t,u=(n.width||i)*o,c=(n.height||i)*o,p=n.x==null?r.length/2-u/2:n.x*o,g=n.y==null?r.length/2-c/2:n.y*o,v=n.opacity==null?1:n.opacity;let S=null;if(n.excavate){let _=Math.floor(p),C=Math.floor(g),M=Math.ceil(u+p-_),U=Math.ceil(c+g-C);S={x:_,y:C,w:M,h:U}}const A=n.crossOrigin;return{x:p,y:g,h:c,w:u,excavation:S,opacity:v,crossOrigin:A}}function Yd(r,t){return t!=null?Math.max(Math.floor(t),0):r?Wd:Vd}function Rc({value:r,level:t,minVersion:e,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:u}){let c=de.useMemo(()=>{const _=(Array.isArray(r)?r:[r]).reduce((C,M)=>(C.push(...Yn.QrSegment.makeSegments(M)),C),[]);return Yn.QrCode.encodeSegments(_,Hd[t],e,void 0,void 0,u)},[r,t,e,u]);const{cells:p,margin:g,numCells:v,calculatedImageSettings:S}=de.useMemo(()=>{let A=c.getModules();const _=Yd(n,s),C=A.length+_*2,M=Zd(A,o,_,i);return{cells:A,margin:_,numCells:C,calculatedImageSettings:M}},[c,o,i,n,s]);return{qrcode:c,margin:g,cells:p,numCells:v,calculatedImageSettings:S}}var Xd=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Jd=de.forwardRef(function(t,e){const n=t,{value:s,size:i=Ec,level:o=Sc,bgColor:u=Bc,fgColor:c=Ac,includeMargin:p=_c,minVersion:g=kc,boostLevel:v,marginSize:S,imageSettings:A}=n,C=hs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:M}=C,U=hs(C,["style"]),D=A==null?void 0:A.src,N=de.useRef(null),K=de.useRef(null),V=de.useCallback(a=>{N.current=a,typeof e=="function"?e(a):e&&(e.current=a)},[e]),[nt,lt]=de.useState(!1),{margin:st,cells:z,numCells:et,calculatedImageSettings:W}=Rc({value:s,level:o,minVersion:g,boostLevel:v,includeMargin:p,marginSize:S,imageSettings:A,size:i});de.useEffect(()=>{if(N.current!=null){const a=N.current,f=a.getContext("2d");if(!f)return;let m=z;const x=K.current,E=W!=null&&x!==null&&x.complete&&x.naturalHeight!==0&&x.naturalWidth!==0;E&&W.excavation!=null&&(m=Mc(z,W.excavation));const I=window.devicePixelRatio||1;a.height=a.width=i*I;const R=i/et*I;f.scale(R,R),f.fillStyle=u,f.fillRect(0,0,et,et),f.fillStyle=c,Xd?f.fill(new Path2D(Ic(m,st))):z.forEach(function(b,h){b.forEach(function(k,G){k&&f.fillRect(G+st,h+st,1,1)})}),W&&(f.globalAlpha=W.opacity),E&&f.drawImage(x,W.x+st,W.y+st,W.w,W.h)}}),de.useEffect(()=>{lt(!1)},[D]);const Q=fs({height:i,width:i},M);let w=null;return D!=null&&(w=de.createElement("img",{src:D,key:D,style:{display:"none"},onLoad:()=>{lt(!0)},ref:K,crossOrigin:W==null?void 0:W.crossOrigin})),de.createElement(de.Fragment,null,de.createElement("canvas",fs({style:Q,height:i,width:i,ref:V,role:"img"},U)),w)});Jd.displayName="QRCodeCanvas";var Cc=de.forwardRef(function(t,e){const n=t,{value:s,size:i=Ec,level:o=Sc,bgColor:u=Bc,fgColor:c=Ac,includeMargin:p=_c,minVersion:g=kc,boostLevel:v,title:S,marginSize:A,imageSettings:_}=n,C=hs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:M,cells:U,numCells:D,calculatedImageSettings:N}=Rc({value:s,level:o,minVersion:g,boostLevel:v,includeMargin:p,marginSize:A,imageSettings:_,size:i});let K=U,V=null;_!=null&&N!=null&&(N.excavation!=null&&(K=Mc(U,N.excavation)),V=de.createElement("image",{href:_.src,height:N.h,width:N.w,x:N.x+M,y:N.y+M,preserveAspectRatio:"none",opacity:N.opacity,crossOrigin:N.crossOrigin}));const nt=Ic(K,M);return de.createElement("svg",fs({height:i,width:i,viewBox:`0 0 ${D} ${D}`,ref:e,role:"img"},C),!!S&&de.createElement("title",null,S),de.createElement("path",{fill:u,d:`M0,0 h${D}v${D}H0z`,shapeRendering:"crispEdges"}),de.createElement("path",{fill:c,d:nt,shapeRendering:"crispEdges"}),V)});Cc.displayName="QRCodeSVG";const wn=[{symbol:"SOL",name:"Wrapped SOL",mint:"So11111111111111111111111111111111111111112"},{symbol:"USDC",name:"USD Coin",mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"},{symbol:"USDT",name:"Tether",mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"},{symbol:"JUP",name:"Jupiter",mint:"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"},{symbol:"BONK",name:"Bonk",mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"},{symbol:"WIF",name:"dogwifhat",mint:"EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"},{symbol:"JITOSOL",name:"Jito Staked SOL",mint:"J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn"},{symbol:"RAY",name:"Raydium",mint:"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"},{symbol:"PYTH",name:"Pyth Network",mint:"HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3"},{symbol:"ORCA",name:"Orca",mint:"orcaEKTdK7LKz57vaAYr9QeNsVEPfiu6QeMU1kektZE"}
21],dr=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/,Lc=1,Xe="__custom_mint__",No=typeof window>"u"?"https://api.mainnet-beta.solana.com":`${window.location.origin}/api/solana-rpc/`,Hn=Dn,Qd="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",t0=new Map(Array.from(Qd).map((r,t)=>[r,t])),Sn=r=>{const t=r==null?void 0:r.trim();return t?wn.find(e=>e.mint===t)||{symbol:"CUSTOM",name:"Custom Mint",mint:t}:null},To=r=>`${r.symbol} - ${r.name} (${r.mint.slice(0,6)}...${r.mint.slice(-4)})`,e0=r=>`Wallet mint (${r.slice(0,6)}...${r.slice(-4)})`,n0=r=>{if(!r)return new Uint8Array;const t=[0];for(const n of r){const s=t0.get(n);if(s===void 0)throw new Error("Private key is not valid Base58.");let i=s;for(let o=0;o<t.length;o+=1){const u=t[o]*58+i;t[o]=u&255,i=u>>8}for(;i>0;)t.push(i&255),i>>=8}let e=0;for(;e<r.length&&r[e]==="1";)t.push(0),e+=1;return Uint8Array.from(t.reverse())},r0=r=>{const t=r.trim();if(!t)throw new Error("Enter a private key first.");if(t.startsWith("[")){let n;try{n=JSON.parse(t)}catch{throw new Error("JSON private key format is invalid.")}if(!Array.isArray(n))throw new Error("JSON private key must be an array of bytes.");const s=Uint8Array.from(n);if(s.length===64||s.length===32)return s;throw new Error("Private key array must be 32 or 64 bytes.")}const e=n0(t);if(e.length===64||e.length===32)return e;throw new Error("Base58 private key must decode to 32 or 64 bytes.")},ds=r=>{const t=r0(r);return t.length===64?tr.fromSecretKey(t):tr.fromSeed(t)},i0=(r,t)=>{const e=r.trim();if(!e)throw new Error(t);return dr.test(e)?new it(e):ds(e).publicKey},s0=(r,t)=>{const e=r.trim();if(!/^\d+(\.\d+)?$/.test(e))throw new Error("Amount must be numeric.");const[n,s=""]=e.split(".");if(s.length>t)throw new Error(`Amount has too many decimal places for this mint (max ${t}).`);const i=`${n}${s.padEnd(t,"0")}`.replace(/^0+(?=\d)/,""),o=BigInt(i||"0");if(o<=0n)throw new Error("Amount must be greater than 0.");return o},o0=r=>new Promise(t=>setTimeout(t,r)),a0=r=>!!(r&&!r.err&&(r.confirmationStatus==="confirmed"||r.confirmationStatus==="finalized")),c0=async(r,t,e=2e4)=>{var s;const n=Date.now();for(;Date.now()-n<=e;){const o=((s=(await r.getSignatureStatuses([t],{searchTransactionHistory:!0})).value)==null?void 0:s[0])||null;if(o!=null&&o.err)throw new Error(`Transaction failed on-chain: ${JSON.stringify(o.err)}`);if(a0(o))return o;await o0(1200)}return null},Nc=r=>btoa(unescape(encodeURIComponent(r))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""),u0=r=>{const t=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(r.length/4)*4,"=");return decodeURIComponent(escape(atob(t)))},Ur=r=>{if(!r)return null;try{const t=u0(r),e=JSON.parse(t);return(e==null?void 0:e.type)!=="quiqrpay-crypto-terminal"||(e==null?void 0:e.version)!==Lc?null:e}catch{return null}},Xi=r=>{const t=r||window.location.hash;return t.startsWith("#")&&new URLSearchParams(t.slice(1)).get("pay")||""},l0=r=>{const t=Nc(JSON.stringify(r));return`${window.location.origin}/crypto-sender#pay=${t}`};function w0(){const[r,t]=Tt.useState({privateKey:"",amount:"",target:"",mint:wn[0].mint,customMint:""}),[e,n]=Tt.useState(""),[s,i]=Tt.useState(!1),[o,u]=Tt.useState(!1),[c,p]=Tt.useState(""),[g,v]=Tt.useState(""),[S,A]=Tt.useState(!1),[_,C]=Tt.useState([]),[M,U]=Tt.useState({receiverPublicAddress:"",amount:"",mint:wn[0].mint,customMint:"",note:""}),[D,N]=Tt.useState(""),[K,V]=Tt.useState(""),[nt,lt]=Tt.useState(""),[st,z]=Tt.useState(""),[et,W]=Tt.useState(!1),[Q,w]=Tt.useState(""),[a,f]=Tt.useState(""),[m,x]=Tt.useState(""),[E,I]=Tt.useState(()=>Ur(Xi(window.location.hash))),R=Tt.useMemo(()=>{const tt=new Set(wn.map(ot=>ot.mint));return _.filter(ot=>!tt.has(ot))},[_]),b=Tt.useMemo(()=>r.mint===Xe?r.customMint.trim():r.mint,[r.mint,r.customMint]),h=Tt.useMemo(()=>M.mint===Xe?M.customMint.trim():M.mint,[M.mint,M.customMint]),k=Tt.useMemo(()=>r.mint===Xe?Sn(r.customMint)||{symbol:"CUSTOM",name:"Custom Mint",mint:r.customMint.trim()||"Not set"}:Sn(b)||wn[0],[r.mint,r.customMint,b]),G=Tt.useMemo(()=>M.mint===Xe?Sn(M.customMint)||{symbol:"CUSTOM",name:"Custom Mint",mint:M.customMint.trim()||"Not set"}:Sn(h)||wn[0],[M.mint,M.customMint,h]),j=Tt.useMemo(()=>Sn(E==null?void 0:E.mint)||{symbol:(E==null?void 0:E.mintSymbol)||"CUSTOM",name:"Custom Mint",mint:(E==null?void 0:E.mint)||""},[E==null?void 0:E.mint]);Tt.useEffect(()=>{typeof window<"u"&&typeof window.Buffer>"u"&&(window.Buffer=bt.Buffer)},[]),Tt.useEffect(()=>(document.body.classList.add("crypto-sender-headerless"),()=>{document.body.classList.remove("crypto-sender-headerless")}),[]),Tt.useEffect(()=>{const tt=()=>{const ot=Ur(Xi(window.location.hash));I(ot),w((ot==null?void 0:ot.amount)||""),f(ot?"Loaded payment request from shared link/QR.":"")};return window.addEventListener("hashchange",tt),tt(),()=>{window.removeEventListener("hashchange",tt)}},[]);const Y=tt=>{const{name:ot,value:yt}=tt.target;t(dt=>ot==="mint"?{...dt,mint:yt,customMint:yt===Xe?dt.customMint:""}:{...dt,[ot]:yt})}
21,gt=tt=>{const{name:ot,value:yt}=tt.target;U(dt=>ot==="mint"?{...dt,mint:yt,customMint:yt===Xe?dt.customMint:""}:{...dt,[ot]:yt})},ht=async()=>{var tt,ot;if(!r.privateKey.trim()){v("Enter a private key first, then load wallet mints.");return}A(!0),v("Loading wallet mints from Solana RPC...");try{const dt=ds(r.privateKey).publicKey,Fe=await new Io(No,"confirmed").getParsedTokenAccountsByOwner(dt,{programId:Hn}),wt=Array.from(new Set(Fe.value.map(_t=>{var kt,Nt;const Dt=_t.account.data;return typeof Dt!="object"?"":((Nt=(kt=Dt==null?void 0:Dt.parsed)==null?void 0:kt.info)==null?void 0:Nt.mint)||""}).filter(_t=>dr.test(_t))));C(wt),v(wt.length>0?`Detected ${wt.length} wallet mint${wt.length===1?"":"s"} for ${dt.toBase58().slice(0,6)}...${dt.toBase58().slice(-4)}.`:`No SPL token mints found for ${dt.toBase58().slice(0,6)}...${dt.toBase58().slice(-4)}.`)}catch(yt){C([]);const dt=(tt=yt==null?void 0:yt.message)!=null&&tt.includes("Failed to fetch")||(ot=yt==null?void 0:yt.message)!=null&&ot.includes("403")?"Could not reach Solana RPC. Check /api/solana-rpc proxy and nginx config.":(yt==null?void 0:yt.message)||"Could not load wallet mints from private key.";v(dt)}finally{A(!1)}},ft=async tt=>{var Mt,Fe;tt.preventDefault();const ot=Number.parseFloat(r.amount),yt=b;if(!Number.isFinite(ot)||ot<=0){n("Enter a valid amount greater than 0.");return}if(!r.privateKey.trim()){n("Private key is required for your local trigger payload.");return}if(!r.target.trim()){n("Target address (public or private) is required.");return}if(!yt||!dr.test(yt)){n("Provide a valid mint address (popular, wallet, or custom).");return}const dt=Sn(yt)||{symbol:"CUSTOM",name:"Custom Mint",mint:yt};i(!0),n("Preparing transaction and signing locally...");try{const wt=ds(r.privateKey),_t=i0(r.target,"Target address (public or private) is required."),Dt=new it(yt),kt=new Io(No,"confirmed"),Nt=await zd(kt,Dt,"confirmed",Hn),Ne=s0(r.amount,Nt.decimals),Pt=Co(Dt,wt.publicKey,!1,Hn,er),y=Co(Dt,_t,!1,Hn,er);if(!await kt.getAccountInfo(Pt,"confirmed"))throw new Error("Sender wallet does not have a token account for this mint.");const d=await kt.getAccountInfo(y,"confirmed"),B=new tn;d||B.add(Kd(wt.publicKey,y,_t,Dt,Hn,er)),B.add(Dd(Pt,Dt,y,wt.publicKey,Ne,Nt.decimals,[],Hn));const L=await kt.getLatestBlockhash("confirmed");B.recentBlockhash=L.blockhash,B.feePayer=wt.publicKey,B.sign(wt);const T=await kt.sendRawTransaction(B.serialize(),{skipPreflight:!1,maxRetries:3});if(n(`Submitted transaction ${T}. Waiting for on-chain confirmation...`),!await c0(kt,T,45e3))throw new Error(`Transaction ${T} was sent but not confirmed within 45 seconds. It may still finalize shortly; check the signature on a Solana explorer.`);const vt={privateKey:r.privateKey.trim(),amount:ot.toString(),target:_t.toBase58(),mint:yt,mintSymbol:dt.symbol,mintName:dt.name,signature:T,triggeredAt:new Date().toISOString()};window.dispatchEvent(new CustomEvent("quiqrpay:crypto-sender-trigger",{detail:vt})),p(vt.triggeredAt),n(`Sent ${r.amount.trim()} ${dt.symbol} on-chain. Tx: ${T}. No server storage was used.`)}catch(wt){const _t=(Mt=wt==null?void 0:wt.message)!=null&&Mt.includes("Failed to fetch")||(Fe=wt==null?void 0:wt.message)!=null&&Fe.includes("403")?"Could not reach Solana RPC. Check /api/solana-rpc proxy and nginx config.":(wt==null?void 0:wt.message)||"Could not submit on-chain transfer.";n(_t)}finally{i(!1)}},Ot=tt=>{tt.preventDefault();const ot=Number.parseFloat(M.amount),yt=h;if(!M.receiverPublicAddress.trim()){N("Receiver public address is required."),V("");return}if(!dr.test(M.receiverPublicAddress.trim())){N("Receiver address should be a valid Solana public address format."),V("");return}if(!Number.isFinite(ot)||ot<=0){N("Enter a valid payment amount greater than 0."),V("");return}if(!yt||!dr.test(yt)){N("Provide a valid mint address (popular or custom)."),V("");return}const dt=Sn(yt)||{symbol:"CUSTOM"},Mt={version:Lc,type:"quiqrpay-crypto-terminal",to:M.receiverPublicAddress.trim(),amount:ot.toString(),mint:yt,mintSymbol:dt.symbol,note:M.note.trim(),createdAt:new Date().toISOString()},Fe=l0(Mt);V(Fe),lt(Fe),N("QR generated locally. Share the QR or link directly with the payer.")},Rt=()=>{if(!nt.trim()){f("Paste a shared link or token first.");return}
21try{const tt=new URL(nt),ot=Xi(tt.hash);if(!Ur(ot)){f("Could not parse a valid payment payload from that link.");return}window.location.hash=`pay=${ot}`,f("Shared payment request loaded.")}catch{const ot=Ur(nt.trim());if(!ot){f("Could not parse a valid payment payload from input.");return}const yt=Nc(JSON.stringify(ot));window.location.hash=`pay=${yt}`,f("Shared payment request loaded.")}},Lt=async()=>{if(!K){N("Generate a QR first so there is a link to copy.");return}try{await navigator.clipboard.writeText(K),N("Share link copied.")}catch{N("Clipboard not available. Copy the link manually.")}},Re=tt=>{if(tt.preventDefault(),!E){f("Load a valid shared payment request first.");return}if(!st.trim()){f("Payer private key is required for local trigger.");return}const ot=Number.parseFloat(Q);if(!Number.isFinite(ot)||ot<=0){f("Confirm a valid amount greater than 0.");return}const yt={payerPrivateKey:st.trim(),amount:ot.toString(),target:E.to,mint:E.mint,mintSymbol:j.symbol,note:E.note||"",source:"shared-qr",triggeredAt:new Date().toISOString()};window.dispatchEvent(new CustomEvent("quiqrpay:crypto-terminal-pay-trigger",{detail:yt})),x(yt.triggeredAt);const dt=new URLSearchParams({amount:yt.amount,"spl-token":yt.mint}),Mt=`solana:${yt.target}?${dt.toString()}`;window.location.assign(Mt),f("Triggered locally and opened a Solana deep link for payment. No server request was made.")};return $.jsx("main",{className:"crypto-sender-page",children:$.jsxs("section",{className:"crypto-sender-panel",children:[$.jsx("h1",{children:"Crypto Sender"}),$.jsx("p",{className:"crypto-sender-copy",children:"Browser-only utilities. No storage on QuiQRPay servers and no API handling on the backend."}),$.jsxs("div",{className:"crypto-sender-grid",children:[$.jsxs("section",{className:"crypto-sender-card",children:[$.jsx("h2",{children:"Pay"}),$.jsxs("form",{className:"crypto-sender-form",onSubmit:ft,children:[$.jsx("label",{htmlFor:"privateKey",children:"1) Sender private key"}),$.jsxs("div",{className:"crypto-sender-private-key-row",children:[$.jsx("input",{id:"privateKey",name:"privateKey",type:o?"text":"password",placeholder:"Base58 or JSON array private key",value:r.privateKey,onChange:Y,autoComplete:"off",spellCheck:"false"}),$.jsx("button",{type:"button",className:"crypto-sender-toggle",onClick:()=>u(tt=>!tt),children:o?"Hide":"Show"})]}),$.jsx("button",{type:"button",className:"crypto-sender-submit crypto-secondary-btn crypto-inline-action-btn",onClick:ht,disabled:S,children:S?"Loading wallet mints...":"Load wallet mints from private key"}),g&&$.jsx("p",{className:"crypto-sender-small crypto-wallet-status",children:g}),$.jsx("label",{htmlFor:"amount",children:"2) Amount to send"}),$.jsx("input",{id:"amount",name:"amount",type:"number",step:"any",min:"0",placeholder:"0.00",value:r.amount,onChange:Y}),$.jsx("label",{htmlFor:"target",children:"3) Target address (public or private)"}),$.jsx("input",{id:"target",name:"target",type:"text",placeholder:"Recipient public key or private key",value:r.target,onChange:Y,autoComplete:"off",spellCheck:"false"}),$.jsx("label",{htmlFor:"mint",children:"4) Mint address (top Solana picks)"}),$.jsxs("select",{id:"mint",name:"mint",value:r.mint,onChange:Y,children:[$.jsx("optgroup",{label:"Popular mints",children:wn.map(tt=>$.jsx("option",{value:tt.mint,children:To(tt)},tt.mint))}),R.length>0&&$.jsx("optgroup",{label:"Detected wallet mints",children:R.map(tt=>$.jsx("option",{value:tt,children:e0(tt)},tt))}),$.jsx("option",{value:Xe,children:"Custom mint address"})]}),r.mint===Xe&&$.jsx("input",{id:"customDirectMint",name:"customMint",type:"text",placeholder:"Custom mint address",value:r.customMint,onChange:Y,autoComplete:"off",spellCheck:"false"}),$.jsx("button",{type:"submit",className:"crypto-sender-submit",disabled:s,children:s?"Sending on-chain...":"Send on-chain now"})]}),$.jsxs("div",{className:"crypto-sender-meta",children:[$.jsxs("p",{children:[$.jsx("strong",{children:"Selected mint:"})," ",$.jsxs("span",{className:"crypto-mint-value",children:[k.symbol," (",k.mint,")"]})]}),c&&$.jsxs("p",{children:[$.jsx("strong",{children:"Last trigger:"}
21)," ",new Date(c).toLocaleString()]}),e&&$.jsx("p",{className:"crypto-sender-status",children:e})]})]}),$.jsxs("section",{className:"crypto-sender-card",children:[$.jsx("h2",{children:"Receive"}),$.jsxs("form",{className:"crypto-sender-form",onSubmit:Ot,children:[$.jsx("label",{htmlFor:"receiverPublicAddress",children:"Receiver public address"}),$.jsx("input",{id:"receiverPublicAddress",name:"receiverPublicAddress",type:"text",placeholder:"Receiver Solana public address",value:M.receiverPublicAddress,onChange:gt,autoComplete:"off",spellCheck:"false"}),$.jsx("label",{htmlFor:"terminalAmount",children:"Transaction amount"}),$.jsx("input",{id:"terminalAmount",name:"amount",type:"number",step:"any",min:"0",placeholder:"0.00",value:M.amount,onChange:gt}),$.jsx("label",{htmlFor:"terminalMint",children:"Mint address"}),$.jsxs("select",{id:"terminalMint",name:"mint",value:M.mint,onChange:gt,children:[wn.map(tt=>$.jsx("option",{value:tt.mint,children:To(tt)},tt.mint)),$.jsx("option",{value:Xe,children:"Custom mint address"})]}),M.mint===Xe&&$.jsx("input",{id:"customTerminalMint",name:"customMint",type:"text",placeholder:"Custom mint address",value:M.customMint,onChange:gt,autoComplete:"off",spellCheck:"false"}),$.jsx("label",{htmlFor:"terminalNote",children:"Optional note/memo"}),$.jsx("input",{id:"terminalNote",name:"note",type:"text",placeholder:"Order #, memo, or checkout reference",value:M.note,onChange:gt,autoComplete:"off",spellCheck:"false"}),$.jsx("button",{type:"submit",className:"crypto-sender-submit",children:"Generate payment QR"})]}),K&&$.jsxs("div",{className:"crypto-terminal-qr-wrap",children:[$.jsx(Cc,{className:"crypto-terminal-qr",value:K,size:210,level:"M",marginSize:4,bgColor:"#FFFFFF",fgColor:"#0f172a",title:"QuiQRPay crypto payment request"}),$.jsx("p",{className:"crypto-sender-small",children:"Share this QR or link with payer."}),$.jsx("textarea",{className:"crypto-sender-link-box",value:K,readOnly:!0}),$.jsx("button",{type:"button",className:"crypto-sender-submit crypto-secondary-btn",onClick:Lt,children:"Copy share link"})]}),$.jsxs("div",{className:"crypto-sender-meta",children:[$.jsxs("p",{children:[$.jsx("strong",{children:"Selected mint:"})," ",$.jsxs("span",{className:"crypto-mint-value",children:[G.symbol," (",G.mint,")"]})]}),D&&$.jsx("p",{className:"crypto-sender-status",children:D})]})]}),$.jsxs("section",{className:"crypto-sender-card crypto-sender-card-full",children:[$.jsx("h2",{children:"Payer Confirm And Trigger"}),$.jsx("p",{className:"crypto-sender-small",children:"Paste a shared payment link/token or open this page with `#pay=...` from the QR."}),$.jsxs("div",{className:"crypto-inline-row",children:[$.jsx("input",{type:"text",placeholder:"Paste shared link or payload token",value:nt,onChange:tt=>lt(tt.target.value),autoComplete:"off",spellCheck:"false"}),$.jsx("button",{type:"button",className:"crypto-sender-submit crypto-secondary-btn",onClick:Rt,children:"Load request"})]}),E?$.jsxs("form",{className:"crypto-sender-form crypto-payer-form",onSubmit:Re,children:[$.jsxs("div",{className:"crypto-request-preview",children:[$.jsxs("p",{children:[$.jsx("strong",{children:"Receiver:"})," ",$.jsx("span",{className:"crypto-address-value",children:E.to})]}),$.jsxs("p",{children:[$.jsx("strong",{children:"Requested amount:"})," ",E.amount]}),$.jsxs("p",{children:[$.jsx("strong",{children:"Mint:"})," ",$.jsxs("span",{className:"crypto-mint-value",children:[j.symbol," (",E.mint,")"]})]}),E.note&&$.jsxs("p",{children:[$.jsx("strong",{children:"Note:"})," ",E.note]})]}),$.jsx("label",{htmlFor:"payerAmount",children:"Confirm transaction amount"}),$.jsx("input",{id:"payerAmount",type:"number",step:"any",min:"0",value:Q,onChange:tt=>w(tt.target.value)}),$.jsx("label",{htmlFor:"payerPrivateKey",children:"Payer private key"}),$.jsxs("div",{className:"crypto-sender-private-key-row",children:[$.jsx("input",{id:"payerPrivateKey",type:et?"text":"password",placeholder:"Base58 or JSON array private key",value:st,onChange:tt=>z(tt.target.value),autoComplete:"off",spellCheck:"false"}),$.jsx("button",{type:"button",className:"crypto-sender-toggle",onClick:()=>W(tt=>!tt),children:et?"Hide":"Show"})]}),$.jsx("button",{type:"submit",className:"crypto-sender-submit",children:"Confirm and trigger local send"})]}):$.jsx("p",{className:"crypto-sender-small crypto-empty-request",children:"No valid shared request loaded yet."}),$.jsxs("div",{className:"crypto-sender-meta",children:[m&&$.jsxs("p",{children:[$.jsx("strong",{children:"Last payer trigger:"}
21)," ",new Date(m).toLocaleString()]}),a&&$.jsx("p",{className:"crypto-sender-status",children:a})]})]})]})]})})}export{w0 as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.