@ensofinance/checkout-widget 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -199,5 +199,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
199
199
|
* @license MIT
|
|
200
200
|
*/var xC;function Iy(){return xC||(xC=1,function(t){const e=EW(),n=SW(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=O,t.INSPECT_MAX_BYTES=50;const i=2147483647;t.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&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 o(){try{const _=new Uint8Array(1),x={foo:function(){return 42}};return Object.setPrototypeOf(x,Uint8Array.prototype),Object.setPrototypeOf(_,x),_.foo()===42}catch(_){return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(_){if(_>i)throw new RangeError('The value "'+_+'" is invalid for option "size"');const x=new Uint8Array(_);return Object.setPrototypeOf(x,a.prototype),x}function a(_,x,A){if(typeof _=="number"){if(typeof x=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(_)}return l(_,x,A)}a.poolSize=8192;function l(_,x,A){if(typeof _=="string")return h(_,x);if(ArrayBuffer.isView(_))return b(_);if(_==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof _);if(hn(_,ArrayBuffer)||_&&hn(_.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(hn(_,SharedArrayBuffer)||_&&hn(_.buffer,SharedArrayBuffer)))return p(_,x,A);if(typeof _=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const H=_.valueOf&&_.valueOf();if(H!=null&&H!==_)return a.from(H,x,A);const te=w(_);if(te)return te;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof _[Symbol.toPrimitive]=="function")return a.from(_[Symbol.toPrimitive]("string"),x,A);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof _)}a.from=function(_,x,A){return l(_,x,A)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function c(_){if(typeof _!="number")throw new TypeError('"size" argument must be of type number');if(_<0)throw new RangeError('The value "'+_+'" is invalid for option "size"')}function u(_,x,A){return c(_),_<=0?s(_):x!==void 0?typeof A=="string"?s(_).fill(x,A):s(_).fill(x):s(_)}a.alloc=function(_,x,A){return u(_,x,A)};function d(_){return c(_),s(_<0?0:S(_)|0)}a.allocUnsafe=function(_){return d(_)},a.allocUnsafeSlow=function(_){return d(_)};function h(_,x){if((typeof x!="string"||x==="")&&(x="utf8"),!a.isEncoding(x))throw new TypeError("Unknown encoding: "+x);const A=T(_,x)|0;let H=s(A);const te=H.write(_,x);return te!==A&&(H=H.slice(0,te)),H}function g(_){const x=_.length<0?0:S(_.length)|0,A=s(x);for(let H=0;H<x;H+=1)A[H]=_[H]&255;return A}function b(_){if(hn(_,Uint8Array)){const x=new Uint8Array(_);return p(x.buffer,x.byteOffset,x.byteLength)}return g(_)}function p(_,x,A){if(x<0||_.byteLength<x)throw new RangeError('"offset" is outside of buffer bounds');if(_.byteLength<x+(A||0))throw new RangeError('"length" is outside of buffer bounds');let H;return x===void 0&&A===void 0?H=new Uint8Array(_):A===void 0?H=new Uint8Array(_,x):H=new Uint8Array(_,x,A),Object.setPrototypeOf(H,a.prototype),H}function w(_){if(a.isBuffer(_)){const x=S(_.length)|0,A=s(x);return A.length===0||_.copy(A,0,0,x),A}if(_.length!==void 0)return typeof _.length!="number"||ft(_.length)?s(0):g(_);if(_.type==="Buffer"&&Array.isArray(_.data))return g(_.data)}function S(_){if(_>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return _|0}function O(_){return+_!=_&&(_=0),a.alloc(+_)}a.isBuffer=function(x){return x!=null&&x._isBuffer===!0&&x!==a.prototype},a.compare=function(x,A){if(hn(x,Uint8Array)&&(x=a.from(x,x.offset,x.byteLength)),hn(A,Uint8Array)&&(A=a.from(A,A.offset,A.byteLength)),!a.isBuffer(x)||!a.isBuffer(A))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(x===A)return 0;let H=x.length,te=A.length;for(let ie=0,ue=Math.min(H,te);ie<ue;++ie)if(x[ie]!==A[ie]){H=x[ie],te=A[ie];break}return H<te?-1:te<H?1:0},a.isEncoding=function(x){switch(String(x).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(x,A){if(!Array.isArray(x))throw new TypeError('"list" argument must be an Array of Buffers');if(x.length===0)return a.alloc(0);let H;if(A===void 0)for(A=0,H=0;H<x.length;++H)A+=x[H].length;const te=a.allocUnsafe(A);let ie=0;for(H=0;H<x.length;++H){let ue=x[H];if(hn(ue,Uint8Array))ie+ue.length>te.length?(a.isBuffer(ue)||(ue=a.from(ue)),ue.copy(te,ie)):Uint8Array.prototype.set.call(te,ue,ie);else if(a.isBuffer(ue))ue.copy(te,ie);else throw new TypeError('"list" argument must be an Array of Buffers');ie+=ue.length}return te};function T(_,x){if(a.isBuffer(_))return _.length;if(ArrayBuffer.isView(_)||hn(_,ArrayBuffer))return _.byteLength;if(typeof _!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof _);const A=_.length,H=arguments.length>2&&arguments[2]===!0;if(!H&&A===0)return 0;let te=!1;for(;;)switch(x){case"ascii":case"latin1":case"binary":return A;case"utf8":case"utf-8":return st(_).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A*2;case"hex":return A>>>1;case"base64":return at(_).length;default:if(te)return H?-1:st(_).length;x=(""+x).toLowerCase(),te=!0}}a.byteLength=T;function $(_,x,A){let H=!1;if((x===void 0||x<0)&&(x=0),x>this.length||((A===void 0||A>this.length)&&(A=this.length),A<=0)||(A>>>=0,x>>>=0,A<=x))return"";for(_||(_="utf8");;)switch(_){case"hex":return D(this,x,A);case"utf8":case"utf-8":return f(this,x,A);case"ascii":return I(this,x,A);case"latin1":case"binary":return N(this,x,A);case"base64":return C(this,x,A);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,x,A);default:if(H)throw new TypeError("Unknown encoding: "+_);_=(_+"").toLowerCase(),H=!0}}a.prototype._isBuffer=!0;function R(_,x,A){const H=_[x];_[x]=_[A],_[A]=H}a.prototype.swap16=function(){const x=this.length;if(x%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let A=0;A<x;A+=2)R(this,A,A+1);return this},a.prototype.swap32=function(){const x=this.length;if(x%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let A=0;A<x;A+=4)R(this,A,A+3),R(this,A+1,A+2);return this},a.prototype.swap64=function(){const x=this.length;if(x%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let A=0;A<x;A+=8)R(this,A,A+7),R(this,A+1,A+6),R(this,A+2,A+5),R(this,A+3,A+4);return this},a.prototype.toString=function(){const x=this.length;return x===0?"":arguments.length===0?f(this,0,x):$.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(x){if(!a.isBuffer(x))throw new TypeError("Argument must be a Buffer");return this===x?!0:a.compare(this,x)===0},a.prototype.inspect=function(){let x="";const A=t.INSPECT_MAX_BYTES;return x=this.toString("hex",0,A).replace(/(.{2})/g,"$1 ").trim(),this.length>A&&(x+=" ... "),"<Buffer "+x+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(x,A,H,te,ie){if(hn(x,Uint8Array)&&(x=a.from(x,x.offset,x.byteLength)),!a.isBuffer(x))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof x);if(A===void 0&&(A=0),H===void 0&&(H=x?x.length:0),te===void 0&&(te=0),ie===void 0&&(ie=this.length),A<0||H>x.length||te<0||ie>this.length)throw new RangeError("out of range index");if(te>=ie&&A>=H)return 0;if(te>=ie)return-1;if(A>=H)return 1;if(A>>>=0,H>>>=0,te>>>=0,ie>>>=0,this===x)return 0;let ue=ie-te,De=H-A;const Le=Math.min(ue,De),Me=this.slice(te,ie),yt=x.slice(A,H);for(let Ne=0;Ne<Le;++Ne)if(Me[Ne]!==yt[Ne]){ue=Me[Ne],De=yt[Ne];break}return ue<De?-1:De<ue?1:0};function j(_,x,A,H,te){if(_.length===0)return-1;if(typeof A=="string"?(H=A,A=0):A>2147483647?A=2147483647:A<-2147483648&&(A=-2147483648),A=+A,ft(A)&&(A=te?0:_.length-1),A<0&&(A=_.length+A),A>=_.length){if(te)return-1;A=_.length-1}else if(A<0)if(te)A=0;else return-1;if(typeof x=="string"&&(x=a.from(x,H)),a.isBuffer(x))return x.length===0?-1:q(_,x,A,H,te);if(typeof x=="number")return x=x&255,typeof Uint8Array.prototype.indexOf=="function"?te?Uint8Array.prototype.indexOf.call(_,x,A):Uint8Array.prototype.lastIndexOf.call(_,x,A):q(_,[x],A,H,te);throw new TypeError("val must be string, number or Buffer")}function q(_,x,A,H,te){let ie=1,ue=_.length,De=x.length;if(H!==void 0&&(H=String(H).toLowerCase(),H==="ucs2"||H==="ucs-2"||H==="utf16le"||H==="utf-16le")){if(_.length<2||x.length<2)return-1;ie=2,ue/=2,De/=2,A/=2}function Le(yt,Ne){return ie===1?yt[Ne]:yt.readUInt16BE(Ne*ie)}let Me;if(te){let yt=-1;for(Me=A;Me<ue;Me++)if(Le(_,Me)===Le(x,yt===-1?0:Me-yt)){if(yt===-1&&(yt=Me),Me-yt+1===De)return yt*ie}else yt!==-1&&(Me-=Me-yt),yt=-1}else for(A+De>ue&&(A=ue-De),Me=A;Me>=0;Me--){let yt=!0;for(let Ne=0;Ne<De;Ne++)if(Le(_,Me+Ne)!==Le(x,Ne)){yt=!1;break}if(yt)return Me}return-1}a.prototype.includes=function(x,A,H){return this.indexOf(x,A,H)!==-1},a.prototype.indexOf=function(x,A,H){return j(this,x,A,H,!0)},a.prototype.lastIndexOf=function(x,A,H){return j(this,x,A,H,!1)};function G(_,x,A,H){A=Number(A)||0;const te=_.length-A;H?(H=Number(H),H>te&&(H=te)):H=te;const ie=x.length;H>ie/2&&(H=ie/2);let ue;for(ue=0;ue<H;++ue){const De=parseInt(x.substr(ue*2,2),16);if(ft(De))return ue;_[A+ue]=De}return ue}function L(_,x,A,H){return it(st(x,_.length-A),_,A,H)}function V(_,x,A,H){return it(dt(x),_,A,H)}function W(_,x,A,H){return it(at(x),_,A,H)}function z(_,x,A,H){return it(ji(x,_.length-A),_,A,H)}a.prototype.write=function(x,A,H,te){if(A===void 0)te="utf8",H=this.length,A=0;else if(H===void 0&&typeof A=="string")te=A,H=this.length,A=0;else if(isFinite(A))A=A>>>0,isFinite(H)?(H=H>>>0,te===void 0&&(te="utf8")):(te=H,H=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ie=this.length-A;if((H===void 0||H>ie)&&(H=ie),x.length>0&&(H<0||A<0)||A>this.length)throw new RangeError("Attempt to write outside buffer bounds");te||(te="utf8");let ue=!1;for(;;)switch(te){case"hex":return G(this,x,A,H);case"utf8":case"utf-8":return L(this,x,A,H);case"ascii":case"latin1":case"binary":return V(this,x,A,H);case"base64":return W(this,x,A,H);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,x,A,H);default:if(ue)throw new TypeError("Unknown encoding: "+te);te=(""+te).toLowerCase(),ue=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function C(_,x,A){return x===0&&A===_.length?e.fromByteArray(_):e.fromByteArray(_.slice(x,A))}function f(_,x,A){A=Math.min(_.length,A);const H=[];let te=x;for(;te<A;){const ie=_[te];let ue=null,De=ie>239?4:ie>223?3:ie>191?2:1;if(te+De<=A){let Le,Me,yt,Ne;switch(De){case 1:ie<128&&(ue=ie);break;case 2:Le=_[te+1],(Le&192)===128&&(Ne=(ie&31)<<6|Le&63,Ne>127&&(ue=Ne));break;case 3:Le=_[te+1],Me=_[te+2],(Le&192)===128&&(Me&192)===128&&(Ne=(ie&15)<<12|(Le&63)<<6|Me&63,Ne>2047&&(Ne<55296||Ne>57343)&&(ue=Ne));break;case 4:Le=_[te+1],Me=_[te+2],yt=_[te+3],(Le&192)===128&&(Me&192)===128&&(yt&192)===128&&(Ne=(ie&15)<<18|(Le&63)<<12|(Me&63)<<6|yt&63,Ne>65535&&Ne<1114112&&(ue=Ne))}}ue===null?(ue=65533,De=1):ue>65535&&(ue-=65536,H.push(ue>>>10&1023|55296),ue=56320|ue&1023),H.push(ue),te+=De}return E(H)}const y=4096;function E(_){const x=_.length;if(x<=y)return String.fromCharCode.apply(String,_);let A="",H=0;for(;H<x;)A+=String.fromCharCode.apply(String,_.slice(H,H+=y));return A}function I(_,x,A){let H="";A=Math.min(_.length,A);for(let te=x;te<A;++te)H+=String.fromCharCode(_[te]&127);return H}function N(_,x,A){let H="";A=Math.min(_.length,A);for(let te=x;te<A;++te)H+=String.fromCharCode(_[te]);return H}function D(_,x,A){const H=_.length;(!x||x<0)&&(x=0),(!A||A<0||A>H)&&(A=H);let te="";for(let ie=x;ie<A;++ie)te+=mt[_[ie]];return te}function M(_,x,A){const H=_.slice(x,A);let te="";for(let ie=0;ie<H.length-1;ie+=2)te+=String.fromCharCode(H[ie]+H[ie+1]*256);return te}a.prototype.slice=function(x,A){const H=this.length;x=~~x,A=A===void 0?H:~~A,x<0?(x+=H,x<0&&(x=0)):x>H&&(x=H),A<0?(A+=H,A<0&&(A=0)):A>H&&(A=H),A<x&&(A=x);const te=this.subarray(x,A);return Object.setPrototypeOf(te,a.prototype),te};function P(_,x,A){if(_%1!==0||_<0)throw new RangeError("offset is not uint");if(_+x>A)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(x,A,H){x=x>>>0,A=A>>>0,H||P(x,A,this.length);let te=this[x],ie=1,ue=0;for(;++ue<A&&(ie*=256);)te+=this[x+ue]*ie;return te},a.prototype.readUintBE=a.prototype.readUIntBE=function(x,A,H){x=x>>>0,A=A>>>0,H||P(x,A,this.length);let te=this[x+--A],ie=1;for(;A>0&&(ie*=256);)te+=this[x+--A]*ie;return te},a.prototype.readUint8=a.prototype.readUInt8=function(x,A){return x=x>>>0,A||P(x,1,this.length),this[x]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(x,A){return x=x>>>0,A||P(x,2,this.length),this[x]|this[x+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(x,A){return x=x>>>0,A||P(x,2,this.length),this[x]<<8|this[x+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(x,A){return x=x>>>0,A||P(x,4,this.length),(this[x]|this[x+1]<<8|this[x+2]<<16)+this[x+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(x,A){return x=x>>>0,A||P(x,4,this.length),this[x]*16777216+(this[x+1]<<16|this[x+2]<<8|this[x+3])},a.prototype.readBigUInt64LE=hi(function(x){x=x>>>0,me(x,"offset");const A=this[x],H=this[x+7];(A===void 0||H===void 0)&&Ae(x,this.length-8);const te=A+this[++x]*2**8+this[++x]*2**16+this[++x]*2**24,ie=this[++x]+this[++x]*2**8+this[++x]*2**16+H*2**24;return BigInt(te)+(BigInt(ie)<<BigInt(32))}),a.prototype.readBigUInt64BE=hi(function(x){x=x>>>0,me(x,"offset");const A=this[x],H=this[x+7];(A===void 0||H===void 0)&&Ae(x,this.length-8);const te=A*2**24+this[++x]*2**16+this[++x]*2**8+this[++x],ie=this[++x]*2**24+this[++x]*2**16+this[++x]*2**8+H;return(BigInt(te)<<BigInt(32))+BigInt(ie)}),a.prototype.readIntLE=function(x,A,H){x=x>>>0,A=A>>>0,H||P(x,A,this.length);let te=this[x],ie=1,ue=0;for(;++ue<A&&(ie*=256);)te+=this[x+ue]*ie;return ie*=128,te>=ie&&(te-=Math.pow(2,8*A)),te},a.prototype.readIntBE=function(x,A,H){x=x>>>0,A=A>>>0,H||P(x,A,this.length);let te=A,ie=1,ue=this[x+--te];for(;te>0&&(ie*=256);)ue+=this[x+--te]*ie;return ie*=128,ue>=ie&&(ue-=Math.pow(2,8*A)),ue},a.prototype.readInt8=function(x,A){return x=x>>>0,A||P(x,1,this.length),this[x]&128?(255-this[x]+1)*-1:this[x]},a.prototype.readInt16LE=function(x,A){x=x>>>0,A||P(x,2,this.length);const H=this[x]|this[x+1]<<8;return H&32768?H|4294901760:H},a.prototype.readInt16BE=function(x,A){x=x>>>0,A||P(x,2,this.length);const H=this[x+1]|this[x]<<8;return H&32768?H|4294901760:H},a.prototype.readInt32LE=function(x,A){return x=x>>>0,A||P(x,4,this.length),this[x]|this[x+1]<<8|this[x+2]<<16|this[x+3]<<24},a.prototype.readInt32BE=function(x,A){return x=x>>>0,A||P(x,4,this.length),this[x]<<24|this[x+1]<<16|this[x+2]<<8|this[x+3]},a.prototype.readBigInt64LE=hi(function(x){x=x>>>0,me(x,"offset");const A=this[x],H=this[x+7];(A===void 0||H===void 0)&&Ae(x,this.length-8);const te=this[x+4]+this[x+5]*2**8+this[x+6]*2**16+(H<<24);return(BigInt(te)<<BigInt(32))+BigInt(A+this[++x]*2**8+this[++x]*2**16+this[++x]*2**24)}),a.prototype.readBigInt64BE=hi(function(x){x=x>>>0,me(x,"offset");const A=this[x],H=this[x+7];(A===void 0||H===void 0)&&Ae(x,this.length-8);const te=(A<<24)+this[++x]*2**16+this[++x]*2**8+this[++x];return(BigInt(te)<<BigInt(32))+BigInt(this[++x]*2**24+this[++x]*2**16+this[++x]*2**8+H)}),a.prototype.readFloatLE=function(x,A){return x=x>>>0,A||P(x,4,this.length),n.read(this,x,!0,23,4)},a.prototype.readFloatBE=function(x,A){return x=x>>>0,A||P(x,4,this.length),n.read(this,x,!1,23,4)},a.prototype.readDoubleLE=function(x,A){return x=x>>>0,A||P(x,8,this.length),n.read(this,x,!0,52,8)},a.prototype.readDoubleBE=function(x,A){return x=x>>>0,A||P(x,8,this.length),n.read(this,x,!1,52,8)};function m(_,x,A,H,te,ie){if(!a.isBuffer(_))throw new TypeError('"buffer" argument must be a Buffer instance');if(x>te||x<ie)throw new RangeError('"value" argument is out of bounds');if(A+H>_.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(x,A,H,te){if(x=+x,A=A>>>0,H=H>>>0,!te){const De=Math.pow(2,8*H)-1;m(this,x,A,H,De,0)}let ie=1,ue=0;for(this[A]=x&255;++ue<H&&(ie*=256);)this[A+ue]=x/ie&255;return A+H},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(x,A,H,te){if(x=+x,A=A>>>0,H=H>>>0,!te){const De=Math.pow(2,8*H)-1;m(this,x,A,H,De,0)}let ie=H-1,ue=1;for(this[A+ie]=x&255;--ie>=0&&(ue*=256);)this[A+ie]=x/ue&255;return A+H},a.prototype.writeUint8=a.prototype.writeUInt8=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,1,255,0),this[A]=x&255,A+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,2,65535,0),this[A]=x&255,this[A+1]=x>>>8,A+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,2,65535,0),this[A]=x>>>8,this[A+1]=x&255,A+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,4,4294967295,0),this[A+3]=x>>>24,this[A+2]=x>>>16,this[A+1]=x>>>8,this[A]=x&255,A+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,4,4294967295,0),this[A]=x>>>24,this[A+1]=x>>>16,this[A+2]=x>>>8,this[A+3]=x&255,A+4};function v(_,x,A,H,te){se(x,H,te,_,A,7);let ie=Number(x&BigInt(4294967295));_[A++]=ie,ie=ie>>8,_[A++]=ie,ie=ie>>8,_[A++]=ie,ie=ie>>8,_[A++]=ie;let ue=Number(x>>BigInt(32)&BigInt(4294967295));return _[A++]=ue,ue=ue>>8,_[A++]=ue,ue=ue>>8,_[A++]=ue,ue=ue>>8,_[A++]=ue,A}function B(_,x,A,H,te){se(x,H,te,_,A,7);let ie=Number(x&BigInt(4294967295));_[A+7]=ie,ie=ie>>8,_[A+6]=ie,ie=ie>>8,_[A+5]=ie,ie=ie>>8,_[A+4]=ie;let ue=Number(x>>BigInt(32)&BigInt(4294967295));return _[A+3]=ue,ue=ue>>8,_[A+2]=ue,ue=ue>>8,_[A+1]=ue,ue=ue>>8,_[A]=ue,A+8}a.prototype.writeBigUInt64LE=hi(function(x,A=0){return v(this,x,A,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=hi(function(x,A=0){return B(this,x,A,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(x,A,H,te){if(x=+x,A=A>>>0,!te){const Le=Math.pow(2,8*H-1);m(this,x,A,H,Le-1,-Le)}let ie=0,ue=1,De=0;for(this[A]=x&255;++ie<H&&(ue*=256);)x<0&&De===0&&this[A+ie-1]!==0&&(De=1),this[A+ie]=(x/ue>>0)-De&255;return A+H},a.prototype.writeIntBE=function(x,A,H,te){if(x=+x,A=A>>>0,!te){const Le=Math.pow(2,8*H-1);m(this,x,A,H,Le-1,-Le)}let ie=H-1,ue=1,De=0;for(this[A+ie]=x&255;--ie>=0&&(ue*=256);)x<0&&De===0&&this[A+ie+1]!==0&&(De=1),this[A+ie]=(x/ue>>0)-De&255;return A+H},a.prototype.writeInt8=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,1,127,-128),x<0&&(x=255+x+1),this[A]=x&255,A+1},a.prototype.writeInt16LE=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,2,32767,-32768),this[A]=x&255,this[A+1]=x>>>8,A+2},a.prototype.writeInt16BE=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,2,32767,-32768),this[A]=x>>>8,this[A+1]=x&255,A+2},a.prototype.writeInt32LE=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,4,2147483647,-2147483648),this[A]=x&255,this[A+1]=x>>>8,this[A+2]=x>>>16,this[A+3]=x>>>24,A+4},a.prototype.writeInt32BE=function(x,A,H){return x=+x,A=A>>>0,H||m(this,x,A,4,2147483647,-2147483648),x<0&&(x=4294967295+x+1),this[A]=x>>>24,this[A+1]=x>>>16,this[A+2]=x>>>8,this[A+3]=x&255,A+4},a.prototype.writeBigInt64LE=hi(function(x,A=0){return v(this,x,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=hi(function(x,A=0){return B(this,x,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function U(_,x,A,H,te,ie){if(A+H>_.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("Index out of range")}function Q(_,x,A,H,te){return x=+x,A=A>>>0,te||U(_,x,A,4),n.write(_,x,A,H,23,4),A+4}a.prototype.writeFloatLE=function(x,A,H){return Q(this,x,A,!0,H)},a.prototype.writeFloatBE=function(x,A,H){return Q(this,x,A,!1,H)};function ee(_,x,A,H,te){return x=+x,A=A>>>0,te||U(_,x,A,8),n.write(_,x,A,H,52,8),A+8}a.prototype.writeDoubleLE=function(x,A,H){return ee(this,x,A,!0,H)},a.prototype.writeDoubleBE=function(x,A,H){return ee(this,x,A,!1,H)},a.prototype.copy=function(x,A,H,te){if(!a.isBuffer(x))throw new TypeError("argument should be a Buffer");if(H||(H=0),!te&&te!==0&&(te=this.length),A>=x.length&&(A=x.length),A||(A=0),te>0&&te<H&&(te=H),te===H||x.length===0||this.length===0)return 0;if(A<0)throw new RangeError("targetStart out of bounds");if(H<0||H>=this.length)throw new RangeError("Index out of range");if(te<0)throw new RangeError("sourceEnd out of bounds");te>this.length&&(te=this.length),x.length-A<te-H&&(te=x.length-A+H);const ie=te-H;return this===x&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(A,H,te):Uint8Array.prototype.set.call(x,this.subarray(H,te),A),ie},a.prototype.fill=function(x,A,H,te){if(typeof x=="string"){if(typeof A=="string"?(te=A,A=0,H=this.length):typeof H=="string"&&(te=H,H=this.length),te!==void 0&&typeof te!="string")throw new TypeError("encoding must be a string");if(typeof te=="string"&&!a.isEncoding(te))throw new TypeError("Unknown encoding: "+te);if(x.length===1){const ue=x.charCodeAt(0);(te==="utf8"&&ue<128||te==="latin1")&&(x=ue)}}else typeof x=="number"?x=x&255:typeof x=="boolean"&&(x=Number(x));if(A<0||this.length<A||this.length<H)throw new RangeError("Out of range index");if(H<=A)return this;A=A>>>0,H=H===void 0?this.length:H>>>0,x||(x=0);let ie;if(typeof x=="number")for(ie=A;ie<H;++ie)this[ie]=x;else{const ue=a.isBuffer(x)?x:a.from(x,te),De=ue.length;if(De===0)throw new TypeError('The value "'+x+'" is invalid for argument "value"');for(ie=0;ie<H-A;++ie)this[ie+A]=ue[ie%De]}return this};const Z={};function Y(_,x,A){Z[_]=class extends A{constructor(){super(),Object.defineProperty(this,"message",{value:x.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${_}]`,this.stack,delete this.name}get code(){return _}set code(te){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:te,writable:!0})}toString(){return`${this.name} [${_}]: ${this.message}`}}}Y("ERR_BUFFER_OUT_OF_BOUNDS",function(_){return _?`${_} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Y("ERR_INVALID_ARG_TYPE",function(_,x){return`The "${_}" argument must be of type number. Received type ${typeof x}`},TypeError),Y("ERR_OUT_OF_RANGE",function(_,x,A){let H=`The value of "${_}" is out of range.`,te=A;return Number.isInteger(A)&&Math.abs(A)>2**32?te=re(String(A)):typeof A=="bigint"&&(te=String(A),(A>BigInt(2)**BigInt(32)||A<-(BigInt(2)**BigInt(32)))&&(te=re(te)),te+="n"),H+=` It must be ${x}. Received ${te}`,H},RangeError);function re(_){let x="",A=_.length;const H=_[0]==="-"?1:0;for(;A>=H+4;A-=3)x=`_${_.slice(A-3,A)}${x}`;return`${_.slice(0,A)}${x}`}function de(_,x,A){me(x,"offset"),(_[x]===void 0||_[x+A]===void 0)&&Ae(x,_.length-(A+1))}function se(_,x,A,H,te,ie){if(_>A||_<x){const ue=typeof x=="bigint"?"n":"";let De;throw x===0||x===BigInt(0)?De=`>= 0${ue} and < 2${ue} ** ${(ie+1)*8}${ue}`:De=`>= -(2${ue} ** ${(ie+1)*8-1}${ue}) and < 2 ** ${(ie+1)*8-1}${ue}`,new Z.ERR_OUT_OF_RANGE("value",De,_)}de(H,te,ie)}function me(_,x){if(typeof _!="number")throw new Z.ERR_INVALID_ARG_TYPE(x,"number",_)}function Ae(_,x,A){throw Math.floor(_)!==_?(me(_,A),new Z.ERR_OUT_OF_RANGE("offset","an integer",_)):x<0?new Z.ERR_BUFFER_OUT_OF_BOUNDS:new Z.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${x}`,_)}const Re=/[^+/0-9A-Za-z-_]/g;function Ct(_){if(_=_.split("=")[0],_=_.trim().replace(Re,""),_.length<2)return"";for(;_.length%4!==0;)_=_+"=";return _}function st(_,x){x=x||1/0;let A;const H=_.length;let te=null;const ie=[];for(let ue=0;ue<H;++ue){if(A=_.charCodeAt(ue),A>55295&&A<57344){if(!te){if(A>56319){(x-=3)>-1&&ie.push(239,191,189);continue}else if(ue+1===H){(x-=3)>-1&&ie.push(239,191,189);continue}te=A;continue}if(A<56320){(x-=3)>-1&&ie.push(239,191,189),te=A;continue}A=(te-55296<<10|A-56320)+65536}else te&&(x-=3)>-1&&ie.push(239,191,189);if(te=null,A<128){if((x-=1)<0)break;ie.push(A)}else if(A<2048){if((x-=2)<0)break;ie.push(A>>6|192,A&63|128)}else if(A<65536){if((x-=3)<0)break;ie.push(A>>12|224,A>>6&63|128,A&63|128)}else if(A<1114112){if((x-=4)<0)break;ie.push(A>>18|240,A>>12&63|128,A>>6&63|128,A&63|128)}else throw new Error("Invalid code point")}return ie}function dt(_){const x=[];for(let A=0;A<_.length;++A)x.push(_.charCodeAt(A)&255);return x}function ji(_,x){let A,H,te;const ie=[];for(let ue=0;ue<_.length&&!((x-=2)<0);++ue)A=_.charCodeAt(ue),H=A>>8,te=A%256,ie.push(te),ie.push(H);return ie}function at(_){return e.toByteArray(Ct(_))}function it(_,x,A,H){let te;for(te=0;te<H&&!(te+A>=x.length||te>=_.length);++te)x[te+A]=_[te];return te}function hn(_,x){return _ instanceof x||_!=null&&_.constructor!=null&&_.constructor.name!=null&&_.constructor.name===x.name}function ft(_){return _!==_}const mt=function(){const _="0123456789abcdef",x=new Array(256);for(let A=0;A<16;++A){const H=A*16;for(let te=0;te<16;++te)x[H+te]=_[A]+_[te]}return x}();function hi(_){return typeof BigInt=="undefined"?It:_}function It(){throw new Error("BigInt not supported")}}(Cy)),Cy}var Fe=Iy(),EC=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},SC=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}};typeof window!="undefined"&&(window.Buffer=window.Buffer||Fe.Buffer);var AW=function(t){return EC(void 0,void 0,void 0,function(){var e,n,r;return SC(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e=Ea(t.integrationName),[4,e.connect({onlyIfTrusted:!0}).catch(function(){return e.connect()})];case 1:if(n=i.sent(),n!=null&&n.publicKey)return t.targetChainId=="103"?[2,{accounts:[n.publicKey.toString()],chainId:"103",isConnected:!0}]:[2,{accounts:[n.publicKey.toString()],chainId:"101",isConnected:!0}];if(e.publicKey)return[2,{accounts:[e.publicKey.toString()],chainId:"101",isConnected:!0}];throw new Error("".concat(t.integrationName," connection failed - no public key returned"));case 2:return r=i.sent(),[2,r instanceof Error?r:new Error("Failed to connect to ".concat(t.integrationName," wallet"))];case 3:return[2]}})})},kW=function(t){return EC(void 0,void 0,void 0,function(){var e,n;return SC(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=Ea(t),[4,e.disconnect()];case 1:return r.sent(),[3,3];case 2:return n=r.sent(),[2,n instanceof Error?n:new Error("Failed to disconnect from ".concat(t," wallet"))];case 3:return[2]}})})};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Oy=BigInt(0),Ty=BigInt(1);function Sa(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}"`;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function ii(t,e,n=""){const r=Hu(t),i=t==null?void 0:t.length,o=e!==void 0;if(!r||o&&i!==e){const s=n&&`"${n}" `,a=o?` of length ${e}`:"",l=r?`length=${i}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+a+", got "+l)}return t}function gp(t){const e=t.toString(16);return e.length&1?"0"+e:e}function AC(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Oy:BigInt("0x"+t)}function mp(t){return AC(na(t))}function xd(t){return co(t),AC(na(Uint8Array.from(t).reverse()))}function Py(t,e){return xh(t.toString(16).padStart(e*2,"0"))}function kC(t,e){return Py(t,e).reverse()}function St(t,e,n){let r;if(typeof e=="string")try{r=xh(e)}catch(o){throw new Error(t+" must be hex string or Uint8Array, cause: "+o)}else if(Hu(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(t+" of length "+n+" expected, got "+i);return r}function CC(t){return Uint8Array.from(t)}const Ny=t=>typeof t=="bigint"&&Oy<=t;function CW(t,e,n){return Ny(t)&&Ny(e)&&Ny(n)&&e<=t&&t<n}function By(t,e,n,r){if(!CW(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function IC(t){let e;for(e=0;t>Oy;t>>=Ty,e+=1);return e}const Ed=t=>(Ty<<BigInt(t))-Ty;function IW(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=g=>new Uint8Array(g),i=g=>Uint8Array.of(g);let o=r(t),s=r(t),a=0;const l=()=>{o.fill(1),s.fill(0),a=0},c=(...g)=>n(s,o,...g),u=(g=r(0))=>{s=c(i(0),g),o=c(),g.length!==0&&(s=c(i(1),g),o=c())},d=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){o=c();const p=o.slice();b.push(p),g+=o.length}return Ii(...b)};return(g,b)=>{l(),u(g);let p;for(;!(p=b(d()));)u();return l(),p}}function Sd(t,e,n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(i,o,s){const a=t[i];if(s&&a===void 0)return;const l=typeof a;if(l!==o||a===null)throw new Error(`param "${i}" is invalid: expected ${o}, got ${l}`)}Object.entries(e).forEach(([i,o])=>r(i,o,!1)),Object.entries(n).forEach(([i,o])=>r(i,o,!0))}function yp(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(i!==void 0)return i;const o=t(n,...r);return e.set(n,o),o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const or=BigInt(0),xn=BigInt(1),Aa=BigInt(2),OC=BigInt(3),TC=BigInt(4),PC=BigInt(5),OW=BigInt(7),NC=BigInt(8),TW=BigInt(9),BC=BigInt(16);function _t(t,e){const n=t%e;return n>=or?n:e+n}function At(t,e,n){let r=t;for(;e-- >or;)r*=r,r%=n;return r}function RC(t,e){if(t===or)throw new Error("invert: expected non-zero number");if(e<=or)throw new Error("invert: expected positive modulus, got "+e);let n=_t(t,e),r=e,i=or,o=xn;for(;n!==or;){const a=r/n,l=r%n,c=i-o*a;r=n,n=l,i=o,o=c}if(r!==xn)throw new Error("invert: does not exist");return _t(i,e)}function Ry(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function MC(t,e){const n=(t.ORDER+xn)/TC,r=t.pow(e,n);return Ry(t,r,e),r}function PW(t,e){const n=(t.ORDER-PC)/NC,r=t.mul(e,Aa),i=t.pow(r,n),o=t.mul(e,i),s=t.mul(t.mul(o,Aa),i),a=t.mul(o,t.sub(s,t.ONE));return Ry(t,a,e),a}function NW(t){const e=ka(t),n=LC(t),r=n(e,e.neg(e.ONE)),i=n(e,r),o=n(e,e.neg(r)),s=(t+OW)/BC;return(a,l)=>{let c=a.pow(l,s),u=a.mul(c,r);const d=a.mul(c,i),h=a.mul(c,o),g=a.eql(a.sqr(u),l),b=a.eql(a.sqr(d),l);c=a.cmov(c,u,g),u=a.cmov(h,d,b);const p=a.eql(a.sqr(u),l),w=a.cmov(c,u,p);return Ry(a,w,l),w}}function LC(t){if(t<OC)throw new Error("sqrt is not defined for small field");let e=t-xn,n=0;for(;e%Aa===or;)e/=Aa,n++;let r=Aa;const i=ka(t);for(;_C(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return MC;let o=i.pow(r,e);const s=(e+xn)/Aa;return function(l,c){if(l.is0(c))return c;if(_C(l,c)!==1)throw new Error("Cannot find square root");let u=n,d=l.mul(l.ONE,o),h=l.pow(c,e),g=l.pow(c,s);for(;!l.eql(h,l.ONE);){if(l.is0(h))return l.ZERO;let b=1,p=l.sqr(h);for(;!l.eql(p,l.ONE);)if(b++,p=l.sqr(p),b===u)throw new Error("Cannot find square root");const w=xn<<BigInt(u-b-1),S=l.pow(d,w);u=b,d=l.sqr(S),h=l.mul(h,d),g=l.mul(g,S)}return g}}function BW(t){return t%TC===OC?MC:t%NC===PC?PW:t%BC===TW?NW(t):LC(t)}const RW=(t,e)=>(_t(t,e)&xn)===xn,MW=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function LW(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=MW.reduce((r,i)=>(r[i]="function",r),e);return Sd(t,n),t}function FW(t,e,n){if(n<or)throw new Error("invalid exponent, negatives unsupported");if(n===or)return t.ONE;if(n===xn)return e;let r=t.ONE,i=e;for(;n>or;)n&xn&&(r=t.mul(r,i)),i=t.sqr(i),n>>=xn;return r}function FC(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),i=e.reduce((s,a,l)=>t.is0(a)?s:(r[l]=s,t.mul(s,a)),t.ONE),o=t.inv(i);return e.reduceRight((s,a,l)=>t.is0(a)?s:(r[l]=t.mul(s,r[l]),t.mul(s,a)),o),r}function _C(t,e){const n=(t.ORDER-xn)/Aa,r=t.pow(e,n),i=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),s=t.eql(r,t.neg(t.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function VC(t,e){e!==void 0&&Wu(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ka(t,e,n=!1,r={}){if(t<=or)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,o,s=!1,a;if(typeof e=="object"&&e!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const h=e;h.BITS&&(i=h.BITS),h.sqrt&&(o=h.sqrt),typeof h.isLE=="boolean"&&(n=h.isLE),typeof h.modFromBytes=="boolean"&&(s=h.modFromBytes),a=h.allowedLengths}else typeof e=="number"&&(i=e),r.sqrt&&(o=r.sqrt);const{nBitLength:l,nByteLength:c}=VC(t,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const d=Object.freeze({ORDER:t,isLE:n,BITS:l,BYTES:c,MASK:Ed(l),ZERO:or,ONE:xn,allowedLengths:a,create:h=>_t(h,t),isValid:h=>{if(typeof h!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof h);return or<=h&&h<t},is0:h=>h===or,isValidNot0:h=>!d.is0(h)&&d.isValid(h),isOdd:h=>(h&xn)===xn,neg:h=>_t(-h,t),eql:(h,g)=>h===g,sqr:h=>_t(h*h,t),add:(h,g)=>_t(h+g,t),sub:(h,g)=>_t(h-g,t),mul:(h,g)=>_t(h*g,t),pow:(h,g)=>FW(d,h,g),div:(h,g)=>_t(h*RC(g,t),t),sqrN:h=>h*h,addN:(h,g)=>h+g,subN:(h,g)=>h-g,mulN:(h,g)=>h*g,inv:h=>RC(h,t),sqrt:o||(h=>(u||(u=BW(t)),u(d,h))),toBytes:h=>n?kC(h,c):Py(h,c),fromBytes:(h,g=!0)=>{if(a){if(!a.includes(h.length)||h.length>c)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+h.length);const p=new Uint8Array(c);p.set(h,n?0:p.length-h.length),h=p}if(h.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+h.length);let b=n?xd(h):mp(h);if(s&&(b=_t(b,t)),!g&&!d.isValid(b))throw new Error("invalid field element: outside of range 0..ORDER");return b},invertBatch:h=>FC(d,h),cmov:(h,g,b)=>b?g:h});return Object.freeze(d)}function DC(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function zC(t){const e=DC(t);return e+Math.ceil(e/2)}function _W(t,e,n=!1){const r=t.length,i=DC(e),o=zC(e);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=n?xd(t):mp(t),a=_t(s,e-xn)+xn;return n?kC(a,i):Py(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nc=BigInt(0),Ca=BigInt(1);function bp(t,e){const n=e.negate();return t?n:e}function Ia(t,e){const n=FC(t.Fp,e.map(r=>r.Z));return e.map((r,i)=>t.fromAffine(r.toAffine(n[i])))}function UC(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function My(t,e){UC(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),i=2**t,o=Ed(t),s=BigInt(t);return{windows:n,windowSize:r,mask:o,maxNumber:i,shiftBy:s}}function $C(t,e,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(t&i),l=t>>s;a>r&&(a-=o,l+=Ca);const c=e*r,u=c+Math.abs(a)-1,d=a===0,h=a<0,g=e%2!==0;return{nextN:l,offset:u,isZero:d,isNeg:h,isNegF:g,offsetF:c}}function VW(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function DW(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Ly=new WeakMap,HC=new WeakMap;function Fy(t){return HC.get(t)||1}function WC(t){if(t!==nc)throw new Error("invalid wNAF")}class GC{constructor(e,n){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n}_unsafeLadder(e,n,r=this.ZERO){let i=e;for(;n>nc;)n&Ca&&(r=r.add(i)),i=i.double(),n>>=Ca;return r}precomputeWindow(e,n){const{windows:r,windowSize:i}=My(n,this.bits),o=[];let s=e,a=s;for(let l=0;l<r;l++){a=s,o.push(a);for(let c=1;c<i;c++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(e,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let i=this.ZERO,o=this.BASE;const s=My(e,this.bits);for(let a=0;a<s.windows;a++){const{nextN:l,offset:c,isZero:u,isNeg:d,isNegF:h,offsetF:g}=$C(r,a,s);r=l,u?o=o.add(bp(h,n[g])):i=i.add(bp(d,n[c]))}return WC(r),{p:i,f:o}}wNAFUnsafe(e,n,r,i=this.ZERO){const o=My(e,this.bits);for(let s=0;s<o.windows&&r!==nc;s++){const{nextN:a,offset:l,isZero:c,isNeg:u}=$C(r,s,o);if(r=a,!c){const d=n[l];i=i.add(u?d.negate():d)}}return WC(r),i}getPrecomputes(e,n,r){let i=Ly.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(i=r(i)),Ly.set(n,i))),i}cached(e,n,r){const i=Fy(e);return this.wNAF(i,this.getPrecomputes(i,e,r),n)}unsafe(e,n,r,i){const o=Fy(e);return o===1?this._unsafeLadder(e,n,i):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),n,i)}createCache(e,n){UC(n,this.bits),HC.set(e,n),Ly.delete(e)}hasCache(e){return Fy(e)!==1}}function zW(t,e,n,r){let i=e,o=t.ZERO,s=t.ZERO;for(;n>nc||r>nc;)n&Ca&&(o=o.add(i)),r&Ca&&(s=s.add(i)),i=i.double(),n>>=Ca,r>>=Ca;return{p1:o,p2:s}}function jC(t,e,n,r){VW(n,t),DW(r,e);const i=n.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,a=IC(BigInt(i));let l=1;a>12?l=a-3:a>4?l=a-2:a>0&&(l=2);const c=Ed(l),u=new Array(Number(c)+1).fill(s),d=Math.floor((e.BITS-1)/l)*l;let h=s;for(let g=d;g>=0;g-=l){u.fill(s);for(let p=0;p<o;p++){const w=r[p],S=Number(w>>BigInt(g)&c);u[S]=u[S].add(n[p])}let b=s;for(let p=u.length-1,w=s;p>0;p--)w=w.add(u[p]),b=b.add(w);if(h=h.add(b),g!==0)for(let p=0;p<l;p++)h=h.double()}return h}function KC(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return LW(e),e}else return ka(t,{isLE:n})}function qC(t,e,n={},r){if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const l of["p","n","h"]){const c=e[l];if(!(typeof c=="bigint"&&c>nc))throw new Error(`CURVE.${l} must be positive bigint`)}const i=KC(e.p,n.Fp,r),o=KC(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(const l of a)if(!i.isValid(e[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:i,Fn:o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ps=BigInt(0),dn=BigInt(1),_y=BigInt(2),UW=BigInt(8);function $W(t,e,n,r){const i=t.sqr(n),o=t.sqr(r),s=t.add(t.mul(e.a,i),o),a=t.add(t.ONE,t.mul(e.d,t.mul(i,o)));return t.eql(s,a)}function HW(t,e={}){const n=qC("edwards",t,e,e.FpFnLE),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s}=o;Sd(e,{},{uvRatio:"function"});const a=_y<<BigInt(i.BYTES*8)-dn,l=w=>r.create(w),c=e.uvRatio||((w,S)=>{try{return{isValid:!0,value:r.sqrt(r.div(w,S))}}catch(O){return{isValid:!1,value:ps}}});if(!$W(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function u(w,S,O=!1){const T=O?dn:ps;return By("coordinate "+w,S,T,a),S}function d(w){if(!(w instanceof b))throw new Error("ExtendedPoint expected")}const h=yp((w,S)=>{const{X:O,Y:T,Z:$}=w,R=w.is0();S==null&&(S=R?UW:r.inv($));const j=l(O*S),q=l(T*S),G=r.mul($,S);if(R)return{x:ps,y:dn};if(G!==dn)throw new Error("invZ was invalid");return{x:j,y:q}}),g=yp(w=>{const{a:S,d:O}=o;if(w.is0())throw new Error("bad point: ZERO");const{X:T,Y:$,Z:R,T:j}=w,q=l(T*T),G=l($*$),L=l(R*R),V=l(L*L),W=l(q*S),z=l(L*l(W+G)),C=l(V+l(O*l(q*G)));if(z!==C)throw new Error("bad point: equation left != right (1)");const f=l(T*$),y=l(R*j);if(f!==y)throw new Error("bad point: equation left != right (2)");return!0});class b{constructor(S,O,T,$){this.X=u("x",S),this.Y=u("y",O),this.Z=u("z",T,!0),this.T=u("t",$),Object.freeze(this)}static CURVE(){return o}static fromAffine(S){if(S instanceof b)throw new Error("extended point not allowed");const{x:O,y:T}=S||{};return u("x",O),u("y",T),new b(O,T,dn,l(O*T))}static fromBytes(S,O=!1){const T=r.BYTES,{a:$,d:R}=o;S=CC(ii(S,T,"point")),Sa(O,"zip215");const j=CC(S),q=S[T-1];j[T-1]=q&-129;const G=xd(j),L=O?a:r.ORDER;By("point.y",G,ps,L);const V=l(G*G),W=l(V-dn),z=l(R*V-$);let{isValid:C,value:f}=c(W,z);if(!C)throw new Error("bad point: invalid y coordinate");const y=(f&dn)===dn,E=(q&128)!==0;if(!O&&f===ps&&E)throw new Error("bad point: x=0 and x_0=1");return E!==y&&(f=l(-f)),b.fromAffine({x:f,y:G})}static fromHex(S,O=!1){return b.fromBytes(St("point",S),O)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(S=8,O=!0){return p.createCache(this,S),O||this.multiply(_y),this}assertValidity(){g(this)}equals(S){d(S);const{X:O,Y:T,Z:$}=this,{X:R,Y:j,Z:q}=S,G=l(O*q),L=l(R*$),V=l(T*q),W=l(j*$);return G===L&&V===W}is0(){return this.equals(b.ZERO)}negate(){return new b(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:S}=o,{X:O,Y:T,Z:$}=this,R=l(O*O),j=l(T*T),q=l(_y*l($*$)),G=l(S*R),L=O+T,V=l(l(L*L)-R-j),W=G+j,z=W-q,C=G-j,f=l(V*z),y=l(W*C),E=l(V*C),I=l(z*W);return new b(f,y,I,E)}add(S){d(S);const{a:O,d:T}=o,{X:$,Y:R,Z:j,T:q}=this,{X:G,Y:L,Z:V,T:W}=S,z=l($*G),C=l(R*L),f=l(q*T*W),y=l(j*V),E=l(($+R)*(G+L)-z-C),I=y-f,N=y+f,D=l(C-O*z),M=l(E*I),P=l(N*D),m=l(E*D),v=l(I*N);return new b(M,P,v,m)}subtract(S){return this.add(S.negate())}multiply(S){if(!i.isValidNot0(S))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:O,f:T}=p.cached(this,S,$=>Ia(b,$));return Ia(b,[O,T])[0]}multiplyUnsafe(S,O=b.ZERO){if(!i.isValid(S))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return S===ps?b.ZERO:this.is0()||S===dn?this:p.unsafe(this,S,T=>Ia(b,T),O)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return p.unsafe(this,o.n).is0()}toAffine(S){return h(this,S)}clearCofactor(){return s===dn?this:this.multiplyUnsafe(s)}toBytes(){const{x:S,y:O}=this.toAffine(),T=r.toBytes(O);return T[T.length-1]|=S&dn?128:0,T}toHex(){return na(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(S){return Ia(b,S)}static msm(S,O){return jC(b,i,S,O)}_setWindowSize(S){this.precompute(S)}toRawBytes(){return this.toBytes()}}b.BASE=new b(o.Gx,o.Gy,dn,l(o.Gx*o.Gy)),b.ZERO=new b(ps,dn,dn,ps),b.Fp=r,b.Fn=i;const p=new GC(b,i.BITS);return b.BASE.precompute(8),b}function WW(t,e,n={}){if(typeof e!="function")throw new Error('"hash" function param is required');Sd(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:i,Fp:o,Fn:s}=t,a=n.randomBytes||om,l=n.adjustScalarBytes||(L=>L),c=n.domain||((L,V,W)=>{if(Sa(W,"phflag"),V.length||W)throw new Error("Contexts/pre-hash are not supported");return L});function u(L){return s.create(xd(L))}function d(L){const V=T.secretKey;L=St("private key",L,V);const W=St("hashed private key",e(L),2*V),z=l(W.slice(0,V)),C=W.slice(V,2*V),f=u(z);return{head:z,prefix:C,scalar:f}}function h(L){const{head:V,prefix:W,scalar:z}=d(L),C=i.multiply(z),f=C.toBytes();return{head:V,prefix:W,scalar:z,point:C,pointBytes:f}}function g(L){return h(L).pointBytes}function b(L=Uint8Array.of(),...V){const W=Ii(...V);return u(e(c(W,St("context",L),!!r)))}function p(L,V,W={}){L=St("message",L),r&&(L=r(L));const{prefix:z,scalar:C,pointBytes:f}=h(V),y=b(W.context,z,L),E=i.multiply(y).toBytes(),I=b(W.context,E,f,L),N=s.create(y+I*C);if(!s.isValid(N))throw new Error("sign failed: invalid s");const D=Ii(E,s.toBytes(N));return ii(D,T.signature,"result")}const w={zip215:!0};function S(L,V,W,z=w){const{context:C,zip215:f}=z,y=T.signature;L=St("signature",L,y),V=St("message",V),W=St("publicKey",W,T.publicKey),f!==void 0&&Sa(f,"zip215"),r&&(V=r(V));const E=y/2,I=L.subarray(0,E),N=xd(L.subarray(E,y));let D,M,P;try{D=t.fromBytes(W,f),M=t.fromBytes(I,f),P=i.multiplyUnsafe(N)}catch(B){return!1}if(!f&&D.isSmallOrder())return!1;const m=b(C,M.toBytes(),D.toBytes(),V);return M.add(D.multiplyUnsafe(m)).subtract(P).clearCofactor().is0()}const O=o.BYTES,T={secretKey:O,publicKey:O,signature:2*O,seed:O};function $(L=a(T.seed)){return ii(L,T.seed,"seed")}function R(L){const V=G.randomSecretKey(L);return{secretKey:V,publicKey:g(V)}}function j(L){return Hu(L)&&L.length===s.BYTES}function q(L,V){try{return!!t.fromBytes(L,V)}catch(W){return!1}}const G={getExtendedPublicKey:h,randomSecretKey:$,isValidSecretKey:j,isValidPublicKey:q,toMontgomery(L){const{y:V}=t.fromBytes(L),W=T.publicKey,z=W===32;if(!z&&W!==57)throw new Error("only defined for 25519 and 448");const C=z?o.div(dn+V,dn-V):o.div(V-dn,V+dn);return o.toBytes(C)},toMontgomeryPriv(L){const V=T.secretKey;ii(L,V);const W=e(L.subarray(0,V));return l(W).subarray(0,V)},randomPrivateKey:$,precompute(L=8,V=t.BASE){return V.precompute(L,!1)}};return Object.freeze({keygen:R,getPublicKey:g,sign:p,verify:S,utils:G,Point:t,lengths:T})}function GW(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp,r=ka(e.n,t.nBitLength,!0),i={Fp:n,Fn:r,uvRatio:t.uvRatio},o={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:i,hash:t.hash,eddsaOpts:o}}function jW(t,e){const n=e.Point;return Object.assign({},e,{ExtendedPoint:n,CURVE:t,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function KW(t){const{CURVE:e,curveOpts:n,hash:r,eddsaOpts:i}=GW(t),o=HW(e,n),s=WW(o,r,i);return jW(t,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qW=BigInt(1),YC=BigInt(2);BigInt(3);const YW=BigInt(5),QW=BigInt(8),Vy=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),QC={p:Vy,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:QW,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function XW(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=Vy,a=t*t%o*t%o,l=At(a,YC,o)*a%o,c=At(l,qW,o)*t%o,u=At(c,YW,o)*c%o,d=At(u,e,o)*u%o,h=At(d,n,o)*d%o,g=At(h,r,o)*h%o,b=At(g,i,o)*g%o,p=At(b,i,o)*g%o,w=At(p,e,o)*u%o;return{pow_p_5_8:At(w,YC,o)*t%o,b2:a}}function JW(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const XC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ZW(t,e){const n=Vy,r=_t(e*e*e,n),i=_t(r*r*e,n),o=XW(t*i).pow_p_5_8;let s=_t(t*r*o,n);const a=_t(e*s*s,n),l=s,c=_t(s*XC,n),u=a===t,d=a===_t(-t,n),h=a===_t(-t*XC,n);return u&&(s=l),(d||h)&&(s=c),RW(s,n)&&(s=_t(-s,n)),{isValid:u||d,value:s}}const eG=ka(QC.p,{isLE:!0}),tG={...QC,Fp:eG,hash:nz,adjustScalarBytes:JW,uvRatio:ZW},Ad=KW(tG);var vp={exports:{}};const nG=lu(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var rG=vp.exports,JC;function ZC(){return JC||(JC=1,function(t){(function(e,n){function r(C,f){if(!C)throw new Error(f||"Assertion failed")}function i(C,f){C.super_=f;var y=function(){};y.prototype=f.prototype,C.prototype=new y,C.prototype.constructor=C}function o(C,f,y){if(o.isBN(C))return C;this.negative=0,this.words=null,this.length=0,this.red=null,C!==null&&((f==="le"||f==="be")&&(y=f,f=10),this._init(C||0,f||10,y||"be"))}typeof e=="object"?e.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var s;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?s=window.Buffer:s=nG.Buffer}catch(C){}o.isBN=function(f){return f instanceof o?!0:f!==null&&typeof f=="object"&&f.constructor.wordSize===o.wordSize&&Array.isArray(f.words)},o.max=function(f,y){return f.cmp(y)>0?f:y},o.min=function(f,y){return f.cmp(y)<0?f:y},o.prototype._init=function(f,y,E){if(typeof f=="number")return this._initNumber(f,y,E);if(typeof f=="object")return this._initArray(f,y,E);y==="hex"&&(y=16),r(y===(y|0)&&y>=2&&y<=36),f=f.toString().replace(/\s+/g,"");var I=0;f[0]==="-"&&(I++,this.negative=1),I<f.length&&(y===16?this._parseHex(f,I,E):(this._parseBase(f,y,I),E==="le"&&this._initArray(this.toArray(),y,E)))},o.prototype._initNumber=function(f,y,E){f<0&&(this.negative=1,f=-f),f<67108864?(this.words=[f&67108863],this.length=1):f<4503599627370496?(this.words=[f&67108863,f/67108864&67108863],this.length=2):(r(f<9007199254740992),this.words=[f&67108863,f/67108864&67108863,1],this.length=3),E==="le"&&this._initArray(this.toArray(),y,E)},o.prototype._initArray=function(f,y,E){if(r(typeof f.length=="number"),f.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(f.length/3),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var N,D,M=0;if(E==="be")for(I=f.length-1,N=0;I>=0;I-=3)D=f[I]|f[I-1]<<8|f[I-2]<<16,this.words[N]|=D<<M&67108863,this.words[N+1]=D>>>26-M&67108863,M+=24,M>=26&&(M-=26,N++);else if(E==="le")for(I=0,N=0;I<f.length;I+=3)D=f[I]|f[I+1]<<8|f[I+2]<<16,this.words[N]|=D<<M&67108863,this.words[N+1]=D>>>26-M&67108863,M+=24,M>=26&&(M-=26,N++);return this._strip()};function a(C,f){var y=C.charCodeAt(f);if(y>=48&&y<=57)return y-48;if(y>=65&&y<=70)return y-55;if(y>=97&&y<=102)return y-87;r(!1,"Invalid character in "+C)}function l(C,f,y){var E=a(C,y);return y-1>=f&&(E|=a(C,y-1)<<4),E}o.prototype._parseHex=function(f,y,E){this.length=Math.ceil((f.length-y)/6),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var N=0,D=0,M;if(E==="be")for(I=f.length-1;I>=y;I-=2)M=l(f,y,I)<<N,this.words[D]|=M&67108863,N>=18?(N-=18,D+=1,this.words[D]|=M>>>26):N+=8;else{var P=f.length-y;for(I=P%2===0?y+1:y;I<f.length;I+=2)M=l(f,y,I)<<N,this.words[D]|=M&67108863,N>=18?(N-=18,D+=1,this.words[D]|=M>>>26):N+=8}this._strip()};function c(C,f,y,E){for(var I=0,N=0,D=Math.min(C.length,y),M=f;M<D;M++){var P=C.charCodeAt(M)-48;I*=E,P>=49?N=P-49+10:P>=17?N=P-17+10:N=P,r(P>=0&&N<E,"Invalid character"),I+=N}return I}o.prototype._parseBase=function(f,y,E){this.words=[0],this.length=1;for(var I=0,N=1;N<=67108863;N*=y)I++;I--,N=N/y|0;for(var D=f.length-E,M=D%I,P=Math.min(D,D-M)+E,m=0,v=E;v<P;v+=I)m=c(f,v,v+I,y),this.imuln(N),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m);if(M!==0){var B=1;for(m=c(f,v,f.length,y),v=0;v<M;v++)B*=y;this.imuln(B),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m)}this._strip()},o.prototype.copy=function(f){f.words=new Array(this.length);for(var y=0;y<this.length;y++)f.words[y]=this.words[y];f.length=this.length,f.negative=this.negative,f.red=this.red};function u(C,f){C.words=f.words,C.length=f.length,C.negative=f.negative,C.red=f.red}if(o.prototype._move=function(f){u(f,this)},o.prototype.clone=function(){var f=new o(null);return this.copy(f),f},o.prototype._expand=function(f){for(;this.length<f;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol!="undefined"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=d}catch(C){o.prototype.inspect=d}else o.prototype.inspect=d;function d(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var h=["","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"],g=[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],b=[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];o.prototype.toString=function(f,y){f=f||10,y=y|0||1;var E;if(f===16||f==="hex"){E="";for(var I=0,N=0,D=0;D<this.length;D++){var M=this.words[D],P=((M<<I|N)&16777215).toString(16);N=M>>>24-I&16777215,I+=2,I>=26&&(I-=26,D--),N!==0||D!==this.length-1?E=h[6-P.length]+P+E:E=P+E}for(N!==0&&(E=N.toString(16)+E);E.length%y!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}if(f===(f|0)&&f>=2&&f<=36){var m=g[f],v=b[f];E="";var B=this.clone();for(B.negative=0;!B.isZero();){var U=B.modrn(v).toString(f);B=B.idivn(v),B.isZero()?E=U+E:E=h[m-U.length]+U+E}for(this.isZero()&&(E="0"+E);E.length%y!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var f=this.words[0];return this.length===2?f+=this.words[1]*67108864:this.length===3&&this.words[2]===1?f+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-f:f},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(f,y){return this.toArrayLike(s,f,y)}),o.prototype.toArray=function(f,y){return this.toArrayLike(Array,f,y)};var p=function(f,y){return f.allocUnsafe?f.allocUnsafe(y):new f(y)};o.prototype.toArrayLike=function(f,y,E){this._strip();var I=this.byteLength(),N=E||Math.max(1,I);r(I<=N,"byte array longer than desired length"),r(N>0,"Requested array length <= 0");var D=p(f,N),M=y==="le"?"LE":"BE";return this["_toArrayLike"+M](D,I),D},o.prototype._toArrayLikeLE=function(f,y){for(var E=0,I=0,N=0,D=0;N<this.length;N++){var M=this.words[N]<<D|I;f[E++]=M&255,E<f.length&&(f[E++]=M>>8&255),E<f.length&&(f[E++]=M>>16&255),D===6?(E<f.length&&(f[E++]=M>>24&255),I=0,D=0):(I=M>>>24,D+=2)}if(E<f.length)for(f[E++]=I;E<f.length;)f[E++]=0},o.prototype._toArrayLikeBE=function(f,y){for(var E=f.length-1,I=0,N=0,D=0;N<this.length;N++){var M=this.words[N]<<D|I;f[E--]=M&255,E>=0&&(f[E--]=M>>8&255),E>=0&&(f[E--]=M>>16&255),D===6?(E>=0&&(f[E--]=M>>24&255),I=0,D=0):(I=M>>>24,D+=2)}if(E>=0)for(f[E--]=I;E>=0;)f[E--]=0},Math.clz32?o.prototype._countBits=function(f){return 32-Math.clz32(f)}:o.prototype._countBits=function(f){var y=f,E=0;return y>=4096&&(E+=13,y>>>=13),y>=64&&(E+=7,y>>>=7),y>=8&&(E+=4,y>>>=4),y>=2&&(E+=2,y>>>=2),E+y},o.prototype._zeroBits=function(f){if(f===0)return 26;var y=f,E=0;return(y&8191)===0&&(E+=13,y>>>=13),(y&127)===0&&(E+=7,y>>>=7),(y&15)===0&&(E+=4,y>>>=4),(y&3)===0&&(E+=2,y>>>=2),(y&1)===0&&E++,E},o.prototype.bitLength=function(){var f=this.words[this.length-1],y=this._countBits(f);return(this.length-1)*26+y};function w(C){for(var f=new Array(C.bitLength()),y=0;y<f.length;y++){var E=y/26|0,I=y%26;f[y]=C.words[E]>>>I&1}return f}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,y=0;y<this.length;y++){var E=this._zeroBits(this.words[y]);if(f+=E,E!==26)break}return f},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(f){return this.negative!==0?this.abs().inotn(f).iaddn(1):this.clone()},o.prototype.fromTwos=function(f){return this.testn(f-1)?this.notn(f).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(f){for(;this.length<f.length;)this.words[this.length++]=0;for(var y=0;y<f.length;y++)this.words[y]=this.words[y]|f.words[y];return this._strip()},o.prototype.ior=function(f){return r((this.negative|f.negative)===0),this.iuor(f)},o.prototype.or=function(f){return this.length>f.length?this.clone().ior(f):f.clone().ior(this)},o.prototype.uor=function(f){return this.length>f.length?this.clone().iuor(f):f.clone().iuor(this)},o.prototype.iuand=function(f){var y;this.length>f.length?y=f:y=this;for(var E=0;E<y.length;E++)this.words[E]=this.words[E]&f.words[E];return this.length=y.length,this._strip()},o.prototype.iand=function(f){return r((this.negative|f.negative)===0),this.iuand(f)},o.prototype.and=function(f){return this.length>f.length?this.clone().iand(f):f.clone().iand(this)},o.prototype.uand=function(f){return this.length>f.length?this.clone().iuand(f):f.clone().iuand(this)},o.prototype.iuxor=function(f){var y,E;this.length>f.length?(y=this,E=f):(y=f,E=this);for(var I=0;I<E.length;I++)this.words[I]=y.words[I]^E.words[I];if(this!==y)for(;I<y.length;I++)this.words[I]=y.words[I];return this.length=y.length,this._strip()},o.prototype.ixor=function(f){return r((this.negative|f.negative)===0),this.iuxor(f)},o.prototype.xor=function(f){return this.length>f.length?this.clone().ixor(f):f.clone().ixor(this)},o.prototype.uxor=function(f){return this.length>f.length?this.clone().iuxor(f):f.clone().iuxor(this)},o.prototype.inotn=function(f){r(typeof f=="number"&&f>=0);var y=Math.ceil(f/26)|0,E=f%26;this._expand(y),E>0&&y--;for(var I=0;I<y;I++)this.words[I]=~this.words[I]&67108863;return E>0&&(this.words[I]=~this.words[I]&67108863>>26-E),this._strip()},o.prototype.notn=function(f){return this.clone().inotn(f)},o.prototype.setn=function(f,y){r(typeof f=="number"&&f>=0);var E=f/26|0,I=f%26;return this._expand(E+1),y?this.words[E]=this.words[E]|1<<I:this.words[E]=this.words[E]&~(1<<I),this._strip()},o.prototype.iadd=function(f){var y;if(this.negative!==0&&f.negative===0)return this.negative=0,y=this.isub(f),this.negative^=1,this._normSign();if(this.negative===0&&f.negative!==0)return f.negative=0,y=this.isub(f),f.negative=1,y._normSign();var E,I;this.length>f.length?(E=this,I=f):(E=f,I=this);for(var N=0,D=0;D<I.length;D++)y=(E.words[D]|0)+(I.words[D]|0)+N,this.words[D]=y&67108863,N=y>>>26;for(;N!==0&&D<E.length;D++)y=(E.words[D]|0)+N,this.words[D]=y&67108863,N=y>>>26;if(this.length=E.length,N!==0)this.words[this.length]=N,this.length++;else if(E!==this)for(;D<E.length;D++)this.words[D]=E.words[D];return this},o.prototype.add=function(f){var y;return f.negative!==0&&this.negative===0?(f.negative=0,y=this.sub(f),f.negative^=1,y):f.negative===0&&this.negative!==0?(this.negative=0,y=f.sub(this),this.negative=1,y):this.length>f.length?this.clone().iadd(f):f.clone().iadd(this)},o.prototype.isub=function(f){if(f.negative!==0){f.negative=0;var y=this.iadd(f);return f.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(f),this.negative=1,this._normSign();var E=this.cmp(f);if(E===0)return this.negative=0,this.length=1,this.words[0]=0,this;var I,N;E>0?(I=this,N=f):(I=f,N=this);for(var D=0,M=0;M<N.length;M++)y=(I.words[M]|0)-(N.words[M]|0)+D,D=y>>26,this.words[M]=y&67108863;for(;D!==0&&M<I.length;M++)y=(I.words[M]|0)+D,D=y>>26,this.words[M]=y&67108863;if(D===0&&M<I.length&&I!==this)for(;M<I.length;M++)this.words[M]=I.words[M];return this.length=Math.max(this.length,M),I!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(f){return this.clone().isub(f)};function S(C,f,y){y.negative=f.negative^C.negative;var E=C.length+f.length|0;y.length=E,E=E-1|0;var I=C.words[0]|0,N=f.words[0]|0,D=I*N,M=D&67108863,P=D/67108864|0;y.words[0]=M;for(var m=1;m<E;m++){for(var v=P>>>26,B=P&67108863,U=Math.min(m,f.length-1),Q=Math.max(0,m-C.length+1);Q<=U;Q++){var ee=m-Q|0;I=C.words[ee]|0,N=f.words[Q]|0,D=I*N+B,v+=D/67108864|0,B=D&67108863}y.words[m]=B|0,P=v|0}return P!==0?y.words[m]=P|0:y.length--,y._strip()}var O=function(f,y,E){var I=f.words,N=y.words,D=E.words,M=0,P,m,v,B=I[0]|0,U=B&8191,Q=B>>>13,ee=I[1]|0,Z=ee&8191,Y=ee>>>13,re=I[2]|0,de=re&8191,se=re>>>13,me=I[3]|0,Ae=me&8191,Re=me>>>13,Ct=I[4]|0,st=Ct&8191,dt=Ct>>>13,ji=I[5]|0,at=ji&8191,it=ji>>>13,hn=I[6]|0,ft=hn&8191,mt=hn>>>13,hi=I[7]|0,It=hi&8191,_=hi>>>13,x=I[8]|0,A=x&8191,H=x>>>13,te=I[9]|0,ie=te&8191,ue=te>>>13,De=N[0]|0,Le=De&8191,Me=De>>>13,yt=N[1]|0,Ne=yt&8191,Vt=yt>>>13,mT=N[2]|0,Dt=mT&8191,zt=mT>>>13,yT=N[3]|0,Ut=yT&8191,$t=yT>>>13,bT=N[4]|0,Ht=bT&8191,Wt=bT>>>13,vT=N[5]|0,Gt=vT&8191,jt=vT>>>13,wT=N[6]|0,Kt=wT&8191,qt=wT>>>13,xT=N[7]|0,Yt=xT&8191,Qt=xT>>>13,ET=N[8]|0,Xt=ET&8191,Jt=ET>>>13,ST=N[9]|0,Zt=ST&8191,en=ST>>>13;E.negative=f.negative^y.negative,E.length=19,P=Math.imul(U,Le),m=Math.imul(U,Me),m=m+Math.imul(Q,Le)|0,v=Math.imul(Q,Me);var Ab=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Ab>>>26)|0,Ab&=67108863,P=Math.imul(Z,Le),m=Math.imul(Z,Me),m=m+Math.imul(Y,Le)|0,v=Math.imul(Y,Me),P=P+Math.imul(U,Ne)|0,m=m+Math.imul(U,Vt)|0,m=m+Math.imul(Q,Ne)|0,v=v+Math.imul(Q,Vt)|0;var kb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(kb>>>26)|0,kb&=67108863,P=Math.imul(de,Le),m=Math.imul(de,Me),m=m+Math.imul(se,Le)|0,v=Math.imul(se,Me),P=P+Math.imul(Z,Ne)|0,m=m+Math.imul(Z,Vt)|0,m=m+Math.imul(Y,Ne)|0,v=v+Math.imul(Y,Vt)|0,P=P+Math.imul(U,Dt)|0,m=m+Math.imul(U,zt)|0,m=m+Math.imul(Q,Dt)|0,v=v+Math.imul(Q,zt)|0;var Cb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Cb>>>26)|0,Cb&=67108863,P=Math.imul(Ae,Le),m=Math.imul(Ae,Me),m=m+Math.imul(Re,Le)|0,v=Math.imul(Re,Me),P=P+Math.imul(de,Ne)|0,m=m+Math.imul(de,Vt)|0,m=m+Math.imul(se,Ne)|0,v=v+Math.imul(se,Vt)|0,P=P+Math.imul(Z,Dt)|0,m=m+Math.imul(Z,zt)|0,m=m+Math.imul(Y,Dt)|0,v=v+Math.imul(Y,zt)|0,P=P+Math.imul(U,Ut)|0,m=m+Math.imul(U,$t)|0,m=m+Math.imul(Q,Ut)|0,v=v+Math.imul(Q,$t)|0;var Ib=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Ib>>>26)|0,Ib&=67108863,P=Math.imul(st,Le),m=Math.imul(st,Me),m=m+Math.imul(dt,Le)|0,v=Math.imul(dt,Me),P=P+Math.imul(Ae,Ne)|0,m=m+Math.imul(Ae,Vt)|0,m=m+Math.imul(Re,Ne)|0,v=v+Math.imul(Re,Vt)|0,P=P+Math.imul(de,Dt)|0,m=m+Math.imul(de,zt)|0,m=m+Math.imul(se,Dt)|0,v=v+Math.imul(se,zt)|0,P=P+Math.imul(Z,Ut)|0,m=m+Math.imul(Z,$t)|0,m=m+Math.imul(Y,Ut)|0,v=v+Math.imul(Y,$t)|0,P=P+Math.imul(U,Ht)|0,m=m+Math.imul(U,Wt)|0,m=m+Math.imul(Q,Ht)|0,v=v+Math.imul(Q,Wt)|0;var Ob=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Ob>>>26)|0,Ob&=67108863,P=Math.imul(at,Le),m=Math.imul(at,Me),m=m+Math.imul(it,Le)|0,v=Math.imul(it,Me),P=P+Math.imul(st,Ne)|0,m=m+Math.imul(st,Vt)|0,m=m+Math.imul(dt,Ne)|0,v=v+Math.imul(dt,Vt)|0,P=P+Math.imul(Ae,Dt)|0,m=m+Math.imul(Ae,zt)|0,m=m+Math.imul(Re,Dt)|0,v=v+Math.imul(Re,zt)|0,P=P+Math.imul(de,Ut)|0,m=m+Math.imul(de,$t)|0,m=m+Math.imul(se,Ut)|0,v=v+Math.imul(se,$t)|0,P=P+Math.imul(Z,Ht)|0,m=m+Math.imul(Z,Wt)|0,m=m+Math.imul(Y,Ht)|0,v=v+Math.imul(Y,Wt)|0,P=P+Math.imul(U,Gt)|0,m=m+Math.imul(U,jt)|0,m=m+Math.imul(Q,Gt)|0,v=v+Math.imul(Q,jt)|0;var Tb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Tb>>>26)|0,Tb&=67108863,P=Math.imul(ft,Le),m=Math.imul(ft,Me),m=m+Math.imul(mt,Le)|0,v=Math.imul(mt,Me),P=P+Math.imul(at,Ne)|0,m=m+Math.imul(at,Vt)|0,m=m+Math.imul(it,Ne)|0,v=v+Math.imul(it,Vt)|0,P=P+Math.imul(st,Dt)|0,m=m+Math.imul(st,zt)|0,m=m+Math.imul(dt,Dt)|0,v=v+Math.imul(dt,zt)|0,P=P+Math.imul(Ae,Ut)|0,m=m+Math.imul(Ae,$t)|0,m=m+Math.imul(Re,Ut)|0,v=v+Math.imul(Re,$t)|0,P=P+Math.imul(de,Ht)|0,m=m+Math.imul(de,Wt)|0,m=m+Math.imul(se,Ht)|0,v=v+Math.imul(se,Wt)|0,P=P+Math.imul(Z,Gt)|0,m=m+Math.imul(Z,jt)|0,m=m+Math.imul(Y,Gt)|0,v=v+Math.imul(Y,jt)|0,P=P+Math.imul(U,Kt)|0,m=m+Math.imul(U,qt)|0,m=m+Math.imul(Q,Kt)|0,v=v+Math.imul(Q,qt)|0;var Pb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Pb>>>26)|0,Pb&=67108863,P=Math.imul(It,Le),m=Math.imul(It,Me),m=m+Math.imul(_,Le)|0,v=Math.imul(_,Me),P=P+Math.imul(ft,Ne)|0,m=m+Math.imul(ft,Vt)|0,m=m+Math.imul(mt,Ne)|0,v=v+Math.imul(mt,Vt)|0,P=P+Math.imul(at,Dt)|0,m=m+Math.imul(at,zt)|0,m=m+Math.imul(it,Dt)|0,v=v+Math.imul(it,zt)|0,P=P+Math.imul(st,Ut)|0,m=m+Math.imul(st,$t)|0,m=m+Math.imul(dt,Ut)|0,v=v+Math.imul(dt,$t)|0,P=P+Math.imul(Ae,Ht)|0,m=m+Math.imul(Ae,Wt)|0,m=m+Math.imul(Re,Ht)|0,v=v+Math.imul(Re,Wt)|0,P=P+Math.imul(de,Gt)|0,m=m+Math.imul(de,jt)|0,m=m+Math.imul(se,Gt)|0,v=v+Math.imul(se,jt)|0,P=P+Math.imul(Z,Kt)|0,m=m+Math.imul(Z,qt)|0,m=m+Math.imul(Y,Kt)|0,v=v+Math.imul(Y,qt)|0,P=P+Math.imul(U,Yt)|0,m=m+Math.imul(U,Qt)|0,m=m+Math.imul(Q,Yt)|0,v=v+Math.imul(Q,Qt)|0;var Nb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Nb>>>26)|0,Nb&=67108863,P=Math.imul(A,Le),m=Math.imul(A,Me),m=m+Math.imul(H,Le)|0,v=Math.imul(H,Me),P=P+Math.imul(It,Ne)|0,m=m+Math.imul(It,Vt)|0,m=m+Math.imul(_,Ne)|0,v=v+Math.imul(_,Vt)|0,P=P+Math.imul(ft,Dt)|0,m=m+Math.imul(ft,zt)|0,m=m+Math.imul(mt,Dt)|0,v=v+Math.imul(mt,zt)|0,P=P+Math.imul(at,Ut)|0,m=m+Math.imul(at,$t)|0,m=m+Math.imul(it,Ut)|0,v=v+Math.imul(it,$t)|0,P=P+Math.imul(st,Ht)|0,m=m+Math.imul(st,Wt)|0,m=m+Math.imul(dt,Ht)|0,v=v+Math.imul(dt,Wt)|0,P=P+Math.imul(Ae,Gt)|0,m=m+Math.imul(Ae,jt)|0,m=m+Math.imul(Re,Gt)|0,v=v+Math.imul(Re,jt)|0,P=P+Math.imul(de,Kt)|0,m=m+Math.imul(de,qt)|0,m=m+Math.imul(se,Kt)|0,v=v+Math.imul(se,qt)|0,P=P+Math.imul(Z,Yt)|0,m=m+Math.imul(Z,Qt)|0,m=m+Math.imul(Y,Yt)|0,v=v+Math.imul(Y,Qt)|0,P=P+Math.imul(U,Xt)|0,m=m+Math.imul(U,Jt)|0,m=m+Math.imul(Q,Xt)|0,v=v+Math.imul(Q,Jt)|0;var Bb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Bb>>>26)|0,Bb&=67108863,P=Math.imul(ie,Le),m=Math.imul(ie,Me),m=m+Math.imul(ue,Le)|0,v=Math.imul(ue,Me),P=P+Math.imul(A,Ne)|0,m=m+Math.imul(A,Vt)|0,m=m+Math.imul(H,Ne)|0,v=v+Math.imul(H,Vt)|0,P=P+Math.imul(It,Dt)|0,m=m+Math.imul(It,zt)|0,m=m+Math.imul(_,Dt)|0,v=v+Math.imul(_,zt)|0,P=P+Math.imul(ft,Ut)|0,m=m+Math.imul(ft,$t)|0,m=m+Math.imul(mt,Ut)|0,v=v+Math.imul(mt,$t)|0,P=P+Math.imul(at,Ht)|0,m=m+Math.imul(at,Wt)|0,m=m+Math.imul(it,Ht)|0,v=v+Math.imul(it,Wt)|0,P=P+Math.imul(st,Gt)|0,m=m+Math.imul(st,jt)|0,m=m+Math.imul(dt,Gt)|0,v=v+Math.imul(dt,jt)|0,P=P+Math.imul(Ae,Kt)|0,m=m+Math.imul(Ae,qt)|0,m=m+Math.imul(Re,Kt)|0,v=v+Math.imul(Re,qt)|0,P=P+Math.imul(de,Yt)|0,m=m+Math.imul(de,Qt)|0,m=m+Math.imul(se,Yt)|0,v=v+Math.imul(se,Qt)|0,P=P+Math.imul(Z,Xt)|0,m=m+Math.imul(Z,Jt)|0,m=m+Math.imul(Y,Xt)|0,v=v+Math.imul(Y,Jt)|0,P=P+Math.imul(U,Zt)|0,m=m+Math.imul(U,en)|0,m=m+Math.imul(Q,Zt)|0,v=v+Math.imul(Q,en)|0;var Rb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Rb>>>26)|0,Rb&=67108863,P=Math.imul(ie,Ne),m=Math.imul(ie,Vt),m=m+Math.imul(ue,Ne)|0,v=Math.imul(ue,Vt),P=P+Math.imul(A,Dt)|0,m=m+Math.imul(A,zt)|0,m=m+Math.imul(H,Dt)|0,v=v+Math.imul(H,zt)|0,P=P+Math.imul(It,Ut)|0,m=m+Math.imul(It,$t)|0,m=m+Math.imul(_,Ut)|0,v=v+Math.imul(_,$t)|0,P=P+Math.imul(ft,Ht)|0,m=m+Math.imul(ft,Wt)|0,m=m+Math.imul(mt,Ht)|0,v=v+Math.imul(mt,Wt)|0,P=P+Math.imul(at,Gt)|0,m=m+Math.imul(at,jt)|0,m=m+Math.imul(it,Gt)|0,v=v+Math.imul(it,jt)|0,P=P+Math.imul(st,Kt)|0,m=m+Math.imul(st,qt)|0,m=m+Math.imul(dt,Kt)|0,v=v+Math.imul(dt,qt)|0,P=P+Math.imul(Ae,Yt)|0,m=m+Math.imul(Ae,Qt)|0,m=m+Math.imul(Re,Yt)|0,v=v+Math.imul(Re,Qt)|0,P=P+Math.imul(de,Xt)|0,m=m+Math.imul(de,Jt)|0,m=m+Math.imul(se,Xt)|0,v=v+Math.imul(se,Jt)|0,P=P+Math.imul(Z,Zt)|0,m=m+Math.imul(Z,en)|0,m=m+Math.imul(Y,Zt)|0,v=v+Math.imul(Y,en)|0;var Mb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Mb>>>26)|0,Mb&=67108863,P=Math.imul(ie,Dt),m=Math.imul(ie,zt),m=m+Math.imul(ue,Dt)|0,v=Math.imul(ue,zt),P=P+Math.imul(A,Ut)|0,m=m+Math.imul(A,$t)|0,m=m+Math.imul(H,Ut)|0,v=v+Math.imul(H,$t)|0,P=P+Math.imul(It,Ht)|0,m=m+Math.imul(It,Wt)|0,m=m+Math.imul(_,Ht)|0,v=v+Math.imul(_,Wt)|0,P=P+Math.imul(ft,Gt)|0,m=m+Math.imul(ft,jt)|0,m=m+Math.imul(mt,Gt)|0,v=v+Math.imul(mt,jt)|0,P=P+Math.imul(at,Kt)|0,m=m+Math.imul(at,qt)|0,m=m+Math.imul(it,Kt)|0,v=v+Math.imul(it,qt)|0,P=P+Math.imul(st,Yt)|0,m=m+Math.imul(st,Qt)|0,m=m+Math.imul(dt,Yt)|0,v=v+Math.imul(dt,Qt)|0,P=P+Math.imul(Ae,Xt)|0,m=m+Math.imul(Ae,Jt)|0,m=m+Math.imul(Re,Xt)|0,v=v+Math.imul(Re,Jt)|0,P=P+Math.imul(de,Zt)|0,m=m+Math.imul(de,en)|0,m=m+Math.imul(se,Zt)|0,v=v+Math.imul(se,en)|0;var Lb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Lb>>>26)|0,Lb&=67108863,P=Math.imul(ie,Ut),m=Math.imul(ie,$t),m=m+Math.imul(ue,Ut)|0,v=Math.imul(ue,$t),P=P+Math.imul(A,Ht)|0,m=m+Math.imul(A,Wt)|0,m=m+Math.imul(H,Ht)|0,v=v+Math.imul(H,Wt)|0,P=P+Math.imul(It,Gt)|0,m=m+Math.imul(It,jt)|0,m=m+Math.imul(_,Gt)|0,v=v+Math.imul(_,jt)|0,P=P+Math.imul(ft,Kt)|0,m=m+Math.imul(ft,qt)|0,m=m+Math.imul(mt,Kt)|0,v=v+Math.imul(mt,qt)|0,P=P+Math.imul(at,Yt)|0,m=m+Math.imul(at,Qt)|0,m=m+Math.imul(it,Yt)|0,v=v+Math.imul(it,Qt)|0,P=P+Math.imul(st,Xt)|0,m=m+Math.imul(st,Jt)|0,m=m+Math.imul(dt,Xt)|0,v=v+Math.imul(dt,Jt)|0,P=P+Math.imul(Ae,Zt)|0,m=m+Math.imul(Ae,en)|0,m=m+Math.imul(Re,Zt)|0,v=v+Math.imul(Re,en)|0;var Fb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Fb>>>26)|0,Fb&=67108863,P=Math.imul(ie,Ht),m=Math.imul(ie,Wt),m=m+Math.imul(ue,Ht)|0,v=Math.imul(ue,Wt),P=P+Math.imul(A,Gt)|0,m=m+Math.imul(A,jt)|0,m=m+Math.imul(H,Gt)|0,v=v+Math.imul(H,jt)|0,P=P+Math.imul(It,Kt)|0,m=m+Math.imul(It,qt)|0,m=m+Math.imul(_,Kt)|0,v=v+Math.imul(_,qt)|0,P=P+Math.imul(ft,Yt)|0,m=m+Math.imul(ft,Qt)|0,m=m+Math.imul(mt,Yt)|0,v=v+Math.imul(mt,Qt)|0,P=P+Math.imul(at,Xt)|0,m=m+Math.imul(at,Jt)|0,m=m+Math.imul(it,Xt)|0,v=v+Math.imul(it,Jt)|0,P=P+Math.imul(st,Zt)|0,m=m+Math.imul(st,en)|0,m=m+Math.imul(dt,Zt)|0,v=v+Math.imul(dt,en)|0;var _b=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(_b>>>26)|0,_b&=67108863,P=Math.imul(ie,Gt),m=Math.imul(ie,jt),m=m+Math.imul(ue,Gt)|0,v=Math.imul(ue,jt),P=P+Math.imul(A,Kt)|0,m=m+Math.imul(A,qt)|0,m=m+Math.imul(H,Kt)|0,v=v+Math.imul(H,qt)|0,P=P+Math.imul(It,Yt)|0,m=m+Math.imul(It,Qt)|0,m=m+Math.imul(_,Yt)|0,v=v+Math.imul(_,Qt)|0,P=P+Math.imul(ft,Xt)|0,m=m+Math.imul(ft,Jt)|0,m=m+Math.imul(mt,Xt)|0,v=v+Math.imul(mt,Jt)|0,P=P+Math.imul(at,Zt)|0,m=m+Math.imul(at,en)|0,m=m+Math.imul(it,Zt)|0,v=v+Math.imul(it,en)|0;var Vb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Vb>>>26)|0,Vb&=67108863,P=Math.imul(ie,Kt),m=Math.imul(ie,qt),m=m+Math.imul(ue,Kt)|0,v=Math.imul(ue,qt),P=P+Math.imul(A,Yt)|0,m=m+Math.imul(A,Qt)|0,m=m+Math.imul(H,Yt)|0,v=v+Math.imul(H,Qt)|0,P=P+Math.imul(It,Xt)|0,m=m+Math.imul(It,Jt)|0,m=m+Math.imul(_,Xt)|0,v=v+Math.imul(_,Jt)|0,P=P+Math.imul(ft,Zt)|0,m=m+Math.imul(ft,en)|0,m=m+Math.imul(mt,Zt)|0,v=v+Math.imul(mt,en)|0;var Db=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Db>>>26)|0,Db&=67108863,P=Math.imul(ie,Yt),m=Math.imul(ie,Qt),m=m+Math.imul(ue,Yt)|0,v=Math.imul(ue,Qt),P=P+Math.imul(A,Xt)|0,m=m+Math.imul(A,Jt)|0,m=m+Math.imul(H,Xt)|0,v=v+Math.imul(H,Jt)|0,P=P+Math.imul(It,Zt)|0,m=m+Math.imul(It,en)|0,m=m+Math.imul(_,Zt)|0,v=v+Math.imul(_,en)|0;var zb=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(zb>>>26)|0,zb&=67108863,P=Math.imul(ie,Xt),m=Math.imul(ie,Jt),m=m+Math.imul(ue,Xt)|0,v=Math.imul(ue,Jt),P=P+Math.imul(A,Zt)|0,m=m+Math.imul(A,en)|0,m=m+Math.imul(H,Zt)|0,v=v+Math.imul(H,en)|0;var Ub=(M+P|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Ub>>>26)|0,Ub&=67108863,P=Math.imul(ie,Zt),m=Math.imul(ie,en),m=m+Math.imul(ue,Zt)|0,v=Math.imul(ue,en);var $b=(M+P|0)+((m&8191)<<13)|0;return M=(v+(m>>>13)|0)+($b>>>26)|0,$b&=67108863,D[0]=Ab,D[1]=kb,D[2]=Cb,D[3]=Ib,D[4]=Ob,D[5]=Tb,D[6]=Pb,D[7]=Nb,D[8]=Bb,D[9]=Rb,D[10]=Mb,D[11]=Lb,D[12]=Fb,D[13]=_b,D[14]=Vb,D[15]=Db,D[16]=zb,D[17]=Ub,D[18]=$b,M!==0&&(D[19]=M,E.length++),E};Math.imul||(O=S);function T(C,f,y){y.negative=f.negative^C.negative,y.length=C.length+f.length;for(var E=0,I=0,N=0;N<y.length-1;N++){var D=I;I=0;for(var M=E&67108863,P=Math.min(N,f.length-1),m=Math.max(0,N-C.length+1);m<=P;m++){var v=N-m,B=C.words[v]|0,U=f.words[m]|0,Q=B*U,ee=Q&67108863;D=D+(Q/67108864|0)|0,ee=ee+M|0,M=ee&67108863,D=D+(ee>>>26)|0,I+=D>>>26,D&=67108863}y.words[N]=M,E=D,D=I}return E!==0?y.words[N]=E:y.length--,y._strip()}function $(C,f,y){return T(C,f,y)}o.prototype.mulTo=function(f,y){var E,I=this.length+f.length;return this.length===10&&f.length===10?E=O(this,f,y):I<63?E=S(this,f,y):I<1024?E=T(this,f,y):E=$(this,f,y),E},o.prototype.mul=function(f){var y=new o(null);return y.words=new Array(this.length+f.length),this.mulTo(f,y)},o.prototype.mulf=function(f){var y=new o(null);return y.words=new Array(this.length+f.length),$(this,f,y)},o.prototype.imul=function(f){return this.clone().mulTo(f,this)},o.prototype.imuln=function(f){var y=f<0;y&&(f=-f),r(typeof f=="number"),r(f<67108864);for(var E=0,I=0;I<this.length;I++){var N=(this.words[I]|0)*f,D=(N&67108863)+(E&67108863);E>>=26,E+=N/67108864|0,E+=D>>>26,this.words[I]=D&67108863}return E!==0&&(this.words[I]=E,this.length++),this.length=f===0?1:this.length,y?this.ineg():this},o.prototype.muln=function(f){return this.clone().imuln(f)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(f){var y=w(f);if(y.length===0)return new o(1);for(var E=this,I=0;I<y.length&&y[I]===0;I++,E=E.sqr());if(++I<y.length)for(var N=E.sqr();I<y.length;I++,N=N.sqr())y[I]!==0&&(E=E.mul(N));return E},o.prototype.iushln=function(f){r(typeof f=="number"&&f>=0);var y=f%26,E=(f-y)/26,I=67108863>>>26-y<<26-y,N;if(y!==0){var D=0;for(N=0;N<this.length;N++){var M=this.words[N]&I,P=(this.words[N]|0)-M<<y;this.words[N]=P|D,D=M>>>26-y}D&&(this.words[N]=D,this.length++)}if(E!==0){for(N=this.length-1;N>=0;N--)this.words[N+E]=this.words[N];for(N=0;N<E;N++)this.words[N]=0;this.length+=E}return this._strip()},o.prototype.ishln=function(f){return r(this.negative===0),this.iushln(f)},o.prototype.iushrn=function(f,y,E){r(typeof f=="number"&&f>=0);var I;y?I=(y-y%26)/26:I=0;var N=f%26,D=Math.min((f-N)/26,this.length),M=67108863^67108863>>>N<<N,P=E;if(I-=D,I=Math.max(0,I),P){for(var m=0;m<D;m++)P.words[m]=this.words[m];P.length=D}if(D!==0)if(this.length>D)for(this.length-=D,m=0;m<this.length;m++)this.words[m]=this.words[m+D];else this.words[0]=0,this.length=1;var v=0;for(m=this.length-1;m>=0&&(v!==0||m>=I);m--){var B=this.words[m]|0;this.words[m]=v<<26-N|B>>>N,v=B&M}return P&&v!==0&&(P.words[P.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(f,y,E){return r(this.negative===0),this.iushrn(f,y,E)},o.prototype.shln=function(f){return this.clone().ishln(f)},o.prototype.ushln=function(f){return this.clone().iushln(f)},o.prototype.shrn=function(f){return this.clone().ishrn(f)},o.prototype.ushrn=function(f){return this.clone().iushrn(f)},o.prototype.testn=function(f){r(typeof f=="number"&&f>=0);var y=f%26,E=(f-y)/26,I=1<<y;if(this.length<=E)return!1;var N=this.words[E];return!!(N&I)},o.prototype.imaskn=function(f){r(typeof f=="number"&&f>=0);var y=f%26,E=(f-y)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=E)return this;if(y!==0&&E++,this.length=Math.min(E,this.length),y!==0){var I=67108863^67108863>>>y<<y;this.words[this.length-1]&=I}return this._strip()},o.prototype.maskn=function(f){return this.clone().imaskn(f)},o.prototype.iaddn=function(f){return r(typeof f=="number"),r(f<67108864),f<0?this.isubn(-f):this.negative!==0?this.length===1&&(this.words[0]|0)<=f?(this.words[0]=f-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(f),this.negative=1,this):this._iaddn(f)},o.prototype._iaddn=function(f){this.words[0]+=f;for(var y=0;y<this.length&&this.words[y]>=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},o.prototype.isubn=function(f){if(r(typeof f=="number"),r(f<67108864),f<0)return this.iaddn(-f);if(this.negative!==0)return this.negative=0,this.iaddn(f),this.negative=1,this;if(this.words[0]-=f,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},o.prototype.addn=function(f){return this.clone().iaddn(f)},o.prototype.subn=function(f){return this.clone().isubn(f)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(f,y,E){var I=f.length+E,N;this._expand(I);var D,M=0;for(N=0;N<f.length;N++){D=(this.words[N+E]|0)+M;var P=(f.words[N]|0)*y;D-=P&67108863,M=(D>>26)-(P/67108864|0),this.words[N+E]=D&67108863}for(;N<this.length-E;N++)D=(this.words[N+E]|0)+M,M=D>>26,this.words[N+E]=D&67108863;if(M===0)return this._strip();for(r(M===-1),M=0,N=0;N<this.length;N++)D=-(this.words[N]|0)+M,M=D>>26,this.words[N]=D&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(f,y){var E=this.length-f.length,I=this.clone(),N=f,D=N.words[N.length-1]|0,M=this._countBits(D);E=26-M,E!==0&&(N=N.ushln(E),I.iushln(E),D=N.words[N.length-1]|0);var P=I.length-N.length,m;if(y!=="mod"){m=new o(null),m.length=P+1,m.words=new Array(m.length);for(var v=0;v<m.length;v++)m.words[v]=0}var B=I.clone()._ishlnsubmul(N,1,P);B.negative===0&&(I=B,m&&(m.words[P]=1));for(var U=P-1;U>=0;U--){var Q=(I.words[N.length+U]|0)*67108864+(I.words[N.length+U-1]|0);for(Q=Math.min(Q/D|0,67108863),I._ishlnsubmul(N,Q,U);I.negative!==0;)Q--,I.negative=0,I._ishlnsubmul(N,1,U),I.isZero()||(I.negative^=1);m&&(m.words[U]=Q)}return m&&m._strip(),I._strip(),y!=="div"&&E!==0&&I.iushrn(E),{div:m||null,mod:I}},o.prototype.divmod=function(f,y,E){if(r(!f.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var I,N,D;return this.negative!==0&&f.negative===0?(D=this.neg().divmod(f,y),y!=="mod"&&(I=D.div.neg()),y!=="div"&&(N=D.mod.neg(),E&&N.negative!==0&&N.iadd(f)),{div:I,mod:N}):this.negative===0&&f.negative!==0?(D=this.divmod(f.neg(),y),y!=="mod"&&(I=D.div.neg()),{div:I,mod:D.mod}):(this.negative&f.negative)!==0?(D=this.neg().divmod(f.neg(),y),y!=="div"&&(N=D.mod.neg(),E&&N.negative!==0&&N.isub(f)),{div:D.div,mod:N}):f.length>this.length||this.cmp(f)<0?{div:new o(0),mod:this}:f.length===1?y==="div"?{div:this.divn(f.words[0]),mod:null}:y==="mod"?{div:null,mod:new o(this.modrn(f.words[0]))}:{div:this.divn(f.words[0]),mod:new o(this.modrn(f.words[0]))}:this._wordDiv(f,y)},o.prototype.div=function(f){return this.divmod(f,"div",!1).div},o.prototype.mod=function(f){return this.divmod(f,"mod",!1).mod},o.prototype.umod=function(f){return this.divmod(f,"mod",!0).mod},o.prototype.divRound=function(f){var y=this.divmod(f);if(y.mod.isZero())return y.div;var E=y.div.negative!==0?y.mod.isub(f):y.mod,I=f.ushrn(1),N=f.andln(1),D=E.cmp(I);return D<0||N===1&&D===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},o.prototype.modrn=function(f){var y=f<0;y&&(f=-f),r(f<=67108863);for(var E=(1<<26)%f,I=0,N=this.length-1;N>=0;N--)I=(E*I+(this.words[N]|0))%f;return y?-I:I},o.prototype.modn=function(f){return this.modrn(f)},o.prototype.idivn=function(f){var y=f<0;y&&(f=-f),r(f<=67108863);for(var E=0,I=this.length-1;I>=0;I--){var N=(this.words[I]|0)+E*67108864;this.words[I]=N/f|0,E=N%f}return this._strip(),y?this.ineg():this},o.prototype.divn=function(f){return this.clone().idivn(f)},o.prototype.egcd=function(f){r(f.negative===0),r(!f.isZero());var y=this,E=f.clone();y.negative!==0?y=y.umod(f):y=y.clone();for(var I=new o(1),N=new o(0),D=new o(0),M=new o(1),P=0;y.isEven()&&E.isEven();)y.iushrn(1),E.iushrn(1),++P;for(var m=E.clone(),v=y.clone();!y.isZero();){for(var B=0,U=1;(y.words[0]&U)===0&&B<26;++B,U<<=1);if(B>0)for(y.iushrn(B);B-- >0;)(I.isOdd()||N.isOdd())&&(I.iadd(m),N.isub(v)),I.iushrn(1),N.iushrn(1);for(var Q=0,ee=1;(E.words[0]&ee)===0&&Q<26;++Q,ee<<=1);if(Q>0)for(E.iushrn(Q);Q-- >0;)(D.isOdd()||M.isOdd())&&(D.iadd(m),M.isub(v)),D.iushrn(1),M.iushrn(1);y.cmp(E)>=0?(y.isub(E),I.isub(D),N.isub(M)):(E.isub(y),D.isub(I),M.isub(N))}return{a:D,b:M,gcd:E.iushln(P)}},o.prototype._invmp=function(f){r(f.negative===0),r(!f.isZero());var y=this,E=f.clone();y.negative!==0?y=y.umod(f):y=y.clone();for(var I=new o(1),N=new o(0),D=E.clone();y.cmpn(1)>0&&E.cmpn(1)>0;){for(var M=0,P=1;(y.words[0]&P)===0&&M<26;++M,P<<=1);if(M>0)for(y.iushrn(M);M-- >0;)I.isOdd()&&I.iadd(D),I.iushrn(1);for(var m=0,v=1;(E.words[0]&v)===0&&m<26;++m,v<<=1);if(m>0)for(E.iushrn(m);m-- >0;)N.isOdd()&&N.iadd(D),N.iushrn(1);y.cmp(E)>=0?(y.isub(E),I.isub(N)):(E.isub(y),N.isub(I))}var B;return y.cmpn(1)===0?B=I:B=N,B.cmpn(0)<0&&B.iadd(f),B},o.prototype.gcd=function(f){if(this.isZero())return f.abs();if(f.isZero())return this.abs();var y=this.clone(),E=f.clone();y.negative=0,E.negative=0;for(var I=0;y.isEven()&&E.isEven();I++)y.iushrn(1),E.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;E.isEven();)E.iushrn(1);var N=y.cmp(E);if(N<0){var D=y;y=E,E=D}else if(N===0||E.cmpn(1)===0)break;y.isub(E)}while(!0);return E.iushln(I)},o.prototype.invm=function(f){return this.egcd(f).a.umod(f)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(f){return this.words[0]&f},o.prototype.bincn=function(f){r(typeof f=="number");var y=f%26,E=(f-y)/26,I=1<<y;if(this.length<=E)return this._expand(E+1),this.words[E]|=I,this;for(var N=I,D=E;N!==0&&D<this.length;D++){var M=this.words[D]|0;M+=N,N=M>>>26,M&=67108863,this.words[D]=M}return N!==0&&(this.words[D]=N,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(f){var y=f<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var E;if(this.length>1)E=1;else{y&&(f=-f),r(f<=67108863,"Number is too big");var I=this.words[0]|0;E=I===f?0:I<f?-1:1}return this.negative!==0?-E|0:E},o.prototype.cmp=function(f){if(this.negative!==0&&f.negative===0)return-1;if(this.negative===0&&f.negative!==0)return 1;var y=this.ucmp(f);return this.negative!==0?-y|0:y},o.prototype.ucmp=function(f){if(this.length>f.length)return 1;if(this.length<f.length)return-1;for(var y=0,E=this.length-1;E>=0;E--){var I=this.words[E]|0,N=f.words[E]|0;if(I!==N){I<N?y=-1:I>N&&(y=1);break}}return y},o.prototype.gtn=function(f){return this.cmpn(f)===1},o.prototype.gt=function(f){return this.cmp(f)===1},o.prototype.gten=function(f){return this.cmpn(f)>=0},o.prototype.gte=function(f){return this.cmp(f)>=0},o.prototype.ltn=function(f){return this.cmpn(f)===-1},o.prototype.lt=function(f){return this.cmp(f)===-1},o.prototype.lten=function(f){return this.cmpn(f)<=0},o.prototype.lte=function(f){return this.cmp(f)<=0},o.prototype.eqn=function(f){return this.cmpn(f)===0},o.prototype.eq=function(f){return this.cmp(f)===0},o.red=function(f){return new W(f)},o.prototype.toRed=function(f){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),f.convertTo(this)._forceRed(f)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(f){return this.red=f,this},o.prototype.forceRed=function(f){return r(!this.red,"Already a number in reduction context"),this._forceRed(f)},o.prototype.redAdd=function(f){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,f)},o.prototype.redIAdd=function(f){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,f)},o.prototype.redSub=function(f){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,f)},o.prototype.redISub=function(f){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,f)},o.prototype.redShl=function(f){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,f)},o.prototype.redMul=function(f){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.mul(this,f)},o.prototype.redIMul=function(f){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.imul(this,f)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(f){return r(this.red&&!f.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,f)};var R={k256:null,p224:null,p192:null,p25519:null};function j(C,f){this.name=C,this.p=new o(f,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}j.prototype._tmp=function(){var f=new o(null);return f.words=new Array(Math.ceil(this.n/13)),f},j.prototype.ireduce=function(f){var y=f,E;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),E=y.bitLength();while(E>this.n);var I=E<this.n?-1:y.ucmp(this.p);return I===0?(y.words[0]=0,y.length=1):I>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},j.prototype.split=function(f,y){f.iushrn(this.n,0,y)},j.prototype.imulK=function(f){return f.imul(this.k)};function q(){j.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(q,j),q.prototype.split=function(f,y){for(var E=4194303,I=Math.min(f.length,9),N=0;N<I;N++)y.words[N]=f.words[N];if(y.length=I,f.length<=9){f.words[0]=0,f.length=1;return}var D=f.words[9];for(y.words[y.length++]=D&E,N=10;N<f.length;N++){var M=f.words[N]|0;f.words[N-10]=(M&E)<<4|D>>>22,D=M}D>>>=22,f.words[N-10]=D,D===0&&f.length>10?f.length-=10:f.length-=9},q.prototype.imulK=function(f){f.words[f.length]=0,f.words[f.length+1]=0,f.length+=2;for(var y=0,E=0;E<f.length;E++){var I=f.words[E]|0;y+=I*977,f.words[E]=y&67108863,y=I*64+(y/67108864|0)}return f.words[f.length-1]===0&&(f.length--,f.words[f.length-1]===0&&f.length--),f};function G(){j.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(G,j);function L(){j.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(L,j);function V(){j.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(V,j),V.prototype.imulK=function(f){for(var y=0,E=0;E<f.length;E++){var I=(f.words[E]|0)*19+y,N=I&67108863;I>>>=26,f.words[E]=N,y=I}return y!==0&&(f.words[f.length++]=y),f},o._prime=function(f){if(R[f])return R[f];var y;if(f==="k256")y=new q;else if(f==="p224")y=new G;else if(f==="p192")y=new L;else if(f==="p25519")y=new V;else throw new Error("Unknown prime "+f);return R[f]=y,y};function W(C){if(typeof C=="string"){var f=o._prime(C);this.m=f.p,this.prime=f}else r(C.gtn(1),"modulus must be greater than 1"),this.m=C,this.prime=null}W.prototype._verify1=function(f){r(f.negative===0,"red works only with positives"),r(f.red,"red works only with red numbers")},W.prototype._verify2=function(f,y){r((f.negative|y.negative)===0,"red works only with positives"),r(f.red&&f.red===y.red,"red works only with red numbers")},W.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(u(f,f.umod(this.m)._forceRed(this)),f)},W.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},W.prototype.add=function(f,y){this._verify2(f,y);var E=f.add(y);return E.cmp(this.m)>=0&&E.isub(this.m),E._forceRed(this)},W.prototype.iadd=function(f,y){this._verify2(f,y);var E=f.iadd(y);return E.cmp(this.m)>=0&&E.isub(this.m),E},W.prototype.sub=function(f,y){this._verify2(f,y);var E=f.sub(y);return E.cmpn(0)<0&&E.iadd(this.m),E._forceRed(this)},W.prototype.isub=function(f,y){this._verify2(f,y);var E=f.isub(y);return E.cmpn(0)<0&&E.iadd(this.m),E},W.prototype.shl=function(f,y){return this._verify1(f),this.imod(f.ushln(y))},W.prototype.imul=function(f,y){return this._verify2(f,y),this.imod(f.imul(y))},W.prototype.mul=function(f,y){return this._verify2(f,y),this.imod(f.mul(y))},W.prototype.isqr=function(f){return this.imul(f,f.clone())},W.prototype.sqr=function(f){return this.mul(f,f)},W.prototype.sqrt=function(f){if(f.isZero())return f.clone();var y=this.m.andln(3);if(r(y%2===1),y===3){var E=this.m.add(new o(1)).iushrn(2);return this.pow(f,E)}for(var I=this.m.subn(1),N=0;!I.isZero()&&I.andln(1)===0;)N++,I.iushrn(1);r(!I.isZero());var D=new o(1).toRed(this),M=D.redNeg(),P=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new o(2*m*m).toRed(this);this.pow(m,P).cmp(M)!==0;)m.redIAdd(M);for(var v=this.pow(m,I),B=this.pow(f,I.addn(1).iushrn(1)),U=this.pow(f,I),Q=N;U.cmp(D)!==0;){for(var ee=U,Z=0;ee.cmp(D)!==0;Z++)ee=ee.redSqr();r(Z<Q);var Y=this.pow(v,new o(1).iushln(Q-Z-1));B=B.redMul(Y),v=Y.redSqr(),U=U.redMul(v),Q=Z}return B},W.prototype.invm=function(f){var y=f._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},W.prototype.pow=function(f,y){if(y.isZero())return new o(1).toRed(this);if(y.cmpn(1)===0)return f.clone();var E=4,I=new Array(1<<E);I[0]=new o(1).toRed(this),I[1]=f;for(var N=2;N<I.length;N++)I[N]=this.mul(I[N-1],f);var D=I[0],M=0,P=0,m=y.bitLength()%26;for(m===0&&(m=26),N=y.length-1;N>=0;N--){for(var v=y.words[N],B=m-1;B>=0;B--){var U=v>>B&1;if(D!==I[0]&&(D=this.sqr(D)),U===0&&M===0){P=0;continue}M<<=1,M|=U,P++,!(P!==E&&(N!==0||B!==0))&&(D=this.mul(D,I[M]),P=0,M=0)}m=26}return D},W.prototype.convertTo=function(f){var y=f.umod(this.m);return y===f?y.clone():y},W.prototype.convertFrom=function(f){var y=f.clone();return y.red=null,y},o.mont=function(f){return new z(f)};function z(C){W.call(this,C),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(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)}i(z,W),z.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},z.prototype.convertFrom=function(f){var y=this.imod(f.mul(this.rinv));return y.red=null,y},z.prototype.imul=function(f,y){if(f.isZero()||y.isZero())return f.words[0]=0,f.length=1,f;var E=f.imul(y),I=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=E.isub(I).iushrn(this.shift),D=N;return N.cmp(this.m)>=0?D=N.isub(this.m):N.cmpn(0)<0&&(D=N.iadd(this.m)),D._forceRed(this)},z.prototype.mul=function(f,y){if(f.isZero()||y.isZero())return new o(0)._forceRed(this);var E=f.mul(y),I=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=E.isub(I).iushrn(this.shift),D=N;return N.cmp(this.m)>=0?D=N.isub(this.m):N.cmpn(0)<0&&(D=N.iadd(this.m)),D._forceRed(this)},z.prototype.invm=function(f){var y=this.imod(f._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(t,rG)}(vp)),vp.exports}var iG=ZC();const eI=sl(iG);var wp={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var tI;function oG(){return tI||(tI=1,function(t,e){var n=Iy(),r=n.Buffer;function i(s,a){for(var l in s)a[l]=s[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=o);function o(s,a,l){return r(s,a,l)}o.prototype=Object.create(r.prototype),i(r,o),o.from=function(s,a,l){if(typeof s=="number")throw new TypeError("Argument must not be a number");return r(s,a,l)},o.alloc=function(s,a,l){if(typeof s!="number")throw new TypeError("Argument must be a number");var c=r(s);return a!==void 0?typeof l=="string"?c.fill(a,l):c.fill(a):c.fill(0),c},o.allocUnsafe=function(s){if(typeof s!="number")throw new TypeError("Argument must be a number");return r(s)},o.allocUnsafeSlow=function(s){if(typeof s!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(s)}}(wp,wp.exports)),wp.exports}var Dy,nI;function sG(){if(nI)return Dy;nI=1;var t=oG().Buffer;function e(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var o=0;o<n.length;o++){var s=n.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var l=n.length,c=n.charAt(0),u=Math.log(l)/Math.log(256),d=Math.log(256)/Math.log(l);function h(p){if((Array.isArray(p)||p instanceof Uint8Array)&&(p=t.from(p)),!t.isBuffer(p))throw new TypeError("Expected Buffer");if(p.length===0)return"";for(var w=0,S=0,O=0,T=p.length;O!==T&&p[O]===0;)O++,w++;for(var $=(T-O)*d+1>>>0,R=new Uint8Array($);O!==T;){for(var j=p[O],q=0,G=$-1;(j!==0||q<S)&&G!==-1;G--,q++)j+=256*R[G]>>>0,R[G]=j%l>>>0,j=j/l>>>0;if(j!==0)throw new Error("Non-zero carry");S=q,O++}for(var L=$-S;L!==$&&R[L]===0;)L++;for(var V=c.repeat(w);L<$;++L)V+=n.charAt(R[L]);return V}function g(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return t.alloc(0);for(var w=0,S=0,O=0;p[w]===c;)S++,w++;for(var T=(p.length-w)*u+1>>>0,$=new Uint8Array(T);w<p.length;){var R=p.charCodeAt(w);if(R>255)return;var j=r[R];if(j===255)return;for(var q=0,G=T-1;(j!==0||q<O)&&G!==-1;G--,q++)j+=l*$[G]>>>0,$[G]=j%256>>>0,j=j/256>>>0;if(j!==0)throw new Error("Non-zero carry");O=q,w++}for(var L=T-O;L!==T&&$[L]===0;)L++;var V=t.allocUnsafe(S+(T-L));V.fill(0,0,S);for(var W=S;L!==T;)V[W++]=$[L++];return V}function b(p){var w=g(p);if(w)return w;throw new Error("Non-base"+l+" character")}return{encode:h,decodeUnsafe:g,decode:b}}return Dy=e,Dy}var zy,rI;function iI(){if(rI)return zy;rI=1;var t=sG(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return zy=t(e),zy}var aG=iI();const Hn=sl(aG);var ot={};function Ao(t,e,n){return e<=t&&t<=n}function xp(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function lG(t){for(var e=String(t),n=e.length,r=0,i=[];r<n;){var o=e.charCodeAt(r);if(o<55296||o>57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(r===n-1)i.push(65533);else{var s=t.charCodeAt(r+1);if(56320<=s&&s<=57343){var a=o&1023,l=s&1023;i.push(65536+(a<<10)+l),r+=1}else i.push(65533)}r+=1}return i}function cG(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var Ep=-1;function Uy(t){this.tokens=[].slice.call(t)}Uy.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Ep},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var rc=-1;function $y(t,e){if(t)throw TypeError("Decoder error");return e||65533}var Sp="utf-8";function Ap(t,e){if(!(this instanceof Ap))return new Ap(t,e);if(t=t!==void 0?String(t).toLowerCase():Sp,t!==Sp)throw new Error("Encoding not supported. Only utf-8 is supported");e=xp(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Ap.prototype={decode:function(e,n){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),n=xp(n),this._streaming||(this._decoder=new uG({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var i=new Uy(r),o=[],s;!i.endOfStream()&&(s=this._decoder.handler(i,i.read()),s!==rc);)s!==null&&(Array.isArray(s)?o.push.apply(o,s):o.push(s));if(!this._streaming){do{if(s=this._decoder.handler(i,i.read()),s===rc)break;s!==null&&(Array.isArray(s)?o.push.apply(o,s):o.push(s))}while(!i.endOfStream());this._decoder=null}return o.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(o[0]===65279?(this._BOMseen=!0,o.shift()):this._BOMseen=!0),cG(o)}};function kp(t,e){if(!(this instanceof kp))return new kp(t,e);if(t=t!==void 0?String(t).toLowerCase():Sp,t!==Sp)throw new Error("Encoding not supported. Only utf-8 is supported");e=xp(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}kp.prototype={encode:function(e,n){e=e?String(e):"",n=xp(n),this._streaming||(this._encoder=new dG(this._options)),this._streaming=!!n.stream;for(var r=[],i=new Uy(lG(e)),o;!i.endOfStream()&&(o=this._encoder.handler(i,i.read()),o!==rc);)Array.isArray(o)?r.push.apply(r,o):r.push(o);if(!this._streaming){for(;o=this._encoder.handler(i,i.read()),o!==rc;)Array.isArray(o)?r.push.apply(r,o):r.push(o);this._encoder=null}return new Uint8Array(r)}};function uG(t){var e=t.fatal,n=0,r=0,i=0,o=128,s=191;this.handler=function(a,l){if(l===Ep&&i!==0)return i=0,$y(e);if(l===Ep)return rc;if(i===0){if(Ao(l,0,127))return l;if(Ao(l,194,223))i=1,n=l-192;else if(Ao(l,224,239))l===224&&(o=160),l===237&&(s=159),i=2,n=l-224;else if(Ao(l,240,244))l===240&&(o=144),l===244&&(s=143),i=3,n=l-240;else return $y(e);return n=n<<6*i,null}if(!Ao(l,o,s))return n=i=r=0,o=128,s=191,a.prepend(l),$y(e);if(o=128,s=191,r+=1,n+=l-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function dG(t){t.fatal,this.handler=function(e,n){if(n===Ep)return rc;if(Ao(n,0,127))return n;var r,i;Ao(n,128,2047)?(r=1,i=192):Ao(n,2048,65535)?(r=2,i=224):Ao(n,65536,1114111)&&(r=3,i=240);for(var o=[(n>>6*r)+i];r>0;){var s=n>>6*(r-1);o.push(128|s&63),r-=1}return o}}const fG=lu(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Ap,TextEncoder:kp},Symbol.toStringTag,{value:"Module"})));var oI;function hG(){if(oI)return ot;oI=1;var t=ot&&ot.__createBinding||(Object.create?function(L,V,W,z){z===void 0&&(z=W),Object.defineProperty(L,z,{enumerable:!0,get:function(){return V[W]}})}:function(L,V,W,z){z===void 0&&(z=W),L[z]=V[W]}),e=ot&&ot.__setModuleDefault||(Object.create?function(L,V){Object.defineProperty(L,"default",{enumerable:!0,value:V})}:function(L,V){L.default=V}),n=ot&&ot.__decorate||function(L,V,W,z){var C=arguments.length,f=C<3?V:z===null?z=Object.getOwnPropertyDescriptor(V,W):z,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(L,V,W,z);else for(var E=L.length-1;E>=0;E--)(y=L[E])&&(f=(C<3?y(f):C>3?y(V,W,f):y(V,W))||f);return C>3&&f&&Object.defineProperty(V,W,f),f},r=ot&&ot.__importStar||function(L){if(L&&L.__esModule)return L;var V={};if(L!=null)for(var W in L)W!=="default"&&Object.hasOwnProperty.call(L,W)&&t(V,L,W);return e(V,L),V},i=ot&&ot.__importDefault||function(L){return L&&L.__esModule?L:{default:L}};Object.defineProperty(ot,"__esModule",{value:!0}),ot.deserializeUnchecked=ot.deserialize=ot.serialize=ot.BinaryReader=ot.BinaryWriter=ot.BorshError=ot.baseDecode=ot.baseEncode=void 0;const o=i(ZC()),s=i(iI()),a=r(fG),l=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,c=new l("utf-8",{fatal:!0});function u(L){return typeof L=="string"&&(L=Buffer.from(L,"utf8")),s.default.encode(Buffer.from(L))}ot.baseEncode=u;function d(L){return Buffer.from(s.default.decode(L))}ot.baseDecode=d;const h=1024;class g extends Error{constructor(V){super(V),this.fieldPath=[],this.originalMessage=V}addToFieldPath(V){this.fieldPath.splice(0,0,V),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}ot.BorshError=g;class b{constructor(){this.buf=Buffer.alloc(h),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(h)]))}writeU8(V){this.maybeResize(),this.buf.writeUInt8(V,this.length),this.length+=1}writeU16(V){this.maybeResize(),this.buf.writeUInt16LE(V,this.length),this.length+=2}writeU32(V){this.maybeResize(),this.buf.writeUInt32LE(V,this.length),this.length+=4}writeU64(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",8)))}writeU128(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",16)))}writeU256(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",32)))}writeU512(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",64)))}writeBuffer(V){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),V,Buffer.alloc(h)]),this.length+=V.length}writeString(V){this.maybeResize();const W=Buffer.from(V,"utf8");this.writeU32(W.length),this.writeBuffer(W)}writeFixedArray(V){this.writeBuffer(Buffer.from(V))}writeArray(V,W){this.maybeResize(),this.writeU32(V.length);for(const z of V)this.maybeResize(),W(z)}toArray(){return this.buf.subarray(0,this.length)}}ot.BinaryWriter=b;function p(L,V,W){const z=W.value;W.value=function(...C){try{return z.apply(this,C)}catch(f){if(f instanceof RangeError){const y=f.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(y)>=0)throw new g("Reached the end of buffer when deserializing")}throw f}}}class w{constructor(V){this.buf=V,this.offset=0}readU8(){const V=this.buf.readUInt8(this.offset);return this.offset+=1,V}readU16(){const V=this.buf.readUInt16LE(this.offset);return this.offset+=2,V}readU32(){const V=this.buf.readUInt32LE(this.offset);return this.offset+=4,V}readU64(){const V=this.readBuffer(8);return new o.default(V,"le")}readU128(){const V=this.readBuffer(16);return new o.default(V,"le")}readU256(){const V=this.readBuffer(32);return new o.default(V,"le")}readU512(){const V=this.readBuffer(64);return new o.default(V,"le")}readBuffer(V){if(this.offset+V>this.buf.length)throw new g(`Expected buffer length ${V} isn't within bounds`);const W=this.buf.slice(this.offset,this.offset+V);return this.offset+=V,W}readString(){const V=this.readU32(),W=this.readBuffer(V);try{return c.decode(W)}catch(z){throw new g(`Error decoding UTF-8 string: ${z}`)}}readFixedArray(V){return new Uint8Array(this.readBuffer(V))}readArray(V){const W=this.readU32(),z=Array();for(let C=0;C<W;++C)z.push(V());return z}}n([p],w.prototype,"readU8",null),n([p],w.prototype,"readU16",null),n([p],w.prototype,"readU32",null),n([p],w.prototype,"readU64",null),n([p],w.prototype,"readU128",null),n([p],w.prototype,"readU256",null),n([p],w.prototype,"readU512",null),n([p],w.prototype,"readString",null),n([p],w.prototype,"readFixedArray",null),n([p],w.prototype,"readArray",null),ot.BinaryReader=w;function S(L){return L.charAt(0).toUpperCase()+L.slice(1)}function O(L,V,W,z,C){try{if(typeof z=="string")C[`write${S(z)}`](W);else if(z instanceof Array)if(typeof z[0]=="number"){if(W.length!==z[0])throw new g(`Expecting byte array of length ${z[0]}, but got ${W.length} bytes`);C.writeFixedArray(W)}else if(z.length===2&&typeof z[1]=="number"){if(W.length!==z[1])throw new g(`Expecting byte array of length ${z[1]}, but got ${W.length} bytes`);for(let f=0;f<z[1];f++)O(L,null,W[f],z[0],C)}else C.writeArray(W,f=>{O(L,V,f,z[0],C)});else if(z.kind!==void 0)switch(z.kind){case"option":{W==null?C.writeU8(0):(C.writeU8(1),O(L,V,W,z.type,C));break}case"map":{C.writeU32(W.size),W.forEach((f,y)=>{O(L,V,y,z.key,C),O(L,V,f,z.value,C)});break}default:throw new g(`FieldType ${z} unrecognized`)}else T(L,W,C)}catch(f){throw f instanceof g&&f.addToFieldPath(V),f}}function T(L,V,W){if(typeof V.borshSerialize=="function"){V.borshSerialize(W);return}const z=L.get(V.constructor);if(!z)throw new g(`Class ${V.constructor.name} is missing in schema`);if(z.kind==="struct")z.fields.map(([C,f])=>{O(L,C,V[C],f,W)});else if(z.kind==="enum"){const C=V[z.field];for(let f=0;f<z.values.length;++f){const[y,E]=z.values[f];if(y===C){W.writeU8(f),O(L,y,V[y],E,W);break}}}else throw new g(`Unexpected schema kind: ${z.kind} for ${V.constructor.name}`)}function $(L,V,W=b){const z=new W;return T(L,V,z),z.toArray()}ot.serialize=$;function R(L,V,W,z){try{if(typeof W=="string")return z[`read${S(W)}`]();if(W instanceof Array){if(typeof W[0]=="number")return z.readFixedArray(W[0]);if(typeof W[1]=="number"){const C=[];for(let f=0;f<W[1];f++)C.push(R(L,null,W[0],z));return C}else return z.readArray(()=>R(L,V,W[0],z))}if(W.kind==="option")return z.readU8()?R(L,V,W.type,z):void 0;if(W.kind==="map"){let C=new Map;const f=z.readU32();for(let y=0;y<f;y++){const E=R(L,V,W.key,z),I=R(L,V,W.value,z);C.set(E,I)}return C}return j(L,W,z)}catch(C){throw C instanceof g&&C.addToFieldPath(V),C}}function j(L,V,W){if(typeof V.borshDeserialize=="function")return V.borshDeserialize(W);const z=L.get(V);if(!z)throw new g(`Class ${V.name} is missing in schema`);if(z.kind==="struct"){const C={};for(const[f,y]of L.get(V).fields)C[f]=R(L,f,y,W);return new V(C)}if(z.kind==="enum"){const C=W.readU8();if(C>=z.values.length)throw new g(`Enum index: ${C} is out of range`);const[f,y]=z.values[C],E=R(L,f,y,W);return new V({[f]:E})}throw new g(`Unexpected schema kind: ${z.kind} for ${V.constructor.name}`)}function q(L,V,W,z=w){const C=new z(W),f=j(L,V,C);if(C.offset<W.length)throw new g(`Unexpected ${W.length-C.offset} bytes after deserialized data`);return f}ot.deserialize=q;function G(L,V,W,z=w){const C=new z(W);return j(L,V,C)}return ot.deserializeUnchecked=G,ot}var Hy=hG(),ae={},sI;function pG(){if(sI)return ae;sI=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.s16=ae.s8=ae.nu64be=ae.u48be=ae.u40be=ae.u32be=ae.u24be=ae.u16be=ae.nu64=ae.u48=ae.u40=ae.u32=ae.u24=ae.u16=ae.u8=ae.offset=ae.greedy=ae.Constant=ae.UTF8=ae.CString=ae.Blob=ae.Boolean=ae.BitField=ae.BitStructure=ae.VariantLayout=ae.Union=ae.UnionLayoutDiscriminator=ae.UnionDiscriminator=ae.Structure=ae.Sequence=ae.DoubleBE=ae.Double=ae.FloatBE=ae.Float=ae.NearInt64BE=ae.NearInt64=ae.NearUInt64BE=ae.NearUInt64=ae.IntBE=ae.Int=ae.UIntBE=ae.UInt=ae.OffsetLayout=ae.GreedyCount=ae.ExternalLayout=ae.bindConstructorLayout=ae.nameWithProperty=ae.Layout=ae.uint8ArrayToBuffer=ae.checkUint8Array=void 0,ae.constant=ae.utf8=ae.cstr=ae.blob=ae.unionLayoutDiscriminator=ae.union=ae.seq=ae.bits=ae.struct=ae.f64be=ae.f64=ae.f32be=ae.f32=ae.ns64be=ae.s48be=ae.s40be=ae.s32be=ae.s24be=ae.s16be=ae.ns64=ae.s48=ae.s40=ae.s32=ae.s24=void 0;const t=Iy();function e(m){if(!(m instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}ae.checkUint8Array=e;function n(m){return e(m),t.Buffer.from(m.buffer,m.byteOffset,m.length)}ae.uint8ArrayToBuffer=n;let r=class{constructor(v,B){if(!Number.isInteger(v))throw new TypeError("span must be an integer");this.span=v,this.property=B}makeDestinationObject(){return{}}getSpan(v,B){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(v){const B=Object.create(this.constructor.prototype);return Object.assign(B,this),B.property=v,B}fromArray(v){}};ae.Layout=r;function i(m,v){return v.property?m+"["+v.property+"]":m}ae.nameWithProperty=i;function o(m,v){if(typeof m!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(m,"layout_"))throw new Error("Class is already bound to a layout");if(!(v&&v instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(v,"boundConstructor_"))throw new Error("layout is already bound to a constructor");m.layout_=v,v.boundConstructor_=m,v.makeDestinationObject=()=>new m,Object.defineProperty(m.prototype,"encode",{value(B,U){return v.encode(this,B,U)},writable:!0}),Object.defineProperty(m,"decode",{value(B,U){return v.decode(B,U)},writable:!0})}ae.bindConstructorLayout=o;class s extends r{isCount(){throw new Error("ExternalLayout is abstract")}}ae.ExternalLayout=s;class a extends s{constructor(v=1,B){if(!Number.isInteger(v)||0>=v)throw new TypeError("elementSpan must be a (positive) integer");super(-1,B),this.elementSpan=v}isCount(){return!0}decode(v,B=0){e(v);const U=v.length-B;return Math.floor(U/this.elementSpan)}encode(v,B,U){return 0}}ae.GreedyCount=a;class l extends s{constructor(v,B=0,U){if(!(v instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(B))throw new TypeError("offset must be integer or undefined");super(v.span,U||v.property),this.layout=v,this.offset=B}isCount(){return this.layout instanceof c||this.layout instanceof u}decode(v,B=0){return this.layout.decode(v,B+this.offset)}encode(v,B,U=0){return this.layout.encode(v,B,U+this.offset)}}ae.OffsetLayout=l;class c extends r{constructor(v,B){if(super(v,B),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,B=0){return n(v).readUIntLE(B,this.span)}encode(v,B,U=0){return n(B).writeUIntLE(v,U,this.span),this.span}}ae.UInt=c;class u extends r{constructor(v,B){if(super(v,B),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,B=0){return n(v).readUIntBE(B,this.span)}encode(v,B,U=0){return n(B).writeUIntBE(v,U,this.span),this.span}}ae.UIntBE=u;class d extends r{constructor(v,B){if(super(v,B),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,B=0){return n(v).readIntLE(B,this.span)}encode(v,B,U=0){return n(B).writeIntLE(v,U,this.span),this.span}}ae.Int=d;class h extends r{constructor(v,B){if(super(v,B),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,B=0){return n(v).readIntBE(B,this.span)}encode(v,B,U=0){return n(B).writeIntBE(v,U,this.span),this.span}}ae.IntBE=h;const g=Math.pow(2,32);function b(m){const v=Math.floor(m/g),B=m-v*g;return{hi32:v,lo32:B}}function p(m,v){return m*g+v}class w extends r{constructor(v){super(8,v)}decode(v,B=0){const U=n(v),Q=U.readUInt32LE(B),ee=U.readUInt32LE(B+4);return p(ee,Q)}encode(v,B,U=0){const Q=b(v),ee=n(B);return ee.writeUInt32LE(Q.lo32,U),ee.writeUInt32LE(Q.hi32,U+4),8}}ae.NearUInt64=w;class S extends r{constructor(v){super(8,v)}decode(v,B=0){const U=n(v),Q=U.readUInt32BE(B),ee=U.readUInt32BE(B+4);return p(Q,ee)}encode(v,B,U=0){const Q=b(v),ee=n(B);return ee.writeUInt32BE(Q.hi32,U),ee.writeUInt32BE(Q.lo32,U+4),8}}ae.NearUInt64BE=S;class O extends r{constructor(v){super(8,v)}decode(v,B=0){const U=n(v),Q=U.readUInt32LE(B),ee=U.readInt32LE(B+4);return p(ee,Q)}encode(v,B,U=0){const Q=b(v),ee=n(B);return ee.writeUInt32LE(Q.lo32,U),ee.writeInt32LE(Q.hi32,U+4),8}}ae.NearInt64=O;class T extends r{constructor(v){super(8,v)}decode(v,B=0){const U=n(v),Q=U.readInt32BE(B),ee=U.readUInt32BE(B+4);return p(Q,ee)}encode(v,B,U=0){const Q=b(v),ee=n(B);return ee.writeInt32BE(Q.hi32,U),ee.writeUInt32BE(Q.lo32,U+4),8}}ae.NearInt64BE=T;class $ extends r{constructor(v){super(4,v)}decode(v,B=0){return n(v).readFloatLE(B)}encode(v,B,U=0){return n(B).writeFloatLE(v,U),4}}ae.Float=$;class R extends r{constructor(v){super(4,v)}decode(v,B=0){return n(v).readFloatBE(B)}encode(v,B,U=0){return n(B).writeFloatBE(v,U),4}}ae.FloatBE=R;class j extends r{constructor(v){super(8,v)}decode(v,B=0){return n(v).readDoubleLE(B)}encode(v,B,U=0){return n(B).writeDoubleLE(v,U),8}}ae.Double=j;class q extends r{constructor(v){super(8,v)}decode(v,B=0){return n(v).readDoubleBE(B)}encode(v,B,U=0){return n(B).writeDoubleBE(v,U),8}}ae.DoubleBE=q;class G extends r{constructor(v,B,U){if(!(v instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(B instanceof s&&B.isCount()||Number.isInteger(B)&&0<=B))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let Q=-1;!(B instanceof s)&&0<v.span&&(Q=B*v.span),super(Q,U),this.elementLayout=v,this.count=B}getSpan(v,B=0){if(0<=this.span)return this.span;let U=0,Q=this.count;if(Q instanceof s&&(Q=Q.decode(v,B)),0<this.elementLayout.span)U=Q*this.elementLayout.span;else{let ee=0;for(;ee<Q;)U+=this.elementLayout.getSpan(v,B+U),++ee}return U}decode(v,B=0){const U=[];let Q=0,ee=this.count;for(ee instanceof s&&(ee=ee.decode(v,B));Q<ee;)U.push(this.elementLayout.decode(v,B)),B+=this.elementLayout.getSpan(v,B),Q+=1;return U}encode(v,B,U=0){const Q=this.elementLayout,ee=v.reduce((Z,Y)=>Z+Q.encode(Y,B,U+Z),0);return this.count instanceof s&&this.count.encode(v.length,B,U),ee}}ae.Sequence=G;class L extends r{constructor(v,B,U){if(!(Array.isArray(v)&&v.reduce((ee,Z)=>ee&&Z instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof B=="boolean"&&U===void 0&&(U=B,B=void 0);for(const ee of v)if(0>ee.span&&ee.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let Q=-1;try{Q=v.reduce((ee,Z)=>ee+Z.getSpan(),0)}catch(ee){}super(Q,B),this.fields=v,this.decodePrefixes=!!U}getSpan(v,B=0){if(0<=this.span)return this.span;let U=0;try{U=this.fields.reduce((Q,ee)=>{const Z=ee.getSpan(v,B);return B+=Z,Q+Z},0)}catch(Q){throw new RangeError("indeterminate span")}return U}decode(v,B=0){e(v);const U=this.makeDestinationObject();for(const Q of this.fields)if(Q.property!==void 0&&(U[Q.property]=Q.decode(v,B)),B+=Q.getSpan(v,B),this.decodePrefixes&&v.length===B)break;return U}encode(v,B,U=0){const Q=U;let ee=0,Z=0;for(const Y of this.fields){let re=Y.span;if(Z=0<re?re:0,Y.property!==void 0){const de=v[Y.property];de!==void 0&&(Z=Y.encode(de,B,U),0>re&&(re=Y.getSpan(B,U)))}ee=U,U+=re}return ee+Z-Q}fromArray(v){const B=this.makeDestinationObject();for(const U of this.fields)U.property!==void 0&&0<v.length&&(B[U.property]=v.shift());return B}layoutFor(v){if(typeof v!="string")throw new TypeError("property must be string");for(const B of this.fields)if(B.property===v)return B}offsetOf(v){if(typeof v!="string")throw new TypeError("property must be string");let B=0;for(const U of this.fields){if(U.property===v)return B;0>U.span?B=-1:0<=B&&(B+=U.span)}}}ae.Structure=L;class V{constructor(v){this.property=v}decode(v,B){throw new Error("UnionDiscriminator is abstract")}encode(v,B,U){throw new Error("UnionDiscriminator is abstract")}}ae.UnionDiscriminator=V;class W extends V{constructor(v,B){if(!(v instanceof s&&v.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(B||v.property||"variant"),this.layout=v}decode(v,B){return this.layout.decode(v,B)}encode(v,B,U){return this.layout.encode(v,B,U)}}ae.UnionLayoutDiscriminator=W;class z extends r{constructor(v,B,U){let Q;if(v instanceof c||v instanceof u)Q=new W(new l(v));else if(v instanceof s&&v.isCount())Q=new W(v);else if(v instanceof V)Q=v;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(B===void 0&&(B=null),!(B===null||B instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(B!==null){if(0>B.span)throw new Error("defaultLayout must have constant span");B.property===void 0&&(B=B.replicate("content"))}let ee=-1;B&&(ee=B.span,0<=ee&&(v instanceof c||v instanceof u)&&(ee+=Q.layout.span)),super(ee,U),this.discriminator=Q,this.usesPrefixDiscriminator=v instanceof c||v instanceof u,this.defaultLayout=B,this.registry={};let Z=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(Y){return Z(Y)},this.configGetSourceVariant=function(Y){Z=Y.bind(this)}}getSpan(v,B=0){if(0<=this.span)return this.span;const U=this.getVariant(v,B);if(!U)throw new Error("unable to determine span for unrecognized variant");return U.getSpan(v,B)}defaultGetSourceVariant(v){if(Object.prototype.hasOwnProperty.call(v,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(v,this.defaultLayout.property))return;const B=this.registry[v[this.discriminator.property]];if(B&&(!B.layout||B.property&&Object.prototype.hasOwnProperty.call(v,B.property)))return B}else for(const B in this.registry){const U=this.registry[B];if(U.property&&Object.prototype.hasOwnProperty.call(v,U.property))return U}throw new Error("unable to infer src variant")}decode(v,B=0){let U;const Q=this.discriminator,ee=Q.decode(v,B),Z=this.registry[ee];if(Z===void 0){const Y=this.defaultLayout;let re=0;this.usesPrefixDiscriminator&&(re=Q.layout.span),U=this.makeDestinationObject(),U[Q.property]=ee,U[Y.property]=Y.decode(v,B+re)}else U=Z.decode(v,B);return U}encode(v,B,U=0){const Q=this.getSourceVariant(v);if(Q===void 0){const ee=this.discriminator,Z=this.defaultLayout;let Y=0;return this.usesPrefixDiscriminator&&(Y=ee.layout.span),ee.encode(v[ee.property],B,U),Y+Z.encode(v[Z.property],B,U+Y)}return Q.encode(v,B,U)}addVariant(v,B,U){const Q=new C(this,v,B,U);return this.registry[v]=Q,Q}getVariant(v,B=0){let U;return v instanceof Uint8Array?U=this.discriminator.decode(v,B):U=v,this.registry[U]}}ae.Union=z;class C extends r{constructor(v,B,U,Q){if(!(v instanceof z))throw new TypeError("union must be a Union");if(!Number.isInteger(B)||0>B)throw new TypeError("variant must be a (non-negative) integer");if(typeof U=="string"&&Q===void 0&&(Q=U,U=null),U){if(!(U instanceof r))throw new TypeError("layout must be a Layout");if(v.defaultLayout!==null&&0<=U.span&&U.span>v.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof Q!="string")throw new TypeError("variant must have a String property")}let ee=v.span;0>v.span&&(ee=U?U.span:0,0<=ee&&v.usesPrefixDiscriminator&&(ee+=v.discriminator.layout.span)),super(ee,Q),this.union=v,this.variant=B,this.layout=U||null}getSpan(v,B=0){if(0<=this.span)return this.span;let U=0;this.union.usesPrefixDiscriminator&&(U=this.union.discriminator.layout.span);let Q=0;return this.layout&&(Q=this.layout.getSpan(v,B+U)),U+Q}decode(v,B=0){const U=this.makeDestinationObject();if(this!==this.union.getVariant(v,B))throw new Error("variant mismatch");let Q=0;return this.union.usesPrefixDiscriminator&&(Q=this.union.discriminator.layout.span),this.layout?U[this.property]=this.layout.decode(v,B+Q):this.property?U[this.property]=!0:this.union.usesPrefixDiscriminator&&(U[this.union.discriminator.property]=this.variant),U}encode(v,B,U=0){let Q=0;if(this.union.usesPrefixDiscriminator&&(Q=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(v,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,B,U);let ee=Q;if(this.layout&&(this.layout.encode(v[this.property],B,U+Q),ee+=this.layout.getSpan(B,U+Q),0<=this.union.span&&ee>this.union.span))throw new Error("encoded variant overruns containing union");return ee}fromArray(v){if(this.layout)return this.layout.fromArray(v)}}ae.VariantLayout=C;function f(m){return 0>m&&(m+=4294967296),m}class y extends r{constructor(v,B,U){if(!(v instanceof c||v instanceof u))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof B=="string"&&U===void 0&&(U=B,B=!1),4<v.span)throw new RangeError("word cannot exceed 32 bits");super(v.span,U),this.word=v,this.msb=!!B,this.fields=[];let Q=0;this._packedSetValue=function(ee){return Q=f(ee),this},this._packedGetValue=function(){return Q}}decode(v,B=0){const U=this.makeDestinationObject(),Q=this.word.decode(v,B);this._packedSetValue(Q);for(const ee of this.fields)ee.property!==void 0&&(U[ee.property]=ee.decode(v));return U}encode(v,B,U=0){const Q=this.word.decode(B,U);this._packedSetValue(Q);for(const ee of this.fields)if(ee.property!==void 0){const Z=v[ee.property];Z!==void 0&&ee.encode(Z)}return this.word.encode(this._packedGetValue(),B,U)}addField(v,B){const U=new E(this,v,B);return this.fields.push(U),U}addBoolean(v){const B=new I(this,v);return this.fields.push(B),B}fieldFor(v){if(typeof v!="string")throw new TypeError("property must be string");for(const B of this.fields)if(B.property===v)return B}}ae.BitStructure=y;class E{constructor(v,B,U){if(!(v instanceof y))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(B)||0>=B)throw new TypeError("bits must be positive integer");const Q=8*v.span,ee=v.fields.reduce((Z,Y)=>Z+Y.bits,0);if(B+ee>Q)throw new Error("bits too long for span remainder ("+(Q-ee)+" of "+Q+" remain)");this.container=v,this.bits=B,this.valueMask=(1<<B)-1,B===32&&(this.valueMask=4294967295),this.start=ee,this.container.msb&&(this.start=Q-ee-B),this.wordMask=f(this.valueMask<<this.start),this.property=U}decode(v,B){const U=this.container._packedGetValue();return f(U&this.wordMask)>>>this.start}encode(v){if(typeof v!="number"||!Number.isInteger(v)||v!==f(v&this.valueMask))throw new TypeError(i("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const B=this.container._packedGetValue(),U=f(v<<this.start);this.container._packedSetValue(f(B&~this.wordMask)|U)}}ae.BitField=E;class I extends E{constructor(v,B){super(v,1,B)}decode(v,B){return!!super.decode(v,B)}encode(v){typeof v=="boolean"&&(v=+v),super.encode(v)}}ae.Boolean=I;class N extends r{constructor(v,B){if(!(v instanceof s&&v.isCount()||Number.isInteger(v)&&0<=v))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let U=-1;v instanceof s||(U=v),super(U,B),this.length=v}getSpan(v,B){let U=this.span;return 0>U&&(U=this.length.decode(v,B)),U}decode(v,B=0){let U=this.span;return 0>U&&(U=this.length.decode(v,B)),n(v).slice(B,B+U)}encode(v,B,U){let Q=this.length;if(this.length instanceof s&&(Q=v.length),!(v instanceof Uint8Array&&Q===v.length))throw new TypeError(i("Blob.encode",this)+" requires (length "+Q+") Uint8Array as src");if(U+Q>B.length)throw new RangeError("encoding overruns Uint8Array");const ee=n(v);return n(B).write(ee.toString("hex"),U,Q,"hex"),this.length instanceof s&&this.length.encode(Q,B,U),Q}}ae.Blob=N;class D extends r{constructor(v){super(-1,v)}getSpan(v,B=0){e(v);let U=B;for(;U<v.length&&v[U]!==0;)U+=1;return 1+U-B}decode(v,B=0){const U=this.getSpan(v,B);return n(v).slice(B,B+U-1).toString("utf-8")}encode(v,B,U=0){typeof v!="string"&&(v=String(v));const Q=t.Buffer.from(v,"utf8"),ee=Q.length;if(U+ee>B.length)throw new RangeError("encoding overruns Buffer");const Z=n(B);return Q.copy(Z,U),Z[U+ee]=0,ee+1}}ae.CString=D;class M extends r{constructor(v,B){if(typeof v=="string"&&B===void 0&&(B=v,v=void 0),v===void 0)v=-1;else if(!Number.isInteger(v))throw new TypeError("maxSpan must be an integer");super(-1,B),this.maxSpan=v}getSpan(v,B=0){return e(v),v.length-B}decode(v,B=0){const U=this.getSpan(v,B);if(0<=this.maxSpan&&this.maxSpan<U)throw new RangeError("text length exceeds maxSpan");return n(v).slice(B,B+U).toString("utf-8")}encode(v,B,U=0){typeof v!="string"&&(v=String(v));const Q=t.Buffer.from(v,"utf8"),ee=Q.length;if(0<=this.maxSpan&&this.maxSpan<ee)throw new RangeError("text length exceeds maxSpan");if(U+ee>B.length)throw new RangeError("encoding overruns Buffer");return Q.copy(n(B),U),ee}}ae.UTF8=M;class P extends r{constructor(v,B){super(0,B),this.value=v}decode(v,B){return this.value}encode(v,B,U){return 0}}return ae.Constant=P,ae.greedy=(m,v)=>new a(m,v),ae.offset=(m,v,B)=>new l(m,v,B),ae.u8=m=>new c(1,m),ae.u16=m=>new c(2,m),ae.u24=m=>new c(3,m),ae.u32=m=>new c(4,m),ae.u40=m=>new c(5,m),ae.u48=m=>new c(6,m),ae.nu64=m=>new w(m),ae.u16be=m=>new u(2,m),ae.u24be=m=>new u(3,m),ae.u32be=m=>new u(4,m),ae.u40be=m=>new u(5,m),ae.u48be=m=>new u(6,m),ae.nu64be=m=>new S(m),ae.s8=m=>new d(1,m),ae.s16=m=>new d(2,m),ae.s24=m=>new d(3,m),ae.s32=m=>new d(4,m),ae.s40=m=>new d(5,m),ae.s48=m=>new d(6,m),ae.ns64=m=>new O(m),ae.s16be=m=>new h(2,m),ae.s24be=m=>new h(3,m),ae.s32be=m=>new h(4,m),ae.s40be=m=>new h(5,m),ae.s48be=m=>new h(6,m),ae.ns64be=m=>new T(m),ae.f32=m=>new $(m),ae.f32be=m=>new R(m),ae.f64=m=>new j(m),ae.f64be=m=>new q(m),ae.struct=(m,v,B)=>new L(m,v,B),ae.bits=(m,v,B)=>new y(m,v,B),ae.seq=(m,v,B)=>new G(m,v,B),ae.union=(m,v,B)=>new z(m,v,B),ae.unionLayoutDiscriminator=(m,v)=>new W(m,v),ae.blob=(m,v)=>new N(m,v),ae.cstr=m=>new D(m),ae.utf8=(m,v)=>new M(m,v),ae.constant=(m,v)=>new P(m,v),ae}var X=pG();class gG extends TypeError{constructor(e,n){let r;const{message:i,explanation:o,...s}=e,{path:a}=e,l=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(o!=null?o:l),o!=null&&(this.cause=l),Object.assign(this,s),this.name=this.constructor.name,this.failures=()=>r!=null?r:r=[e,...n()]}}function mG(t){return kd(t)&&typeof t[Symbol.iterator]=="function"}function kd(t){return typeof t=="object"&&t!=null}function Cp(t){return kd(t)&&!Array.isArray(t)}function oi(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function yG(t){const{done:e,value:n}=t.next();return e?void 0:n}function bG(t,e,n,r){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:o}=e,{type:s}=n,{refinement:a,message:l=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${oi(r)}\``}=t;return{value:r,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:l}}function*aI(t,e,n,r){mG(t)||(t=[t]);for(const i of t){const o=bG(i,e,n,r);o&&(yield o)}}function*Wy(t,e,n={}){const{path:r=[],branch:i=[t],coerce:o=!1,mask:s=!1}=n,a={path:r,branch:i,mask:s};o&&(t=e.coercer(t,a));let l="valid";for(const c of e.validator(t,a))c.explanation=n.message,l="not_valid",yield[c,void 0];for(let[c,u,d]of e.entries(t,a)){const h=Wy(u,d,{path:c===void 0?r:[...r,c],branch:c===void 0?i:[...i,u],coerce:o,mask:s,message:n.message});for(const g of h)g[0]?(l=g[0].refinement!=null?"not_refined":"not_valid",yield[g[0],void 0]):o&&(u=g[1],c===void 0?t=u:t instanceof Map?t.set(c,u):t instanceof Set?t.add(u):kd(t)&&(u!==void 0||c in t)&&(t[c]=u))}if(l!=="not_valid")for(const c of e.refiner(t,a))c.explanation=n.message,l="not_refined",yield[c,void 0];l==="valid"&&(yield[void 0,t])}let Ri=class{constructor(e){const{type:n,schema:r,validator:i,refiner:o,coercer:s=l=>l,entries:a=function*(){}}=e;this.type=n,this.schema=r,this.entries=a,this.coercer=s,i?this.validator=(l,c)=>{const u=i(l,c);return aI(u,c,this,l)}:this.validator=()=>[],o?this.refiner=(l,c)=>{const u=o(l,c);return aI(u,c,this,l)}:this.refiner=()=>[]}assert(e,n){return vG(e,this,n)}create(e,n){return Cd(e,this,n)}is(e){return lI(e,this)}mask(e,n){return wG(e,this,n)}validate(e,n={}){return Id(e,this,n)}};function vG(t,e,n){const r=Id(t,e,{message:n});if(r[0])throw r[0]}function Cd(t,e,n){const r=Id(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function wG(t,e,n){const r=Id(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function lI(t,e){return!Id(t,e)[0]}function Id(t,e,n={}){const r=Wy(t,e,n),i=yG(r);return i[0]?[new gG(i[0],function*(){for(const s of r)s[0]&&(yield s[0])}),void 0]:[void 0,i[1]]}function Oa(t,e){return new Ri({type:t,schema:null,validator:e})}function xG(){return Oa("any",()=>!0)}function we(t){return new Ri({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${oi(e)}`}})}function Mi(){return Oa("boolean",t=>typeof t=="boolean")}function Gy(t){return Oa("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${oi(e)}`)}function wt(t){const e=oi(t),n=typeof t;return new Ri({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator(r){return r===t||`Expected the literal \`${e}\`, but received: ${oi(r)}`}})}function EG(){return Oa("never",()=>!1)}function xe(t){return new Ri({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})}function le(){return Oa("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${oi(t)}`)}function Ce(t){return new Ri({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function cI(t,e){return new Ri({type:"record",schema:null,*entries(n){if(kd(n))for(const r in n){const i=n[r];yield[r,r,t],yield[r,i,e]}},validator(n){return Cp(n)||`Expected an object, but received: ${oi(n)}`},coercer(n){return Cp(n)?{...n}:n}})}function ge(){return Oa("string",t=>typeof t=="string"||`Expected a string, but received: ${oi(t)}`)}function jy(t){const e=EG();return new Ri({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(t.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],t[i]||e]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${oi(n)}`},coercer(n){return Array.isArray(n)?n.slice():n}})}function he(t){const e=Object.keys(t);return new Ri({type:"type",schema:t,*entries(n){if(kd(n))for(const r of e)yield[r,n[r],t[r]]},validator(n){return Cp(n)||`Expected an object, but received: ${oi(n)}`},coercer(n){return Cp(n)?{...n}:n}})}function Wn(t){const e=t.map(n=>n.type).join(" | ");return new Ri({type:"union",schema:null,coercer(n,r){for(const i of t){const[o,s]=i.validate(n,{coerce:!0,mask:r.mask});if(!o)return s}return n},validator(n,r){const i=[];for(const o of t){const[...s]=Wy(n,o,r),[a]=s;if(a[0])for(const[l]of s)l&&i.push(l);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${oi(n)}`,...i]}})}function ic(){return Oa("unknown",()=>!0)}function Od(t,e,n){return new Ri({...t,coercer:(r,i)=>lI(r,e)?t.coercer(n(r,i),i):t.coercer(r,i)})}var Ip,SG=new Uint8Array(16);function uI(){if(!Ip&&(Ip=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Ip))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ip(SG)}const AG=/^(?:[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 Op(t){return typeof t=="string"&&AG.test(t)}for(var En=[],Ky=0;Ky<256;++Ky)En.push((Ky+256).toString(16).substr(1));function Tp(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(En[t[e+0]]+En[t[e+1]]+En[t[e+2]]+En[t[e+3]]+"-"+En[t[e+4]]+En[t[e+5]]+"-"+En[t[e+6]]+En[t[e+7]]+"-"+En[t[e+8]]+En[t[e+9]]+"-"+En[t[e+10]]+En[t[e+11]]+En[t[e+12]]+En[t[e+13]]+En[t[e+14]]+En[t[e+15]]).toLowerCase();if(!Op(n))throw TypeError("Stringified UUID is invalid");return n}var dI,qy,Yy=0,Qy=0;function kG(t,e,n){var r=e&&n||0,i=e||new Array(16);t=t||{};var o=t.node||dI,s=t.clockseq!==void 0?t.clockseq:qy;if(o==null||s==null){var a=t.random||(t.rng||uI)();o==null&&(o=dI=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),s==null&&(s=qy=(a[6]<<8|a[7])&16383)}var l=t.msecs!==void 0?t.msecs:Date.now(),c=t.nsecs!==void 0?t.nsecs:Qy+1,u=l-Yy+(c-Qy)/1e4;if(u<0&&t.clockseq===void 0&&(s=s+1&16383),(u<0||l>Yy)&&t.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Yy=l,Qy=c,qy=s,l+=122192928e5;var d=((l&268435455)*1e4+c)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var h=l/4294967296*1e4&268435455;i[r++]=h>>>8&255,i[r++]=h&255,i[r++]=h>>>24&15|16,i[r++]=h>>>16&255,i[r++]=s>>>8|128,i[r++]=s&255;for(var g=0;g<6;++g)i[r+g]=o[g];return e||Tp(i)}function fI(t){if(!Op(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=e&255,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=e&255,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=e&255,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=e&255,n}function CG(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var IG="6ba7b810-9dad-11d1-80b4-00c04fd430c8",OG="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function hI(t,e,n){function r(i,o,s,a){if(typeof i=="string"&&(i=CG(i)),typeof o=="string"&&(o=fI(o)),o.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var l=new Uint8Array(16+i.length);if(l.set(o),l.set(i,o.length),l=n(l),l[6]=l[6]&15|e,l[8]=l[8]&63|128,s){a=a||0;for(var c=0;c<16;++c)s[a+c]=l[c];return s}return Tp(l)}try{r.name=t}catch(i){}return r.DNS=IG,r.URL=OG,r}function TG(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return PG(NG(BG(t),t.length*8))}function PG(t){for(var e=[],n=t.length*32,r="0123456789abcdef",i=0;i<n;i+=8){var o=t[i>>5]>>>i%32&255,s=parseInt(r.charAt(o>>>4&15)+r.charAt(o&15),16);e.push(s)}return e}function pI(t){return(t+64>>>9<<4)+14+1}function NG(t,e){t[e>>5]|=128<<e%32,t[pI(e)-1]=e;for(var n=1732584193,r=-271733879,i=-1732584194,o=271733878,s=0;s<t.length;s+=16){var a=n,l=r,c=i,u=o;n=On(n,r,i,o,t[s],7,-680876936),o=On(o,n,r,i,t[s+1],12,-389564586),i=On(i,o,n,r,t[s+2],17,606105819),r=On(r,i,o,n,t[s+3],22,-1044525330),n=On(n,r,i,o,t[s+4],7,-176418897),o=On(o,n,r,i,t[s+5],12,1200080426),i=On(i,o,n,r,t[s+6],17,-1473231341),r=On(r,i,o,n,t[s+7],22,-45705983),n=On(n,r,i,o,t[s+8],7,1770035416),o=On(o,n,r,i,t[s+9],12,-1958414417),i=On(i,o,n,r,t[s+10],17,-42063),r=On(r,i,o,n,t[s+11],22,-1990404162),n=On(n,r,i,o,t[s+12],7,1804603682),o=On(o,n,r,i,t[s+13],12,-40341101),i=On(i,o,n,r,t[s+14],17,-1502002290),r=On(r,i,o,n,t[s+15],22,1236535329),n=Tn(n,r,i,o,t[s+1],5,-165796510),o=Tn(o,n,r,i,t[s+6],9,-1069501632),i=Tn(i,o,n,r,t[s+11],14,643717713),r=Tn(r,i,o,n,t[s],20,-373897302),n=Tn(n,r,i,o,t[s+5],5,-701558691),o=Tn(o,n,r,i,t[s+10],9,38016083),i=Tn(i,o,n,r,t[s+15],14,-660478335),r=Tn(r,i,o,n,t[s+4],20,-405537848),n=Tn(n,r,i,o,t[s+9],5,568446438),o=Tn(o,n,r,i,t[s+14],9,-1019803690),i=Tn(i,o,n,r,t[s+3],14,-187363961),r=Tn(r,i,o,n,t[s+8],20,1163531501),n=Tn(n,r,i,o,t[s+13],5,-1444681467),o=Tn(o,n,r,i,t[s+2],9,-51403784),i=Tn(i,o,n,r,t[s+7],14,1735328473),r=Tn(r,i,o,n,t[s+12],20,-1926607734),n=Pn(n,r,i,o,t[s+5],4,-378558),o=Pn(o,n,r,i,t[s+8],11,-2022574463),i=Pn(i,o,n,r,t[s+11],16,1839030562),r=Pn(r,i,o,n,t[s+14],23,-35309556),n=Pn(n,r,i,o,t[s+1],4,-1530992060),o=Pn(o,n,r,i,t[s+4],11,1272893353),i=Pn(i,o,n,r,t[s+7],16,-155497632),r=Pn(r,i,o,n,t[s+10],23,-1094730640),n=Pn(n,r,i,o,t[s+13],4,681279174),o=Pn(o,n,r,i,t[s],11,-358537222),i=Pn(i,o,n,r,t[s+3],16,-722521979),r=Pn(r,i,o,n,t[s+6],23,76029189),n=Pn(n,r,i,o,t[s+9],4,-640364487),o=Pn(o,n,r,i,t[s+12],11,-421815835),i=Pn(i,o,n,r,t[s+15],16,530742520),r=Pn(r,i,o,n,t[s+2],23,-995338651),n=Nn(n,r,i,o,t[s],6,-198630844),o=Nn(o,n,r,i,t[s+7],10,1126891415),i=Nn(i,o,n,r,t[s+14],15,-1416354905),r=Nn(r,i,o,n,t[s+5],21,-57434055),n=Nn(n,r,i,o,t[s+12],6,1700485571),o=Nn(o,n,r,i,t[s+3],10,-1894986606),i=Nn(i,o,n,r,t[s+10],15,-1051523),r=Nn(r,i,o,n,t[s+1],21,-2054922799),n=Nn(n,r,i,o,t[s+8],6,1873313359),o=Nn(o,n,r,i,t[s+15],10,-30611744),i=Nn(i,o,n,r,t[s+6],15,-1560198380),r=Nn(r,i,o,n,t[s+13],21,1309151649),n=Nn(n,r,i,o,t[s+4],6,-145523070),o=Nn(o,n,r,i,t[s+11],10,-1120210379),i=Nn(i,o,n,r,t[s+2],15,718787259),r=Nn(r,i,o,n,t[s+9],21,-343485551),n=gs(n,a),r=gs(r,l),i=gs(i,c),o=gs(o,u)}return[n,r,i,o]}function BG(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(pI(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function gs(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function RG(t,e){return t<<e|t>>>32-e}function Pp(t,e,n,r,i,o){return gs(RG(gs(gs(e,t),gs(r,o)),i),n)}function On(t,e,n,r,i,o,s){return Pp(e&n|~e&r,t,e,i,o,s)}function Tn(t,e,n,r,i,o,s){return Pp(e&r|n&~r,t,e,i,o,s)}function Pn(t,e,n,r,i,o,s){return Pp(e^n^r,t,e,i,o,s)}function Nn(t,e,n,r,i,o,s){return Pp(n^(e|~r),t,e,i,o,s)}var MG=hI("v3",48,TG);function LG(t,e,n){t=t||{};var r=t.random||(t.rng||uI)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=r[i];return e}return Tp(r)}function FG(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function Xy(t,e){return t<<e|t>>>32-e}function _G(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var r=unescape(encodeURIComponent(t));t=[];for(var i=0;i<r.length;++i)t.push(r.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var o=t.length/4+2,s=Math.ceil(o/16),a=new Array(s),l=0;l<s;++l){for(var c=new Uint32Array(16),u=0;u<16;++u)c[u]=t[l*64+u*4]<<24|t[l*64+u*4+1]<<16|t[l*64+u*4+2]<<8|t[l*64+u*4+3];a[l]=c}a[s-1][14]=(t.length-1)*8/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=(t.length-1)*8&4294967295;for(var d=0;d<s;++d){for(var h=new Uint32Array(80),g=0;g<16;++g)h[g]=a[d][g];for(var b=16;b<80;++b)h[b]=Xy(h[b-3]^h[b-8]^h[b-14]^h[b-16],1);for(var p=n[0],w=n[1],S=n[2],O=n[3],T=n[4],$=0;$<80;++$){var R=Math.floor($/20),j=Xy(p,5)+FG(R,w,S,O)+T+e[R]+h[$]>>>0;T=O,O=S,S=Xy(w,30)>>>0,w=p,p=j}n[0]=n[0]+p>>>0,n[1]=n[1]+w>>>0,n[2]=n[2]+S>>>0,n[3]=n[3]+O>>>0,n[4]=n[4]+T>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var VG=hI("v5",80,_G);const DG="00000000-0000-0000-0000-000000000000";function zG(t){if(!Op(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const gI=lu(Object.freeze(Object.defineProperty({__proto__:null,NIL:DG,parse:fI,stringify:Tp,v1:kG,v3:MG,v4:LG,v5:VG,validate:Op,version:zG},Symbol.toStringTag,{value:"Module"})));var Jy,mI;function UG(){if(mI)return Jy;mI=1;const t=gI.v4;return Jy=function(n,r,i,o){if(typeof n!="string")throw new TypeError(n+" must be a string");o=o||{};const s=typeof o.version=="number"?o.version:2;if(s!==1&&s!==2)throw new TypeError(s+" must be 1 or 2");const a={method:n};if(s===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof i=="undefined"){const l=typeof o.generator=="function"?o.generator:function(){return t()};a.id=l(a,o)}else s===2&&i===null?o.notificationIdNull&&(a.id=null):a.id=i;return a},Jy}var Zy,yI;function $G(){if(yI)return Zy;yI=1;const t=gI.v4,e=UG(),n=function(r,i){if(!(this instanceof n))return new n(r,i);i||(i={}),this.options={reviver:typeof i.reviver!="undefined"?i.reviver:null,replacer:typeof i.replacer!="undefined"?i.replacer:null,generator:typeof i.generator!="undefined"?i.generator:function(){return t()},version:typeof i.version!="undefined"?i.version:2,notificationIdNull:typeof i.notificationIdNull=="boolean"?i.notificationIdNull:!1},this.callServer=r};return Zy=n,n.prototype.request=function(r,i,o,s){const a=this;let l=null;const c=Array.isArray(r)&&typeof i=="function";if(this.options.version===1&&c)throw new TypeError("JSON-RPC 1.0 does not support batching");if(c||!c&&r&&typeof r=="object"&&typeof i=="function")s=i,l=r;else{typeof o=="function"&&(s=o,o=void 0);const h=typeof s=="function";try{l=e(r,i,o,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(g){if(h)return s(g);throw g}if(!h)return l}let d;try{d=JSON.stringify(l,this.options.replacer)}catch(h){return s(h)}return this.callServer(d,function(h,g){a._parseResponse(h,g,s)}),l},n.prototype._parseResponse=function(r,i,o){if(r){o(r);return}if(!i)return o();let s;try{s=JSON.parse(i,this.options.reviver)}catch(a){return o(a)}if(o.length===3)if(Array.isArray(s)){const a=function(c){return typeof c.error!="undefined"},l=function(c){return!a(c)};return o(null,s.filter(a),s.filter(l))}else return o(null,s.error,s.result);o(null,s)},Zy}$G();var eb={exports:{}},bI;function HG(){return bI||(bI=1,function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function o(l,c,u,d,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var g=new i(u,d||l,h),b=n?n+c:c;return l._events[b]?l._events[b].fn?l._events[b]=[l._events[b],g]:l._events[b].push(g):(l._events[b]=g,l._eventsCount++),l}function s(l,c){--l._eventsCount===0?l._events=new r:delete l._events[c]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],u,d;if(this._eventsCount===0)return c;for(d in u=this._events)e.call(u,d)&&c.push(n?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},a.prototype.listeners=function(c){var u=n?n+c:c,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,g=d.length,b=new Array(g);h<g;h++)b[h]=d[h].fn;return b},a.prototype.listenerCount=function(c){var u=n?n+c:c,d=this._events[u];return d?d.fn?1:d.length:0},a.prototype.emit=function(c,u,d,h,g,b){var p=n?n+c:c;if(!this._events[p])return!1;var w=this._events[p],S=arguments.length,O,T;if(w.fn){switch(w.once&&this.removeListener(c,w.fn,void 0,!0),S){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,u),!0;case 3:return w.fn.call(w.context,u,d),!0;case 4:return w.fn.call(w.context,u,d,h),!0;case 5:return w.fn.call(w.context,u,d,h,g),!0;case 6:return w.fn.call(w.context,u,d,h,g,b),!0}for(T=1,O=new Array(S-1);T<S;T++)O[T-1]=arguments[T];w.fn.apply(w.context,O)}else{var $=w.length,R;for(T=0;T<$;T++)switch(w[T].once&&this.removeListener(c,w[T].fn,void 0,!0),S){case 1:w[T].fn.call(w[T].context);break;case 2:w[T].fn.call(w[T].context,u);break;case 3:w[T].fn.call(w[T].context,u,d);break;case 4:w[T].fn.call(w[T].context,u,d,h);break;default:if(!O)for(R=1,O=new Array(S-1);R<S;R++)O[R-1]=arguments[R];w[T].fn.apply(w[T].context,O)}}return!0},a.prototype.on=function(c,u,d){return o(this,c,u,d,!1)},a.prototype.once=function(c,u,d){return o(this,c,u,d,!0)},a.prototype.removeListener=function(c,u,d,h){var g=n?n+c:c;if(!this._events[g])return this;if(!u)return s(this,g),this;var b=this._events[g];if(b.fn)b.fn===u&&(!h||b.once)&&(!d||b.context===d)&&s(this,g);else{for(var p=0,w=[],S=b.length;p<S;p++)(b[p].fn!==u||h&&!b[p].once||d&&b[p].context!==d)&&w.push(b[p]);w.length?this._events[g]=w.length===1?w[0]:w:s(this,g)}return this},a.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&s(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a}(eb)),eb.exports}HG();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vI=(t,e)=>(t+(t>=0?e:-e)/wI)/e;function WG(t,e,n){const[[r,i],[o,s]]=e,a=vI(s*t,n),l=vI(-i*t,n);let c=t-a*r-l*o,u=-a*i-l*s;const d=c<Co,h=u<Co;d&&(c=-c),h&&(u=-u);const g=Ed(Math.ceil(IC(n)/2))+oc;if(c<Co||c>=g||u<Co||u>=g)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:c,k2neg:h,k2:u}}function tb(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function nb(t,e){const n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return Sa(n.lowS,"lowS"),Sa(n.prehash,"prehash"),n.format!==void 0&&tb(n.format),n}class GG extends Error{constructor(e=""){super(e)}}const ko={Err:GG,_tlv:{encode:(t,e)=>{const{Err:n}=ko;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,i=gp(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?gp(i.length/2|128):"";return gp(t)+o+i+e},decode(t,e){const{Err:n}=ko;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const i=e[r++],o=!!(i&128);let s=0;if(!o)s=i;else{const l=i&127;if(!l)throw new n("tlv.decode(long): indefinite length not supported");if(l>4)throw new n("tlv.decode(long): byte length is too big");const c=e.subarray(r,r+l);if(c.length!==l)throw new n("tlv.decode: length bytes not complete");if(c[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const u of c)s=s<<8|u;if(r+=l,s<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+s)}}},_int:{encode(t){const{Err:e}=ko;if(t<Co)throw new e("integer: negative integers are not allowed");let n=gp(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=ko;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return mp(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=ko,i=St("signature",t),{v:o,l:s}=r.decode(48,i);if(s.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l}=r.decode(2,o),{v:c,l:u}=r.decode(2,l);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(c)}},hexFromSig(t){const{_tlv:e,_int:n}=ko,r=e.encode(2,n.encode(t.r)),i=e.encode(2,n.encode(t.s)),o=r+i;return e.encode(48,o)}},Co=BigInt(0),oc=BigInt(1),wI=BigInt(2),Np=BigInt(3),jG=BigInt(4);function sc(t,e){const{BYTES:n}=t;let r;if(typeof e=="bigint")r=e;else{let i=St("private key",e);try{r=t.fromBytes(i)}catch(o){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof e}`)}}if(!t.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function KG(t,e={}){const n=qC("weierstrass",t,e),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s,n:a}=o;Sd(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:l}=e;if(l&&(!r.is0(o.a)||typeof l.beta!="bigint"||!Array.isArray(l.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const c=EI(r,i);function u(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function d(z,C,f){const{x:y,y:E}=C.toAffine(),I=r.toBytes(y);if(Sa(f,"isCompressed"),f){u();const N=!r.isOdd(E);return Ii(xI(N),I)}else return Ii(Uint8Array.of(4),I,r.toBytes(E))}function h(z){ii(z,void 0,"Point");const{publicKey:C,publicKeyUncompressed:f}=c,y=z.length,E=z[0],I=z.subarray(1);if(y===C&&(E===2||E===3)){const N=r.fromBytes(I);if(!r.isValid(N))throw new Error("bad point: is not on curve, wrong x");const D=p(N);let M;try{M=r.sqrt(D)}catch(v){const B=v instanceof Error?": "+v.message:"";throw new Error("bad point: is not on curve, sqrt error"+B)}u();const P=r.isOdd(M);return(E&1)===1!==P&&(M=r.neg(M)),{x:N,y:M}}else if(y===f&&E===4){const N=r.BYTES,D=r.fromBytes(I.subarray(0,N)),M=r.fromBytes(I.subarray(N,N*2));if(!w(D,M))throw new Error("bad point: is not on curve");return{x:D,y:M}}else throw new Error(`bad point: got length ${y}, expected compressed=${C} or uncompressed=${f}`)}const g=e.toBytes||d,b=e.fromBytes||h;function p(z){const C=r.sqr(z),f=r.mul(C,z);return r.add(r.add(f,r.mul(z,o.a)),o.b)}function w(z,C){const f=r.sqr(C),y=p(z);return r.eql(f,y)}if(!w(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const S=r.mul(r.pow(o.a,Np),jG),O=r.mul(r.sqr(o.b),BigInt(27));if(r.is0(r.add(S,O)))throw new Error("bad curve params: a or b");function T(z,C,f=!1){if(!r.isValid(C)||f&&r.is0(C))throw new Error(`bad point coordinate ${z}`);return C}function $(z){if(!(z instanceof L))throw new Error("ProjectivePoint expected")}function R(z){if(!l||!l.basises)throw new Error("no endo");return WG(z,l.basises,i.ORDER)}const j=yp((z,C)=>{const{X:f,Y:y,Z:E}=z;if(r.eql(E,r.ONE))return{x:f,y};const I=z.is0();C==null&&(C=I?r.ONE:r.inv(E));const N=r.mul(f,C),D=r.mul(y,C),M=r.mul(E,C);if(I)return{x:r.ZERO,y:r.ZERO};if(!r.eql(M,r.ONE))throw new Error("invZ was invalid");return{x:N,y:D}}),q=yp(z=>{if(z.is0()){if(e.allowInfinityPoint&&!r.is0(z.Y))return;throw new Error("bad point: ZERO")}const{x:C,y:f}=z.toAffine();if(!r.isValid(C)||!r.isValid(f))throw new Error("bad point: x or y not field elements");if(!w(C,f))throw new Error("bad point: equation left != right");if(!z.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function G(z,C,f,y,E){return f=new L(r.mul(f.X,z),f.Y,f.Z),C=bp(y,C),f=bp(E,f),C.add(f)}class L{constructor(C,f,y){this.X=T("x",C),this.Y=T("y",f,!0),this.Z=T("z",y),Object.freeze(this)}static CURVE(){return o}static fromAffine(C){const{x:f,y}=C||{};if(!C||!r.isValid(f)||!r.isValid(y))throw new Error("invalid affine point");if(C instanceof L)throw new Error("projective point not allowed");return r.is0(f)&&r.is0(y)?L.ZERO:new L(f,y,r.ONE)}static fromBytes(C){const f=L.fromAffine(b(ii(C,void 0,"point")));return f.assertValidity(),f}static fromHex(C){return L.fromBytes(St("pointHex",C))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(C=8,f=!0){return W.createCache(this,C),f||this.multiply(Np),this}assertValidity(){q(this)}hasEvenY(){const{y:C}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(C)}equals(C){$(C);const{X:f,Y:y,Z:E}=this,{X:I,Y:N,Z:D}=C,M=r.eql(r.mul(f,D),r.mul(I,E)),P=r.eql(r.mul(y,D),r.mul(N,E));return M&&P}negate(){return new L(this.X,r.neg(this.Y),this.Z)}double(){const{a:C,b:f}=o,y=r.mul(f,Np),{X:E,Y:I,Z:N}=this;let D=r.ZERO,M=r.ZERO,P=r.ZERO,m=r.mul(E,E),v=r.mul(I,I),B=r.mul(N,N),U=r.mul(E,I);return U=r.add(U,U),P=r.mul(E,N),P=r.add(P,P),D=r.mul(C,P),M=r.mul(y,B),M=r.add(D,M),D=r.sub(v,M),M=r.add(v,M),M=r.mul(D,M),D=r.mul(U,D),P=r.mul(y,P),B=r.mul(C,B),U=r.sub(m,B),U=r.mul(C,U),U=r.add(U,P),P=r.add(m,m),m=r.add(P,m),m=r.add(m,B),m=r.mul(m,U),M=r.add(M,m),B=r.mul(I,N),B=r.add(B,B),m=r.mul(B,U),D=r.sub(D,m),P=r.mul(B,v),P=r.add(P,P),P=r.add(P,P),new L(D,M,P)}add(C){$(C);const{X:f,Y:y,Z:E}=this,{X:I,Y:N,Z:D}=C;let M=r.ZERO,P=r.ZERO,m=r.ZERO;const v=o.a,B=r.mul(o.b,Np);let U=r.mul(f,I),Q=r.mul(y,N),ee=r.mul(E,D),Z=r.add(f,y),Y=r.add(I,N);Z=r.mul(Z,Y),Y=r.add(U,Q),Z=r.sub(Z,Y),Y=r.add(f,E);let re=r.add(I,D);return Y=r.mul(Y,re),re=r.add(U,ee),Y=r.sub(Y,re),re=r.add(y,E),M=r.add(N,D),re=r.mul(re,M),M=r.add(Q,ee),re=r.sub(re,M),m=r.mul(v,Y),M=r.mul(B,ee),m=r.add(M,m),M=r.sub(Q,m),m=r.add(Q,m),P=r.mul(M,m),Q=r.add(U,U),Q=r.add(Q,U),ee=r.mul(v,ee),Y=r.mul(B,Y),Q=r.add(Q,ee),ee=r.sub(U,ee),ee=r.mul(v,ee),Y=r.add(Y,ee),U=r.mul(Q,Y),P=r.add(P,U),U=r.mul(re,Y),M=r.mul(Z,M),M=r.sub(M,U),U=r.mul(Z,Q),m=r.mul(re,m),m=r.add(m,U),new L(M,P,m)}subtract(C){return this.add(C.negate())}is0(){return this.equals(L.ZERO)}multiply(C){const{endo:f}=e;if(!i.isValidNot0(C))throw new Error("invalid scalar: out of range");let y,E;const I=N=>W.cached(this,N,D=>Ia(L,D));if(f){const{k1neg:N,k1:D,k2neg:M,k2:P}=R(C),{p:m,f:v}=I(D),{p:B,f:U}=I(P);E=v.add(U),y=G(f.beta,m,B,N,M)}else{const{p:N,f:D}=I(C);y=N,E=D}return Ia(L,[y,E])[0]}multiplyUnsafe(C){const{endo:f}=e,y=this;if(!i.isValid(C))throw new Error("invalid scalar: out of range");if(C===Co||y.is0())return L.ZERO;if(C===oc)return y;if(W.hasCache(this))return this.multiply(C);if(f){const{k1neg:E,k1:I,k2neg:N,k2:D}=R(C),{p1:M,p2:P}=zW(L,y,I,D);return G(f.beta,M,P,E,N)}else return W.unsafe(y,C)}multiplyAndAddUnsafe(C,f,y){const E=this.multiplyUnsafe(f).add(C.multiplyUnsafe(y));return E.is0()?void 0:E}toAffine(C){return j(this,C)}isTorsionFree(){const{isTorsionFree:C}=e;return s===oc?!0:C?C(L,this):W.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:C}=e;return s===oc?this:C?C(L,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(C=!0){return Sa(C,"isCompressed"),this.assertValidity(),g(L,this,C)}toHex(C=!0){return na(this.toBytes(C))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(C=!0){return this.toBytes(C)}_setWindowSize(C){this.precompute(C)}static normalizeZ(C){return Ia(L,C)}static msm(C,f){return jC(L,i,C,f)}static fromPrivateKey(C){return L.BASE.multiply(sc(i,C))}}L.BASE=new L(o.Gx,o.Gy,r.ONE),L.ZERO=new L(r.ZERO,r.ONE,r.ZERO),L.Fp=r,L.Fn=i;const V=i.BITS,W=new GC(L,e.endo?Math.ceil(V/2):V);return L.BASE.precompute(8),L}function xI(t){return Uint8Array.of(t?2:3)}function EI(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function qG(t,e={}){const{Fn:n}=t,r=e.randomBytes||om,i=Object.assign(EI(t.Fp,n),{seed:zC(n.ORDER)});function o(g){try{return!!sc(n,g)}catch(b){return!1}}function s(g,b){const{publicKey:p,publicKeyUncompressed:w}=i;try{const S=g.length;return b===!0&&S!==p||b===!1&&S!==w?!1:!!t.fromBytes(g)}catch(S){return!1}}function a(g=r(i.seed)){return _W(ii(g,i.seed,"seed"),n.ORDER)}function l(g,b=!0){return t.BASE.multiply(sc(n,g)).toBytes(b)}function c(g){const b=a(g);return{secretKey:b,publicKey:l(b)}}function u(g){if(typeof g=="bigint")return!1;if(g instanceof t)return!0;const{secretKey:b,publicKey:p,publicKeyUncompressed:w}=i;if(n.allowedLengths||b===p)return;const S=St("key",g).length;return S===p||S===w}function d(g,b,p=!0){if(u(g)===!0)throw new Error("first arg must be private key");if(u(b)===!1)throw new Error("second arg must be public key");const w=sc(n,g);return t.fromHex(b).multiply(w).toBytes(p)}return Object.freeze({getPublicKey:l,getSharedSecret:d,keygen:c,Point:t,utils:{isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a,isValidPrivateKey:o,randomPrivateKey:a,normPrivateKeyToScalar:g=>sc(n,g),precompute(g=8,b=t.BASE){return b.precompute(g,!1)}},lengths:i})}function YG(t,e,n={}){xE(e),Sd(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||om,i=n.hmac||((f,...y)=>$E(e,f,Ii(...y))),{Fp:o,Fn:s}=t,{ORDER:a,BITS:l}=s,{keygen:c,getPublicKey:u,getSharedSecret:d,utils:h,lengths:g}=qG(t,n),b={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},p="compact";function w(f){const y=a>>oc;return f>y}function S(f,y){if(!s.isValidNot0(y))throw new Error(`invalid signature ${f}: out of range 1..Point.Fn.ORDER`);return y}function O(f,y){tb(y);const E=g.signature,I=y==="compact"?E:y==="recovered"?E+1:void 0;return ii(f,I,`${y} signature`)}class T{constructor(y,E,I){this.r=S("r",y),this.s=S("s",E),I!=null&&(this.recovery=I),Object.freeze(this)}static fromBytes(y,E=p){O(y,E);let I;if(E==="der"){const{r:P,s:m}=ko.toSig(ii(y));return new T(P,m)}E==="recovered"&&(I=y[0],E="compact",y=y.subarray(1));const N=s.BYTES,D=y.subarray(0,N),M=y.subarray(N,N*2);return new T(s.fromBytes(D),s.fromBytes(M),I)}static fromHex(y,E){return this.fromBytes(xh(y),E)}addRecoveryBit(y){return new T(this.r,this.s,y)}recoverPublicKey(y){const E=o.ORDER,{r:I,s:N,recovery:D}=this;if(D==null||![0,1,2,3].includes(D))throw new Error("recovery id invalid");if(a*wI<E&&D>1)throw new Error("recovery id is ambiguous for h>1 curve");const P=D===2||D===3?I+a:I;if(!o.isValid(P))throw new Error("recovery id 2 or 3 invalid");const m=o.toBytes(P),v=t.fromBytes(Ii(xI((D&1)===0),m)),B=s.inv(P),U=R(St("msgHash",y)),Q=s.create(-U*B),ee=s.create(N*B),Z=t.BASE.multiplyUnsafe(Q).add(v.multiplyUnsafe(ee));if(Z.is0())throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return w(this.s)}toBytes(y=p){if(tb(y),y==="der")return xh(ko.hexFromSig(this));const E=s.toBytes(this.r),I=s.toBytes(this.s);if(y==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Ii(Uint8Array.of(this.recovery),E,I)}return Ii(E,I)}toHex(y){return na(this.toBytes(y))}assertValidity(){}static fromCompact(y){return T.fromBytes(St("sig",y),"compact")}static fromDER(y){return T.fromBytes(St("sig",y),"der")}normalizeS(){return this.hasHighS()?new T(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return na(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return na(this.toBytes("compact"))}}const $=n.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const E=mp(y),I=y.length*8-l;return I>0?E>>BigInt(I):E},R=n.bits2int_modN||function(y){return s.create($(y))},j=Ed(l);function q(f){return By("num < 2^"+l,f,Co,j),s.toBytes(f)}function G(f,y){return ii(f,void 0,"message"),y?ii(e(f),void 0,"prehashed message"):f}function L(f,y,E){if(["recovered","canonical"].some(Q=>Q in E))throw new Error("sign() legacy options not supported");const{lowS:I,prehash:N,extraEntropy:D}=nb(E,b);f=G(f,N);const M=R(f),P=sc(s,y),m=[q(P),q(M)];if(D!=null&&D!==!1){const Q=D===!0?r(g.secretKey):D;m.push(St("extraEntropy",Q))}const v=Ii(...m),B=M;function U(Q){const ee=$(Q);if(!s.isValidNot0(ee))return;const Z=s.inv(ee),Y=t.BASE.multiply(ee).toAffine(),re=s.create(Y.x);if(re===Co)return;const de=s.create(Z*s.create(B+re*P));if(de===Co)return;let se=(Y.x===re?0:2)|Number(Y.y&oc),me=de;return I&&w(de)&&(me=s.neg(de),se^=1),new T(re,me,se)}return{seed:v,k2sig:U}}function V(f,y,E={}){f=St("message",f);const{seed:I,k2sig:N}=L(f,y,E);return IW(e.outputLen,s.BYTES,i)(I,N)}function W(f){let y;const E=typeof f=="string"||Hu(f),I=!E&&f!==null&&typeof f=="object"&&typeof f.r=="bigint"&&typeof f.s=="bigint";if(!E&&!I)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(I)y=new T(f.r,f.s);else if(E){try{y=T.fromBytes(St("sig",f),"der")}catch(N){if(!(N instanceof ko.Err))throw N}if(!y)try{y=T.fromBytes(St("sig",f),"compact")}catch(N){return!1}}return y||!1}function z(f,y,E,I={}){const{lowS:N,prehash:D,format:M}=nb(I,b);if(E=St("publicKey",E),y=G(St("message",y),D),"strict"in I)throw new Error("options.strict was renamed to lowS");const P=M===void 0?W(f):T.fromBytes(St("sig",f),M);if(P===!1)return!1;try{const m=t.fromBytes(E);if(N&&P.hasHighS())return!1;const{r:v,s:B}=P,U=R(y),Q=s.inv(B),ee=s.create(U*Q),Z=s.create(v*Q),Y=t.BASE.multiplyUnsafe(ee).add(m.multiplyUnsafe(Z));return Y.is0()?!1:s.create(Y.x)===v}catch(m){return!1}}function C(f,y,E={}){const{prehash:I}=nb(E,b);return y=G(y,I),T.fromBytes(f,"recovered").recoverPublicKey(y).toBytes()}return Object.freeze({keygen:c,getPublicKey:u,getSharedSecret:d,utils:h,lengths:g,Point:t,sign:V,verify:z,recoverPublicKey:C,Signature:T,hash:e})}function QG(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp;let r=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(s=>Math.ceil(s/2)))):void 0;const i=ka(e.n,{BITS:t.nBitLength,allowedLengths:r,modFromBytes:t.wrapPrivateKey}),o={Fp:n,Fn:i,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:o}}function XG(t){const{CURVE:e,curveOpts:n}=QG(t),r={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:n,hash:t.hash,ecdsaOpts:r}}function JG(t,e){const n=e.Point;return Object.assign({},e,{ProjectivePoint:n,CURVE:Object.assign({},t,VC(n.Fn.ORDER,n.Fn.BITS))})}function ZG(t){const{CURVE:e,curveOpts:n,hash:r,ecdsaOpts:i}=XG(t),o=KG(e,n),s=YG(o,r,i);return JG(t,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ej(t,e){const n=r=>ZG({...t,hash:r});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rb={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},tj={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},SI=BigInt(2);function nj(t){const e=rb.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,d=At(u,n,e)*u%e,h=At(d,n,e)*u%e,g=At(h,SI,e)*c%e,b=At(g,i,e)*g%e,p=At(b,o,e)*b%e,w=At(p,a,e)*p%e,S=At(w,l,e)*w%e,O=At(S,a,e)*p%e,T=At(O,n,e)*u%e,$=At(T,s,e)*b%e,R=At($,r,e)*c%e,j=At(R,SI,e);if(!ib.eql(ib.sqr(j),t))throw new Error("Cannot find square root");return j}const ib=ka(rb.p,{sqrt:nj}),rj=ej({...rb,Fp:ib,lowS:!0,endo:tj},VE);Ad.utils.randomPrivateKey,Ad.getPublicKey;function AI(t){try{return Ad.ExtendedPoint.fromHex(t),!0}catch(e){return!1}}const kI=(t,e)=>Ad.sign(t,e.slice(0,32)),ij=Ad.verify,Gn=t=>Fe.Buffer.isBuffer(t)?t:t instanceof Uint8Array?Fe.Buffer.from(t.buffer,t.byteOffset,t.byteLength):Fe.Buffer.from(t);class oj{constructor(e){Object.assign(this,e)}encode(){return Fe.Buffer.from(Hy.serialize(Bp,this))}static decode(e){return Hy.deserialize(Bp,this,e)}static decodeUnchecked(e){return Hy.deserializeUnchecked(Bp,this,e)}}const Bp=new Map;var CI;const sj=32,ms=32;function aj(t){return t._bn!==void 0}let II=1;class ke extends oj{constructor(e){if(super({}),this._bn=void 0,aj(e))this._bn=e._bn;else{if(typeof e=="string"){const n=Hn.decode(e);if(n.length!=ms)throw new Error("Invalid public key input");this._bn=new eI(n)}else this._bn=new eI(e);if(this._bn.byteLength()>ms)throw new Error("Invalid public key input")}}static unique(){const e=new ke(II);return II+=1,new ke(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Hn.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(Fe.Buffer);if(e.length===ms)return e;const n=Fe.Buffer.alloc(32);return e.copy(n,32-e.length),n}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,n,r){const i=Fe.Buffer.concat([e.toBuffer(),Fe.Buffer.from(n),r.toBuffer()]),o=DE(i);return new ke(o)}static createProgramAddressSync(e,n){let r=Fe.Buffer.alloc(0);e.forEach(function(o){if(o.length>sj)throw new TypeError("Max seed length exceeded");r=Fe.Buffer.concat([r,Gn(o)])}),r=Fe.Buffer.concat([r,n.toBuffer(),Fe.Buffer.from("ProgramDerivedAddress")]);const i=DE(r);if(AI(i))throw new Error("Invalid seeds, address must fall off the curve");return new ke(i)}static async createProgramAddress(e,n){return this.createProgramAddressSync(e,n)}static findProgramAddressSync(e,n){let r=255,i;for(;r!=0;){try{const o=e.concat(Fe.Buffer.from([r]));i=this.createProgramAddressSync(o,n)}catch(o){if(o instanceof TypeError)throw o;r--;continue}return[i,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,n){return this.findProgramAddressSync(e,n)}static isOnCurve(e){const n=new ke(e);return AI(n.toBytes())}}CI=ke,ke.default=new CI("11111111111111111111111111111111"),Bp.set(ke,{kind:"struct",fields:[["_bn","u256"]]}),new ke("BPFLoader1111111111111111111111111111111111");const ac=1232,ob=127,Rp=64;class Mp{constructor(e,n){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=n}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const n of this.keySegments()){if(e<n.length)return n[e];e-=n.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((o,s)=>{r.set(o.toBase58(),s)});const i=o=>{const s=r.get(o.toBase58());if(s===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return s};return e.map(o=>({programIdIndex:i(o.programId),accountKeyIndexes:o.keys.map(s=>i(s.pubkey)),data:o.data}))}}const je=(t="publicKey")=>X.blob(32,t),lj=(t="signature")=>X.blob(64,t),lc=(t="string")=>{const e=X.struct([X.u32("length"),X.u32("lengthPadding"),X.blob(X.offset(X.u32(),-8),"chars")],t),n=e.decode.bind(e),r=e.encode.bind(e),i=e;return i.decode=(o,s)=>n(o,s).chars.toString(),i.encode=(o,s,a)=>{const l={chars:Fe.Buffer.from(o,"utf8")};return r(l,s,a)},i.alloc=o=>X.u32().span+X.u32().span+Fe.Buffer.from(o,"utf8").length,i},cj=(t="authorized")=>X.struct([je("staker"),je("withdrawer")],t),uj=(t="lockup")=>X.struct([X.ns64("unixTimestamp"),X.ns64("epoch"),je("custodian")],t),dj=(t="voteInit")=>X.struct([je("nodePubkey"),je("authorizedVoter"),je("authorizedWithdrawer"),X.u8("commission")],t),fj=(t="voteAuthorizeWithSeedArgs")=>X.struct([X.u32("voteAuthorizationType"),je("currentAuthorityDerivedKeyOwnerPubkey"),lc("currentAuthorityDerivedKeySeed"),je("newAuthorized")],t);function OI(t,e){const n=i=>{if(i.span>=0)return i.span;if(typeof i.alloc=="function")return i.alloc(e[i.property]);if("count"in i&&"elementLayout"in i){const o=e[i.property];if(Array.isArray(o))return o.length*n(i.elementLayout)}else if("fields"in i)return OI({layout:i},e[i.property]);return 0};let r=0;return t.layout.fields.forEach(i=>{r+=n(i)}),r}function br(t){let e=0,n=0;for(;;){let r=t.shift();if(e|=(r&127)<<n*7,n+=1,(r&128)===0)break}return e}function vr(t,e){let n=e;for(;;){let r=n&127;if(n>>=7,n==0){t.push(r);break}else r|=128,t.push(r)}}function Nt(t,e){if(!t)throw new Error(e||"Assertion failed")}class Lp{constructor(e,n){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=n}static compile(e,n){const r=new Map,i=s=>{const a=s.toBase58();let l=r.get(a);return l===void 0&&(l={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,l)),l},o=i(n);o.isSigner=!0,o.isWritable=!0;for(const s of e){i(s.programId).isInvoked=!0;for(const a of s.keys){const l=i(a.pubkey);l.isSigner||(l.isSigner=a.isSigner),l.isWritable||(l.isWritable=a.isWritable)}}return new Lp(n,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];Nt(e.length<=256,"Max static account keys length exceeded");const n=e.filter(([,l])=>l.isSigner&&l.isWritable),r=e.filter(([,l])=>l.isSigner&&!l.isWritable),i=e.filter(([,l])=>!l.isSigner&&l.isWritable),o=e.filter(([,l])=>!l.isSigner&&!l.isWritable),s={numRequiredSignatures:n.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:o.length};{Nt(n.length>0,"Expected at least one writable signer key");const[l]=n[0];Nt(l===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...n.map(([l])=>new ke(l)),...r.map(([l])=>new ke(l)),...i.map(([l])=>new ke(l)),...o.map(([l])=>new ke(l))];return[s,a]}extractTableLookup(e){const[n,r]=this.drainKeysFoundInLookupTable(e.state.addresses,s=>!s.isSigner&&!s.isInvoked&&s.isWritable),[i,o]=this.drainKeysFoundInLookupTable(e.state.addresses,s=>!s.isSigner&&!s.isInvoked&&!s.isWritable);if(!(n.length===0&&i.length===0))return[{accountKey:e.key,writableIndexes:n,readonlyIndexes:i},{writable:r,readonly:o}]}drainKeysFoundInLookupTable(e,n){const r=new Array,i=new Array;for(const[o,s]of this.keyMetaMap.entries())if(n(s)){const a=new ke(o),l=e.findIndex(c=>c.equals(a));l>=0&&(Nt(l<256,"Max lookup table index exceeded"),r.push(l),i.push(a),this.keyMetaMap.delete(o))}return[r,i]}}const TI="Reached end of buffer unexpectedly";function Io(t){if(t.length===0)throw new Error(TI);return t.shift()}function wr(t,...e){var r;const[n]=e;if(e.length===2?n+((r=e[1])!=null?r:0)>t.length:n>=t.length)throw new Error(TI);return t.splice(...e)}class Ta{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(n=>new ke(n)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(n=>this.indexToProgramIds.set(n.programIdIndex,this.accountKeys[n.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Hn.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Mp(this.staticAccountKeys)}static compile(e){const n=Lp.compile(e.instructions,e.payerKey),[r,i]=n.getMessageComponents(),s=new Mp(i).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Hn.encode(a.data)}));return new Ta({header:r,accountKeys:i,recentBlockhash:e.recentBlockhash,instructions:s})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-n,o=this.accountKeys.length-n-this.header.numReadonlyUnsignedAccounts;return r<o}else{const r=n-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,n)=>!this.isProgramId(n))}serialize(){const e=this.accountKeys.length;let n=[];vr(n,e);const r=this.instructions.map(d=>{const{accounts:h,programIdIndex:g}=d,b=Array.from(Hn.decode(d.data));let p=[];vr(p,h.length);let w=[];return vr(w,b.length),{programIdIndex:g,keyIndicesCount:Fe.Buffer.from(p),keyIndices:h,dataLength:Fe.Buffer.from(w),data:b}});let i=[];vr(i,r.length);let o=Fe.Buffer.alloc(ac);Fe.Buffer.from(i).copy(o);let s=i.length;r.forEach(d=>{const g=X.struct([X.u8("programIdIndex"),X.blob(d.keyIndicesCount.length,"keyIndicesCount"),X.seq(X.u8("keyIndex"),d.keyIndices.length,"keyIndices"),X.blob(d.dataLength.length,"dataLength"),X.seq(X.u8("userdatum"),d.data.length,"data")]).encode(d,o,s);s+=g}),o=o.slice(0,s);const a=X.struct([X.blob(1,"numRequiredSignatures"),X.blob(1,"numReadonlySignedAccounts"),X.blob(1,"numReadonlyUnsignedAccounts"),X.blob(n.length,"keyCount"),X.seq(je("key"),e,"keys"),je("recentBlockhash")]),l={numRequiredSignatures:Fe.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Fe.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Fe.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Fe.Buffer.from(n),keys:this.accountKeys.map(d=>Gn(d.toBytes())),recentBlockhash:Hn.decode(this.recentBlockhash)};let c=Fe.Buffer.alloc(2048);const u=a.encode(l,c);return o.copy(c,u),c.slice(0,u+o.length)}static from(e){let n=[...e];const r=Io(n);if(r!==(r&ob))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=Io(n),o=Io(n),s=br(n);let a=[];for(let h=0;h<s;h++){const g=wr(n,0,ms);a.push(new ke(Fe.Buffer.from(g)))}const l=wr(n,0,ms),c=br(n);let u=[];for(let h=0;h<c;h++){const g=Io(n),b=br(n),p=wr(n,0,b),w=br(n),S=wr(n,0,w),O=Hn.encode(Fe.Buffer.from(S));u.push({programIdIndex:g,accounts:p,data:O})}const d={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:o},recentBlockhash:Hn.encode(Fe.Buffer.from(l)),accountKeys:a,instructions:u};return new Ta(d)}}class Td{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const n of this.addressTableLookups)e+=n.readonlyIndexes.length+n.writableIndexes.length;return e}getAccountKeys(e){let n;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");n=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)n=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Mp(this.staticAccountKeys,n)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const i=e-r,o=this.addressTableLookups.reduce((s,a)=>s+a.writableIndexes.length,0);return i<o}else if(e>=this.header.numRequiredSignatures){const i=e-n,s=r-n-this.header.numReadonlyUnsignedAccounts;return i<s}else{const i=n-this.header.numReadonlySignedAccounts;return e<i}}resolveAddressTableLookups(e){const n={writable:[],readonly:[]};for(const r of this.addressTableLookups){const i=e.find(o=>o.key.equals(r.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const o of r.writableIndexes)if(o<i.state.addresses.length)n.writable.push(i.state.addresses[o]);else throw new Error(`Failed to find address for index ${o} in address lookup table ${r.accountKey.toBase58()}`);for(const o of r.readonlyIndexes)if(o<i.state.addresses.length)n.readonly.push(i.state.addresses[o]);else throw new Error(`Failed to find address for index ${o} in address lookup table ${r.accountKey.toBase58()}`)}return n}static compile(e){const n=Lp.compile(e.instructions,e.payerKey),r=new Array,i={writable:new Array,readonly:new Array},o=e.addressLookupTableAccounts||[];for(const u of o){const d=n.extractTableLookup(u);if(d!==void 0){const[h,{writable:g,readonly:b}]=d;r.push(h),i.writable.push(...g),i.readonly.push(...b)}}const[s,a]=n.getMessageComponents(),c=new Mp(a,i).compileInstructions(e.instructions);return new Td({header:s,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){const e=Array();vr(e,this.staticAccountKeys.length);const n=this.serializeInstructions(),r=Array();vr(r,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),o=Array();vr(o,this.addressTableLookups.length);const s=X.struct([X.u8("prefix"),X.struct([X.u8("numRequiredSignatures"),X.u8("numReadonlySignedAccounts"),X.u8("numReadonlyUnsignedAccounts")],"header"),X.blob(e.length,"staticAccountKeysLength"),X.seq(je(),this.staticAccountKeys.length,"staticAccountKeys"),je("recentBlockhash"),X.blob(r.length,"instructionsLength"),X.blob(n.length,"serializedInstructions"),X.blob(o.length,"addressTableLookupsLength"),X.blob(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(ac),c=s.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(u=>u.toBytes()),recentBlockhash:Hn.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:n,addressTableLookupsLength:new Uint8Array(o),serializedAddressTableLookups:i},a);return a.slice(0,c)}serializeInstructions(){let e=0;const n=new Uint8Array(ac);for(const r of this.compiledInstructions){const i=Array();vr(i,r.accountKeyIndexes.length);const o=Array();vr(o,r.data.length);const s=X.struct([X.u8("programIdIndex"),X.blob(i.length,"encodedAccountKeyIndexesLength"),X.seq(X.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),X.blob(o.length,"encodedDataLength"),X.blob(r.data.length,"data")]);e+=s.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(o),data:r.data},n,e)}return n.slice(0,e)}serializeAddressTableLookups(){let e=0;const n=new Uint8Array(ac);for(const r of this.addressTableLookups){const i=Array();vr(i,r.writableIndexes.length);const o=Array();vr(o,r.readonlyIndexes.length);const s=X.struct([je("accountKey"),X.blob(i.length,"encodedWritableIndexesLength"),X.seq(X.u8(),r.writableIndexes.length,"writableIndexes"),X.blob(o.length,"encodedReadonlyIndexesLength"),X.seq(X.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=s.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(o),readonlyIndexes:r.readonlyIndexes},n,e)}return n.slice(0,e)}static deserialize(e){let n=[...e];const r=Io(n),i=r&ob;Nt(r!==i,"Expected versioned message but received legacy message");const o=i;Nt(o===0,`Expected versioned message with version 0 but found version ${o}`);const s={numRequiredSignatures:Io(n),numReadonlySignedAccounts:Io(n),numReadonlyUnsignedAccounts:Io(n)},a=[],l=br(n);for(let b=0;b<l;b++)a.push(new ke(wr(n,0,ms)));const c=Hn.encode(wr(n,0,ms)),u=br(n),d=[];for(let b=0;b<u;b++){const p=Io(n),w=br(n),S=wr(n,0,w),O=br(n),T=new Uint8Array(wr(n,0,O));d.push({programIdIndex:p,accountKeyIndexes:S,data:T})}const h=br(n),g=[];for(let b=0;b<h;b++){const p=new ke(wr(n,0,ms)),w=br(n),S=wr(n,0,w),O=br(n),T=wr(n,0,O);g.push({accountKey:p,writableIndexes:S,readonlyIndexes:T})}return new Td({header:s,staticAccountKeys:a,recentBlockhash:c,compiledInstructions:d,addressTableLookups:g})}}const PI={deserializeMessageVersion(t){const e=t[0],n=e&ob;return n===e?"legacy":n},deserialize:t=>{const e=PI.deserializeMessageVersion(t);if(e==="legacy")return Ta.from(t);if(e===0)return Td.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},hj=Fe.Buffer.alloc(Rp).fill(0);class Bn{constructor(e){this.keys=void 0,this.programId=void 0,this.data=Fe.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:n,isWritable:r})=>({pubkey:e.toJSON(),isSigner:n,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class Fp{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){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,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:n,nonceInfo:r}=e;this.minNonceContextSlot=n,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:n,lastValidBlockHeight:r}=e;this.recentBlockhash=n,this.lastValidBlockHeight=r}else{const{recentBlockhash:n,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=n}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(n=>{"instructions"in n?this.instructions=this.instructions.concat(n.instructions):"data"in n&&"programId"in n&&"keys"in n?this.instructions.push(n):this.instructions.push(new Bn(n))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,n;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?n=[this.nonceInfo.nonceInstruction,...this.instructions]:n=this.instructions):(e=this.recentBlockhash,n=this.instructions),!e)throw new Error("Transaction recentBlockhash required");n.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let p=0;p<n.length;p++)if(n[p].programId===void 0)throw new Error(`Transaction instruction index ${p} has undefined program id`);const i=[],o=[];n.forEach(p=>{p.keys.forEach(S=>{o.push({...S})});const w=p.programId.toString();i.includes(w)||i.push(w)}),i.forEach(p=>{o.push({pubkey:new ke(p),isSigner:!1,isWritable:!1})});const s=[];o.forEach(p=>{const w=p.pubkey.toString(),S=s.findIndex(O=>O.pubkey.toString()===w);S>-1?(s[S].isWritable=s[S].isWritable||p.isWritable,s[S].isSigner=s[S].isSigner||p.isSigner):s.push(p)}),s.sort(function(p,w){if(p.isSigner!==w.isSigner)return p.isSigner?-1:1;if(p.isWritable!==w.isWritable)return p.isWritable?-1:1;const S={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return p.pubkey.toBase58().localeCompare(w.pubkey.toBase58(),"en",S)});const a=s.findIndex(p=>p.pubkey.equals(r));if(a>-1){const[p]=s.splice(a,1);p.isSigner=!0,p.isWritable=!0,s.unshift(p)}else s.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const p of this.signatures){const w=s.findIndex(S=>S.pubkey.equals(p.publicKey));if(w>-1)s[w].isSigner||(s[w].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: ${p.publicKey.toString()}`)}let l=0,c=0,u=0;const d=[],h=[];s.forEach(({pubkey:p,isSigner:w,isWritable:S})=>{w?(d.push(p.toString()),l+=1,S||(c+=1)):(h.push(p.toString()),S||(u+=1))});const g=d.concat(h),b=n.map(p=>{const{data:w,programId:S}=p;return{programIdIndex:g.indexOf(S.toString()),accounts:p.keys.map(O=>g.indexOf(O.pubkey.toString())),data:Hn.encode(w)}});return b.forEach(p=>{Nt(p.programIdIndex>=0),p.accounts.forEach(w=>Nt(w>=0))}),new Ta({header:{numRequiredSignatures:l,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:u},accountKeys:g,recentBlockhash:e,instructions:b})}_compile(){const e=this.compileMessage(),n=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===n.length&&this.signatures.every((i,o)=>n[o].equals(i.publicKey))||(this.signatures=n.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const n=new Set;this.signatures=e.filter(r=>{const i=r.toString();return n.has(i)?!1:(n.add(i),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const o of e){const s=o.publicKey.toString();n.has(s)||(n.add(s),r.push(o))}this.signatures=r.map(o=>({signature:null,publicKey:o.publicKey}));const i=this._compile();this._partialSign(i,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const o of e){const s=o.publicKey.toString();n.has(s)||(n.add(s),r.push(o))}const i=this._compile();this._partialSign(i,...r)}_partialSign(e,...n){const r=e.serialize();n.forEach(i=>{const o=kI(r,i.secretKey);this._addSignature(i.publicKey,Gn(o))})}addSignature(e,n){this._compile(),this._addSignature(e,n)}_addSignature(e,n){Nt(n.length===64);const r=this.signatures.findIndex(i=>e.equals(i.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=Fe.Buffer.from(n)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,n){const r={};for(const{signature:i,publicKey:o}of this.signatures)i===null?n&&(r.missing||(r.missing=[])).push(o):ij(i,e,o.toBytes())||(r.invalid||(r.invalid=[])).push(o);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:n,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(r){const o=this._getMessageSignednessErrors(i,n);if(o){let s="Signature verification failed.";throw o.invalid&&(s+=`
|
|
201
201
|
Invalid signature for public key${o.invalid.length===1?"":"(s)"} [\`${o.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),o.missing&&(s+=`
|
|
202
|
-
Missing signature for public key${o.missing.length===1?"":"(s)"} [\`${o.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(s)}}return this._serialize(i)}_serialize(e){const{signatures:n}=this,r=[];vr(r,n.length);const i=r.length+n.length*64+e.length,o=Fe.Buffer.alloc(i);return Nt(n.length<256),Fe.Buffer.from(r).copy(o,0),n.forEach(({signature:s},a)=>{s!==null&&(Nt(s.length===64,"signature has invalid length"),Fe.Buffer.from(s).copy(o,r.length+a*64))}),e.copy(o,r.length+n.length*64),Nt(o.length<=ac,`Transaction too large: ${o.length} > ${ac}`),o}get keys(){return Nt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return Nt(this.instructions.length===1),this.instructions[0].programId}get data(){return Nt(this.instructions.length===1),this.instructions[0].data}static from(e){let n=[...e];const r=br(n);let i=[];for(let o=0;o<r;o++){const s=wr(n,0,Rp);i.push(Hn.encode(Fe.Buffer.from(s)))}return Fp.populate(Ta.from(n),i)}static populate(e,n=[]){const r=new Fp;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((i,o)=>{const s={signature:i==Hn.encode(hj)?null:Hn.decode(i),publicKey:e.accountKeys[o]};r.signatures.push(s)}),e.instructions.forEach(i=>{const o=i.accounts.map(s=>{const a=e.accountKeys[s];return{pubkey:a,isSigner:r.signatures.some(l=>l.publicKey.toString()===a.toString())||e.isAccountSigner(s),isWritable:e.isAccountWritable(s)}});r.instructions.push(new Bn({keys:o,programId:e.accountKeys[i.programIdIndex],data:Hn.decode(i.data)}))}),r._message=e,r._json=r.toJSON(),r}}class _p{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,n){const{header:r,compiledInstructions:i,recentBlockhash:o}=e,{numRequiredSignatures:s,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:l}=r,c=s-a;Nt(c>0,"Message header is invalid");const u=e.staticAccountKeys.length-s-l;Nt(u>=0,"Message header is invalid");const d=e.getAccountKeys(n),h=d.get(0);if(h===void 0)throw new Error("Failed to decompile message because no account keys were found");const g=[];for(const b of i){const p=[];for(const S of b.accountKeyIndexes){const O=d.get(S);if(O===void 0)throw new Error(`Failed to find key for account key index ${S}`);const T=S<s;let $;T?$=S<c:S<d.staticAccountKeys.length?$=S-s<u:$=S-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,p.push({pubkey:O,isSigner:S<r.numRequiredSignatures,isWritable:$})}const w=d.get(b.programIdIndex);if(w===void 0)throw new Error(`Failed to find program id for program id index ${b.programIdIndex}`);g.push(new Bn({programId:w,data:Gn(b.data),keys:p}))}return new _p({payerKey:h,instructions:g,recentBlockhash:o})}compileToLegacyMessage(){return Ta.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Td.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class Vp{get version(){return this.message.version}constructor(e,n){if(this.signatures=void 0,this.message=void 0,n!==void 0)Nt(n.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=n;else{const r=[];for(let i=0;i<e.header.numRequiredSignatures;i++)r.push(new Uint8Array(Rp));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),n=Array();vr(n,this.signatures.length);const r=X.struct([X.blob(n.length,"encodedSignaturesLength"),X.seq(lj(),this.signatures.length,"signatures"),X.blob(e.length,"serializedMessage")]),i=new Uint8Array(2048),o=r.encode({encodedSignaturesLength:new Uint8Array(n),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,o)}static deserialize(e){let n=[...e];const r=[],i=br(n);for(let s=0;s<i;s++)r.push(new Uint8Array(wr(n,0,Rp)));const o=PI.deserialize(new Uint8Array(n));return new Vp(o,r)}sign(e){const n=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of e){const o=r.findIndex(s=>s.equals(i.publicKey));Nt(o>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[o]=kI(n,i.secretKey)}}addSignature(e,n){Nt(n.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(o=>o.equals(e));Nt(i>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=n}}new ke("SysvarC1ock11111111111111111111111111111111"),new ke("SysvarEpochSchedu1e111111111111111111111111"),new ke("Sysvar1nstructions1111111111111111111111111");const sb=new ke("SysvarRecentB1ockHashes11111111111111111111"),NI=new ke("SysvarRent111111111111111111111111111111111");new ke("SysvarRewards111111111111111111111111111111"),new ke("SysvarS1otHashes111111111111111111111111111"),new ke("SysvarS1otHistory11111111111111111111111111"),new ke("SysvarStakeHistory1111111111111111111111111");function Fr(t,e){const n=t.layout.span>=0?t.layout.span:OI(t,e),r=Fe.Buffer.alloc(n),i=Object.assign({instruction:t.index},e);return t.layout.encode(i,r),r}const pj=X.nu64("lamportsPerSignature"),BI=X.struct([X.u32("version"),X.u32("state"),je("authorizedPubkey"),je("nonce"),X.struct([pj],"feeCalculator")]).span;function gj(t,e){const n=Fe.Buffer.alloc(e);let r=t;for(let i=0;i<e;i++)n[i]=Number(r&BigInt(255)),r>>=BigInt(8);return n}function mj(t){return t.reduceRight((e,n)=>(e<<BigInt(8))+BigInt(n),BigInt(0))}const yj=t=>{const e=t.decode.bind(t),n=t.encode.bind(t);return{decode:e,encode:n}},cc=(t=>e=>{const n=X.blob(t,e),{encode:r,decode:i}=yj(n),o=n;return o.decode=(s,a)=>{const l=i(s,a);return mj(Fe.Buffer.from(l))},o.encode=(s,a,l)=>{const c=gj(s,t);return r(c,a,l)},o})(8),_r=Object.freeze({Create:{index:0,layout:X.struct([X.u32("instruction"),X.ns64("lamports"),X.ns64("space"),je("programId")])},Assign:{index:1,layout:X.struct([X.u32("instruction"),je("programId")])},Transfer:{index:2,layout:X.struct([X.u32("instruction"),cc("lamports")])},CreateWithSeed:{index:3,layout:X.struct([X.u32("instruction"),je("base"),lc("seed"),X.ns64("lamports"),X.ns64("space"),je("programId")])},AdvanceNonceAccount:{index:4,layout:X.struct([X.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:X.struct([X.u32("instruction"),X.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:X.struct([X.u32("instruction"),je("authorized")])},AuthorizeNonceAccount:{index:7,layout:X.struct([X.u32("instruction"),je("authorized")])},Allocate:{index:8,layout:X.struct([X.u32("instruction"),X.ns64("space")])},AllocateWithSeed:{index:9,layout:X.struct([X.u32("instruction"),je("base"),lc("seed"),X.ns64("space"),je("programId")])},AssignWithSeed:{index:10,layout:X.struct([X.u32("instruction"),je("base"),lc("seed"),je("programId")])},TransferWithSeed:{index:11,layout:X.struct([X.u32("instruction"),cc("lamports"),lc("seed"),je("programId")])},UpgradeNonceAccount:{index:12,layout:X.struct([X.u32("instruction")])}});class uc{constructor(){}static createAccount(e){const n=_r.Create,r=Fr(n,{lamports:e.lamports,space:e.space,programId:Gn(e.programId.toBuffer())});return new Bn({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(e){let n,r;if("basePubkey"in e){const i=_r.TransferWithSeed;n=Fr(i,{lamports:BigInt(e.lamports),seed:e.seed,programId:Gn(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=_r.Transfer;n=Fr(i,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Bn({keys:r,programId:this.programId,data:n})}static assign(e){let n,r;if("basePubkey"in e){const i=_r.AssignWithSeed;n=Fr(i,{base:Gn(e.basePubkey.toBuffer()),seed:e.seed,programId:Gn(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=_r.Assign;n=Fr(i,{programId:Gn(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Bn({keys:r,programId:this.programId,data:n})}static createAccountWithSeed(e){const n=_r.CreateWithSeed,r=Fr(n,{base:Gn(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:Gn(e.programId.toBuffer())});let i=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||i.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Bn({keys:i,programId:this.programId,data:r})}static createNonceAccount(e){const n=new Fp;"basePubkey"in e&&"seed"in e?n.add(uc.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:BI,programId:this.programId})):n.add(uc.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:BI,programId:this.programId}));const r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){const n=_r.InitializeNonceAccount,r=Fr(n,{authorized:Gn(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:sb,isSigner:!1,isWritable:!1},{pubkey:NI,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Bn(i)}static nonceAdvance(e){const n=_r.AdvanceNonceAccount,r=Fr(n),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:sb,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Bn(i)}static nonceWithdraw(e){const n=_r.WithdrawNonceAccount,r=Fr(n,{lamports:e.lamports});return new Bn({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:sb,isSigner:!1,isWritable:!1},{pubkey:NI,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(e){const n=_r.AuthorizeNonceAccount,r=Fr(n,{authorized:Gn(e.newAuthorizedPubkey.toBuffer())});return new Bn({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(e){let n,r;if("basePubkey"in e){const i=_r.AllocateWithSeed;n=Fr(i,{base:Gn(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:Gn(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=_r.Allocate;n=Fr(i,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Bn({keys:r,programId:this.programId,data:n})}}uc.programId=new ke("11111111111111111111111111111111"),new ke("BPFLoader2111111111111111111111111111111111"),X.struct([X.u32("typeIndex"),cc("deactivationSlot"),X.nu64("lastExtendedSlot"),X.u8("lastExtendedStartIndex"),X.u8(),X.seq(je(),X.offset(X.u8(),-1),"authority")]);const kt=Od(Gy(ke),ge(),t=>new ke(t)),RI=jy([ge(),wt("base64")]),ab=Od(Gy(Fe.Buffer),RI,t=>Fe.Buffer.from(t[0],"base64"));function MI(t){return Wn([he({jsonrpc:wt("2.0"),id:ge(),result:t}),he({jsonrpc:wt("2.0"),id:ge(),error:he({code:ic(),message:ge(),data:Ce(xG())})})])}const bj=MI(ic());function gt(t){return Od(MI(t),bj,e=>"error"in e?e:{...e,result:Cd(e.result,t)})}function si(t){return gt(he({context:he({slot:le()}),value:t}))}function Dp(t){return he({context:he({slot:le()}),value:t})}const vj=he({foundation:le(),foundationTerm:le(),initial:le(),taper:le(),terminal:le()});gt(we(xe(he({epoch:le(),effectiveSlot:le(),amount:le(),postBalance:le(),commission:Ce(xe(le()))}))));const wj=we(he({slot:le(),prioritizationFee:le()})),xj=he({total:le(),validator:le(),foundation:le(),epoch:le()}),Ej=he({epoch:le(),slotIndex:le(),slotsInEpoch:le(),absoluteSlot:le(),blockHeight:Ce(le()),transactionCount:Ce(le())}),Sj=he({slotsPerEpoch:le(),leaderScheduleSlotOffset:le(),warmup:Mi(),firstNormalEpoch:le(),firstNormalSlot:le()}),Aj=cI(ge(),we(le())),Pa=xe(Wn([he({}),ge()])),kj=he({err:Pa}),Cj=wt("receivedSignature");he({"solana-core":ge(),"feature-set":Ce(le())});const Ij=he({program:ge(),programId:kt,parsed:ic()}),Oj=he({programId:kt,accounts:we(kt),data:ge()});si(he({err:xe(Wn([he({}),ge()])),logs:xe(we(ge())),accounts:Ce(xe(we(xe(he({executable:Mi(),owner:ge(),lamports:le(),data:we(ge()),rentEpoch:Ce(le())}))))),unitsConsumed:Ce(le()),returnData:Ce(xe(he({programId:ge(),data:jy([ge(),wt("base64")])}))),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(Wn([Ij,Oj]))}))))})),si(he({byIdentity:cI(ge(),we(le())),range:he({firstSlot:le(),lastSlot:le()})})),gt(vj),gt(xj),gt(wj),gt(Ej),gt(Sj),gt(Aj),gt(le()),si(he({total:le(),circulating:le(),nonCirculating:le(),nonCirculatingAccounts:we(kt)}));const Tj=he({amount:ge(),uiAmount:xe(le()),decimals:le(),uiAmountString:Ce(ge())});si(we(he({address:kt,amount:ge(),uiAmount:xe(le()),decimals:le(),uiAmountString:Ce(ge())}))),si(we(he({pubkey:kt,account:he({executable:Mi(),owner:kt,lamports:le(),data:ab,rentEpoch:le()})})));const lb=he({program:ge(),parsed:ic(),space:le()});si(we(he({pubkey:kt,account:he({executable:Mi(),owner:kt,lamports:le(),data:lb,rentEpoch:le()})}))),si(we(he({lamports:le(),address:kt})));const cb=he({executable:Mi(),owner:kt,lamports:le(),data:ab,rentEpoch:le()});he({pubkey:kt,account:cb});const Pj=Od(Wn([Gy(Fe.Buffer),lb]),Wn([RI,lb]),t=>Array.isArray(t)?Cd(t,ab):t),Nj=he({executable:Mi(),owner:kt,lamports:le(),data:Pj,rentEpoch:le()});he({pubkey:kt,account:Nj}),he({state:Wn([wt("active"),wt("inactive"),wt("activating"),wt("deactivating")]),active:le(),inactive:le()}),gt(we(he({signature:ge(),slot:le(),err:Pa,memo:xe(ge()),blockTime:Ce(xe(le()))}))),gt(we(he({signature:ge(),slot:le(),err:Pa,memo:xe(ge()),blockTime:Ce(xe(le()))}))),he({subscription:le(),result:Dp(cb)});const Bj=he({pubkey:kt,account:cb});he({subscription:le(),result:Dp(Bj)});const Rj=he({parent:le(),slot:le(),root:le()});he({subscription:le(),result:Rj});const Mj=Wn([he({type:Wn([wt("firstShredReceived"),wt("completed"),wt("optimisticConfirmation"),wt("root")]),slot:le(),timestamp:le()}),he({type:wt("createdBank"),parent:le(),slot:le(),timestamp:le()}),he({type:wt("frozen"),slot:le(),timestamp:le(),stats:he({numTransactionEntries:le(),numSuccessfulTransactions:le(),numFailedTransactions:le(),maxTransactionsPerEntry:le()})}),he({type:wt("dead"),slot:le(),timestamp:le(),err:ge()})]);he({subscription:le(),result:Mj}),he({subscription:le(),result:Dp(Wn([kj,Cj]))}),he({subscription:le(),result:le()}),he({pubkey:ge(),gossip:xe(ge()),tpu:xe(ge()),rpc:xe(ge()),version:xe(ge())});const LI=he({votePubkey:ge(),nodePubkey:ge(),activatedStake:le(),epochVoteAccount:Mi(),epochCredits:we(jy([le(),le(),le()])),commission:le(),lastVote:le(),rootSlot:xe(le())});gt(he({current:we(LI),delinquent:we(LI)}));const Lj=Wn([wt("processed"),wt("confirmed"),wt("finalized")]),Fj=he({slot:le(),confirmations:xe(le()),err:Pa,confirmationStatus:Ce(Lj)});si(we(xe(Fj))),gt(le());const FI=he({accountKey:kt,writableIndexes:we(le()),readonlyIndexes:we(le())}),ub=he({signatures:we(ge()),message:he({accountKeys:we(ge()),header:he({numRequiredSignatures:le(),numReadonlySignedAccounts:le(),numReadonlyUnsignedAccounts:le()}),instructions:we(he({accounts:we(le()),data:ge(),programIdIndex:le()})),recentBlockhash:ge(),addressTableLookups:Ce(we(FI))})}),_I=he({pubkey:kt,signer:Mi(),writable:Mi(),source:Ce(Wn([wt("transaction"),wt("lookupTable")]))}),VI=he({accountKeys:we(_I),signatures:we(ge())}),DI=he({parsed:ic(),program:ge(),programId:kt}),zI=he({accounts:we(kt),data:ge(),programId:kt}),_j=Wn([zI,DI]),Vj=Wn([he({parsed:ic(),program:ge(),programId:ge()}),he({accounts:we(ge()),data:ge(),programId:ge()})]),UI=Od(_j,Vj,t=>"accounts"in t?Cd(t,zI):Cd(t,DI)),$I=he({signatures:we(ge()),message:he({accountKeys:we(_I),instructions:we(UI),recentBlockhash:ge(),addressTableLookups:Ce(xe(we(FI)))})}),zp=he({accountIndex:le(),mint:ge(),owner:Ce(ge()),programId:Ce(ge()),uiTokenAmount:Tj}),HI=he({writable:we(kt),readonly:we(kt)}),Up=he({err:Pa,fee:le(),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(he({accounts:we(le()),data:ge(),programIdIndex:le()}))})))),preBalances:we(le()),postBalances:we(le()),logMessages:Ce(xe(we(ge()))),preTokenBalances:Ce(xe(we(zp))),postTokenBalances:Ce(xe(we(zp))),loadedAddresses:Ce(HI),computeUnitsConsumed:Ce(le())}),db=he({err:Pa,fee:le(),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(UI)})))),preBalances:we(le()),postBalances:we(le()),logMessages:Ce(xe(we(ge()))),preTokenBalances:Ce(xe(we(zp))),postTokenBalances:Ce(xe(we(zp))),loadedAddresses:Ce(HI),computeUnitsConsumed:Ce(le())}),dc=Wn([wt(0),wt("legacy")]),Na=he({pubkey:ge(),lamports:le(),postBalance:xe(le()),rewardType:xe(ge()),commission:Ce(xe(le()))});gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:ub,meta:xe(Up),version:Ce(dc)})),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:VI,meta:xe(Up),version:Ce(dc)})),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:$I,meta:xe(db),version:Ce(dc)})),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:VI,meta:xe(db),version:Ce(dc)})),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:ub,meta:xe(Up)})),rewards:Ce(we(Na)),blockTime:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),signatures:we(ge()),blockTime:xe(le())}))),gt(xe(he({slot:le(),meta:xe(Up),blockTime:Ce(xe(le())),transaction:ub,version:Ce(dc)}))),gt(xe(he({slot:le(),transaction:$I,meta:xe(db),blockTime:Ce(xe(le())),version:Ce(dc)}))),si(he({blockhash:ge(),lastValidBlockHeight:le()})),si(Mi());const Dj=he({slot:le(),numTransactions:le(),numSlots:le(),samplePeriodSecs:le()});gt(we(Dj)),si(xe(he({feeCalculator:he({lamportsPerSignature:le()})}))),gt(ge()),gt(ge());const zj=he({err:Pa,logs:we(ge()),signature:ge()});he({result:Dp(zj),subscription:le()}),Object.freeze({CreateLookupTable:{index:0,layout:X.struct([X.u32("instruction"),cc("recentSlot"),X.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:X.struct([X.u32("instruction")])},ExtendLookupTable:{index:2,layout:X.struct([X.u32("instruction"),cc(),X.seq(je(),X.offset(X.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:X.struct([X.u32("instruction")])},CloseLookupTable:{index:4,layout:X.struct([X.u32("instruction")])}}),new ke("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:X.struct([X.u8("instruction"),X.u32("units"),X.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:X.struct([X.u8("instruction"),X.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:X.struct([X.u8("instruction"),X.u32("units")])},SetComputeUnitPrice:{index:3,layout:X.struct([X.u8("instruction"),cc("microLamports")])}}),new ke("ComputeBudget111111111111111111111111111111"),X.struct([X.u8("numSignatures"),X.u8("padding"),X.u16("signatureOffset"),X.u16("signatureInstructionIndex"),X.u16("publicKeyOffset"),X.u16("publicKeyInstructionIndex"),X.u16("messageDataOffset"),X.u16("messageDataSize"),X.u16("messageInstructionIndex")]),new ke("Ed25519SigVerify111111111111111111111111111"),rj.utils.isValidPrivateKey,X.struct([X.u8("numSignatures"),X.u16("signatureOffset"),X.u8("signatureInstructionIndex"),X.u16("ethAddressOffset"),X.u8("ethAddressInstructionIndex"),X.u16("messageDataOffset"),X.u16("messageDataSize"),X.u8("messageInstructionIndex"),X.blob(20,"ethAddress"),X.blob(64,"signature"),X.u8("recoveryId")]),new ke("KeccakSecp256k11111111111111111111111111111");var WI;new ke("StakeConfig11111111111111111111111111111111");class GI{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}WI=GI,GI.default=new WI(0,0,ke.default),Object.freeze({Initialize:{index:0,layout:X.struct([X.u32("instruction"),cj(),uj()])},Authorize:{index:1,layout:X.struct([X.u32("instruction"),je("newAuthorized"),X.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:X.struct([X.u32("instruction")])},Split:{index:3,layout:X.struct([X.u32("instruction"),X.ns64("lamports")])},Withdraw:{index:4,layout:X.struct([X.u32("instruction"),X.ns64("lamports")])},Deactivate:{index:5,layout:X.struct([X.u32("instruction")])},Merge:{index:7,layout:X.struct([X.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:X.struct([X.u32("instruction"),je("newAuthorized"),X.u32("stakeAuthorizationType"),lc("authoritySeed"),je("authorityOwner")])}}),new ke("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:X.struct([X.u32("instruction"),dj()])},Authorize:{index:1,layout:X.struct([X.u32("instruction"),je("newAuthorized"),X.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:X.struct([X.u32("instruction"),X.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:X.struct([X.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:X.struct([X.u32("instruction"),fj()])}}),new ke("Vote111111111111111111111111111111111111111"),new ke("Va1idator1nfo111111111111111111111111111111"),he({name:ge(),website:Ce(ge()),details:Ce(ge()),iconUrl:Ce(ge()),keybaseUsername:Ce(ge())}),new ke("Vote111111111111111111111111111111111111111"),X.struct([je("nodePubkey"),je("authorizedWithdrawer"),X.u8("commission"),X.nu64(),X.seq(X.struct([X.nu64("slot"),X.u32("confirmationCount")]),X.offset(X.u32(),-8),"votes"),X.u8("rootSlotValid"),X.nu64("rootSlot"),X.nu64(),X.seq(X.struct([X.nu64("epoch"),je("authorizedVoter")]),X.offset(X.u32(),-8),"authorizedVoters"),X.struct([X.seq(X.struct([je("authorizedPubkey"),X.nu64("epochOfLastAuthorizedSwitch"),X.nu64("targetEpoch")]),32,"buf"),X.nu64("idx"),X.u8("isEmpty")],"priorVoters"),X.nu64(),X.seq(X.struct([X.nu64("epoch"),X.nu64("credits"),X.nu64("prevCredits")]),X.offset(X.u32(),-8),"epochCredits"),X.struct([X.nu64("slot"),X.nu64("timestamp")],"lastTimestamp")]);var ys=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},bs=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},$p=new ke("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),jI=new ke("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),KI=new ke("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),Hp=function(t){if(!t||typeof t!="object")return!1;var e=t,n=(e.message||"").toLowerCase();return n.includes("user rejected")||n.includes("declined")||n.includes("cancelled")||n.includes("denied")||e.code===4001};function qI(t,e){return ys(this,arguments,void 0,function(n,r,i){var o;return i===void 0&&(i=$p.toBase58()),bs(this,function(s){switch(s.label){case 0:return[4,ke.findProgramAddress([r.toBuffer(),new ke(i).toBuffer(),n.toBuffer()],KI)];case 1:return o=s.sent()[0],[2,o]}})})}function Uj(t,e,n,r,i){i===void 0&&(i=$p);var o=[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:uc.programId,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1}];return new Bn({keys:o,programId:KI,data:Buffer.alloc(0)})}function $j(t,e,n,r,i,o){i===void 0&&(i=9);var s=Buffer.alloc(10);s[0]=12,s.writeBigUInt64LE(r,1),s[9]=i;var a=jI;return new Bn({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:a,data:s})}function Hj(t){var e=t.fromTokenAccount,n=t.toTokenAccount,r=t.owner,i=t.amount,o=Buffer.alloc(9);return o[0]=3,o.writeBigUInt64LE(i,1),new Bn({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:$p,data:o})}function Wj(t){return ys(this,void 0,void 0,function(){var e,n,r;return bs(this,function(i){switch(i.label){case 0:return[4,YI(t)];case 1:return e=i.sent(),n=new ke(t.fromAddress),r=new _p({payerKey:n,recentBlockhash:t.blockhash,instructions:e}).compileToV0Message(),[2,new Vp(r)]}})})}function YI(t){return ys(this,void 0,void 0,function(){var e,n,r,i,o,s;return bs(this,function(a){switch(a.label){case 0:return e=new ke(t.fromAddress),n=new ke(t.toAddress),r=[],t.tokenMint?[3,1]:(r.push(uc.transfer({fromPubkey:e,toPubkey:n,lamports:Number(t.amount)})),[3,4]);case 1:return i=new ke(t.tokenMint),[4,qI(i,e,t.tokenProgram)];case 2:return o=a.sent(),[4,qI(i,n,t.tokenProgram)];case 3:s=a.sent(),t.createATA&&r.push(Uj(e,s,n,i,t.tokenProgram?new ke(t.tokenProgram):$p)),t.tokenProgram===jI.toBase58()?r.push($j(o,s,e,BigInt(t.amount),t.tokenDecimals,i)):r.push(Hj({fromTokenAccount:o,toTokenAccount:s,owner:e,amount:BigInt(t.amount)})),a.label=4;case 4:return[2,r]}})})}function fc(t,e){return ys(this,void 0,void 0,function(){var r,n,r,i,o;return bs(this,function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),e.signAndSendTransaction?[4,e.signAndSendTransaction(t)]:[3,2];case 1:return r=s.sent().signature,[2,r];case 2:return[4,e.signTransaction(t)];case 3:if(n=s.sent(),!e.sendTransaction)throw new Error("Provider does not support sendTransaction");return[4,e.sendTransaction(n)];case 4:return r=s.sent(),[2,r];case 5:return[3,7];case 6:throw i=s.sent(),console.error("Error in handleManualSignAndSend:",i),i instanceof Error&&(!((o=i.message)===null||o===void 0)&&o.includes("User rejected"))?new Error("Transaction was rejected by user"):i;case 7:return[2]}})})}function Gj(t){return ys(this,void 0,void 0,function(){var e,n,r;return bs(this,function(i){for(e=[],n=function(o){var s=t[o],a=new ke(s.programId),l=s.accounts.map(function(c,u){if(!c.pubKey)throw new Error("Account at instruction ".concat(o,", index ").concat(u," has no pubKey and is not fillable"));var d=new ke(c.pubKey);return{pubkey:d,isSigner:c.isSigner,isWritable:c.isWritable}});e.push(new Bn({keys:l,programId:a,data:Buffer.from(s.data,"base64")}))},r=0;r<t.length;r++)n(r);return[2,e]})})}var QI=function(t){return ys(void 0,void 0,void 0,function(){var e,n,r,i,o,s;return bs(this,function(a){switch(a.label){case 0:return a.trys.push([0,8,,9]),e=Ea(t.walletName),[4,Wj(t)];case 1:return n=a.sent(),r=e.isTrust||e.isTrustWallet||t.walletName.toLowerCase().includes("trust"),r?[4,fc(n,e)]:[3,3];case 2:return[2,a.sent()];case 3:if(!e.signAndSendTransaction)return[3,7];a.label=4;case 4:return a.trys.push([4,6,,7]),[4,e.signAndSendTransaction(n)];case 5:return i=a.sent().signature,[2,i];case 6:if(o=a.sent(),Hp(o))throw new Error("Transaction was rejected by user");return[2,fc(n,e)];case 7:return[2,fc(n,e)];case 8:throw s=a.sent(),Hp(s)?new Error("Transaction was rejected by user"):s instanceof Error?s:new Error("Failed to send SOL transaction with ".concat(t.walletName," wallet"));case 9:return[2]}})})},jj=function(t,e){return ys(void 0,void 0,void 0,function(){var n,r,i,o,s,a;return bs(this,function(l){switch(l.label){case 0:n=t.transactionInstructions.walletName||"Phantom",l.label=1;case 1:return l.trys.push([1,5,,6]),[4,Gj(t.transactionInstructions.instructions)];case 2:return r=l.sent(),i=new ke(e.fromAddress),[4,YI(e)];case 3:return o=l.sent(),r.push.apply(r,o),s=new Vp(new _p({payerKey:i,recentBlockhash:t.transactionInstructions.blockhash,instructions:r}).compileToV0Message()),[4,Kj(n,s)];case 4:return[2,l.sent()];case 5:throw a=l.sent(),Hp(a)?new Error("Transaction was rejected by user"):a instanceof Error?a:new Error("Failed to send SOL transaction with ".concat(n," wallet"));case 6:return[2]}})})},Kj=function(t,e){return ys(void 0,void 0,void 0,function(){var n,r,i,o;return bs(this,function(s){switch(s.label){case 0:return n=Ea(t),r=n.isTrust||n.isTrustWallet||t.includes("trust"),r?[4,fc(e,n)]:[3,2];case 1:return[2,s.sent()];case 2:if(!n.signAndSendTransaction)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,n.signAndSendTransaction(e)];case 4:return i=s.sent().signature,[2,i];case 5:if(o=s.sent(),Hp(o))throw new Error("Transaction was rejected by user");return[2,fc(e,n)];case 6:return[2,fc(e,n)]}})})},fb,XI;function qj(){if(XI)return fb;XI=1;function t(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(n[s]!==255)throw new TypeError(o+" is ambiguous");n[s]=i}var a=e.length,l=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var p=0,w=0,S=0,O=b.length;S!==O&&b[S]===0;)S++,p++;for(var T=(O-S)*u+1>>>0,$=new Uint8Array(T);S!==O;){for(var R=b[S],j=0,q=T-1;(R!==0||j<w)&&q!==-1;q--,j++)R+=256*$[q]>>>0,$[q]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");w=j,S++}for(var G=T-w;G!==T&&$[G]===0;)G++;for(var L=l.repeat(p);G<T;++G)L+=e.charAt($[G]);return L}function h(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;for(var p=0,w=0,S=0;b[p]===l;)w++,p++;for(var O=(b.length-p)*c+1>>>0,T=new Uint8Array(O);b[p];){var $=b.charCodeAt(p);if($>255)return;var R=n[$];if(R===255)return;for(var j=0,q=O-1;(R!==0||j<S)&&q!==-1;q--,j++)R+=a*T[q]>>>0,T[q]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");S=j,p++}for(var G=O-S;G!==O&&T[G]===0;)G++;for(var L=new Uint8Array(w+(O-G)),V=w;G!==O;)L[V++]=T[G++];return L}function g(b){var p=h(b);if(p)return p;throw new Error("Non-base"+a+" character")}return{encode:d,decodeUnsafe:h,decode:g}}return fb=t,fb}var hb,JI;function Yj(){return JI||(JI=1,hb=qj()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),hb}var Qj=Yj();const Xj=sl(Qj);var Jj=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},Zj=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},eK=function(t,e){return Jj(void 0,void 0,void 0,function(){var n,r,i,o;return Zj(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),n=Ea(t),r=new TextEncoder().encode(e),[4,n.signMessage(r)];case 1:return i=s.sent(),[2,Xj.encode(i.signature)];case 2:return o=s.sent(),[2,o instanceof Error?o:new Error("Failed to sign message with ".concat(t," wallet"))];case 3:return[2]}})})},tK=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),vs=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},ws=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},nK=function(t){tK(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.connect=function(n){return vs(this,void 0,void 0,function(){var r,i;return ws(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,AW(n)];case 1:if(r=o.sent(),r instanceof Error)throw r;return[2,{accounts:r.accounts,chainId:r.chainId,isConnected:r.isConnected}];case 2:throw i=o.sent(),this.handleError(i,"connect to Solana wallet");case 3:return[2]}})})},e.prototype.disconnect=function(n){return vs(this,void 0,void 0,function(){var r,i;return ws(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,kW(n.walletName||"Unknown Wallet")];case 1:if(r=o.sent(),r instanceof Error)throw r;return[3,3];case 2:throw i=o.sent(),this.handleError(i,"disconnect from Solana wallet");case 3:return[2]}})})},e.prototype.signMessage=function(n){return vs(this,void 0,void 0,function(){var r,i;return ws(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,eK(n.walletName||"Unknown Wallet",n.message)];case 1:if(r=o.sent(),r instanceof Error)throw r;return[2,r];case 2:throw i=o.sent(),this.handleError(i,"sign Solana message");case 3:return[2]}})})},e.prototype.switchChain=function(n){return vs(this,void 0,void 0,function(){return ws(this,function(r){return[2,{chainId:"101",accounts:[]}]})})},e.prototype.sendNativeTransfer=function(n){return vs(this,void 0,void 0,function(){var r,i;return ws(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,QI({toAddress:n.toAddress,amount:BigInt(n.amount*Math.pow(10,n.decimalPlaces)),fromAddress:n.account,blockhash:n.blockhash||"",walletName:n.walletName||""})];case 1:if(r=o.sent(),typeof r=="string")return[2,r];throw r;case 2:throw i=o.sent(),this.handleError(i,"send Solana native transfer");case 3:return[2]}})})},e.prototype.sendSmartContractInteraction=function(n){return vs(this,void 0,void 0,function(){var r,i,o,s,a,l,c;return ws(this,function(u){switch(u.label){case 0:return r=Ea(n.walletName||""),o=n.account,o?[3,2]:[4,(c=r.publicKey)===null||c===void 0?void 0:c.toString()];case 1:o=u.sent(),u.label=2;case 2:if(i=o,!i)throw new Error("Sender account address is required");if(s=n.args[2]||9,a=n.args[1],l=a,!n.blockhash)throw new Error("Blockhash is required for Solana transactions");return[4,QI({toAddress:n.args[0],amount:l,fromAddress:i,blockhash:n.blockhash,walletName:n.walletName||"",tokenMint:n.address,createATA:n.createATA||!1,tokenProgram:n.tokenProgram,tokenDecimals:s})];case 3:return[2,u.sent()]}})})},e.prototype.sendTransactionWithInstructions=function(n){return vs(this,void 0,void 0,function(){var r,i,o,s,a,l,c,u,d;return ws(this,function(h){switch(h.label){case 0:return r=Ea(n.transactionInstructions.walletName||""),o=n.transferConfig.account,o?[3,2]:[4,(d=r.publicKey)===null||d===void 0?void 0:d.toString()];case 1:o=h.sent(),h.label=2;case 2:if(i=o,!i)throw new Error("Sender account address is required");if(s=n.transferConfig.args[2]||6,a=n.transferConfig.args[1],l=a,!n.transactionInstructions.blockhash)throw new Error("Blockhash is required for Solana transactions");h.label=3;case 3:return h.trys.push([3,5,,6]),[4,jj(n,{toAddress:n.transferConfig.args[0],amount:l,fromAddress:i,blockhash:n.transactionInstructions.blockhash,walletName:n.transactionInstructions.walletName||"",tokenMint:n.transferConfig.address,createATA:n.transferConfig.createATA||!1,tokenProgram:n.transferConfig.tokenProgram,tokenDecimals:s})];case 4:if(c=h.sent(),typeof c=="string")return[2,c];throw c;case 5:throw u=h.sent(),this.handleError(u,"send Solana native transfer");case 6:return[2]}})})},e.prototype.sendNativeSmartContractInteraction=function(){throw new Error("Method not implemented.")},e.prototype.sendTransactionBatch=function(){throw new Error("Method not implemented.")},e.prototype.getWalletCapabilities=function(){return vs(this,void 0,void 0,function(){return ws(this,function(n){return[2,{atomic:{status:"ready"}}]})})},e.prototype.getProviders=function(){var n=bC();return Object.keys(n).map(function(r){return{id:r,type:"solana"}})},e}(sS),ZI=function(){function t(){this.strategies=new Map,this.strategies.set("evm",new xW),this.strategies.set("solana",new nK)}return t.getInstance=function(){return t.instance||(t.instance=new t),t.instance},t.prototype.getStrategy=function(e){var n=this.strategies.get(e);if(!n)throw new Error("No strategy found for network type: ".concat(e));return n},t.prototype.getAllProviders=function(){var e=[];return this.strategies.forEach(function(n){e.push.apply(e,n.getProviders())}),e},t}(),pb=function(){return pb=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},pb.apply(this,arguments)},gb=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},mb=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Pe,eO,Wp,yb=pm,rK=function(){return document.getElementById(yb)};function jn(t){var e,n=rK();if(!n){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no iframe element found"));return}if(!Wp){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no link token origin found"));return}try{(e=n.contentWindow)===null||e===void 0||e.postMessage(t,Wp)}catch(r){console.error("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe")),console.error(r)}}function iK(t){return gb(this,void 0,void 0,function(){var e,e,e,e,n,r,i,o,s,a,l,c,u,d,h,g;return mb(this,function(b){switch(t.data.type){case"brokerageAccountAccessToken":{e={accessToken:t.data.payload},(i=Pe==null?void 0:Pe.onEvent)===null||i===void 0||i.call(Pe,{type:"integrationConnected",payload:e}),(o=Pe==null?void 0:Pe.onIntegrationConnected)===null||o===void 0||o.call(Pe,e);break}case"delayedAuthentication":{e={delayedAuth:t.data.payload},(s=Pe==null?void 0:Pe.onEvent)===null||s===void 0||s.call(Pe,{type:"integrationConnected",payload:e}),(a=Pe==null?void 0:Pe.onIntegrationConnected)===null||a===void 0||a.call(Pe,e);break}case"transferFinished":{e=t.data.payload,(l=Pe==null?void 0:Pe.onEvent)===null||l===void 0||l.call(Pe,{type:"transferCompleted",payload:e}),(c=Pe==null?void 0:Pe.onTransferFinished)===null||c===void 0||c.call(Pe,e);break}case"close":case"done":{e=(u=t.data)===null||u===void 0?void 0:u.payload,(d=Pe==null?void 0:Pe.onExit)===null||d===void 0||d.call(Pe,e==null?void 0:e.errorMessage,e),gm();break}case"loaded":{jn({type:"meshSDKSpecs",payload:pb({},TU)}),n=ZI.getInstance(),r=n.getAllProviders(),jn({type:"SDKinjectedWalletProviders",payload:r}),Pe!=null&&Pe.accessTokens&&jn({type:"frontAccessTokens",payload:Pe.accessTokens}),Pe!=null&&Pe.transferDestinationTokens&&jn({type:"frontTransferDestinationTokens",payload:Pe.transferDestinationTokens}),(h=Pe==null?void 0:Pe.onEvent)===null||h===void 0||h.call(Pe,{type:"pageLoaded"});break}default:{EU(t.data.type)&&((g=Pe==null?void 0:Pe.onEvent)===null||g===void 0||g.call(Pe,t.data));break}}return[2]})})}function oK(t){return gb(this,void 0,void 0,function(){var e,n,p,w,S,O,r,p,w,S,O,i,p,w,S,O,o,p,w,S,O,s,p,l,w,S,O,h,a,u,p,l,w,S,O,h,c,u,p,h,w,S,O,d,p,h,w,S,O,g,p,w,S,b,p,w,S,O,T,$;return mb(this,function(R){switch(R.label){case 0:switch(e=ZI.getInstance(),n=t.data.type,n){case"walletBrowserInjectedWalletSelected":return[3,1];case"walletBrowserSignRequest":return[3,6];case"walletBrowserChainSwitchRequest":return[3,11];case"walletBrowserNativeTransferRequest":return[3,16];case"walletBrowserNonNativeTransferRequest":return[3,21];case"walletBrowserNonNativeSmartDeposit":return[3,21];case"walletBrowserNativeSmartDeposit":return[3,26];case"walletBrowserTransactionBatchRequest":return[3,31];case"walletBrowserWalletCapabilities":return[3,36];case"walletBrowserDisconnect":return[3,41];case"walletBrowserSolanaTransferWithInstructionsRequest":return[3,49]}return[3,54];case 1:p=t.data.payload,R.label=2;case 2:return R.trys.push([2,4,,5]),w=!(($=p.networkType)===null||$===void 0)&&$.includes("solana")?"solana":"evm",S=e.getStrategy(w),[4,S.connect(p)];case 3:return O=R.sent(),jn({type:"SDKinjectedConnectionCompleted",payload:{accounts:O.accounts,chainId:O.chainId,networkType:w}}),[3,5];case 4:return r=R.sent(),console.error("Connection error:",r),Li(r,"SDKinjectedConnectionCompleted"),[3,5];case 5:return[3,54];case 6:p=t.data.payload,R.label=7;case 7:return R.trys.push([7,9,,10]),w=p.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.signMessage(p)];case 8:return O=R.sent(),jn({type:"SDKsignRequestCompleted",payload:O}),[3,10];case 9:return i=R.sent(),Li(i,"SDKsignRequestCompleted"),[3,10];case 10:return[3,54];case 11:p=t.data.payload,R.label=12;case 12:return R.trys.push([12,14,,15]),w=p.networkType==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.switchChain(p)];case 13:return O=R.sent(),jn({type:"SDKswitchChainCompleted",payload:{chainId:O.chainId,accounts:O.accounts,networkType:w}}),[3,15];case 14:return o=R.sent(),console.error("Chain switch failed:",o),Li(o,"SDKswitchChainCompleted"),[3,15];case 15:return[3,54];case 16:p=t.data.payload,R.label=17;case 17:return R.trys.push([17,19,,20]),w=p.network==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.sendNativeTransfer(p)];case 18:return O=R.sent(),jn({type:"SDKnativeTransferCompleted",payload:O}),[3,20];case 19:return s=R.sent(),Li(s,"SDKnativeTransferCompleted"),[3,20];case 20:return[3,54];case 21:p=t.data.payload,l=function(j){switch(j){case"walletBrowserNonNativeTransferRequest":return"SDKnonNativeTransferCompleted";case"walletBrowserNativeSmartDeposit":return"SDKnativeSmartDepositCompleted";case"walletBrowserNonNativeSmartDeposit":return"SDKnonNativeSmartDepositCompleted";default:return"SDKnonNativeTransferCompleted"}},R.label=22;case 22:return R.trys.push([22,24,,25]),w=p.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendSmartContractInteraction(p)];case 23:return O=R.sent(),h=l(t.data.type),jn({type:h,payload:{txHash:O}}),[3,25];case 24:return a=R.sent(),u=l(t.data.type),Li(a,u),[3,25];case 25:return[3,54];case 26:p=t.data.payload,l=function(j){switch(j){case"walletBrowserNonNativeTransferRequest":return"SDKnonNativeTransferCompleted";case"walletBrowserNativeSmartDeposit":return"SDKnativeSmartDepositCompleted";case"walletBrowserNonNativeSmartDeposit":return"SDKnonNativeSmartDepositCompleted";default:return"SDKnonNativeTransferCompleted"}},R.label=27;case 27:return R.trys.push([27,29,,30]),w=p.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendNativeSmartContractInteraction(p)];case 28:return O=R.sent(),h=l(t.data.type),jn({type:h,payload:{txHash:O}}),[3,30];case 29:return c=R.sent(),u=l(t.data.type),Li(c,u),[3,30];case 30:return[3,54];case 31:p=t.data.payload,h="SDKtransactionBatchCompleted",R.label=32;case 32:return R.trys.push([32,34,,35]),w=p.from.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendTransactionBatch(p)];case 33:return O=R.sent(),jn({type:h,payload:{txHash:O}}),[3,35];case 34:return d=R.sent(),Li(d,h),[3,35];case 35:return[3,54];case 36:p=t.data.payload,h="SDKwalletCapabilitiesCompleted",R.label=37;case 37:return R.trys.push([37,39,,40]),w=p.from.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.getWalletCapabilities(p)];case 38:return O=R.sent(),jn({type:h,payload:O}),[3,40];case 39:return g=R.sent(),Li(g,h),[3,40];case 40:return[3,54];case 41:p=t.data.payload,R.label=42;case 42:return R.trys.push([42,47,,48]),p!=null&&p.networkType?(w=p.networkType==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.disconnect(p)]):[3,44];case 43:return R.sent(),[3,46];case 44:return[4,Promise.all([e.getStrategy("solana").disconnect(p),e.getStrategy("evm").disconnect(p)])];case 45:R.sent(),R.label=46;case 46:return jn({type:"SDKdisconnectSuccess"}),[3,48];case 47:return b=R.sent(),console.error("Error during disconnect:",b),Li(b,"SDKdisconnectSuccess"),[3,48];case 48:return[3,54];case 49:p=t.data.payload,R.label=50;case 50:return R.trys.push([50,52,,53]),w="solana",S=e.getStrategy(w),[4,S.sendTransactionWithInstructions(p)];case 51:return O=R.sent(),jn({type:"SDKnonNativeTransferCompleted",payload:{txHash:O}}),[3,53];case 52:return T=R.sent(),Li(T,"SDKdisconnectSuccess"),[3,53];case 53:return[3,54];case 54:return[2]}})})}function bb(t){return gb(this,void 0,void 0,function(){return mb(this,function(e){switch(e.label){case 0:return t.origin!==eO&&t.origin!==Wp?(console.warn("Received message from untrusted origin:",t.origin),[3,5]):[3,1];case 1:return IU(t.data.type)?[4,oK(t)]:[3,3];case 2:return e.sent(),[3,5];case 3:return[4,iK(t)];case 4:e.sent(),e.label=5;case 5:return[2]}})})}function Li(t,e){jn({type:e,payload:{error:t}})}var tO=function(t){var e=function(r,i){var o;if(!r){(o=t==null?void 0:t.onExit)===null||o===void 0||o.call(t,"Invalid link token!");return}Pe=t;var s=window.atob(r);if(s=sK(s,Pe==null?void 0:Pe.language),Wp=new URL(s).origin,window.removeEventListener("message",bb),i){var a=document.getElementById(i);a?(a.allow="clipboard-read *; clipboard-write *",a.src=s,yb=i):console.warn("Mesh SDK: No iframe found with id ".concat(i))}else yb=pm,kU(s);window.addEventListener("message",bb),eO=window.location.origin},n=function(){var r;gm(),window.removeEventListener("message",bb),(r=t.onExit)===null||r===void 0||r.call(t)};return{openLink:e,closeLink:n}};function sK(t,e){return e==="system"&&(e=typeof navigator!="undefined"&&navigator.language?encodeURIComponent(navigator.language):void 0),"".concat(t).concat(t.includes("?")?"&":"?","lng=").concat(e||"en")}const aK="data:image/svg+xml,%3csvg%20width='17'%20height='16'%20viewBox='0%200%2017%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_126_8587)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.3686%2010.6232C16.3715%2010.6146%2016.359%2010.6097%2016.355%2010.6179C14.975%2013.5085%2012.2144%2015.5112%208.66017%2015.5112C4.88611%2015.5112%201.35008%2012.688%201.35008%208.37011C1.35008%204.65011%204.30812%201.56104%207.74213%201.56104C10.6321%201.56104%2012.6382%203.28819%2012.6382%204.51714C12.6382%205.08189%2012.2642%205.48041%2011.6862%205.48041C10.3602%205.48041%209.85022%203.15536%207.33413%203.15536C4.78406%203.15536%202.6081%205.54683%202.6081%208.37011C2.6081%2012.0238%205.56614%2014.4153%208.52417%2014.4153C9.68043%2014.4153%2010.322%2014.1182%2010.5073%2014.0169C10.515%2014.0126%2010.51%2014.0012%2010.5017%2014.0037C10.3174%2014.0604%209.73839%2014.2159%208.93211%2014.2159C5.29405%2014.2159%203.83206%2011.4591%203.83206%209.66544C3.83206%208.30367%204.71606%207.73906%205.43016%207.73906C7.33413%207.73906%207.06219%2011.7248%2011.7542%2011.7248C14.2023%2011.7248%2016.4803%2010.0972%2016.4803%206.87544C16.4803%203.22178%2012.9442%200%208.66017%200C4.17214%200%200.5%203.554%200.5%207.97156C0.5%2012.4223%204.30812%2015.9763%208.66017%2015.9763C12.4804%2015.9763%2015.3429%2013.5242%2016.3686%2010.6232Z'%20fill='%231E171F'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_126_8587'%3e%3crect%20width='16'%20height='16'%20fill='white'%20transform='translate(0.5)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";We("h2",{base:{fontWeight:"600",fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.4px",color:"fg"}});const vb=({icon:t,title:e,description:n})=>k.jsxs(ye,{display:"flex",flexDirection:"row",gap:"16px",width:"100%",alignItems:"flex-start",children:[k.jsx(Lt,{as:t,color:"fg.muted",width:"20px",height:"20px",marginTop:"2px"}),k.jsxs(ye,{display:"flex",flexDirection:"column",gap:"4px",flex:"1",children:[k.jsx(ye,{fontWeight:"600",fontSize:"14px",lineHeight:"120%",color:"fg",children:e}),k.jsx(ye,{fontWeight:"400",fontSize:"12px",lineHeight:"140%",color:"fg.subtle",children:n})]})]}),lK=({onConfirm:t})=>k.jsxs(gr,{children:[k.jsx(ye,{display:"flex",justifyContent:"center",width:"100%",children:k.jsx(ye,{height:"48px",width:"48px",backgroundColor:"gray.200",borderRadius:"90%"})}),k.jsx(ye,{fontWeight:"600",fontSize:"16px",lineHeight:"140%",color:"fg",textAlign:"center",children:"Enso Checkout uses a 3rd party to connect your Binance account."}),k.jsxs(ye,{display:"flex",flexDirection:"column",gap:"12px",width:"100%",children:[k.jsx(vb,{icon:F_,title:"Your sign-in credentials are never stored",description:"All data is encrypted between enso and Binance"}),k.jsx(vb,{icon:V_,title:"2fa always required",description:"Transfers cannot be made without your approval."}),k.jsx(vb,{icon:__,title:"Assets never touch 3rd parties",description:"Your funds are transferred directly to your wallet."}),k.jsxs(rV,{children:[k.jsx(pr,{src:aK,color:"gray",w:"24px"}),"Enso securely encrypts all user data."]})]}),k.jsx(Fn,{onClick:t,children:"Continue to 3rd Party"})]}),cK="0x0000000071727de22e5e9d8baf0edac6f37da032",Gp="https://mesh-bff.enso-checkout.workers.dev",nO=[0,1,2,3,4],wb="9226e5c2-ebc3-4fdd-94f6-ed52cdce1420",rO={1:"e3c7fdd8-b1fc-4e51-85ae-bb276e075611",8453:"aa883b03-120d-477c-a588-37c2afd3ca71",42161:"a34f2431-0ddd-4de4-bc22-4a8143287aeb",137:"7436e9d0-ba42-4d2b-b4c0-8e4e606b2c12",10:"18fa36b0-88a8-43ca-83db-9a874e0a2288",43114:"bad16371-c22a-4bf4-a311-274d046cd760",56:"ed0ebeec-b166-4c8b-8574-cb078f7af8cf",146:"385f0b3a-8471-4b8f-884f-c4f4496f1603"},uK=t=>rO[t]||rO[8453],dK=({setStep:t})=>{const{chainIdOut:e,setMeshAccessToken:n,setSessionId:r}=Qe(),{address:i}=Xe.useAccount(),o=iO(),[s,a]=J.useState(!1);J.useEffect(()=>{const c=localStorage.getItem(o);if(c)try{const u=JSON.parse(c);if(u!=null&&u.accessToken&&(u!=null&&u.sessionId)){n(u.accessToken),r(u.sessionId),t(1);return}}catch(u){console.error("Failed to parse saved Mesh connection",u)}a(!0)},[e,i,o]);const l=()=>{fetch(`${Gp}/linktoken`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:i,integrationId:wb,address:i})}).then(c=>c.json()).then(c=>{r(c.content.sessionId);const u=tO({clientId:i,onIntegrationConnected:d=>{console.log("onIntegrationConnected",d),n(d.accessToken),t(1);try{localStorage.setItem(o,JSON.stringify({accessToken:d.accessToken,sessionId:c.content.sessionId,timestamp:Date.now()})),u.closeLink()}catch(h){console.error("Failed to persist Mesh connection",h)}},onExit:d=>{debugger},onTransferFinished:d=>{debugger},onEvent:d=>{console.log(d)}});u.openLink(c.content.linkToken)}).catch(c=>console.error(c))};return s?k.jsx(lK,{onConfirm:l}):k.jsx(oh,{m:5})},iO=()=>J.useMemo(()=>{const t="meshDeviceId";let e=localStorage.getItem(t);return e||(e=`device_${Date.now()}_${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(t,e)),e},[]),fK=({setStep:t,onTokenSelect:e})=>{const[n,r]=J.useState([]),[i,o]=J.useState([]),[s,a]=J.useState([]),[l,c]=J.useState(null),[u,d]=J.useState(!0),[h,g]=J.useState(null),{address:b}=Xe.useAccount(),{chainIdOut:p,meshAccessToken:w,sessionId:S,setMeshAccessToken:O,setSessionId:T,setTokenIn:$,chainIdIn:R}=Qe(),j=iO();J.useEffect(()=>{w&&S&&p&&(async()=>{var L,V;try{const z=await(await fetch(`${Gp}/holdings`,{method:"POST",headers:{"Content-Type":"application/json","x-session-id":S},body:JSON.stringify({authToken:w.accountTokens[0].accessToken,brokerType:"binanceInternationalDirect"})})).json();if(console.log("Holdings data:",z),z.status==="ok"&&((L=z.content)!=null&&L.cryptocurrencyPositions))r(z.content.cryptocurrencyPositions);else throw z.errorType==="invalidIntegrationToken"&&(console.log("Invalid integration token"),t(0),O(null),T(null),localStorage.removeItem(j)),new Error(z.message||"Failed to fetch holdings");const f=await(await fetch(`${Gp}/tokens?chainId=${R}`)).json();if(console.log("Tokens data:",f),f.status==="success"&&((V=f.content)!=null&&V.tokens)){o(f.content.tokens);const y=f.content.tokens.map(E=>{const I=z.content.cryptocurrencyPositions.find(N=>N.symbol===E.symbol);return I?{...E,balance:I.amount,marketValue:I.marketValue,holding:I}:null}).filter(E=>E!==null&&E.marketValue>5).sort((E,I)=>I.marketValue-E.marketValue);console.log("Matched tokens with balances:",y),a(y)}else throw new Error(f.message||"Failed to fetch supported tokens")}catch(W){debugger;console.error("Error fetching data:",W),g(W instanceof Error?W.message:"Failed to fetch data")}finally{d(!1)}})()},[b,p,w,S]);const q=Bz(s.map(G=>G.symbol),R);return console.log("geckoTokens",q),u?k.jsx(sh,{children:k.jsx(oh,{m:5})}):h?k.jsxs(ye,{p:5,color:"red.500",children:["Error: ",h]}):k.jsxs(gr,{children:[k.jsxs(ye,{mb:4,width:"100%",textAlign:"left",children:[k.jsx(qo,{children:"Your Holdings"}),k.jsxs(em,{children:["Found ",s.length," tokens with balances"]})]}),k.jsx(ye,{overflowY:"scroll",maxH:"400px",children:k.jsx(gh,{children:s.map((G,L)=>{var V,W;return k.jsx(jE,{chainId:p||1,icon:(W=(V=q==null?void 0:q[L])==null?void 0:V.logoURI)==null?void 0:W.replace("/thumb/","/large/"),title:G.name,balance:`${fo(G.balance)} ${G.symbol}`,usdBalance:ra(G.marketValue||0),tag:"",loading:!1,selected:l===G.symbol,onClick:()=>{var z;c(G.symbol),e(G),$((z=q==null?void 0:q[L])==null?void 0:z.address)}},`${G.symbol}-${L}`)})})}),s.length===0&&k.jsx(ye,{textAlign:"center",color:"fg.subtle",py:8,children:"No tokens with balances found for this chain"}),k.jsx(Fn,{disabled:!l,onClick:()=>{t(2)},children:"Continue"})]})},hK=({setStep:t,selectedToken:e})=>{const[n,r]=J.useState(""),[i,o]=J.useState("usd"),[s,a]=J.useState(""),{setAmountIn:l}=Qe(),{tokenInData:c,tokenIn:u}=Jr();J.useEffect(()=>{e&&(r(e.balance.toString()),a(e.marketValue.toFixed(2)))},[e]),J.useEffect(()=>{console.log("tokenIn",u),c!=null&&c.decimals&&l((Number(n)*10**(c==null?void 0:c.decimals)).toFixed())},[n,c==null?void 0:c.decimals]);const d=L=>{if(!e)return;const V=e.balance*L/100,W=e.marketValue*L/100;r(V.toString()),a(W.toFixed(2))},h=L=>{if(e)if(i==="usd"){const V=L.replace("$","");a(V);const W=e.marketValue/e.balance,z=parseFloat(V)/W;r(z.toString())}else{r(L);const V=e.marketValue/e.balance,W=parseFloat(L)*V;a(W.toFixed(2))}},g=()=>{o(i==="usd"?"token":"usd")},b=()=>i==="usd"?{placeholder:"$10.00",displayValue:s?`$${s}`:"",equivalentValue:n?`${fo(parseFloat(n))} ${e==null?void 0:e.symbol}`:"—"}:{placeholder:"0.00",displayValue:n,equivalentValue:s?`$${s}`:"—"},{placeholder:p,displayValue:w,equivalentValue:S}=b(),O=e?parseFloat(n)>e.balance:!0,T=parseFloat(s),$=e?dV[e.symbol]:0,R=e?e.marketValue-5:0,j=e&&T>0&&$&&T<$,q=e&&T>0&&T>R,G=j||q||O;return e?k.jsxs(gr,{children:[k.jsxs(ye,{mb:4,width:"100%",textAlign:"left",children:[k.jsx(qo,{children:"Enter Amount"}),k.jsxs(em,{children:["Available: ",fo(e.balance)," ",e.symbol," ($",ra(e.marketValue),")"]})]}),k.jsxs(ye,{display:"flex",flexDirection:"column",gap:"8px",width:"100%",children:[k.jsxs(ye,{display:"flex",flexDirection:"column",gap:"8px",alignItems:"center",padding:"25.5px",children:[k.jsx(ph,{inputMode:"decimal",marginY:"8px",variant:"text",placeholder:p,value:w,onChange:L=>h(L.target.value)}),k.jsxs(ye,{display:"flex",gap:"3",alignItems:"center",onClick:g,_hover:{background:"bg.subtle"},cursor:"pointer",borderRadius:"lg",px:"3",children:[k.jsx(er,{minWidth:"24px",minHeight:"24px",maxWidth:"24px",background:"transparent",children:k.jsx(Lt,{as:D2,color:"gray",width:"16px",height:"16px"})}),k.jsx(Ge,{fontSize:"sm",color:"fg.muted",children:S})]})]}),k.jsx(ye,{display:"flex",gap:"4px",justifyContent:"center",paddingBottom:"35px",children:[25,50,75,100].map(L=>k.jsx(J2,{onClick:()=>d(L),children:L===100?"Max":`${L}%`},L))})]}),k.jsx(hh,{disabled:!G&&!!n,content:n?j?`Minimum amount is $${$} USD`:q?`Maximum amount is $${R.toFixed(2)} USD (balance - $10)`:O?"Amount exceeds available balance":"":"Please enter an amount",showArrow:!0,children:k.jsx(Fn,{onClick:()=>G||!n?void 0:t(3),disabled:G||!n,children:"Continue"})})]}):k.jsx(gr,{children:k.jsx(ye,{textAlign:"center",color:"fg.subtle",py:8,children:"No token selected"})})},pK=({setStep:t,setUserOp:e})=>{const{chainIdIn:n}=Jr(),{isLoading:r,usdAmountIn:i,routerData:o}=Ml(),{signMessageAsync:s}=Xe.useSignMessage(),{address:a}=Xe.useAccount(),[l,c]=J.useState(!1),u=async()=>{if(!o||o!=null&&o.error){console.error("No valid router data available");return}try{c(!0);const d=o==null?void 0:o.userOp;if(!d){console.error("No userOperation found in routerData");return}console.log("Signing userOperation:",d);const h=wU({userOperation:d,entryPointAddress:cK,entryPointVersion:"0.7",chainId:n});console.log("Signing userOpHash:",h);const g=await s({account:a,message:{raw:h}}),b={...d,signature:g};console.log("signedUserOp",JSON.stringify(b)),e(b),t(4)}catch(d){console.error("Failed to sign userOperation:",d)}finally{c(!1)}};return k.jsxs(gr,{children:[k.jsxs(ro,{flexDirection:"column",gap:"16px",alignItems:"center",width:"100%",children:[k.jsx(io,{loading:r,width:r?"156px":"auto",children:k.jsx(ph,{readOnly:!0,marginY:"8px",variant:"text",placeholder:"$10.00",value:i})}),k.jsx(Oh,{})]}),k.jsx(Ih,{}),k.jsx(Fn,{disabled:!!(o!=null&&o.message)||r||l,loading:r||l,onClick:u,children:r?"Loading quote":l?"Signing...":"Sign Transaction"})]})},gK=({selectedToken:t,userOp:e,setStep:n})=>{const{meshAccessToken:r,amountIn:i,chainIdOut:o}=Qe(),{address:s}=Xe.useAccount(),{tokenInData:a}=Jr(),[l,c]=J.useState(!0);return J.useEffect(()=>{if(!t||!e||!r){console.error("Missing required data for withdrawal initiation");return}const u=a!=null&&a.decimals?Number(i)/10**a.decimals:0;(async()=>{try{const h=[{networkId:uK(o),symbol:t.symbol,address:e.sender,amount:u}];console.log("link request body",{restrictMultipleAccounts:!0,userId:s,integrationId:wb,transferOptions:{toAddresses:h}});const p=await(await fetch(`${Gp}/linktoken`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({restrictMultipleAccounts:!0,userId:s,integrationId:wb,transferOptions:{toAddresses:h}})})).json();console.log("Link token response:",p);const w=r.accountTokens.map(O=>({...O,accountId:O.account.accountId,accountName:O.account.accountName,brokerName:"Binance",brokerType:"binanceInternationalDirect"}));console.log("accessTokens",w);const S=tO({clientId:s,accessTokens:w,onIntegrationConnected:O=>{console.log("Integration connected",O)},onTransferFinished:O=>{console.log("Transfer finished:",O),c(!1)},onExit:O=>{console.log("Mesh link exited:",O),c(!1),n(1)},onEvent:O=>{console.log("Mesh event:",O),O.type==="transferExecuted"&&(console.log("Transfer executed, closing mesh link and moving to TrackUserOp step"),S.closeLink(),n(5))}});S.openLink(p.content.linkToken)}catch(h){console.error("Failed to fetch link token:",h),c(!1)}})()},[t,e]),k.jsx(gr,{children:k.jsx(sh,{children:k.jsx(Ge,{mt:4,children:l?k.jsxs(ro,{alignItems:"center",gap:2,children:[k.jsx(oh,{m:5}),k.jsx(Ge,{children:"Intiating Mesh"})]}):"Transfer completed"})})})},mK=({selectedToken:t,userOp:e,setStep:n})=>{const{chainIdIn:r,tokenInData:i}=Jr(),{amountIn:o}=Qe(),[s,a]=J.useState(null),[l,c]=J.useState("sending"),[u,d]=J.useState("Sending operation to tracker..."),[h,g]=J.useState(!1),[b,p]=J.useState(null);J.useEffect(()=>{(async()=>{if(!t||!e||!i){console.error("Missing required data for tracking"),c("failed"),d("Missing required data");return}try{const q=await(await fetch("https://alpha-scanners-dev-054573dc8549.herokuapp.com/operations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userOperationData:{sender:e.sender,nonce:e.nonce,factory:e.factory,factoryData:e.factoryData,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymaster:e.paymaster,paymasterData:e.paymasterData,paymasterVerificationGasLimit:e.paymasterVerificationGasLimit,paymasterPostOpGasLimit:e.paymasterPostOpGasLimit,signature:e.signature},chainId:r,expectedBalance:o,tokenAddress:i.address})})).json();if(console.log("Operation tracking response:",q),q.success&&q.operationId)a(q.operationId),c("tracking"),d("Tracking operation progress...");else throw new Error(q.message||"Failed to send operation to tracker")}catch(j){console.error("Failed to send operation to tracker:",j),c("failed"),d("Failed to send operation to tracker")}})()},[]),J.useEffect(()=>{if(!s||l!=="tracking")return;const j=setInterval(async()=>{var q,G;try{const V=await(await fetch(`https://alpha-scanners-dev-054573dc8549.herokuapp.com/operations/${s}/status`)).json();console.log("Operation status:",V),((q=V.operation)==null?void 0:q.status)==="completed"?(c("completed"),d("Operation completed successfully!"),b&&(clearInterval(b),p(null))):((G=V.operation)==null?void 0:G.status)==="failed"&&(c("failed"),d("Operation failed"),b&&(clearInterval(b),p(null)))}catch(L){console.error("Failed to fetch operation status:",L)}},3e3);return p(j),()=>{j&&clearInterval(j)}},[s]);const w=()=>{g(!0)},S=()=>{switch(l){case"completed":return"#14AE5C";case"failed":return"#E84142";default:return"#1E171F"}},O=()=>{switch(l){case"sending":case"tracking":return k.jsx(tS,{start:l==="tracking",onFinish:w,duration:120});case"completed":return k.jsx(ye,{display:"flex",flexDirection:"column",alignItems:"center",children:k.jsx(pr,{src:nS,boxShadow:"0px 0px 20px #14AE5C",borderRadius:"90%",width:"58px",height:"58px"})});case"failed":return k.jsx(ye,{display:"flex",flexDirection:"column",alignItems:"center",children:k.jsx(pr,{src:rS,boxShadow:"0px 0px 20px #E84142",borderRadius:"90%",width:"58px",height:"58px"})})}},T=()=>l==="tracking"&&h?k.jsxs(ye,{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",textAlign:"center",children:[k.jsx(Ge,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"8px",children:u}),k.jsx(Ge,{fontSize:"sm",color:"fg.muted",maxWidth:"280px",children:"Your operation is being processed – no action is required from you."})]}):null,$=()=>{switch(l){case"completed":return"Success";case"failed":return"Failed";case"tracking":return"Processing";case"sending":return"Sending";default:return"Unknown"}};return k.jsxs(gr,{children:[k.jsxs(ye,{display:"flex",flexDirection:"column",paddingBottom:"16px",alignItems:"center",width:"100%",children:[O(),T()]}),k.jsx(lh,{size:"sm",variant:"outline",width:"100%",children:k.jsxs(ch,{children:[k.jsxs(so,{children:[k.jsx(ln,{children:"Status"}),k.jsx(ln,{display:"flex",textAlign:"end",justifyContent:"end",children:k.jsx(Ge,{color:S(),children:$()})})]}),s&&k.jsxs(so,{children:[k.jsx(ln,{children:"Operation ID"}),k.jsx(ln,{display:"flex",textAlign:"end",justifyContent:"end",children:k.jsx(Ge,{fontSize:"sm",color:"fg.muted",children:s})})]})]})},"status"),k.jsx(Oh,{}),k.jsx(Ih,{}),(l==="completed"||l==="failed")&&k.jsx(Fn,{onClick:()=>n(0),visual:"solid",children:l==="completed"?"New Deposit":"Retry Deposit"})]})},yK=()=>{const{handleClose:t,setFlow:e,setStep:n}=J.useContext(Ba),[r,i]=J.useState(0),[o,s]=J.useState(null),[a,l]=J.useState(null),{chainIdOut:c}=Qe(),u=Qe(S=>S.setIsCheckout),d=Qe(S=>S.setChainIdIn),h=Xe.useChainId(),{switchChain:g}=Xe.useSwitchChain(),b=h!==c,p=S=>{s(S),console.log("Selected token:",S)};J.useEffect(()=>{d(c),u(!0)},[c]);const w=(()=>{switch(r){case 0:return k.jsx(dK,{setStep:i});case 1:return k.jsx(fK,{setStep:i,onTokenSelect:p});case 2:return k.jsx(hK,{setStep:i,selectedToken:o});case 3:return k.jsx(pK,{setStep:i,setUserOp:l});case 4:return k.jsx(gK,{selectedToken:o,userOp:a,setStep:i});case 5:return k.jsx(mK,{selectedToken:o,userOp:a,setStep:i});default:return null}})();return k.jsxs(k.Fragment,{children:[k.jsx(_n.Header,{children:k.jsxs(Du,{children:[k.jsx(er,{minWidth:"16px",minHeight:"16px",maxWidth:"16px",onClick:()=>{const S=nO.findIndex(O=>O===r)-1;S>0?i(nO[S]):(e(""),n(""))},children:k.jsx(Lt,{as:Vu,color:"gray",width:"16px",height:"16px"})}),k.jsx(ye,{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"100%",children:k.jsx(qo,{children:"Deposit from Binance"})}),t&&k.jsx(er,{onClick:t,minWidth:"16px",minHeight:"16px",maxWidth:"16px",marginLeft:"auto",children:k.jsx(Lt,{as:ta,color:"gray",width:"16px",height:"16px"})})]})}),k.jsx(_n.Body,{children:b?k.jsx(gr,{children:k.jsxs(ye,{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",textAlign:"center",children:[k.jsx(Ge,{fontSize:"16px",fontWeight:"600",children:"Wrong Network"}),k.jsxs(Ge,{fontSize:"14px",color:"fg.muted",children:["Please switch to ",kh(c)," to continue with your Binance withdrawal."]}),k.jsxs(Fn,{onClick:()=>{g({chainId:c})},children:["Switch to ",kh(c)]})]})}):w})]})},bK={mainFlow:{steps:{selectToken:k.jsx(Wz,{}),selectAmount:k.jsx(Xz,{}),quote:k.jsx(nU,{}),confirmTransfer:k.jsx(yU,{})}},exchangeFlow:{steps:{connectExchange:k.jsx(yK,{})}}},Ba=J.createContext({}),oO=({config:{apiKey:t,tokenOut:e,chainIdOut:n,theme:r,enableExchange:i},onClose:o,wrapper:s})=>{const[a,l]=J.useState(""),[c,u]=J.useState(""),d=Qe(w=>w.setEnsoApiToken),h=Qe(w=>w.setTokenOut),g=Qe(w=>w.setChainIdOut),b=J.useMemo(()=>o?()=>{o&&o(),l(""),u("")}:void 0,[o]);J.useEffect(()=>{h(e),g(n)},[e,n]),J.useEffect(()=>{d(t)},[t]);const p=J.useMemo(()=>s!=null?s:({children:w,...S})=>k.jsx(ye,{p:4,w:"374px",...S,children:w}),[s]);return k.jsx(Ba.Provider,{value:{step:a,setStep:l,flow:c,setFlow:u,handleClose:b,enableExchanges:i},children:k.jsx(eV,{themeConfig:r,children:k.jsxs(p,{children:[k.jsx(gU,{}),!c&&!a?k.jsx(Hz,{}):bK[c].steps[a]]})})})},vK=({config:t,setIsActive:e,isActive:n,onClose:r})=>{const i=J.useCallback(()=>{e(!1),r==null||r()},[e,r]);return n?k.jsx(oO,{wrapper:_n,config:t,onClose:i}):null};_e.Checkout=oO,_e.CheckoutModal=vK,Object.defineProperty(_e,Symbol.toStringTag,{value:"Module"})});
|
|
202
|
+
Missing signature for public key${o.missing.length===1?"":"(s)"} [\`${o.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(s)}}return this._serialize(i)}_serialize(e){const{signatures:n}=this,r=[];vr(r,n.length);const i=r.length+n.length*64+e.length,o=Fe.Buffer.alloc(i);return Nt(n.length<256),Fe.Buffer.from(r).copy(o,0),n.forEach(({signature:s},a)=>{s!==null&&(Nt(s.length===64,"signature has invalid length"),Fe.Buffer.from(s).copy(o,r.length+a*64))}),e.copy(o,r.length+n.length*64),Nt(o.length<=ac,`Transaction too large: ${o.length} > ${ac}`),o}get keys(){return Nt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return Nt(this.instructions.length===1),this.instructions[0].programId}get data(){return Nt(this.instructions.length===1),this.instructions[0].data}static from(e){let n=[...e];const r=br(n);let i=[];for(let o=0;o<r;o++){const s=wr(n,0,Rp);i.push(Hn.encode(Fe.Buffer.from(s)))}return Fp.populate(Ta.from(n),i)}static populate(e,n=[]){const r=new Fp;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((i,o)=>{const s={signature:i==Hn.encode(hj)?null:Hn.decode(i),publicKey:e.accountKeys[o]};r.signatures.push(s)}),e.instructions.forEach(i=>{const o=i.accounts.map(s=>{const a=e.accountKeys[s];return{pubkey:a,isSigner:r.signatures.some(l=>l.publicKey.toString()===a.toString())||e.isAccountSigner(s),isWritable:e.isAccountWritable(s)}});r.instructions.push(new Bn({keys:o,programId:e.accountKeys[i.programIdIndex],data:Hn.decode(i.data)}))}),r._message=e,r._json=r.toJSON(),r}}class _p{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,n){const{header:r,compiledInstructions:i,recentBlockhash:o}=e,{numRequiredSignatures:s,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:l}=r,c=s-a;Nt(c>0,"Message header is invalid");const u=e.staticAccountKeys.length-s-l;Nt(u>=0,"Message header is invalid");const d=e.getAccountKeys(n),h=d.get(0);if(h===void 0)throw new Error("Failed to decompile message because no account keys were found");const g=[];for(const b of i){const p=[];for(const S of b.accountKeyIndexes){const O=d.get(S);if(O===void 0)throw new Error(`Failed to find key for account key index ${S}`);const T=S<s;let $;T?$=S<c:S<d.staticAccountKeys.length?$=S-s<u:$=S-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,p.push({pubkey:O,isSigner:S<r.numRequiredSignatures,isWritable:$})}const w=d.get(b.programIdIndex);if(w===void 0)throw new Error(`Failed to find program id for program id index ${b.programIdIndex}`);g.push(new Bn({programId:w,data:Gn(b.data),keys:p}))}return new _p({payerKey:h,instructions:g,recentBlockhash:o})}compileToLegacyMessage(){return Ta.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Td.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class Vp{get version(){return this.message.version}constructor(e,n){if(this.signatures=void 0,this.message=void 0,n!==void 0)Nt(n.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=n;else{const r=[];for(let i=0;i<e.header.numRequiredSignatures;i++)r.push(new Uint8Array(Rp));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),n=Array();vr(n,this.signatures.length);const r=X.struct([X.blob(n.length,"encodedSignaturesLength"),X.seq(lj(),this.signatures.length,"signatures"),X.blob(e.length,"serializedMessage")]),i=new Uint8Array(2048),o=r.encode({encodedSignaturesLength:new Uint8Array(n),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,o)}static deserialize(e){let n=[...e];const r=[],i=br(n);for(let s=0;s<i;s++)r.push(new Uint8Array(wr(n,0,Rp)));const o=PI.deserialize(new Uint8Array(n));return new Vp(o,r)}sign(e){const n=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of e){const o=r.findIndex(s=>s.equals(i.publicKey));Nt(o>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[o]=kI(n,i.secretKey)}}addSignature(e,n){Nt(n.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(o=>o.equals(e));Nt(i>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=n}}new ke("SysvarC1ock11111111111111111111111111111111"),new ke("SysvarEpochSchedu1e111111111111111111111111"),new ke("Sysvar1nstructions1111111111111111111111111");const sb=new ke("SysvarRecentB1ockHashes11111111111111111111"),NI=new ke("SysvarRent111111111111111111111111111111111");new ke("SysvarRewards111111111111111111111111111111"),new ke("SysvarS1otHashes111111111111111111111111111"),new ke("SysvarS1otHistory11111111111111111111111111"),new ke("SysvarStakeHistory1111111111111111111111111");function Fr(t,e){const n=t.layout.span>=0?t.layout.span:OI(t,e),r=Fe.Buffer.alloc(n),i=Object.assign({instruction:t.index},e);return t.layout.encode(i,r),r}const pj=X.nu64("lamportsPerSignature"),BI=X.struct([X.u32("version"),X.u32("state"),je("authorizedPubkey"),je("nonce"),X.struct([pj],"feeCalculator")]).span;function gj(t,e){const n=Fe.Buffer.alloc(e);let r=t;for(let i=0;i<e;i++)n[i]=Number(r&BigInt(255)),r>>=BigInt(8);return n}function mj(t){return t.reduceRight((e,n)=>(e<<BigInt(8))+BigInt(n),BigInt(0))}const yj=t=>{const e=t.decode.bind(t),n=t.encode.bind(t);return{decode:e,encode:n}},cc=(t=>e=>{const n=X.blob(t,e),{encode:r,decode:i}=yj(n),o=n;return o.decode=(s,a)=>{const l=i(s,a);return mj(Fe.Buffer.from(l))},o.encode=(s,a,l)=>{const c=gj(s,t);return r(c,a,l)},o})(8),_r=Object.freeze({Create:{index:0,layout:X.struct([X.u32("instruction"),X.ns64("lamports"),X.ns64("space"),je("programId")])},Assign:{index:1,layout:X.struct([X.u32("instruction"),je("programId")])},Transfer:{index:2,layout:X.struct([X.u32("instruction"),cc("lamports")])},CreateWithSeed:{index:3,layout:X.struct([X.u32("instruction"),je("base"),lc("seed"),X.ns64("lamports"),X.ns64("space"),je("programId")])},AdvanceNonceAccount:{index:4,layout:X.struct([X.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:X.struct([X.u32("instruction"),X.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:X.struct([X.u32("instruction"),je("authorized")])},AuthorizeNonceAccount:{index:7,layout:X.struct([X.u32("instruction"),je("authorized")])},Allocate:{index:8,layout:X.struct([X.u32("instruction"),X.ns64("space")])},AllocateWithSeed:{index:9,layout:X.struct([X.u32("instruction"),je("base"),lc("seed"),X.ns64("space"),je("programId")])},AssignWithSeed:{index:10,layout:X.struct([X.u32("instruction"),je("base"),lc("seed"),je("programId")])},TransferWithSeed:{index:11,layout:X.struct([X.u32("instruction"),cc("lamports"),lc("seed"),je("programId")])},UpgradeNonceAccount:{index:12,layout:X.struct([X.u32("instruction")])}});class uc{constructor(){}static createAccount(e){const n=_r.Create,r=Fr(n,{lamports:e.lamports,space:e.space,programId:Gn(e.programId.toBuffer())});return new Bn({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(e){let n,r;if("basePubkey"in e){const i=_r.TransferWithSeed;n=Fr(i,{lamports:BigInt(e.lamports),seed:e.seed,programId:Gn(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=_r.Transfer;n=Fr(i,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Bn({keys:r,programId:this.programId,data:n})}static assign(e){let n,r;if("basePubkey"in e){const i=_r.AssignWithSeed;n=Fr(i,{base:Gn(e.basePubkey.toBuffer()),seed:e.seed,programId:Gn(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=_r.Assign;n=Fr(i,{programId:Gn(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Bn({keys:r,programId:this.programId,data:n})}static createAccountWithSeed(e){const n=_r.CreateWithSeed,r=Fr(n,{base:Gn(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:Gn(e.programId.toBuffer())});let i=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||i.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Bn({keys:i,programId:this.programId,data:r})}static createNonceAccount(e){const n=new Fp;"basePubkey"in e&&"seed"in e?n.add(uc.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:BI,programId:this.programId})):n.add(uc.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:BI,programId:this.programId}));const r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){const n=_r.InitializeNonceAccount,r=Fr(n,{authorized:Gn(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:sb,isSigner:!1,isWritable:!1},{pubkey:NI,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Bn(i)}static nonceAdvance(e){const n=_r.AdvanceNonceAccount,r=Fr(n),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:sb,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Bn(i)}static nonceWithdraw(e){const n=_r.WithdrawNonceAccount,r=Fr(n,{lamports:e.lamports});return new Bn({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:sb,isSigner:!1,isWritable:!1},{pubkey:NI,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(e){const n=_r.AuthorizeNonceAccount,r=Fr(n,{authorized:Gn(e.newAuthorizedPubkey.toBuffer())});return new Bn({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(e){let n,r;if("basePubkey"in e){const i=_r.AllocateWithSeed;n=Fr(i,{base:Gn(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:Gn(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=_r.Allocate;n=Fr(i,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Bn({keys:r,programId:this.programId,data:n})}}uc.programId=new ke("11111111111111111111111111111111"),new ke("BPFLoader2111111111111111111111111111111111"),X.struct([X.u32("typeIndex"),cc("deactivationSlot"),X.nu64("lastExtendedSlot"),X.u8("lastExtendedStartIndex"),X.u8(),X.seq(je(),X.offset(X.u8(),-1),"authority")]);const kt=Od(Gy(ke),ge(),t=>new ke(t)),RI=jy([ge(),wt("base64")]),ab=Od(Gy(Fe.Buffer),RI,t=>Fe.Buffer.from(t[0],"base64"));function MI(t){return Wn([he({jsonrpc:wt("2.0"),id:ge(),result:t}),he({jsonrpc:wt("2.0"),id:ge(),error:he({code:ic(),message:ge(),data:Ce(xG())})})])}const bj=MI(ic());function gt(t){return Od(MI(t),bj,e=>"error"in e?e:{...e,result:Cd(e.result,t)})}function si(t){return gt(he({context:he({slot:le()}),value:t}))}function Dp(t){return he({context:he({slot:le()}),value:t})}const vj=he({foundation:le(),foundationTerm:le(),initial:le(),taper:le(),terminal:le()});gt(we(xe(he({epoch:le(),effectiveSlot:le(),amount:le(),postBalance:le(),commission:Ce(xe(le()))}))));const wj=we(he({slot:le(),prioritizationFee:le()})),xj=he({total:le(),validator:le(),foundation:le(),epoch:le()}),Ej=he({epoch:le(),slotIndex:le(),slotsInEpoch:le(),absoluteSlot:le(),blockHeight:Ce(le()),transactionCount:Ce(le())}),Sj=he({slotsPerEpoch:le(),leaderScheduleSlotOffset:le(),warmup:Mi(),firstNormalEpoch:le(),firstNormalSlot:le()}),Aj=cI(ge(),we(le())),Pa=xe(Wn([he({}),ge()])),kj=he({err:Pa}),Cj=wt("receivedSignature");he({"solana-core":ge(),"feature-set":Ce(le())});const Ij=he({program:ge(),programId:kt,parsed:ic()}),Oj=he({programId:kt,accounts:we(kt),data:ge()});si(he({err:xe(Wn([he({}),ge()])),logs:xe(we(ge())),accounts:Ce(xe(we(xe(he({executable:Mi(),owner:ge(),lamports:le(),data:we(ge()),rentEpoch:Ce(le())}))))),unitsConsumed:Ce(le()),returnData:Ce(xe(he({programId:ge(),data:jy([ge(),wt("base64")])}))),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(Wn([Ij,Oj]))}))))})),si(he({byIdentity:cI(ge(),we(le())),range:he({firstSlot:le(),lastSlot:le()})})),gt(vj),gt(xj),gt(wj),gt(Ej),gt(Sj),gt(Aj),gt(le()),si(he({total:le(),circulating:le(),nonCirculating:le(),nonCirculatingAccounts:we(kt)}));const Tj=he({amount:ge(),uiAmount:xe(le()),decimals:le(),uiAmountString:Ce(ge())});si(we(he({address:kt,amount:ge(),uiAmount:xe(le()),decimals:le(),uiAmountString:Ce(ge())}))),si(we(he({pubkey:kt,account:he({executable:Mi(),owner:kt,lamports:le(),data:ab,rentEpoch:le()})})));const lb=he({program:ge(),parsed:ic(),space:le()});si(we(he({pubkey:kt,account:he({executable:Mi(),owner:kt,lamports:le(),data:lb,rentEpoch:le()})}))),si(we(he({lamports:le(),address:kt})));const cb=he({executable:Mi(),owner:kt,lamports:le(),data:ab,rentEpoch:le()});he({pubkey:kt,account:cb});const Pj=Od(Wn([Gy(Fe.Buffer),lb]),Wn([RI,lb]),t=>Array.isArray(t)?Cd(t,ab):t),Nj=he({executable:Mi(),owner:kt,lamports:le(),data:Pj,rentEpoch:le()});he({pubkey:kt,account:Nj}),he({state:Wn([wt("active"),wt("inactive"),wt("activating"),wt("deactivating")]),active:le(),inactive:le()}),gt(we(he({signature:ge(),slot:le(),err:Pa,memo:xe(ge()),blockTime:Ce(xe(le()))}))),gt(we(he({signature:ge(),slot:le(),err:Pa,memo:xe(ge()),blockTime:Ce(xe(le()))}))),he({subscription:le(),result:Dp(cb)});const Bj=he({pubkey:kt,account:cb});he({subscription:le(),result:Dp(Bj)});const Rj=he({parent:le(),slot:le(),root:le()});he({subscription:le(),result:Rj});const Mj=Wn([he({type:Wn([wt("firstShredReceived"),wt("completed"),wt("optimisticConfirmation"),wt("root")]),slot:le(),timestamp:le()}),he({type:wt("createdBank"),parent:le(),slot:le(),timestamp:le()}),he({type:wt("frozen"),slot:le(),timestamp:le(),stats:he({numTransactionEntries:le(),numSuccessfulTransactions:le(),numFailedTransactions:le(),maxTransactionsPerEntry:le()})}),he({type:wt("dead"),slot:le(),timestamp:le(),err:ge()})]);he({subscription:le(),result:Mj}),he({subscription:le(),result:Dp(Wn([kj,Cj]))}),he({subscription:le(),result:le()}),he({pubkey:ge(),gossip:xe(ge()),tpu:xe(ge()),rpc:xe(ge()),version:xe(ge())});const LI=he({votePubkey:ge(),nodePubkey:ge(),activatedStake:le(),epochVoteAccount:Mi(),epochCredits:we(jy([le(),le(),le()])),commission:le(),lastVote:le(),rootSlot:xe(le())});gt(he({current:we(LI),delinquent:we(LI)}));const Lj=Wn([wt("processed"),wt("confirmed"),wt("finalized")]),Fj=he({slot:le(),confirmations:xe(le()),err:Pa,confirmationStatus:Ce(Lj)});si(we(xe(Fj))),gt(le());const FI=he({accountKey:kt,writableIndexes:we(le()),readonlyIndexes:we(le())}),ub=he({signatures:we(ge()),message:he({accountKeys:we(ge()),header:he({numRequiredSignatures:le(),numReadonlySignedAccounts:le(),numReadonlyUnsignedAccounts:le()}),instructions:we(he({accounts:we(le()),data:ge(),programIdIndex:le()})),recentBlockhash:ge(),addressTableLookups:Ce(we(FI))})}),_I=he({pubkey:kt,signer:Mi(),writable:Mi(),source:Ce(Wn([wt("transaction"),wt("lookupTable")]))}),VI=he({accountKeys:we(_I),signatures:we(ge())}),DI=he({parsed:ic(),program:ge(),programId:kt}),zI=he({accounts:we(kt),data:ge(),programId:kt}),_j=Wn([zI,DI]),Vj=Wn([he({parsed:ic(),program:ge(),programId:ge()}),he({accounts:we(ge()),data:ge(),programId:ge()})]),UI=Od(_j,Vj,t=>"accounts"in t?Cd(t,zI):Cd(t,DI)),$I=he({signatures:we(ge()),message:he({accountKeys:we(_I),instructions:we(UI),recentBlockhash:ge(),addressTableLookups:Ce(xe(we(FI)))})}),zp=he({accountIndex:le(),mint:ge(),owner:Ce(ge()),programId:Ce(ge()),uiTokenAmount:Tj}),HI=he({writable:we(kt),readonly:we(kt)}),Up=he({err:Pa,fee:le(),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(he({accounts:we(le()),data:ge(),programIdIndex:le()}))})))),preBalances:we(le()),postBalances:we(le()),logMessages:Ce(xe(we(ge()))),preTokenBalances:Ce(xe(we(zp))),postTokenBalances:Ce(xe(we(zp))),loadedAddresses:Ce(HI),computeUnitsConsumed:Ce(le())}),db=he({err:Pa,fee:le(),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(UI)})))),preBalances:we(le()),postBalances:we(le()),logMessages:Ce(xe(we(ge()))),preTokenBalances:Ce(xe(we(zp))),postTokenBalances:Ce(xe(we(zp))),loadedAddresses:Ce(HI),computeUnitsConsumed:Ce(le())}),dc=Wn([wt(0),wt("legacy")]),Na=he({pubkey:ge(),lamports:le(),postBalance:xe(le()),rewardType:xe(ge()),commission:Ce(xe(le()))});gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:ub,meta:xe(Up),version:Ce(dc)})),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:VI,meta:xe(Up),version:Ce(dc)})),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:$I,meta:xe(db),version:Ce(dc)})),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:VI,meta:xe(db),version:Ce(dc)})),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),rewards:Ce(we(Na)),blockTime:xe(le()),blockHeight:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),transactions:we(he({transaction:ub,meta:xe(Up)})),rewards:Ce(we(Na)),blockTime:xe(le())}))),gt(xe(he({blockhash:ge(),previousBlockhash:ge(),parentSlot:le(),signatures:we(ge()),blockTime:xe(le())}))),gt(xe(he({slot:le(),meta:xe(Up),blockTime:Ce(xe(le())),transaction:ub,version:Ce(dc)}))),gt(xe(he({slot:le(),transaction:$I,meta:xe(db),blockTime:Ce(xe(le())),version:Ce(dc)}))),si(he({blockhash:ge(),lastValidBlockHeight:le()})),si(Mi());const Dj=he({slot:le(),numTransactions:le(),numSlots:le(),samplePeriodSecs:le()});gt(we(Dj)),si(xe(he({feeCalculator:he({lamportsPerSignature:le()})}))),gt(ge()),gt(ge());const zj=he({err:Pa,logs:we(ge()),signature:ge()});he({result:Dp(zj),subscription:le()}),Object.freeze({CreateLookupTable:{index:0,layout:X.struct([X.u32("instruction"),cc("recentSlot"),X.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:X.struct([X.u32("instruction")])},ExtendLookupTable:{index:2,layout:X.struct([X.u32("instruction"),cc(),X.seq(je(),X.offset(X.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:X.struct([X.u32("instruction")])},CloseLookupTable:{index:4,layout:X.struct([X.u32("instruction")])}}),new ke("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:X.struct([X.u8("instruction"),X.u32("units"),X.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:X.struct([X.u8("instruction"),X.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:X.struct([X.u8("instruction"),X.u32("units")])},SetComputeUnitPrice:{index:3,layout:X.struct([X.u8("instruction"),cc("microLamports")])}}),new ke("ComputeBudget111111111111111111111111111111"),X.struct([X.u8("numSignatures"),X.u8("padding"),X.u16("signatureOffset"),X.u16("signatureInstructionIndex"),X.u16("publicKeyOffset"),X.u16("publicKeyInstructionIndex"),X.u16("messageDataOffset"),X.u16("messageDataSize"),X.u16("messageInstructionIndex")]),new ke("Ed25519SigVerify111111111111111111111111111"),rj.utils.isValidPrivateKey,X.struct([X.u8("numSignatures"),X.u16("signatureOffset"),X.u8("signatureInstructionIndex"),X.u16("ethAddressOffset"),X.u8("ethAddressInstructionIndex"),X.u16("messageDataOffset"),X.u16("messageDataSize"),X.u8("messageInstructionIndex"),X.blob(20,"ethAddress"),X.blob(64,"signature"),X.u8("recoveryId")]),new ke("KeccakSecp256k11111111111111111111111111111");var WI;new ke("StakeConfig11111111111111111111111111111111");class GI{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}WI=GI,GI.default=new WI(0,0,ke.default),Object.freeze({Initialize:{index:0,layout:X.struct([X.u32("instruction"),cj(),uj()])},Authorize:{index:1,layout:X.struct([X.u32("instruction"),je("newAuthorized"),X.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:X.struct([X.u32("instruction")])},Split:{index:3,layout:X.struct([X.u32("instruction"),X.ns64("lamports")])},Withdraw:{index:4,layout:X.struct([X.u32("instruction"),X.ns64("lamports")])},Deactivate:{index:5,layout:X.struct([X.u32("instruction")])},Merge:{index:7,layout:X.struct([X.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:X.struct([X.u32("instruction"),je("newAuthorized"),X.u32("stakeAuthorizationType"),lc("authoritySeed"),je("authorityOwner")])}}),new ke("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:X.struct([X.u32("instruction"),dj()])},Authorize:{index:1,layout:X.struct([X.u32("instruction"),je("newAuthorized"),X.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:X.struct([X.u32("instruction"),X.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:X.struct([X.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:X.struct([X.u32("instruction"),fj()])}}),new ke("Vote111111111111111111111111111111111111111"),new ke("Va1idator1nfo111111111111111111111111111111"),he({name:ge(),website:Ce(ge()),details:Ce(ge()),iconUrl:Ce(ge()),keybaseUsername:Ce(ge())}),new ke("Vote111111111111111111111111111111111111111"),X.struct([je("nodePubkey"),je("authorizedWithdrawer"),X.u8("commission"),X.nu64(),X.seq(X.struct([X.nu64("slot"),X.u32("confirmationCount")]),X.offset(X.u32(),-8),"votes"),X.u8("rootSlotValid"),X.nu64("rootSlot"),X.nu64(),X.seq(X.struct([X.nu64("epoch"),je("authorizedVoter")]),X.offset(X.u32(),-8),"authorizedVoters"),X.struct([X.seq(X.struct([je("authorizedPubkey"),X.nu64("epochOfLastAuthorizedSwitch"),X.nu64("targetEpoch")]),32,"buf"),X.nu64("idx"),X.u8("isEmpty")],"priorVoters"),X.nu64(),X.seq(X.struct([X.nu64("epoch"),X.nu64("credits"),X.nu64("prevCredits")]),X.offset(X.u32(),-8),"epochCredits"),X.struct([X.nu64("slot"),X.nu64("timestamp")],"lastTimestamp")]);var ys=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},bs=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},$p=new ke("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),jI=new ke("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),KI=new ke("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),Hp=function(t){if(!t||typeof t!="object")return!1;var e=t,n=(e.message||"").toLowerCase();return n.includes("user rejected")||n.includes("declined")||n.includes("cancelled")||n.includes("denied")||e.code===4001};function qI(t,e){return ys(this,arguments,void 0,function(n,r,i){var o;return i===void 0&&(i=$p.toBase58()),bs(this,function(s){switch(s.label){case 0:return[4,ke.findProgramAddress([r.toBuffer(),new ke(i).toBuffer(),n.toBuffer()],KI)];case 1:return o=s.sent()[0],[2,o]}})})}function Uj(t,e,n,r,i){i===void 0&&(i=$p);var o=[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:uc.programId,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1}];return new Bn({keys:o,programId:KI,data:Buffer.alloc(0)})}function $j(t,e,n,r,i,o){i===void 0&&(i=9);var s=Buffer.alloc(10);s[0]=12,s.writeBigUInt64LE(r,1),s[9]=i;var a=jI;return new Bn({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:a,data:s})}function Hj(t){var e=t.fromTokenAccount,n=t.toTokenAccount,r=t.owner,i=t.amount,o=Buffer.alloc(9);return o[0]=3,o.writeBigUInt64LE(i,1),new Bn({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:$p,data:o})}function Wj(t){return ys(this,void 0,void 0,function(){var e,n,r;return bs(this,function(i){switch(i.label){case 0:return[4,YI(t)];case 1:return e=i.sent(),n=new ke(t.fromAddress),r=new _p({payerKey:n,recentBlockhash:t.blockhash,instructions:e}).compileToV0Message(),[2,new Vp(r)]}})})}function YI(t){return ys(this,void 0,void 0,function(){var e,n,r,i,o,s;return bs(this,function(a){switch(a.label){case 0:return e=new ke(t.fromAddress),n=new ke(t.toAddress),r=[],t.tokenMint?[3,1]:(r.push(uc.transfer({fromPubkey:e,toPubkey:n,lamports:Number(t.amount)})),[3,4]);case 1:return i=new ke(t.tokenMint),[4,qI(i,e,t.tokenProgram)];case 2:return o=a.sent(),[4,qI(i,n,t.tokenProgram)];case 3:s=a.sent(),t.createATA&&r.push(Uj(e,s,n,i,t.tokenProgram?new ke(t.tokenProgram):$p)),t.tokenProgram===jI.toBase58()?r.push($j(o,s,e,BigInt(t.amount),t.tokenDecimals,i)):r.push(Hj({fromTokenAccount:o,toTokenAccount:s,owner:e,amount:BigInt(t.amount)})),a.label=4;case 4:return[2,r]}})})}function fc(t,e){return ys(this,void 0,void 0,function(){var r,n,r,i,o;return bs(this,function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),e.signAndSendTransaction?[4,e.signAndSendTransaction(t)]:[3,2];case 1:return r=s.sent().signature,[2,r];case 2:return[4,e.signTransaction(t)];case 3:if(n=s.sent(),!e.sendTransaction)throw new Error("Provider does not support sendTransaction");return[4,e.sendTransaction(n)];case 4:return r=s.sent(),[2,r];case 5:return[3,7];case 6:throw i=s.sent(),console.error("Error in handleManualSignAndSend:",i),i instanceof Error&&(!((o=i.message)===null||o===void 0)&&o.includes("User rejected"))?new Error("Transaction was rejected by user"):i;case 7:return[2]}})})}function Gj(t){return ys(this,void 0,void 0,function(){var e,n,r;return bs(this,function(i){for(e=[],n=function(o){var s=t[o],a=new ke(s.programId),l=s.accounts.map(function(c,u){if(!c.pubKey)throw new Error("Account at instruction ".concat(o,", index ").concat(u," has no pubKey and is not fillable"));var d=new ke(c.pubKey);return{pubkey:d,isSigner:c.isSigner,isWritable:c.isWritable}});e.push(new Bn({keys:l,programId:a,data:Buffer.from(s.data,"base64")}))},r=0;r<t.length;r++)n(r);return[2,e]})})}var QI=function(t){return ys(void 0,void 0,void 0,function(){var e,n,r,i,o,s;return bs(this,function(a){switch(a.label){case 0:return a.trys.push([0,8,,9]),e=Ea(t.walletName),[4,Wj(t)];case 1:return n=a.sent(),r=e.isTrust||e.isTrustWallet||t.walletName.toLowerCase().includes("trust"),r?[4,fc(n,e)]:[3,3];case 2:return[2,a.sent()];case 3:if(!e.signAndSendTransaction)return[3,7];a.label=4;case 4:return a.trys.push([4,6,,7]),[4,e.signAndSendTransaction(n)];case 5:return i=a.sent().signature,[2,i];case 6:if(o=a.sent(),Hp(o))throw new Error("Transaction was rejected by user");return[2,fc(n,e)];case 7:return[2,fc(n,e)];case 8:throw s=a.sent(),Hp(s)?new Error("Transaction was rejected by user"):s instanceof Error?s:new Error("Failed to send SOL transaction with ".concat(t.walletName," wallet"));case 9:return[2]}})})},jj=function(t,e){return ys(void 0,void 0,void 0,function(){var n,r,i,o,s,a;return bs(this,function(l){switch(l.label){case 0:n=t.transactionInstructions.walletName||"Phantom",l.label=1;case 1:return l.trys.push([1,5,,6]),[4,Gj(t.transactionInstructions.instructions)];case 2:return r=l.sent(),i=new ke(e.fromAddress),[4,YI(e)];case 3:return o=l.sent(),r.push.apply(r,o),s=new Vp(new _p({payerKey:i,recentBlockhash:t.transactionInstructions.blockhash,instructions:r}).compileToV0Message()),[4,Kj(n,s)];case 4:return[2,l.sent()];case 5:throw a=l.sent(),Hp(a)?new Error("Transaction was rejected by user"):a instanceof Error?a:new Error("Failed to send SOL transaction with ".concat(n," wallet"));case 6:return[2]}})})},Kj=function(t,e){return ys(void 0,void 0,void 0,function(){var n,r,i,o;return bs(this,function(s){switch(s.label){case 0:return n=Ea(t),r=n.isTrust||n.isTrustWallet||t.includes("trust"),r?[4,fc(e,n)]:[3,2];case 1:return[2,s.sent()];case 2:if(!n.signAndSendTransaction)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,n.signAndSendTransaction(e)];case 4:return i=s.sent().signature,[2,i];case 5:if(o=s.sent(),Hp(o))throw new Error("Transaction was rejected by user");return[2,fc(e,n)];case 6:return[2,fc(e,n)]}})})},fb,XI;function qj(){if(XI)return fb;XI=1;function t(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(n[s]!==255)throw new TypeError(o+" is ambiguous");n[s]=i}var a=e.length,l=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var p=0,w=0,S=0,O=b.length;S!==O&&b[S]===0;)S++,p++;for(var T=(O-S)*u+1>>>0,$=new Uint8Array(T);S!==O;){for(var R=b[S],j=0,q=T-1;(R!==0||j<w)&&q!==-1;q--,j++)R+=256*$[q]>>>0,$[q]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");w=j,S++}for(var G=T-w;G!==T&&$[G]===0;)G++;for(var L=l.repeat(p);G<T;++G)L+=e.charAt($[G]);return L}function h(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;for(var p=0,w=0,S=0;b[p]===l;)w++,p++;for(var O=(b.length-p)*c+1>>>0,T=new Uint8Array(O);b[p];){var $=b.charCodeAt(p);if($>255)return;var R=n[$];if(R===255)return;for(var j=0,q=O-1;(R!==0||j<S)&&q!==-1;q--,j++)R+=a*T[q]>>>0,T[q]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");S=j,p++}for(var G=O-S;G!==O&&T[G]===0;)G++;for(var L=new Uint8Array(w+(O-G)),V=w;G!==O;)L[V++]=T[G++];return L}function g(b){var p=h(b);if(p)return p;throw new Error("Non-base"+a+" character")}return{encode:d,decodeUnsafe:h,decode:g}}return fb=t,fb}var hb,JI;function Yj(){return JI||(JI=1,hb=qj()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),hb}var Qj=Yj();const Xj=sl(Qj);var Jj=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},Zj=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},eK=function(t,e){return Jj(void 0,void 0,void 0,function(){var n,r,i,o;return Zj(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),n=Ea(t),r=new TextEncoder().encode(e),[4,n.signMessage(r)];case 1:return i=s.sent(),[2,Xj.encode(i.signature)];case 2:return o=s.sent(),[2,o instanceof Error?o:new Error("Failed to sign message with ".concat(t," wallet"))];case 3:return[2]}})})},tK=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},t(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),vs=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},ws=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},nK=function(t){tK(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.connect=function(n){return vs(this,void 0,void 0,function(){var r,i;return ws(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,AW(n)];case 1:if(r=o.sent(),r instanceof Error)throw r;return[2,{accounts:r.accounts,chainId:r.chainId,isConnected:r.isConnected}];case 2:throw i=o.sent(),this.handleError(i,"connect to Solana wallet");case 3:return[2]}})})},e.prototype.disconnect=function(n){return vs(this,void 0,void 0,function(){var r,i;return ws(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,kW(n.walletName||"Unknown Wallet")];case 1:if(r=o.sent(),r instanceof Error)throw r;return[3,3];case 2:throw i=o.sent(),this.handleError(i,"disconnect from Solana wallet");case 3:return[2]}})})},e.prototype.signMessage=function(n){return vs(this,void 0,void 0,function(){var r,i;return ws(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,eK(n.walletName||"Unknown Wallet",n.message)];case 1:if(r=o.sent(),r instanceof Error)throw r;return[2,r];case 2:throw i=o.sent(),this.handleError(i,"sign Solana message");case 3:return[2]}})})},e.prototype.switchChain=function(n){return vs(this,void 0,void 0,function(){return ws(this,function(r){return[2,{chainId:"101",accounts:[]}]})})},e.prototype.sendNativeTransfer=function(n){return vs(this,void 0,void 0,function(){var r,i;return ws(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,QI({toAddress:n.toAddress,amount:BigInt(n.amount*Math.pow(10,n.decimalPlaces)),fromAddress:n.account,blockhash:n.blockhash||"",walletName:n.walletName||""})];case 1:if(r=o.sent(),typeof r=="string")return[2,r];throw r;case 2:throw i=o.sent(),this.handleError(i,"send Solana native transfer");case 3:return[2]}})})},e.prototype.sendSmartContractInteraction=function(n){return vs(this,void 0,void 0,function(){var r,i,o,s,a,l,c;return ws(this,function(u){switch(u.label){case 0:return r=Ea(n.walletName||""),o=n.account,o?[3,2]:[4,(c=r.publicKey)===null||c===void 0?void 0:c.toString()];case 1:o=u.sent(),u.label=2;case 2:if(i=o,!i)throw new Error("Sender account address is required");if(s=n.args[2]||9,a=n.args[1],l=a,!n.blockhash)throw new Error("Blockhash is required for Solana transactions");return[4,QI({toAddress:n.args[0],amount:l,fromAddress:i,blockhash:n.blockhash,walletName:n.walletName||"",tokenMint:n.address,createATA:n.createATA||!1,tokenProgram:n.tokenProgram,tokenDecimals:s})];case 3:return[2,u.sent()]}})})},e.prototype.sendTransactionWithInstructions=function(n){return vs(this,void 0,void 0,function(){var r,i,o,s,a,l,c,u,d;return ws(this,function(h){switch(h.label){case 0:return r=Ea(n.transactionInstructions.walletName||""),o=n.transferConfig.account,o?[3,2]:[4,(d=r.publicKey)===null||d===void 0?void 0:d.toString()];case 1:o=h.sent(),h.label=2;case 2:if(i=o,!i)throw new Error("Sender account address is required");if(s=n.transferConfig.args[2]||6,a=n.transferConfig.args[1],l=a,!n.transactionInstructions.blockhash)throw new Error("Blockhash is required for Solana transactions");h.label=3;case 3:return h.trys.push([3,5,,6]),[4,jj(n,{toAddress:n.transferConfig.args[0],amount:l,fromAddress:i,blockhash:n.transactionInstructions.blockhash,walletName:n.transactionInstructions.walletName||"",tokenMint:n.transferConfig.address,createATA:n.transferConfig.createATA||!1,tokenProgram:n.transferConfig.tokenProgram,tokenDecimals:s})];case 4:if(c=h.sent(),typeof c=="string")return[2,c];throw c;case 5:throw u=h.sent(),this.handleError(u,"send Solana native transfer");case 6:return[2]}})})},e.prototype.sendNativeSmartContractInteraction=function(){throw new Error("Method not implemented.")},e.prototype.sendTransactionBatch=function(){throw new Error("Method not implemented.")},e.prototype.getWalletCapabilities=function(){return vs(this,void 0,void 0,function(){return ws(this,function(n){return[2,{atomic:{status:"ready"}}]})})},e.prototype.getProviders=function(){var n=bC();return Object.keys(n).map(function(r){return{id:r,type:"solana"}})},e}(sS),ZI=function(){function t(){this.strategies=new Map,this.strategies.set("evm",new xW),this.strategies.set("solana",new nK)}return t.getInstance=function(){return t.instance||(t.instance=new t),t.instance},t.prototype.getStrategy=function(e){var n=this.strategies.get(e);if(!n)throw new Error("No strategy found for network type: ".concat(e));return n},t.prototype.getAllProviders=function(){var e=[];return this.strategies.forEach(function(n){e.push.apply(e,n.getProviders())}),e},t}(),pb=function(){return pb=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},pb.apply(this,arguments)},gb=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},mb=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Pe,eO,Wp,yb=pm,rK=function(){return document.getElementById(yb)};function jn(t){var e,n=rK();if(!n){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no iframe element found"));return}if(!Wp){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no link token origin found"));return}try{(e=n.contentWindow)===null||e===void 0||e.postMessage(t,Wp)}catch(r){console.error("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe")),console.error(r)}}function iK(t){return gb(this,void 0,void 0,function(){var e,e,e,e,n,r,i,o,s,a,l,c,u,d,h,g;return mb(this,function(b){switch(t.data.type){case"brokerageAccountAccessToken":{e={accessToken:t.data.payload},(i=Pe==null?void 0:Pe.onEvent)===null||i===void 0||i.call(Pe,{type:"integrationConnected",payload:e}),(o=Pe==null?void 0:Pe.onIntegrationConnected)===null||o===void 0||o.call(Pe,e);break}case"delayedAuthentication":{e={delayedAuth:t.data.payload},(s=Pe==null?void 0:Pe.onEvent)===null||s===void 0||s.call(Pe,{type:"integrationConnected",payload:e}),(a=Pe==null?void 0:Pe.onIntegrationConnected)===null||a===void 0||a.call(Pe,e);break}case"transferFinished":{e=t.data.payload,(l=Pe==null?void 0:Pe.onEvent)===null||l===void 0||l.call(Pe,{type:"transferCompleted",payload:e}),(c=Pe==null?void 0:Pe.onTransferFinished)===null||c===void 0||c.call(Pe,e);break}case"close":case"done":{e=(u=t.data)===null||u===void 0?void 0:u.payload,(d=Pe==null?void 0:Pe.onExit)===null||d===void 0||d.call(Pe,e==null?void 0:e.errorMessage,e),gm();break}case"loaded":{jn({type:"meshSDKSpecs",payload:pb({},TU)}),n=ZI.getInstance(),r=n.getAllProviders(),jn({type:"SDKinjectedWalletProviders",payload:r}),Pe!=null&&Pe.accessTokens&&jn({type:"frontAccessTokens",payload:Pe.accessTokens}),Pe!=null&&Pe.transferDestinationTokens&&jn({type:"frontTransferDestinationTokens",payload:Pe.transferDestinationTokens}),(h=Pe==null?void 0:Pe.onEvent)===null||h===void 0||h.call(Pe,{type:"pageLoaded"});break}default:{EU(t.data.type)&&((g=Pe==null?void 0:Pe.onEvent)===null||g===void 0||g.call(Pe,t.data));break}}return[2]})})}function oK(t){return gb(this,void 0,void 0,function(){var e,n,p,w,S,O,r,p,w,S,O,i,p,w,S,O,o,p,w,S,O,s,p,l,w,S,O,h,a,u,p,l,w,S,O,h,c,u,p,h,w,S,O,d,p,h,w,S,O,g,p,w,S,b,p,w,S,O,T,$;return mb(this,function(R){switch(R.label){case 0:switch(e=ZI.getInstance(),n=t.data.type,n){case"walletBrowserInjectedWalletSelected":return[3,1];case"walletBrowserSignRequest":return[3,6];case"walletBrowserChainSwitchRequest":return[3,11];case"walletBrowserNativeTransferRequest":return[3,16];case"walletBrowserNonNativeTransferRequest":return[3,21];case"walletBrowserNonNativeSmartDeposit":return[3,21];case"walletBrowserNativeSmartDeposit":return[3,26];case"walletBrowserTransactionBatchRequest":return[3,31];case"walletBrowserWalletCapabilities":return[3,36];case"walletBrowserDisconnect":return[3,41];case"walletBrowserSolanaTransferWithInstructionsRequest":return[3,49]}return[3,54];case 1:p=t.data.payload,R.label=2;case 2:return R.trys.push([2,4,,5]),w=!(($=p.networkType)===null||$===void 0)&&$.includes("solana")?"solana":"evm",S=e.getStrategy(w),[4,S.connect(p)];case 3:return O=R.sent(),jn({type:"SDKinjectedConnectionCompleted",payload:{accounts:O.accounts,chainId:O.chainId,networkType:w}}),[3,5];case 4:return r=R.sent(),console.error("Connection error:",r),Li(r,"SDKinjectedConnectionCompleted"),[3,5];case 5:return[3,54];case 6:p=t.data.payload,R.label=7;case 7:return R.trys.push([7,9,,10]),w=p.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.signMessage(p)];case 8:return O=R.sent(),jn({type:"SDKsignRequestCompleted",payload:O}),[3,10];case 9:return i=R.sent(),Li(i,"SDKsignRequestCompleted"),[3,10];case 10:return[3,54];case 11:p=t.data.payload,R.label=12;case 12:return R.trys.push([12,14,,15]),w=p.networkType==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.switchChain(p)];case 13:return O=R.sent(),jn({type:"SDKswitchChainCompleted",payload:{chainId:O.chainId,accounts:O.accounts,networkType:w}}),[3,15];case 14:return o=R.sent(),console.error("Chain switch failed:",o),Li(o,"SDKswitchChainCompleted"),[3,15];case 15:return[3,54];case 16:p=t.data.payload,R.label=17;case 17:return R.trys.push([17,19,,20]),w=p.network==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.sendNativeTransfer(p)];case 18:return O=R.sent(),jn({type:"SDKnativeTransferCompleted",payload:O}),[3,20];case 19:return s=R.sent(),Li(s,"SDKnativeTransferCompleted"),[3,20];case 20:return[3,54];case 21:p=t.data.payload,l=function(j){switch(j){case"walletBrowserNonNativeTransferRequest":return"SDKnonNativeTransferCompleted";case"walletBrowserNativeSmartDeposit":return"SDKnativeSmartDepositCompleted";case"walletBrowserNonNativeSmartDeposit":return"SDKnonNativeSmartDepositCompleted";default:return"SDKnonNativeTransferCompleted"}},R.label=22;case 22:return R.trys.push([22,24,,25]),w=p.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendSmartContractInteraction(p)];case 23:return O=R.sent(),h=l(t.data.type),jn({type:h,payload:{txHash:O}}),[3,25];case 24:return a=R.sent(),u=l(t.data.type),Li(a,u),[3,25];case 25:return[3,54];case 26:p=t.data.payload,l=function(j){switch(j){case"walletBrowserNonNativeTransferRequest":return"SDKnonNativeTransferCompleted";case"walletBrowserNativeSmartDeposit":return"SDKnativeSmartDepositCompleted";case"walletBrowserNonNativeSmartDeposit":return"SDKnonNativeSmartDepositCompleted";default:return"SDKnonNativeTransferCompleted"}},R.label=27;case 27:return R.trys.push([27,29,,30]),w=p.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendNativeSmartContractInteraction(p)];case 28:return O=R.sent(),h=l(t.data.type),jn({type:h,payload:{txHash:O}}),[3,30];case 29:return c=R.sent(),u=l(t.data.type),Li(c,u),[3,30];case 30:return[3,54];case 31:p=t.data.payload,h="SDKtransactionBatchCompleted",R.label=32;case 32:return R.trys.push([32,34,,35]),w=p.from.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendTransactionBatch(p)];case 33:return O=R.sent(),jn({type:h,payload:{txHash:O}}),[3,35];case 34:return d=R.sent(),Li(d,h),[3,35];case 35:return[3,54];case 36:p=t.data.payload,h="SDKwalletCapabilitiesCompleted",R.label=37;case 37:return R.trys.push([37,39,,40]),w=p.from.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.getWalletCapabilities(p)];case 38:return O=R.sent(),jn({type:h,payload:O}),[3,40];case 39:return g=R.sent(),Li(g,h),[3,40];case 40:return[3,54];case 41:p=t.data.payload,R.label=42;case 42:return R.trys.push([42,47,,48]),p!=null&&p.networkType?(w=p.networkType==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.disconnect(p)]):[3,44];case 43:return R.sent(),[3,46];case 44:return[4,Promise.all([e.getStrategy("solana").disconnect(p),e.getStrategy("evm").disconnect(p)])];case 45:R.sent(),R.label=46;case 46:return jn({type:"SDKdisconnectSuccess"}),[3,48];case 47:return b=R.sent(),console.error("Error during disconnect:",b),Li(b,"SDKdisconnectSuccess"),[3,48];case 48:return[3,54];case 49:p=t.data.payload,R.label=50;case 50:return R.trys.push([50,52,,53]),w="solana",S=e.getStrategy(w),[4,S.sendTransactionWithInstructions(p)];case 51:return O=R.sent(),jn({type:"SDKnonNativeTransferCompleted",payload:{txHash:O}}),[3,53];case 52:return T=R.sent(),Li(T,"SDKdisconnectSuccess"),[3,53];case 53:return[3,54];case 54:return[2]}})})}function bb(t){return gb(this,void 0,void 0,function(){return mb(this,function(e){switch(e.label){case 0:return t.origin!==eO&&t.origin!==Wp?(console.warn("Received message from untrusted origin:",t.origin),[3,5]):[3,1];case 1:return IU(t.data.type)?[4,oK(t)]:[3,3];case 2:return e.sent(),[3,5];case 3:return[4,iK(t)];case 4:e.sent(),e.label=5;case 5:return[2]}})})}function Li(t,e){jn({type:e,payload:{error:t}})}var tO=function(t){var e=function(r,i){var o;if(!r){(o=t==null?void 0:t.onExit)===null||o===void 0||o.call(t,"Invalid link token!");return}Pe=t;var s=window.atob(r);if(s=sK(s,Pe==null?void 0:Pe.language),Wp=new URL(s).origin,window.removeEventListener("message",bb),i){var a=document.getElementById(i);a?(a.allow="clipboard-read *; clipboard-write *",a.src=s,yb=i):console.warn("Mesh SDK: No iframe found with id ".concat(i))}else yb=pm,kU(s);window.addEventListener("message",bb),eO=window.location.origin},n=function(){var r;gm(),window.removeEventListener("message",bb),(r=t.onExit)===null||r===void 0||r.call(t)};return{openLink:e,closeLink:n}};function sK(t,e){return e==="system"&&(e=typeof navigator!="undefined"&&navigator.language?encodeURIComponent(navigator.language):void 0),"".concat(t).concat(t.includes("?")?"&":"?","lng=").concat(e||"en")}const aK="data:image/svg+xml,%3csvg%20width='17'%20height='16'%20viewBox='0%200%2017%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_126_8587)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.3686%2010.6232C16.3715%2010.6146%2016.359%2010.6097%2016.355%2010.6179C14.975%2013.5085%2012.2144%2015.5112%208.66017%2015.5112C4.88611%2015.5112%201.35008%2012.688%201.35008%208.37011C1.35008%204.65011%204.30812%201.56104%207.74213%201.56104C10.6321%201.56104%2012.6382%203.28819%2012.6382%204.51714C12.6382%205.08189%2012.2642%205.48041%2011.6862%205.48041C10.3602%205.48041%209.85022%203.15536%207.33413%203.15536C4.78406%203.15536%202.6081%205.54683%202.6081%208.37011C2.6081%2012.0238%205.56614%2014.4153%208.52417%2014.4153C9.68043%2014.4153%2010.322%2014.1182%2010.5073%2014.0169C10.515%2014.0126%2010.51%2014.0012%2010.5017%2014.0037C10.3174%2014.0604%209.73839%2014.2159%208.93211%2014.2159C5.29405%2014.2159%203.83206%2011.4591%203.83206%209.66544C3.83206%208.30367%204.71606%207.73906%205.43016%207.73906C7.33413%207.73906%207.06219%2011.7248%2011.7542%2011.7248C14.2023%2011.7248%2016.4803%2010.0972%2016.4803%206.87544C16.4803%203.22178%2012.9442%200%208.66017%200C4.17214%200%200.5%203.554%200.5%207.97156C0.5%2012.4223%204.30812%2015.9763%208.66017%2015.9763C12.4804%2015.9763%2015.3429%2013.5242%2016.3686%2010.6232Z'%20fill='%231E171F'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_126_8587'%3e%3crect%20width='16'%20height='16'%20fill='white'%20transform='translate(0.5)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";We("h2",{base:{fontWeight:"600",fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.4px",color:"fg"}});const vb=({icon:t,title:e,description:n})=>k.jsxs(ye,{display:"flex",flexDirection:"row",gap:"16px",width:"100%",alignItems:"flex-start",children:[k.jsx(Lt,{as:t,color:"fg.muted",width:"20px",height:"20px",marginTop:"2px"}),k.jsxs(ye,{display:"flex",flexDirection:"column",gap:"4px",flex:"1",children:[k.jsx(ye,{fontWeight:"600",fontSize:"14px",lineHeight:"120%",color:"fg",children:e}),k.jsx(ye,{fontWeight:"400",fontSize:"12px",lineHeight:"140%",color:"fg.subtle",children:n})]})]}),lK=({onConfirm:t})=>k.jsxs(gr,{children:[k.jsx(ye,{display:"flex",justifyContent:"center",width:"100%",children:k.jsx(ye,{height:"48px",width:"48px",backgroundColor:"gray.200",borderRadius:"90%"})}),k.jsx(ye,{fontWeight:"600",fontSize:"16px",lineHeight:"140%",color:"fg",textAlign:"center",children:"Enso Checkout uses a 3rd party to connect your Binance account."}),k.jsxs(ye,{display:"flex",flexDirection:"column",gap:"12px",width:"100%",children:[k.jsx(vb,{icon:F_,title:"Your sign-in credentials are never stored",description:"All data is encrypted between enso and Binance"}),k.jsx(vb,{icon:V_,title:"2fa always required",description:"Transfers cannot be made without your approval."}),k.jsx(vb,{icon:__,title:"Assets never touch 3rd parties",description:"Your funds are transferred directly to your wallet."}),k.jsxs(rV,{children:[k.jsx(pr,{src:aK,color:"gray",w:"24px"}),"Enso securely encrypts all user data."]})]}),k.jsx(Fn,{onClick:t,children:"Continue to 3rd Party"})]}),cK="0x0000000071727de22e5e9d8baf0edac6f37da032",Gp="https://mesh-bff.enso-checkout.workers.dev",nO=[0,1,2,3,4],wb="9226e5c2-ebc3-4fdd-94f6-ed52cdce1420",rO={1:"e3c7fdd8-b1fc-4e51-85ae-bb276e075611",8453:"aa883b03-120d-477c-a588-37c2afd3ca71",42161:"a34f2431-0ddd-4de4-bc22-4a8143287aeb",137:"7436e9d0-ba42-4d2b-b4c0-8e4e606b2c12",10:"18fa36b0-88a8-43ca-83db-9a874e0a2288",43114:"bad16371-c22a-4bf4-a311-274d046cd760",56:"ed0ebeec-b166-4c8b-8574-cb078f7af8cf",146:"385f0b3a-8471-4b8f-884f-c4f4496f1603"},uK=t=>rO[t]||rO[8453],dK=({setStep:t})=>{const{chainIdOut:e,setMeshAccessToken:n,setSessionId:r}=Qe(),{address:i}=Xe.useAccount(),o=iO(),[s,a]=J.useState(!1);J.useEffect(()=>{const c=localStorage.getItem(o);if(c)try{const u=JSON.parse(c);if(u!=null&&u.accessToken&&(u!=null&&u.sessionId)){n(u.accessToken),r(u.sessionId),t(1);return}}catch(u){console.error("Failed to parse saved Mesh connection",u)}a(!0)},[e,i,o]);const l=()=>{fetch(`${Gp}/linktoken`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:i,integrationId:wb,address:i})}).then(c=>c.json()).then(c=>{r(c.content.sessionId);const u=tO({clientId:i,onIntegrationConnected:d=>{console.log("onIntegrationConnected",d),n(d.accessToken),t(1);try{localStorage.setItem(o,JSON.stringify({accessToken:d.accessToken,sessionId:c.content.sessionId,timestamp:Date.now()})),u.closeLink()}catch(h){console.error("Failed to persist Mesh connection",h)}},onExit:d=>{debugger},onTransferFinished:d=>{debugger},onEvent:d=>{console.log(d)}});u.openLink(c.content.linkToken)}).catch(c=>console.error(c))};return s?k.jsx(lK,{onConfirm:l}):k.jsx(oh,{m:5})},iO=()=>J.useMemo(()=>{const t="meshDeviceId";let e=localStorage.getItem(t);return e||(e=`device_${Date.now()}_${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(t,e)),e},[]),fK=({setStep:t,onTokenSelect:e})=>{const[n,r]=J.useState([]),[i,o]=J.useState([]),[s,a]=J.useState([]),[l,c]=J.useState(null),[u,d]=J.useState(!0),[h,g]=J.useState(null),{address:b}=Xe.useAccount(),{chainIdOut:p,meshAccessToken:w,sessionId:S,setMeshAccessToken:O,setSessionId:T,setTokenIn:$,chainIdIn:R}=Qe(),j=iO();J.useEffect(()=>{w&&S&&p&&(async()=>{var L,V;try{const z=await(await fetch(`${Gp}/holdings`,{method:"POST",headers:{"Content-Type":"application/json","x-session-id":S},body:JSON.stringify({authToken:w.accountTokens[0].accessToken,brokerType:"binanceInternationalDirect"})})).json();if(console.log("Holdings data:",z),z.status==="ok"&&((L=z.content)!=null&&L.cryptocurrencyPositions))r(z.content.cryptocurrencyPositions);else throw z.errorType==="invalidIntegrationToken"&&(console.log("Invalid integration token"),t(0),O(null),T(null),localStorage.removeItem(j)),new Error(z.message||"Failed to fetch holdings");const f=await(await fetch(`${Gp}/tokens?chainId=${R}`)).json();if(console.log("Tokens data:",f),f.status==="success"&&((V=f.content)!=null&&V.tokens)){o(f.content.tokens);const y=f.content.tokens.map(E=>{const I=z.content.cryptocurrencyPositions.find(N=>N.symbol===E.symbol);return I?{...E,balance:I.amount,marketValue:I.marketValue,holding:I}:null}).filter(E=>E!==null&&E.marketValue>5).sort((E,I)=>I.marketValue-E.marketValue);console.log("Matched tokens with balances:",y),a(y)}else throw new Error(f.message||"Failed to fetch supported tokens")}catch(W){debugger;console.error("Error fetching data:",W),g(W instanceof Error?W.message:"Failed to fetch data")}finally{d(!1)}})()},[b,p,w,S]);const q=Bz(s.map(G=>G.symbol),R);return console.log("geckoTokens",q),u?k.jsx(sh,{children:k.jsx(oh,{m:5})}):h?k.jsxs(ye,{p:5,color:"red.500",children:["Error: ",h]}):k.jsxs(gr,{children:[k.jsxs(ye,{mb:4,width:"100%",textAlign:"left",children:[k.jsx(qo,{children:"Your Holdings"}),k.jsxs(em,{children:["Found ",s.length," tokens with balances"]})]}),k.jsx(ye,{overflowY:"scroll",maxH:"400px",children:k.jsx(gh,{children:s.map((G,L)=>{var V,W;return k.jsx(jE,{chainId:p||1,icon:(W=(V=q==null?void 0:q[L])==null?void 0:V.logoURI)==null?void 0:W.replace("/thumb/","/large/"),title:G.name,balance:`${fo(G.balance)} ${G.symbol}`,usdBalance:ra(G.marketValue||0),tag:"",loading:!1,selected:l===G.symbol,onClick:()=>{var z;c(G.symbol),e(G),$((z=q==null?void 0:q[L])==null?void 0:z.address)}},`${G.symbol}-${L}`)})})}),s.length===0&&k.jsx(ye,{textAlign:"center",color:"fg.subtle",py:8,children:"No tokens with balances found for this chain"}),k.jsx(Fn,{disabled:!l,onClick:()=>{t(2)},children:"Continue"})]})},hK=({setStep:t,selectedToken:e})=>{const[n,r]=J.useState(""),[i,o]=J.useState("usd"),[s,a]=J.useState(""),{setAmountIn:l}=Qe(),{tokenInData:c,tokenIn:u}=Jr();J.useEffect(()=>{e&&(r(e.balance.toString()),a(e.marketValue.toFixed(2)))},[e]),J.useEffect(()=>{console.log("tokenIn",u),c!=null&&c.decimals&&l((Number(n)*10**(c==null?void 0:c.decimals)).toFixed())},[n,c==null?void 0:c.decimals]);const d=L=>{if(!e)return;const V=e.balance*L/100,W=e.marketValue*L/100;r(V.toString()),a(W.toFixed(2))},h=L=>{if(e)if(i==="usd"){const V=L.replace("$","");a(V);const W=e.marketValue/e.balance,z=parseFloat(V)/W;r(z.toString())}else{r(L);const V=e.marketValue/e.balance,W=parseFloat(L)*V;a(W.toFixed(2))}},g=()=>{o(i==="usd"?"token":"usd")},b=()=>i==="usd"?{placeholder:"$10.00",displayValue:s?`$${s}`:"",equivalentValue:n?`${fo(parseFloat(n))} ${e==null?void 0:e.symbol}`:"—"}:{placeholder:"0.00",displayValue:n,equivalentValue:s?`$${s}`:"—"},{placeholder:p,displayValue:w,equivalentValue:S}=b(),O=e?parseFloat(n)>e.balance:!0,T=parseFloat(s),$=e?dV[e.symbol]:0,R=e?e.marketValue-5:0,j=e&&T>0&&$&&T<$,q=e&&T>0&&T>R,G=j||q||O;return e?k.jsxs(gr,{children:[k.jsxs(ye,{mb:4,width:"100%",textAlign:"left",children:[k.jsx(qo,{children:"Enter Amount"}),k.jsxs(em,{children:["Available: ",fo(e.balance)," ",e.symbol," ($",ra(e.marketValue),")"]})]}),k.jsxs(ye,{display:"flex",flexDirection:"column",gap:"8px",width:"100%",children:[k.jsxs(ye,{display:"flex",flexDirection:"column",gap:"8px",alignItems:"center",padding:"25.5px",children:[k.jsx(ph,{inputMode:"decimal",marginY:"8px",variant:"text",placeholder:p,value:w,onChange:L=>h(L.target.value)}),k.jsxs(ye,{display:"flex",gap:"3",alignItems:"center",onClick:g,_hover:{background:"bg.subtle"},cursor:"pointer",borderRadius:"lg",px:"3",children:[k.jsx(er,{minWidth:"24px",minHeight:"24px",maxWidth:"24px",background:"transparent",children:k.jsx(Lt,{as:D2,color:"gray",width:"16px",height:"16px"})}),k.jsx(Ge,{fontSize:"sm",color:"fg.muted",children:S})]})]}),k.jsx(ye,{display:"flex",gap:"4px",justifyContent:"center",paddingBottom:"35px",children:[25,50,75,100].map(L=>k.jsx(J2,{onClick:()=>d(L),children:L===100?"Max":`${L}%`},L))})]}),k.jsx(hh,{disabled:!G&&!!n,content:n?j?`Minimum amount is $${$} USD`:q?`Maximum amount is $${R.toFixed(2)} USD (balance - $10)`:O?"Amount exceeds available balance":"":"Please enter an amount",showArrow:!0,children:k.jsx(Fn,{onClick:()=>G||!n?void 0:t(3),disabled:G||!n,children:"Continue"})})]}):k.jsx(gr,{children:k.jsx(ye,{textAlign:"center",color:"fg.subtle",py:8,children:"No token selected"})})},pK=({setStep:t,setUserOp:e})=>{const{chainIdIn:n}=Jr(),{routeLoading:r,usdAmountIn:i,routeData:o}=Ml(),{signMessageAsync:s}=Xe.useSignMessage(),{address:a}=Xe.useAccount(),[l,c]=J.useState(!1),u=async()=>{if(!o||o!=null&&o.error){console.error("No valid router data available");return}try{c(!0);const d=o==null?void 0:o.userOp;if(!d){console.error("No userOperation found in routeData");return}console.log("Signing userOperation:",d);const h=wU({userOperation:d,entryPointAddress:cK,entryPointVersion:"0.7",chainId:n});console.log("Signing userOpHash:",h);const g=await s({account:a,message:{raw:h}}),b={...d,signature:g};console.log("signedUserOp",JSON.stringify(b)),e(b),t(4)}catch(d){console.error("Failed to sign userOperation:",d)}finally{c(!1)}};return k.jsxs(gr,{children:[k.jsxs(ro,{flexDirection:"column",gap:"16px",alignItems:"center",width:"100%",children:[k.jsx(io,{loading:r,width:r?"156px":"auto",children:k.jsx(ph,{readOnly:!0,marginY:"8px",variant:"text",placeholder:"$10.00",value:i})}),k.jsx(Oh,{})]}),k.jsx(Ih,{}),k.jsx(Fn,{disabled:!!(o!=null&&o.message)||r||l,loading:r||l,onClick:u,children:r?"Loading quote":l?"Signing...":"Sign Transaction"})]})},gK=({selectedToken:t,userOp:e,setStep:n})=>{const{meshAccessToken:r,amountIn:i,chainIdOut:o}=Qe(),{address:s}=Xe.useAccount(),{tokenInData:a}=Jr(),[l,c]=J.useState(!0);return J.useEffect(()=>{if(!t||!e||!r){console.error("Missing required data for withdrawal initiation");return}const u=a!=null&&a.decimals?Number(i)/10**a.decimals:0;(async()=>{try{const h=[{networkId:uK(o),symbol:t.symbol,address:e.sender,amount:u}];console.log("link request body",{restrictMultipleAccounts:!0,userId:s,integrationId:wb,transferOptions:{toAddresses:h}});const p=await(await fetch(`${Gp}/linktoken`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({restrictMultipleAccounts:!0,userId:s,integrationId:wb,transferOptions:{toAddresses:h}})})).json();console.log("Link token response:",p);const w=r.accountTokens.map(O=>({...O,accountId:O.account.accountId,accountName:O.account.accountName,brokerName:"Binance",brokerType:"binanceInternationalDirect"}));console.log("accessTokens",w);const S=tO({clientId:s,accessTokens:w,onIntegrationConnected:O=>{console.log("Integration connected",O)},onTransferFinished:O=>{console.log("Transfer finished:",O),c(!1)},onExit:O=>{console.log("Mesh link exited:",O),c(!1),n(1)},onEvent:O=>{console.log("Mesh event:",O),O.type==="transferExecuted"&&(console.log("Transfer executed, closing mesh link and moving to TrackUserOp step"),S.closeLink(),n(5))}});S.openLink(p.content.linkToken)}catch(h){console.error("Failed to fetch link token:",h),c(!1)}})()},[t,e]),k.jsx(gr,{children:k.jsx(sh,{children:k.jsx(Ge,{mt:4,children:l?k.jsxs(ro,{alignItems:"center",gap:2,children:[k.jsx(oh,{m:5}),k.jsx(Ge,{children:"Intiating Mesh"})]}):"Transfer completed"})})})},mK=({selectedToken:t,userOp:e,setStep:n})=>{const{chainIdIn:r,tokenInData:i}=Jr(),{amountIn:o}=Qe(),[s,a]=J.useState(null),[l,c]=J.useState("sending"),[u,d]=J.useState("Sending operation to tracker..."),[h,g]=J.useState(!1),[b,p]=J.useState(null);J.useEffect(()=>{(async()=>{if(!t||!e||!i){console.error("Missing required data for tracking"),c("failed"),d("Missing required data");return}try{const q=await(await fetch("https://alpha-scanners-dev-054573dc8549.herokuapp.com/operations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userOperationData:{sender:e.sender,nonce:e.nonce,factory:e.factory,factoryData:e.factoryData,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymaster:e.paymaster,paymasterData:e.paymasterData,paymasterVerificationGasLimit:e.paymasterVerificationGasLimit,paymasterPostOpGasLimit:e.paymasterPostOpGasLimit,signature:e.signature},chainId:r,expectedBalance:o,tokenAddress:i.address})})).json();if(console.log("Operation tracking response:",q),q.success&&q.operationId)a(q.operationId),c("tracking"),d("Tracking operation progress...");else throw new Error(q.message||"Failed to send operation to tracker")}catch(j){console.error("Failed to send operation to tracker:",j),c("failed"),d("Failed to send operation to tracker")}})()},[]),J.useEffect(()=>{if(!s||l!=="tracking")return;const j=setInterval(async()=>{var q,G;try{const V=await(await fetch(`https://alpha-scanners-dev-054573dc8549.herokuapp.com/operations/${s}/status`)).json();console.log("Operation status:",V),((q=V.operation)==null?void 0:q.status)==="completed"?(c("completed"),d("Operation completed successfully!"),b&&(clearInterval(b),p(null))):((G=V.operation)==null?void 0:G.status)==="failed"&&(c("failed"),d("Operation failed"),b&&(clearInterval(b),p(null)))}catch(L){console.error("Failed to fetch operation status:",L)}},3e3);return p(j),()=>{j&&clearInterval(j)}},[s]);const w=()=>{g(!0)},S=()=>{switch(l){case"completed":return"#14AE5C";case"failed":return"#E84142";default:return"#1E171F"}},O=()=>{switch(l){case"sending":case"tracking":return k.jsx(tS,{start:l==="tracking",onFinish:w,duration:120});case"completed":return k.jsx(ye,{display:"flex",flexDirection:"column",alignItems:"center",children:k.jsx(pr,{src:nS,boxShadow:"0px 0px 20px #14AE5C",borderRadius:"90%",width:"58px",height:"58px"})});case"failed":return k.jsx(ye,{display:"flex",flexDirection:"column",alignItems:"center",children:k.jsx(pr,{src:rS,boxShadow:"0px 0px 20px #E84142",borderRadius:"90%",width:"58px",height:"58px"})})}},T=()=>l==="tracking"&&h?k.jsxs(ye,{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",textAlign:"center",children:[k.jsx(Ge,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"8px",children:u}),k.jsx(Ge,{fontSize:"sm",color:"fg.muted",maxWidth:"280px",children:"Your operation is being processed – no action is required from you."})]}):null,$=()=>{switch(l){case"completed":return"Success";case"failed":return"Failed";case"tracking":return"Processing";case"sending":return"Sending";default:return"Unknown"}};return k.jsxs(gr,{children:[k.jsxs(ye,{display:"flex",flexDirection:"column",paddingBottom:"16px",alignItems:"center",width:"100%",children:[O(),T()]}),k.jsx(lh,{size:"sm",variant:"outline",width:"100%",children:k.jsxs(ch,{children:[k.jsxs(so,{children:[k.jsx(ln,{children:"Status"}),k.jsx(ln,{display:"flex",textAlign:"end",justifyContent:"end",children:k.jsx(Ge,{color:S(),children:$()})})]}),s&&k.jsxs(so,{children:[k.jsx(ln,{children:"Operation ID"}),k.jsx(ln,{display:"flex",textAlign:"end",justifyContent:"end",children:k.jsx(Ge,{fontSize:"sm",color:"fg.muted",children:s})})]})]})},"status"),k.jsx(Oh,{}),k.jsx(Ih,{}),(l==="completed"||l==="failed")&&k.jsx(Fn,{onClick:()=>n(0),visual:"solid",children:l==="completed"?"New Deposit":"Retry Deposit"})]})},yK=()=>{const{handleClose:t,setFlow:e,setStep:n}=J.useContext(Ba),[r,i]=J.useState(0),[o,s]=J.useState(null),[a,l]=J.useState(null),{chainIdOut:c}=Qe(),u=Qe(S=>S.setIsCheckout),d=Qe(S=>S.setChainIdIn),h=Xe.useChainId(),{switchChain:g}=Xe.useSwitchChain(),b=h!==c,p=S=>{s(S),console.log("Selected token:",S)};J.useEffect(()=>{d(c),u(!0)},[c]);const w=(()=>{switch(r){case 0:return k.jsx(dK,{setStep:i});case 1:return k.jsx(fK,{setStep:i,onTokenSelect:p});case 2:return k.jsx(hK,{setStep:i,selectedToken:o});case 3:return k.jsx(pK,{setStep:i,setUserOp:l});case 4:return k.jsx(gK,{selectedToken:o,userOp:a,setStep:i});case 5:return k.jsx(mK,{selectedToken:o,userOp:a,setStep:i});default:return null}})();return k.jsxs(k.Fragment,{children:[k.jsx(_n.Header,{children:k.jsxs(Du,{children:[k.jsx(er,{minWidth:"16px",minHeight:"16px",maxWidth:"16px",onClick:()=>{const S=nO.findIndex(O=>O===r)-1;S>0?i(nO[S]):(e(""),n(""))},children:k.jsx(Lt,{as:Vu,color:"gray",width:"16px",height:"16px"})}),k.jsx(ye,{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"100%",children:k.jsx(qo,{children:"Deposit from Binance"})}),t&&k.jsx(er,{onClick:t,minWidth:"16px",minHeight:"16px",maxWidth:"16px",marginLeft:"auto",children:k.jsx(Lt,{as:ta,color:"gray",width:"16px",height:"16px"})})]})}),k.jsx(_n.Body,{children:b?k.jsx(gr,{children:k.jsxs(ye,{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",textAlign:"center",children:[k.jsx(Ge,{fontSize:"16px",fontWeight:"600",children:"Wrong Network"}),k.jsxs(Ge,{fontSize:"14px",color:"fg.muted",children:["Please switch to ",kh(c)," to continue with your Binance withdrawal."]}),k.jsxs(Fn,{onClick:()=>{g({chainId:c})},children:["Switch to ",kh(c)]})]})}):w})]})},bK={mainFlow:{steps:{selectToken:k.jsx(Wz,{}),selectAmount:k.jsx(Xz,{}),quote:k.jsx(nU,{}),confirmTransfer:k.jsx(yU,{})}},exchangeFlow:{steps:{connectExchange:k.jsx(yK,{})}}},Ba=J.createContext({}),oO=({config:{apiKey:t,tokenOut:e,chainIdOut:n,theme:r,enableExchange:i},onClose:o,wrapper:s})=>{const[a,l]=J.useState(""),[c,u]=J.useState(""),d=Qe(w=>w.setEnsoApiToken),h=Qe(w=>w.setTokenOut),g=Qe(w=>w.setChainIdOut),b=J.useMemo(()=>o?()=>{o&&o(),l(""),u("")}:void 0,[o]);J.useEffect(()=>{h(e),g(n)},[e,n]),J.useEffect(()=>{d(t)},[t]);const p=J.useMemo(()=>s!=null?s:({children:w,...S})=>k.jsx(ye,{p:4,w:"374px",...S,children:w}),[s]);return k.jsx(Ba.Provider,{value:{step:a,setStep:l,flow:c,setFlow:u,handleClose:b,enableExchanges:i},children:k.jsx(eV,{themeConfig:r,children:k.jsxs(p,{children:[k.jsx(gU,{}),!c&&!a?k.jsx(Hz,{}):bK[c].steps[a]]})})})},vK=({config:t,setIsActive:e,isActive:n,onClose:r})=>{const i=J.useCallback(()=>{e(!1),r==null||r()},[e,r]);return n?k.jsx(oO,{wrapper:_n,config:t,onClose:i}):null};_e.Checkout=oO,_e.CheckoutModal=vK,Object.defineProperty(_e,Symbol.toStringTag,{value:"Module"})});
|
|
203
203
|
//# sourceMappingURL=checkout-widget.umd.js.map
|