@ensofinance/checkout-widget 0.0.7 → 0.0.8

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 IC;function Ty(){return IC||(IC=1,function(t){const e=IW(),n=OW(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=P,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 g(_,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=O(_,x)|0;let H=s(A);const te=H.write(_,x);return te!==A&&(H=H.slice(0,te)),H}function p(_){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 g(x.buffer,x.byteOffset,x.byteLength)}return p(_)}function g(_,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):p(_);if(_.type==="Buffer"&&Array.isArray(_.data))return p(_.data)}function S(_){if(_>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return _|0}function P(_){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 O(_,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=O;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 B(this,x,A);case"base64":return k(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 W(_,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 F(_,x,A,H){return rt(st(x,_.length-A),_,A,H)}function V(_,x,A,H){return rt(dt(x),_,A,H)}function G(_,x,A,H){return rt(at(x),_,A,H)}function z(_,x,A,H){return rt(qi(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 W(this,x,A,H);case"utf8":case"utf-8":return F(this,x,A,H);case"ascii":case"latin1":case"binary":return V(this,x,A,H);case"base64":return G(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 k(_,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 B(_,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 T(_,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||T(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||T(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||T(x,1,this.length),this[x]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(x,A){return x=x>>>0,A||T(x,2,this.length),this[x]|this[x+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(x,A){return x=x>>>0,A||T(x,2,this.length),this[x]<<8|this[x+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(x,A){return x=x>>>0,A||T(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||T(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,ye(x,"offset");const A=this[x],H=this[x+7];(A===void 0||H===void 0)&&Se(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,ye(x,"offset");const A=this[x],H=this[x+7];(A===void 0||H===void 0)&&Se(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||T(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||T(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||T(x,1,this.length),this[x]&128?(255-this[x]+1)*-1:this[x]},a.prototype.readInt16LE=function(x,A){x=x>>>0,A||T(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||T(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||T(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||T(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,ye(x,"offset");const A=this[x],H=this[x+7];(A===void 0||H===void 0)&&Se(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,ye(x,"offset");const A=this[x],H=this[x+7];(A===void 0||H===void 0)&&Se(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||T(x,4,this.length),n.read(this,x,!0,23,4)},a.prototype.readFloatBE=function(x,A){return x=x>>>0,A||T(x,4,this.length),n.read(this,x,!1,23,4)},a.prototype.readDoubleLE=function(x,A){return x=x>>>0,A||T(x,8,this.length),n.read(this,x,!0,52,8)},a.prototype.readDoubleBE=function(x,A){return x=x>>>0,A||T(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 N(_,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 N(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 N(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){ye(x,"offset"),(_[x]===void 0||_[x+A]===void 0)&&Se(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 ye(_,x){if(typeof _!="number")throw new Z.ERR_INVALID_ARG_TYPE(x,"number",_)}function Se(_,x,A){throw Math.floor(_)!==_?(ye(_,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 qi(_,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 rt(_,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")}}(Oy)),Oy}var _e=Ty(),OC=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())})},TC=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||_e.Buffer);var TW=function(t){return OC(void 0,void 0,void 0,function(){var e,n,r;return TC(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]}})})},PW=function(t){return OC(void 0,void 0,void 0,function(){var e,n;return TC(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 Py=BigInt(0),Ny=BigInt(1);function Aa(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 hp(t){const e=t.toString(16);return e.length&1?"0"+e:e}function PC(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Py:BigInt("0x"+t)}function pp(t){return PC(ra(t))}function xd(t){return fo(t),PC(ra(Uint8Array.from(t).reverse()))}function By(t,e){return wh(t.toString(16).padStart(e*2,"0"))}function NC(t,e){return By(t,e).reverse()}function At(t,e,n){let r;if(typeof e=="string")try{r=wh(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 BC(t){return Uint8Array.from(t)}const Ry=t=>typeof t=="bigint"&&Py<=t;function NW(t,e,n){return Ry(t)&&Ry(e)&&Ry(n)&&e<=t&&t<n}function My(t,e,n,r){if(!NW(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function RC(t){let e;for(e=0;t>Py;t>>=Ny,e+=1);return e}const Ed=t=>(Ny<<BigInt(t))-Ny;function BW(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=p=>new Uint8Array(p),i=p=>Uint8Array.of(p);let o=r(t),s=r(t),a=0;const l=()=>{o.fill(1),s.fill(0),a=0},c=(...p)=>n(s,o,...p),u=(p=r(0))=>{s=c(i(0),p),o=c(),p.length!==0&&(s=c(i(1),p),o=c())},d=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let p=0;const b=[];for(;p<e;){o=c();const g=o.slice();b.push(g),p+=o.length}return Ii(...b)};return(p,b)=>{l(),u(p);let g;for(;!(g=b(d()));)u();return l(),g}}function Ad(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 gp(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),Sa=BigInt(2),MC=BigInt(3),LC=BigInt(4),FC=BigInt(5),RW=BigInt(7),_C=BigInt(8),MW=BigInt(9),VC=BigInt(16);function _t(t,e){const n=t%e;return n>=or?n:e+n}function St(t,e,n){let r=t;for(;e-- >or;)r*=r,r%=n;return r}function DC(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 Ly(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function zC(t,e){const n=(t.ORDER+xn)/LC,r=t.pow(e,n);return Ly(t,r,e),r}function LW(t,e){const n=(t.ORDER-FC)/_C,r=t.mul(e,Sa),i=t.pow(r,n),o=t.mul(e,i),s=t.mul(t.mul(o,Sa),i),a=t.mul(o,t.sub(s,t.ONE));return Ly(t,a,e),a}function FW(t){const e=ka(t),n=UC(t),r=n(e,e.neg(e.ONE)),i=n(e,r),o=n(e,e.neg(r)),s=(t+RW)/VC;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),p=a.eql(a.sqr(u),l),b=a.eql(a.sqr(d),l);c=a.cmov(c,u,p),u=a.cmov(h,d,b);const g=a.eql(a.sqr(u),l),w=a.cmov(c,u,g);return Ly(a,w,l),w}}function UC(t){if(t<MC)throw new Error("sqrt is not defined for small field");let e=t-xn,n=0;for(;e%Sa===or;)e/=Sa,n++;let r=Sa;const i=ka(t);for(;HC(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return zC;let o=i.pow(r,e);const s=(e+xn)/Sa;return function(l,c){if(l.is0(c))return c;if(HC(l,c)!==1)throw new Error("Cannot find square root");let u=n,d=l.mul(l.ONE,o),h=l.pow(c,e),p=l.pow(c,s);for(;!l.eql(h,l.ONE);){if(l.is0(h))return l.ZERO;let b=1,g=l.sqr(h);for(;!l.eql(g,l.ONE);)if(b++,g=l.sqr(g),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),p=l.mul(p,S)}return p}}function _W(t){return t%LC===MC?zC:t%_C===FC?LW:t%VC===MW?FW(t):UC(t)}const VW=(t,e)=>(_t(t,e)&xn)===xn,DW=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function zW(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=DW.reduce((r,i)=>(r[i]="function",r),e);return Ad(t,n),t}function UW(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 $C(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 HC(t,e){const n=(t.ORDER-xn)/Sa,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 WC(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}=WC(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,p)=>h===p,sqr:h=>_t(h*h,t),add:(h,p)=>_t(h+p,t),sub:(h,p)=>_t(h-p,t),mul:(h,p)=>_t(h*p,t),pow:(h,p)=>UW(d,h,p),div:(h,p)=>_t(h*DC(p,t),t),sqrN:h=>h*h,addN:(h,p)=>h+p,subN:(h,p)=>h-p,mulN:(h,p)=>h*p,inv:h=>DC(h,t),sqrt:o||(h=>(u||(u=_W(t)),u(d,h))),toBytes:h=>n?NC(h,c):By(h,c),fromBytes:(h,p=!0)=>{if(a){if(!a.includes(h.length)||h.length>c)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+h.length);const g=new Uint8Array(c);g.set(h,n?0:g.length-h.length),h=g}if(h.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+h.length);let b=n?xd(h):pp(h);if(s&&(b=_t(b,t)),!p&&!d.isValid(b))throw new Error("invalid field element: outside of range 0..ORDER");return b},invertBatch:h=>$C(d,h),cmov:(h,p,b)=>b?p:h});return Object.freeze(d)}function GC(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 jC(t){const e=GC(t);return e+Math.ceil(e/2)}function $W(t,e,n=!1){const r=t.length,i=GC(e),o=jC(e);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=n?xd(t):pp(t),a=_t(s,e-xn)+xn;return n?NC(a,i):By(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nc=BigInt(0),Ca=BigInt(1);function mp(t,e){const n=e.negate();return t?n:e}function Ia(t,e){const n=$C(t.Fp,e.map(r=>r.Z));return e.map((r,i)=>t.fromAffine(r.toAffine(n[i])))}function KC(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Fy(t,e){KC(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 qC(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,p=e%2!==0;return{nextN:l,offset:u,isZero:d,isNeg:h,isNegF:p,offsetF:c}}function HW(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 WW(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 _y=new WeakMap,YC=new WeakMap;function Vy(t){return YC.get(t)||1}function QC(t){if(t!==nc)throw new Error("invalid wNAF")}class XC{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}=Fy(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=Fy(e,this.bits);for(let a=0;a<s.windows;a++){const{nextN:l,offset:c,isZero:u,isNeg:d,isNegF:h,offsetF:p}=qC(r,a,s);r=l,u?o=o.add(mp(h,n[p])):i=i.add(mp(d,n[c]))}return QC(r),{p:i,f:o}}wNAFUnsafe(e,n,r,i=this.ZERO){const o=Fy(e,this.bits);for(let s=0;s<o.windows&&r!==nc;s++){const{nextN:a,offset:l,isZero:c,isNeg:u}=qC(r,s,o);if(r=a,!c){const d=n[l];i=i.add(u?d.negate():d)}}return QC(r),i}getPrecomputes(e,n,r){let i=_y.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(i=r(i)),_y.set(n,i))),i}cached(e,n,r){const i=Vy(e);return this.wNAF(i,this.getPrecomputes(i,e,r),n)}unsafe(e,n,r,i){const o=Vy(e);return o===1?this._unsafeLadder(e,n,i):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),n,i)}createCache(e,n){KC(n,this.bits),YC.set(e,n),_y.delete(e)}hasCache(e){return Vy(e)!==1}}function GW(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){HW(n,t),WW(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=RC(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 p=d;p>=0;p-=l){u.fill(s);for(let g=0;g<o;g++){const w=r[g],S=Number(w>>BigInt(p)&c);u[S]=u[S].add(n[g])}let b=s;for(let g=u.length-1,w=s;g>0;g--)w=w.add(u[g]),b=b.add(w);if(h=h.add(b),p!==0)for(let g=0;g<l;g++)h=h.double()}return h}function ZC(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return zW(e),e}else return ka(t,{isLE:n})}function eI(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=ZC(e.p,n.Fp,r),o=ZC(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 gs=BigInt(0),dn=BigInt(1),Dy=BigInt(2),jW=BigInt(8);function KW(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 qW(t,e={}){const n=eI("edwards",t,e,e.FpFnLE),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s}=o;Ad(e,{},{uvRatio:"function"});const a=Dy<<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(P){return{isValid:!1,value:gs}}});if(!KW(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function u(w,S,P=!1){const O=P?dn:gs;return My("coordinate "+w,S,O,a),S}function d(w){if(!(w instanceof b))throw new Error("ExtendedPoint expected")}const h=gp((w,S)=>{const{X:P,Y:O,Z:$}=w,R=w.is0();S==null&&(S=R?jW:r.inv($));const j=l(P*S),q=l(O*S),W=r.mul($,S);if(R)return{x:gs,y:dn};if(W!==dn)throw new Error("invZ was invalid");return{x:j,y:q}}),p=gp(w=>{const{a:S,d:P}=o;if(w.is0())throw new Error("bad point: ZERO");const{X:O,Y:$,Z:R,T:j}=w,q=l(O*O),W=l($*$),F=l(R*R),V=l(F*F),G=l(q*S),z=l(F*l(G+W)),k=l(V+l(P*l(q*W)));if(z!==k)throw new Error("bad point: equation left != right (1)");const f=l(O*$),y=l(R*j);if(f!==y)throw new Error("bad point: equation left != right (2)");return!0});class b{constructor(S,P,O,$){this.X=u("x",S),this.Y=u("y",P),this.Z=u("z",O,!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:P,y:O}=S||{};return u("x",P),u("y",O),new b(P,O,dn,l(P*O))}static fromBytes(S,P=!1){const O=r.BYTES,{a:$,d:R}=o;S=BC(ii(S,O,"point")),Aa(P,"zip215");const j=BC(S),q=S[O-1];j[O-1]=q&-129;const W=xd(j),F=P?a:r.ORDER;My("point.y",W,gs,F);const V=l(W*W),G=l(V-dn),z=l(R*V-$);let{isValid:k,value:f}=c(G,z);if(!k)throw new Error("bad point: invalid y coordinate");const y=(f&dn)===dn,E=(q&128)!==0;if(!P&&f===gs&&E)throw new Error("bad point: x=0 and x_0=1");return E!==y&&(f=l(-f)),b.fromAffine({x:f,y:W})}static fromHex(S,P=!1){return b.fromBytes(At("point",S),P)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(S=8,P=!0){return g.createCache(this,S),P||this.multiply(Dy),this}assertValidity(){p(this)}equals(S){d(S);const{X:P,Y:O,Z:$}=this,{X:R,Y:j,Z:q}=S,W=l(P*q),F=l(R*$),V=l(O*q),G=l(j*$);return W===F&&V===G}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:P,Y:O,Z:$}=this,R=l(P*P),j=l(O*O),q=l(Dy*l($*$)),W=l(S*R),F=P+O,V=l(l(F*F)-R-j),G=W+j,z=G-q,k=W-j,f=l(V*z),y=l(G*k),E=l(V*k),I=l(z*G);return new b(f,y,I,E)}add(S){d(S);const{a:P,d:O}=o,{X:$,Y:R,Z:j,T:q}=this,{X:W,Y:F,Z:V,T:G}=S,z=l($*W),k=l(R*F),f=l(q*O*G),y=l(j*V),E=l(($+R)*(W+F)-z-k),I=y-f,B=y+f,D=l(k-P*z),M=l(E*I),T=l(B*D),m=l(E*D),v=l(I*B);return new b(M,T,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:P,f:O}=g.cached(this,S,$=>Ia(b,$));return Ia(b,[P,O])[0]}multiplyUnsafe(S,P=b.ZERO){if(!i.isValid(S))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return S===gs?b.ZERO:this.is0()||S===dn?this:g.unsafe(this,S,O=>Ia(b,O),P)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return g.unsafe(this,o.n).is0()}toAffine(S){return h(this,S)}clearCofactor(){return s===dn?this:this.multiplyUnsafe(s)}toBytes(){const{x:S,y:P}=this.toAffine(),O=r.toBytes(P);return O[O.length-1]|=S&dn?128:0,O}toHex(){return ra(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,P){return JC(b,i,S,P)}_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(gs,dn,dn,gs),b.Fp=r,b.Fn=i;const g=new XC(b,i.BITS);return b.BASE.precompute(8),b}function YW(t,e,n={}){if(typeof e!="function")throw new Error('"hash" function param is required');Ad(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||(F=>F),c=n.domain||((F,V,G)=>{if(Aa(G,"phflag"),V.length||G)throw new Error("Contexts/pre-hash are not supported");return F});function u(F){return s.create(xd(F))}function d(F){const V=O.secretKey;F=At("private key",F,V);const G=At("hashed private key",e(F),2*V),z=l(G.slice(0,V)),k=G.slice(V,2*V),f=u(z);return{head:z,prefix:k,scalar:f}}function h(F){const{head:V,prefix:G,scalar:z}=d(F),k=i.multiply(z),f=k.toBytes();return{head:V,prefix:G,scalar:z,point:k,pointBytes:f}}function p(F){return h(F).pointBytes}function b(F=Uint8Array.of(),...V){const G=Ii(...V);return u(e(c(G,At("context",F),!!r)))}function g(F,V,G={}){F=At("message",F),r&&(F=r(F));const{prefix:z,scalar:k,pointBytes:f}=h(V),y=b(G.context,z,F),E=i.multiply(y).toBytes(),I=b(G.context,E,f,F),B=s.create(y+I*k);if(!s.isValid(B))throw new Error("sign failed: invalid s");const D=Ii(E,s.toBytes(B));return ii(D,O.signature,"result")}const w={zip215:!0};function S(F,V,G,z=w){const{context:k,zip215:f}=z,y=O.signature;F=At("signature",F,y),V=At("message",V),G=At("publicKey",G,O.publicKey),f!==void 0&&Aa(f,"zip215"),r&&(V=r(V));const E=y/2,I=F.subarray(0,E),B=xd(F.subarray(E,y));let D,M,T;try{D=t.fromBytes(G,f),M=t.fromBytes(I,f),T=i.multiplyUnsafe(B)}catch(N){return!1}if(!f&&D.isSmallOrder())return!1;const m=b(k,M.toBytes(),D.toBytes(),V);return M.add(D.multiplyUnsafe(m)).subtract(T).clearCofactor().is0()}const P=o.BYTES,O={secretKey:P,publicKey:P,signature:2*P,seed:P};function $(F=a(O.seed)){return ii(F,O.seed,"seed")}function R(F){const V=W.randomSecretKey(F);return{secretKey:V,publicKey:p(V)}}function j(F){return Hu(F)&&F.length===s.BYTES}function q(F,V){try{return!!t.fromBytes(F,V)}catch(G){return!1}}const W={getExtendedPublicKey:h,randomSecretKey:$,isValidSecretKey:j,isValidPublicKey:q,toMontgomery(F){const{y:V}=t.fromBytes(F),G=O.publicKey,z=G===32;if(!z&&G!==57)throw new Error("only defined for 25519 and 448");const k=z?o.div(dn+V,dn-V):o.div(V-dn,V+dn);return o.toBytes(k)},toMontgomeryPriv(F){const V=O.secretKey;ii(F,V);const G=e(F.subarray(0,V));return l(G).subarray(0,V)},randomPrivateKey:$,precompute(F=8,V=t.BASE){return V.precompute(F,!1)}};return Object.freeze({keygen:R,getPublicKey:p,sign:g,verify:S,utils:W,Point:t,lengths:O})}function QW(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 XW(t,e){const n=e.Point;return Object.assign({},e,{ExtendedPoint:n,CURVE:t,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function JW(t){const{CURVE:e,curveOpts:n,hash:r,eddsaOpts:i}=QW(t),o=qW(e,n),s=YW(o,r,i);return XW(t,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ZW=BigInt(1),tI=BigInt(2);BigInt(3);const eG=BigInt(5),tG=BigInt(8),zy=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),nI={p:zy,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:tG,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function nG(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=zy,a=t*t%o*t%o,l=St(a,tI,o)*a%o,c=St(l,ZW,o)*t%o,u=St(c,eG,o)*c%o,d=St(u,e,o)*u%o,h=St(d,n,o)*d%o,p=St(h,r,o)*h%o,b=St(p,i,o)*p%o,g=St(b,i,o)*p%o,w=St(g,e,o)*u%o;return{pow_p_5_8:St(w,tI,o)*t%o,b2:a}}function rG(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const rI=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function iG(t,e){const n=zy,r=_t(e*e*e,n),i=_t(r*r*e,n),o=nG(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*rI,n),u=a===t,d=a===_t(-t,n),h=a===_t(-t*rI,n);return u&&(s=l),(d||h)&&(s=c),VW(s,n)&&(s=_t(-s,n)),{isValid:u||d,value:s}}const oG=ka(nI.p,{isLE:!0}),sG={...nI,Fp:oG,hash:az,adjustScalarBytes:rG,uvRatio:iG},Sd=JW(sG);var yp={exports:{}};const aG=lu(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var lG=yp.exports,iI;function oI(){return iI||(iI=1,function(t){(function(e,n){function r(k,f){if(!k)throw new Error(f||"Assertion failed")}function i(k,f){k.super_=f;var y=function(){};y.prototype=f.prototype,k.prototype=new y,k.prototype.constructor=k}function o(k,f,y){if(o.isBN(k))return k;this.negative=0,this.words=null,this.length=0,this.red=null,k!==null&&((f==="le"||f==="be")&&(y=f,f=10),this._init(k||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=aG.Buffer}catch(k){}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 B,D,M=0;if(E==="be")for(I=f.length-1,B=0;I>=0;I-=3)D=f[I]|f[I-1]<<8|f[I-2]<<16,this.words[B]|=D<<M&67108863,this.words[B+1]=D>>>26-M&67108863,M+=24,M>=26&&(M-=26,B++);else if(E==="le")for(I=0,B=0;I<f.length;I+=3)D=f[I]|f[I+1]<<8|f[I+2]<<16,this.words[B]|=D<<M&67108863,this.words[B+1]=D>>>26-M&67108863,M+=24,M>=26&&(M-=26,B++);return this._strip()};function a(k,f){var y=k.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 "+k)}function l(k,f,y){var E=a(k,y);return y-1>=f&&(E|=a(k,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 B=0,D=0,M;if(E==="be")for(I=f.length-1;I>=y;I-=2)M=l(f,y,I)<<B,this.words[D]|=M&67108863,B>=18?(B-=18,D+=1,this.words[D]|=M>>>26):B+=8;else{var T=f.length-y;for(I=T%2===0?y+1:y;I<f.length;I+=2)M=l(f,y,I)<<B,this.words[D]|=M&67108863,B>=18?(B-=18,D+=1,this.words[D]|=M>>>26):B+=8}this._strip()};function c(k,f,y,E){for(var I=0,B=0,D=Math.min(k.length,y),M=f;M<D;M++){var T=k.charCodeAt(M)-48;I*=E,T>=49?B=T-49+10:T>=17?B=T-17+10:B=T,r(T>=0&&B<E,"Invalid character"),I+=B}return I}o.prototype._parseBase=function(f,y,E){this.words=[0],this.length=1;for(var I=0,B=1;B<=67108863;B*=y)I++;I--,B=B/y|0;for(var D=f.length-E,M=D%I,T=Math.min(D,D-M)+E,m=0,v=E;v<T;v+=I)m=c(f,v,v+I,y),this.imuln(B),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m);if(M!==0){var N=1;for(m=c(f,v,f.length,y),v=0;v<M;v++)N*=y;this.imuln(N),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(k,f){k.words=f.words,k.length=f.length,k.negative=f.negative,k.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(k){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"],p=[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,B=0,D=0;D<this.length;D++){var M=this.words[D],T=((M<<I|B)&16777215).toString(16);B=M>>>24-I&16777215,I+=2,I>=26&&(I-=26,D--),B!==0||D!==this.length-1?E=h[6-T.length]+T+E:E=T+E}for(B!==0&&(E=B.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=p[f],v=b[f];E="";var N=this.clone();for(N.negative=0;!N.isZero();){var U=N.modrn(v).toString(f);N=N.idivn(v),N.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 g=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(),B=E||Math.max(1,I);r(I<=B,"byte array longer than desired length"),r(B>0,"Requested array length <= 0");var D=g(f,B),M=y==="le"?"LE":"BE";return this["_toArrayLike"+M](D,I),D},o.prototype._toArrayLikeLE=function(f,y){for(var E=0,I=0,B=0,D=0;B<this.length;B++){var M=this.words[B]<<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,B=0,D=0;B<this.length;B++){var M=this.words[B]<<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(k){for(var f=new Array(k.bitLength()),y=0;y<f.length;y++){var E=y/26|0,I=y%26;f[y]=k.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 B=0,D=0;D<I.length;D++)y=(E.words[D]|0)+(I.words[D]|0)+B,this.words[D]=y&67108863,B=y>>>26;for(;B!==0&&D<E.length;D++)y=(E.words[D]|0)+B,this.words[D]=y&67108863,B=y>>>26;if(this.length=E.length,B!==0)this.words[this.length]=B,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,B;E>0?(I=this,B=f):(I=f,B=this);for(var D=0,M=0;M<B.length;M++)y=(I.words[M]|0)-(B.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(k,f,y){y.negative=f.negative^k.negative;var E=k.length+f.length|0;y.length=E,E=E-1|0;var I=k.words[0]|0,B=f.words[0]|0,D=I*B,M=D&67108863,T=D/67108864|0;y.words[0]=M;for(var m=1;m<E;m++){for(var v=T>>>26,N=T&67108863,U=Math.min(m,f.length-1),Q=Math.max(0,m-k.length+1);Q<=U;Q++){var ee=m-Q|0;I=k.words[ee]|0,B=f.words[Q]|0,D=I*B+N,v+=D/67108864|0,N=D&67108863}y.words[m]=N|0,T=v|0}return T!==0?y.words[m]=T|0:y.length--,y._strip()}var P=function(f,y,E){var I=f.words,B=y.words,D=E.words,M=0,T,m,v,N=I[0]|0,U=N&8191,Q=N>>>13,ee=I[1]|0,Z=ee&8191,Y=ee>>>13,re=I[2]|0,de=re&8191,se=re>>>13,ye=I[3]|0,Se=ye&8191,Re=ye>>>13,Ct=I[4]|0,st=Ct&8191,dt=Ct>>>13,qi=I[5]|0,at=qi&8191,rt=qi>>>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=B[0]|0,Le=De&8191,Me=De>>>13,yt=B[1]|0,Ne=yt&8191,Vt=yt>>>13,ET=B[2]|0,Dt=ET&8191,zt=ET>>>13,AT=B[3]|0,Ut=AT&8191,$t=AT>>>13,ST=B[4]|0,Ht=ST&8191,Wt=ST>>>13,kT=B[5]|0,Gt=kT&8191,jt=kT>>>13,CT=B[6]|0,Kt=CT&8191,qt=CT>>>13,IT=B[7]|0,Yt=IT&8191,Qt=IT>>>13,OT=B[8]|0,Xt=OT&8191,Jt=OT>>>13,TT=B[9]|0,Zt=TT&8191,en=TT>>>13;E.negative=f.negative^y.negative,E.length=19,T=Math.imul(U,Le),m=Math.imul(U,Me),m=m+Math.imul(Q,Le)|0,v=Math.imul(Q,Me);var Ib=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Ib>>>26)|0,Ib&=67108863,T=Math.imul(Z,Le),m=Math.imul(Z,Me),m=m+Math.imul(Y,Le)|0,v=Math.imul(Y,Me),T=T+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 Ob=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Ob>>>26)|0,Ob&=67108863,T=Math.imul(de,Le),m=Math.imul(de,Me),m=m+Math.imul(se,Le)|0,v=Math.imul(se,Me),T=T+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,T=T+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 Tb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Tb>>>26)|0,Tb&=67108863,T=Math.imul(Se,Le),m=Math.imul(Se,Me),m=m+Math.imul(Re,Le)|0,v=Math.imul(Re,Me),T=T+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,T=T+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,T=T+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 Pb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Pb>>>26)|0,Pb&=67108863,T=Math.imul(st,Le),m=Math.imul(st,Me),m=m+Math.imul(dt,Le)|0,v=Math.imul(dt,Me),T=T+Math.imul(Se,Ne)|0,m=m+Math.imul(Se,Vt)|0,m=m+Math.imul(Re,Ne)|0,v=v+Math.imul(Re,Vt)|0,T=T+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,T=T+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,T=T+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 Nb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Nb>>>26)|0,Nb&=67108863,T=Math.imul(at,Le),m=Math.imul(at,Me),m=m+Math.imul(rt,Le)|0,v=Math.imul(rt,Me),T=T+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,T=T+Math.imul(Se,Dt)|0,m=m+Math.imul(Se,zt)|0,m=m+Math.imul(Re,Dt)|0,v=v+Math.imul(Re,zt)|0,T=T+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,T=T+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,T=T+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 Bb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Bb>>>26)|0,Bb&=67108863,T=Math.imul(ft,Le),m=Math.imul(ft,Me),m=m+Math.imul(mt,Le)|0,v=Math.imul(mt,Me),T=T+Math.imul(at,Ne)|0,m=m+Math.imul(at,Vt)|0,m=m+Math.imul(rt,Ne)|0,v=v+Math.imul(rt,Vt)|0,T=T+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,T=T+Math.imul(Se,Ut)|0,m=m+Math.imul(Se,$t)|0,m=m+Math.imul(Re,Ut)|0,v=v+Math.imul(Re,$t)|0,T=T+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,T=T+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,T=T+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 Rb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Rb>>>26)|0,Rb&=67108863,T=Math.imul(It,Le),m=Math.imul(It,Me),m=m+Math.imul(_,Le)|0,v=Math.imul(_,Me),T=T+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,T=T+Math.imul(at,Dt)|0,m=m+Math.imul(at,zt)|0,m=m+Math.imul(rt,Dt)|0,v=v+Math.imul(rt,zt)|0,T=T+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,T=T+Math.imul(Se,Ht)|0,m=m+Math.imul(Se,Wt)|0,m=m+Math.imul(Re,Ht)|0,v=v+Math.imul(Re,Wt)|0,T=T+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,T=T+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,T=T+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 Mb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Mb>>>26)|0,Mb&=67108863,T=Math.imul(A,Le),m=Math.imul(A,Me),m=m+Math.imul(H,Le)|0,v=Math.imul(H,Me),T=T+Math.imul(It,Ne)|0,m=m+Math.imul(It,Vt)|0,m=m+Math.imul(_,Ne)|0,v=v+Math.imul(_,Vt)|0,T=T+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,T=T+Math.imul(at,Ut)|0,m=m+Math.imul(at,$t)|0,m=m+Math.imul(rt,Ut)|0,v=v+Math.imul(rt,$t)|0,T=T+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,T=T+Math.imul(Se,Gt)|0,m=m+Math.imul(Se,jt)|0,m=m+Math.imul(Re,Gt)|0,v=v+Math.imul(Re,jt)|0,T=T+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,T=T+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,T=T+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 Lb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Lb>>>26)|0,Lb&=67108863,T=Math.imul(ie,Le),m=Math.imul(ie,Me),m=m+Math.imul(ue,Le)|0,v=Math.imul(ue,Me),T=T+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,T=T+Math.imul(It,Dt)|0,m=m+Math.imul(It,zt)|0,m=m+Math.imul(_,Dt)|0,v=v+Math.imul(_,zt)|0,T=T+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,T=T+Math.imul(at,Ht)|0,m=m+Math.imul(at,Wt)|0,m=m+Math.imul(rt,Ht)|0,v=v+Math.imul(rt,Wt)|0,T=T+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,T=T+Math.imul(Se,Kt)|0,m=m+Math.imul(Se,qt)|0,m=m+Math.imul(Re,Kt)|0,v=v+Math.imul(Re,qt)|0,T=T+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,T=T+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,T=T+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 Fb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Fb>>>26)|0,Fb&=67108863,T=Math.imul(ie,Ne),m=Math.imul(ie,Vt),m=m+Math.imul(ue,Ne)|0,v=Math.imul(ue,Vt),T=T+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,T=T+Math.imul(It,Ut)|0,m=m+Math.imul(It,$t)|0,m=m+Math.imul(_,Ut)|0,v=v+Math.imul(_,$t)|0,T=T+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,T=T+Math.imul(at,Gt)|0,m=m+Math.imul(at,jt)|0,m=m+Math.imul(rt,Gt)|0,v=v+Math.imul(rt,jt)|0,T=T+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,T=T+Math.imul(Se,Yt)|0,m=m+Math.imul(Se,Qt)|0,m=m+Math.imul(Re,Yt)|0,v=v+Math.imul(Re,Qt)|0,T=T+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,T=T+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 _b=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(_b>>>26)|0,_b&=67108863,T=Math.imul(ie,Dt),m=Math.imul(ie,zt),m=m+Math.imul(ue,Dt)|0,v=Math.imul(ue,zt),T=T+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,T=T+Math.imul(It,Ht)|0,m=m+Math.imul(It,Wt)|0,m=m+Math.imul(_,Ht)|0,v=v+Math.imul(_,Wt)|0,T=T+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,T=T+Math.imul(at,Kt)|0,m=m+Math.imul(at,qt)|0,m=m+Math.imul(rt,Kt)|0,v=v+Math.imul(rt,qt)|0,T=T+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,T=T+Math.imul(Se,Xt)|0,m=m+Math.imul(Se,Jt)|0,m=m+Math.imul(Re,Xt)|0,v=v+Math.imul(Re,Jt)|0,T=T+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 Vb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Vb>>>26)|0,Vb&=67108863,T=Math.imul(ie,Ut),m=Math.imul(ie,$t),m=m+Math.imul(ue,Ut)|0,v=Math.imul(ue,$t),T=T+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,T=T+Math.imul(It,Gt)|0,m=m+Math.imul(It,jt)|0,m=m+Math.imul(_,Gt)|0,v=v+Math.imul(_,jt)|0,T=T+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,T=T+Math.imul(at,Yt)|0,m=m+Math.imul(at,Qt)|0,m=m+Math.imul(rt,Yt)|0,v=v+Math.imul(rt,Qt)|0,T=T+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,T=T+Math.imul(Se,Zt)|0,m=m+Math.imul(Se,en)|0,m=m+Math.imul(Re,Zt)|0,v=v+Math.imul(Re,en)|0;var Db=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Db>>>26)|0,Db&=67108863,T=Math.imul(ie,Ht),m=Math.imul(ie,Wt),m=m+Math.imul(ue,Ht)|0,v=Math.imul(ue,Wt),T=T+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,T=T+Math.imul(It,Kt)|0,m=m+Math.imul(It,qt)|0,m=m+Math.imul(_,Kt)|0,v=v+Math.imul(_,qt)|0,T=T+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,T=T+Math.imul(at,Xt)|0,m=m+Math.imul(at,Jt)|0,m=m+Math.imul(rt,Xt)|0,v=v+Math.imul(rt,Jt)|0,T=T+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 zb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(zb>>>26)|0,zb&=67108863,T=Math.imul(ie,Gt),m=Math.imul(ie,jt),m=m+Math.imul(ue,Gt)|0,v=Math.imul(ue,jt),T=T+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,T=T+Math.imul(It,Yt)|0,m=m+Math.imul(It,Qt)|0,m=m+Math.imul(_,Yt)|0,v=v+Math.imul(_,Qt)|0,T=T+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,T=T+Math.imul(at,Zt)|0,m=m+Math.imul(at,en)|0,m=m+Math.imul(rt,Zt)|0,v=v+Math.imul(rt,en)|0;var Ub=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Ub>>>26)|0,Ub&=67108863,T=Math.imul(ie,Kt),m=Math.imul(ie,qt),m=m+Math.imul(ue,Kt)|0,v=Math.imul(ue,qt),T=T+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,T=T+Math.imul(It,Xt)|0,m=m+Math.imul(It,Jt)|0,m=m+Math.imul(_,Xt)|0,v=v+Math.imul(_,Jt)|0,T=T+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 $b=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+($b>>>26)|0,$b&=67108863,T=Math.imul(ie,Yt),m=Math.imul(ie,Qt),m=m+Math.imul(ue,Yt)|0,v=Math.imul(ue,Qt),T=T+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,T=T+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 Hb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Hb>>>26)|0,Hb&=67108863,T=Math.imul(ie,Xt),m=Math.imul(ie,Jt),m=m+Math.imul(ue,Xt)|0,v=Math.imul(ue,Jt),T=T+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 Wb=(M+T|0)+((m&8191)<<13)|0;M=(v+(m>>>13)|0)+(Wb>>>26)|0,Wb&=67108863,T=Math.imul(ie,Zt),m=Math.imul(ie,en),m=m+Math.imul(ue,Zt)|0,v=Math.imul(ue,en);var Gb=(M+T|0)+((m&8191)<<13)|0;return M=(v+(m>>>13)|0)+(Gb>>>26)|0,Gb&=67108863,D[0]=Ib,D[1]=Ob,D[2]=Tb,D[3]=Pb,D[4]=Nb,D[5]=Bb,D[6]=Rb,D[7]=Mb,D[8]=Lb,D[9]=Fb,D[10]=_b,D[11]=Vb,D[12]=Db,D[13]=zb,D[14]=Ub,D[15]=$b,D[16]=Hb,D[17]=Wb,D[18]=Gb,M!==0&&(D[19]=M,E.length++),E};Math.imul||(P=S);function O(k,f,y){y.negative=f.negative^k.negative,y.length=k.length+f.length;for(var E=0,I=0,B=0;B<y.length-1;B++){var D=I;I=0;for(var M=E&67108863,T=Math.min(B,f.length-1),m=Math.max(0,B-k.length+1);m<=T;m++){var v=B-m,N=k.words[v]|0,U=f.words[m]|0,Q=N*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[B]=M,E=D,D=I}return E!==0?y.words[B]=E:y.length--,y._strip()}function $(k,f,y){return O(k,f,y)}o.prototype.mulTo=function(f,y){var E,I=this.length+f.length;return this.length===10&&f.length===10?E=P(this,f,y):I<63?E=S(this,f,y):I<1024?E=O(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 B=(this.words[I]|0)*f,D=(B&67108863)+(E&67108863);E>>=26,E+=B/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 B=E.sqr();I<y.length;I++,B=B.sqr())y[I]!==0&&(E=E.mul(B));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,B;if(y!==0){var D=0;for(B=0;B<this.length;B++){var M=this.words[B]&I,T=(this.words[B]|0)-M<<y;this.words[B]=T|D,D=M>>>26-y}D&&(this.words[B]=D,this.length++)}if(E!==0){for(B=this.length-1;B>=0;B--)this.words[B+E]=this.words[B];for(B=0;B<E;B++)this.words[B]=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 B=f%26,D=Math.min((f-B)/26,this.length),M=67108863^67108863>>>B<<B,T=E;if(I-=D,I=Math.max(0,I),T){for(var m=0;m<D;m++)T.words[m]=this.words[m];T.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 N=this.words[m]|0;this.words[m]=v<<26-B|N>>>B,v=N&M}return T&&v!==0&&(T.words[T.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 B=this.words[E];return!!(B&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,B;this._expand(I);var D,M=0;for(B=0;B<f.length;B++){D=(this.words[B+E]|0)+M;var T=(f.words[B]|0)*y;D-=T&67108863,M=(D>>26)-(T/67108864|0),this.words[B+E]=D&67108863}for(;B<this.length-E;B++)D=(this.words[B+E]|0)+M,M=D>>26,this.words[B+E]=D&67108863;if(M===0)return this._strip();for(r(M===-1),M=0,B=0;B<this.length;B++)D=-(this.words[B]|0)+M,M=D>>26,this.words[B]=D&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(f,y){var E=this.length-f.length,I=this.clone(),B=f,D=B.words[B.length-1]|0,M=this._countBits(D);E=26-M,E!==0&&(B=B.ushln(E),I.iushln(E),D=B.words[B.length-1]|0);var T=I.length-B.length,m;if(y!=="mod"){m=new o(null),m.length=T+1,m.words=new Array(m.length);for(var v=0;v<m.length;v++)m.words[v]=0}var N=I.clone()._ishlnsubmul(B,1,T);N.negative===0&&(I=N,m&&(m.words[T]=1));for(var U=T-1;U>=0;U--){var Q=(I.words[B.length+U]|0)*67108864+(I.words[B.length+U-1]|0);for(Q=Math.min(Q/D|0,67108863),I._ishlnsubmul(B,Q,U);I.negative!==0;)Q--,I.negative=0,I._ishlnsubmul(B,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,B,D;return this.negative!==0&&f.negative===0?(D=this.neg().divmod(f,y),y!=="mod"&&(I=D.div.neg()),y!=="div"&&(B=D.mod.neg(),E&&B.negative!==0&&B.iadd(f)),{div:I,mod:B}):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"&&(B=D.mod.neg(),E&&B.negative!==0&&B.isub(f)),{div:D.div,mod:B}):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),B=f.andln(1),D=E.cmp(I);return D<0||B===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,B=this.length-1;B>=0;B--)I=(E*I+(this.words[B]|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 B=(this.words[I]|0)+E*67108864;this.words[I]=B/f|0,E=B%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),B=new o(0),D=new o(0),M=new o(1),T=0;y.isEven()&&E.isEven();)y.iushrn(1),E.iushrn(1),++T;for(var m=E.clone(),v=y.clone();!y.isZero();){for(var N=0,U=1;(y.words[0]&U)===0&&N<26;++N,U<<=1);if(N>0)for(y.iushrn(N);N-- >0;)(I.isOdd()||B.isOdd())&&(I.iadd(m),B.isub(v)),I.iushrn(1),B.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),B.isub(M)):(E.isub(y),D.isub(I),M.isub(B))}return{a:D,b:M,gcd:E.iushln(T)}},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),B=new o(0),D=E.clone();y.cmpn(1)>0&&E.cmpn(1)>0;){for(var M=0,T=1;(y.words[0]&T)===0&&M<26;++M,T<<=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;)B.isOdd()&&B.iadd(D),B.iushrn(1);y.cmp(E)>=0?(y.isub(E),I.isub(B)):(E.isub(y),B.isub(I))}var N;return y.cmpn(1)===0?N=I:N=B,N.cmpn(0)<0&&N.iadd(f),N},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 B=y.cmp(E);if(B<0){var D=y;y=E,E=D}else if(B===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 B=I,D=E;B!==0&&D<this.length;D++){var M=this.words[D]|0;M+=B,B=M>>>26,M&=67108863,this.words[D]=M}return B!==0&&(this.words[D]=B,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,B=f.words[E]|0;if(I!==B){I<B?y=-1:I>B&&(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 G(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(k,f){this.name=k,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),B=0;B<I;B++)y.words[B]=f.words[B];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,B=10;B<f.length;B++){var M=f.words[B]|0;f.words[B-10]=(M&E)<<4|D>>>22,D=M}D>>>=22,f.words[B-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 W(){j.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(W,j);function F(){j.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(F,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,B=I&67108863;I>>>=26,f.words[E]=B,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 W;else if(f==="p192")y=new F;else if(f==="p25519")y=new V;else throw new Error("Unknown prime "+f);return R[f]=y,y};function G(k){if(typeof k=="string"){var f=o._prime(k);this.m=f.p,this.prime=f}else r(k.gtn(1),"modulus must be greater than 1"),this.m=k,this.prime=null}G.prototype._verify1=function(f){r(f.negative===0,"red works only with positives"),r(f.red,"red works only with red numbers")},G.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")},G.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(u(f,f.umod(this.m)._forceRed(this)),f)},G.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},G.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)},G.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},G.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)},G.prototype.isub=function(f,y){this._verify2(f,y);var E=f.isub(y);return E.cmpn(0)<0&&E.iadd(this.m),E},G.prototype.shl=function(f,y){return this._verify1(f),this.imod(f.ushln(y))},G.prototype.imul=function(f,y){return this._verify2(f,y),this.imod(f.imul(y))},G.prototype.mul=function(f,y){return this._verify2(f,y),this.imod(f.mul(y))},G.prototype.isqr=function(f){return this.imul(f,f.clone())},G.prototype.sqr=function(f){return this.mul(f,f)},G.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),B=0;!I.isZero()&&I.andln(1)===0;)B++,I.iushrn(1);r(!I.isZero());var D=new o(1).toRed(this),M=D.redNeg(),T=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new o(2*m*m).toRed(this);this.pow(m,T).cmp(M)!==0;)m.redIAdd(M);for(var v=this.pow(m,I),N=this.pow(f,I.addn(1).iushrn(1)),U=this.pow(f,I),Q=B;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));N=N.redMul(Y),v=Y.redSqr(),U=U.redMul(v),Q=Z}return N},G.prototype.invm=function(f){var y=f._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},G.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 B=2;B<I.length;B++)I[B]=this.mul(I[B-1],f);var D=I[0],M=0,T=0,m=y.bitLength()%26;for(m===0&&(m=26),B=y.length-1;B>=0;B--){for(var v=y.words[B],N=m-1;N>=0;N--){var U=v>>N&1;if(D!==I[0]&&(D=this.sqr(D)),U===0&&M===0){T=0;continue}M<<=1,M|=U,T++,!(T!==E&&(B!==0||N!==0))&&(D=this.mul(D,I[M]),T=0,M=0)}m=26}return D},G.prototype.convertTo=function(f){var y=f.umod(this.m);return y===f?y.clone():y},G.prototype.convertFrom=function(f){var y=f.clone();return y.red=null,y},o.mont=function(f){return new z(f)};function z(k){G.call(this,k),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,G),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),B=E.isub(I).iushrn(this.shift),D=B;return B.cmp(this.m)>=0?D=B.isub(this.m):B.cmpn(0)<0&&(D=B.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),B=E.isub(I).iushrn(this.shift),D=B;return B.cmp(this.m)>=0?D=B.isub(this.m):B.cmpn(0)<0&&(D=B.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,lG)}(yp)),yp.exports}var cG=oI();const sI=sl(cG);var bp={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var aI;function uG(){return aI||(aI=1,function(t,e){var n=Ty(),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)}}(bp,bp.exports)),bp.exports}var Uy,lI;function dG(){if(lI)return Uy;lI=1;var t=uG().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(g){if((Array.isArray(g)||g instanceof Uint8Array)&&(g=t.from(g)),!t.isBuffer(g))throw new TypeError("Expected Buffer");if(g.length===0)return"";for(var w=0,S=0,P=0,O=g.length;P!==O&&g[P]===0;)P++,w++;for(var $=(O-P)*d+1>>>0,R=new Uint8Array($);P!==O;){for(var j=g[P],q=0,W=$-1;(j!==0||q<S)&&W!==-1;W--,q++)j+=256*R[W]>>>0,R[W]=j%l>>>0,j=j/l>>>0;if(j!==0)throw new Error("Non-zero carry");S=q,P++}for(var F=$-S;F!==$&&R[F]===0;)F++;for(var V=c.repeat(w);F<$;++F)V+=n.charAt(R[F]);return V}function p(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return t.alloc(0);for(var w=0,S=0,P=0;g[w]===c;)S++,w++;for(var O=(g.length-w)*u+1>>>0,$=new Uint8Array(O);w<g.length;){var R=g.charCodeAt(w);if(R>255)return;var j=r[R];if(j===255)return;for(var q=0,W=O-1;(j!==0||q<P)&&W!==-1;W--,q++)j+=l*$[W]>>>0,$[W]=j%256>>>0,j=j/256>>>0;if(j!==0)throw new Error("Non-zero carry");P=q,w++}for(var F=O-P;F!==O&&$[F]===0;)F++;var V=t.allocUnsafe(S+(O-F));V.fill(0,0,S);for(var G=S;F!==O;)V[G++]=$[F++];return V}function b(g){var w=p(g);if(w)return w;throw new Error("Non-base"+l+" character")}return{encode:h,decodeUnsafe:p,decode:b}}return Uy=e,Uy}var $y,cI;function uI(){if(cI)return $y;cI=1;var t=dG(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return $y=t(e),$y}var fG=uI();const $n=sl(fG);var ot={};function Co(t,e,n){return e<=t&&t<=n}function vp(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function hG(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 pG(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 wp=-1;function Hy(t){this.tokens=[].slice.call(t)}Hy.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():wp},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 Wy(t,e){if(t)throw TypeError("Decoder error");return e||65533}var xp="utf-8";function Ep(t,e){if(!(this instanceof Ep))return new Ep(t,e);if(t=t!==void 0?String(t).toLowerCase():xp,t!==xp)throw new Error("Encoding not supported. Only utf-8 is supported");e=vp(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})}Ep.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=vp(n),this._streaming||(this._decoder=new gG({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var i=new Hy(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),pG(o)}};function Ap(t,e){if(!(this instanceof Ap))return new Ap(t,e);if(t=t!==void 0?String(t).toLowerCase():xp,t!==xp)throw new Error("Encoding not supported. Only utf-8 is supported");e=vp(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Ap.prototype={encode:function(e,n){e=e?String(e):"",n=vp(n),this._streaming||(this._encoder=new mG(this._options)),this._streaming=!!n.stream;for(var r=[],i=new Hy(hG(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 gG(t){var e=t.fatal,n=0,r=0,i=0,o=128,s=191;this.handler=function(a,l){if(l===wp&&i!==0)return i=0,Wy(e);if(l===wp)return rc;if(i===0){if(Co(l,0,127))return l;if(Co(l,194,223))i=1,n=l-192;else if(Co(l,224,239))l===224&&(o=160),l===237&&(s=159),i=2,n=l-224;else if(Co(l,240,244))l===240&&(o=144),l===244&&(s=143),i=3,n=l-240;else return Wy(e);return n=n<<6*i,null}if(!Co(l,o,s))return n=i=r=0,o=128,s=191,a.prepend(l),Wy(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 mG(t){t.fatal,this.handler=function(e,n){if(n===wp)return rc;if(Co(n,0,127))return n;var r,i;Co(n,128,2047)?(r=1,i=192):Co(n,2048,65535)?(r=2,i=224):Co(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 yG=lu(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Ep,TextEncoder:Ap},Symbol.toStringTag,{value:"Module"})));var dI;function bG(){if(dI)return ot;dI=1;var t=ot&&ot.__createBinding||(Object.create?function(F,V,G,z){z===void 0&&(z=G),Object.defineProperty(F,z,{enumerable:!0,get:function(){return V[G]}})}:function(F,V,G,z){z===void 0&&(z=G),F[z]=V[G]}),e=ot&&ot.__setModuleDefault||(Object.create?function(F,V){Object.defineProperty(F,"default",{enumerable:!0,value:V})}:function(F,V){F.default=V}),n=ot&&ot.__decorate||function(F,V,G,z){var k=arguments.length,f=k<3?V:z===null?z=Object.getOwnPropertyDescriptor(V,G):z,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(F,V,G,z);else for(var E=F.length-1;E>=0;E--)(y=F[E])&&(f=(k<3?y(f):k>3?y(V,G,f):y(V,G))||f);return k>3&&f&&Object.defineProperty(V,G,f),f},r=ot&&ot.__importStar||function(F){if(F&&F.__esModule)return F;var V={};if(F!=null)for(var G in F)G!=="default"&&Object.hasOwnProperty.call(F,G)&&t(V,F,G);return e(V,F),V},i=ot&&ot.__importDefault||function(F){return F&&F.__esModule?F:{default:F}};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(oI()),s=i(uI()),a=r(yG),l=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,c=new l("utf-8",{fatal:!0});function u(F){return typeof F=="string"&&(F=Buffer.from(F,"utf8")),s.default.encode(Buffer.from(F))}ot.baseEncode=u;function d(F){return Buffer.from(s.default.decode(F))}ot.baseDecode=d;const h=1024;class p 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=p;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 G=Buffer.from(V,"utf8");this.writeU32(G.length),this.writeBuffer(G)}writeFixedArray(V){this.writeBuffer(Buffer.from(V))}writeArray(V,G){this.maybeResize(),this.writeU32(V.length);for(const z of V)this.maybeResize(),G(z)}toArray(){return this.buf.subarray(0,this.length)}}ot.BinaryWriter=b;function g(F,V,G){const z=G.value;G.value=function(...k){try{return z.apply(this,k)}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 p("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 p(`Expected buffer length ${V} isn't within bounds`);const G=this.buf.slice(this.offset,this.offset+V);return this.offset+=V,G}readString(){const V=this.readU32(),G=this.readBuffer(V);try{return c.decode(G)}catch(z){throw new p(`Error decoding UTF-8 string: ${z}`)}}readFixedArray(V){return new Uint8Array(this.readBuffer(V))}readArray(V){const G=this.readU32(),z=Array();for(let k=0;k<G;++k)z.push(V());return z}}n([g],w.prototype,"readU8",null),n([g],w.prototype,"readU16",null),n([g],w.prototype,"readU32",null),n([g],w.prototype,"readU64",null),n([g],w.prototype,"readU128",null),n([g],w.prototype,"readU256",null),n([g],w.prototype,"readU512",null),n([g],w.prototype,"readString",null),n([g],w.prototype,"readFixedArray",null),n([g],w.prototype,"readArray",null),ot.BinaryReader=w;function S(F){return F.charAt(0).toUpperCase()+F.slice(1)}function P(F,V,G,z,k){try{if(typeof z=="string")k[`write${S(z)}`](G);else if(z instanceof Array)if(typeof z[0]=="number"){if(G.length!==z[0])throw new p(`Expecting byte array of length ${z[0]}, but got ${G.length} bytes`);k.writeFixedArray(G)}else if(z.length===2&&typeof z[1]=="number"){if(G.length!==z[1])throw new p(`Expecting byte array of length ${z[1]}, but got ${G.length} bytes`);for(let f=0;f<z[1];f++)P(F,null,G[f],z[0],k)}else k.writeArray(G,f=>{P(F,V,f,z[0],k)});else if(z.kind!==void 0)switch(z.kind){case"option":{G==null?k.writeU8(0):(k.writeU8(1),P(F,V,G,z.type,k));break}case"map":{k.writeU32(G.size),G.forEach((f,y)=>{P(F,V,y,z.key,k),P(F,V,f,z.value,k)});break}default:throw new p(`FieldType ${z} unrecognized`)}else O(F,G,k)}catch(f){throw f instanceof p&&f.addToFieldPath(V),f}}function O(F,V,G){if(typeof V.borshSerialize=="function"){V.borshSerialize(G);return}const z=F.get(V.constructor);if(!z)throw new p(`Class ${V.constructor.name} is missing in schema`);if(z.kind==="struct")z.fields.map(([k,f])=>{P(F,k,V[k],f,G)});else if(z.kind==="enum"){const k=V[z.field];for(let f=0;f<z.values.length;++f){const[y,E]=z.values[f];if(y===k){G.writeU8(f),P(F,y,V[y],E,G);break}}}else throw new p(`Unexpected schema kind: ${z.kind} for ${V.constructor.name}`)}function $(F,V,G=b){const z=new G;return O(F,V,z),z.toArray()}ot.serialize=$;function R(F,V,G,z){try{if(typeof G=="string")return z[`read${S(G)}`]();if(G instanceof Array){if(typeof G[0]=="number")return z.readFixedArray(G[0]);if(typeof G[1]=="number"){const k=[];for(let f=0;f<G[1];f++)k.push(R(F,null,G[0],z));return k}else return z.readArray(()=>R(F,V,G[0],z))}if(G.kind==="option")return z.readU8()?R(F,V,G.type,z):void 0;if(G.kind==="map"){let k=new Map;const f=z.readU32();for(let y=0;y<f;y++){const E=R(F,V,G.key,z),I=R(F,V,G.value,z);k.set(E,I)}return k}return j(F,G,z)}catch(k){throw k instanceof p&&k.addToFieldPath(V),k}}function j(F,V,G){if(typeof V.borshDeserialize=="function")return V.borshDeserialize(G);const z=F.get(V);if(!z)throw new p(`Class ${V.name} is missing in schema`);if(z.kind==="struct"){const k={};for(const[f,y]of F.get(V).fields)k[f]=R(F,f,y,G);return new V(k)}if(z.kind==="enum"){const k=G.readU8();if(k>=z.values.length)throw new p(`Enum index: ${k} is out of range`);const[f,y]=z.values[k],E=R(F,f,y,G);return new V({[f]:E})}throw new p(`Unexpected schema kind: ${z.kind} for ${V.constructor.name}`)}function q(F,V,G,z=w){const k=new z(G),f=j(F,V,k);if(k.offset<G.length)throw new p(`Unexpected ${G.length-k.offset} bytes after deserialized data`);return f}ot.deserialize=q;function W(F,V,G,z=w){const k=new z(G);return j(F,V,k)}return ot.deserializeUnchecked=W,ot}var Gy=bG(),ae={},fI;function vG(){if(fI)return ae;fI=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=Ty();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,N){if(!Number.isInteger(v))throw new TypeError("span must be an integer");this.span=v,this.property=N}makeDestinationObject(){return{}}getSpan(v,N){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(v){const N=Object.create(this.constructor.prototype);return Object.assign(N,this),N.property=v,N}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(N,U){return v.encode(this,N,U)},writable:!0}),Object.defineProperty(m,"decode",{value(N,U){return v.decode(N,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,N){if(!Number.isInteger(v)||0>=v)throw new TypeError("elementSpan must be a (positive) integer");super(-1,N),this.elementSpan=v}isCount(){return!0}decode(v,N=0){e(v);const U=v.length-N;return Math.floor(U/this.elementSpan)}encode(v,N,U){return 0}}ae.GreedyCount=a;class l extends s{constructor(v,N=0,U){if(!(v instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(N))throw new TypeError("offset must be integer or undefined");super(v.span,U||v.property),this.layout=v,this.offset=N}isCount(){return this.layout instanceof c||this.layout instanceof u}decode(v,N=0){return this.layout.decode(v,N+this.offset)}encode(v,N,U=0){return this.layout.encode(v,N,U+this.offset)}}ae.OffsetLayout=l;class c extends r{constructor(v,N){if(super(v,N),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,N=0){return n(v).readUIntLE(N,this.span)}encode(v,N,U=0){return n(N).writeUIntLE(v,U,this.span),this.span}}ae.UInt=c;class u extends r{constructor(v,N){if(super(v,N),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,N=0){return n(v).readUIntBE(N,this.span)}encode(v,N,U=0){return n(N).writeUIntBE(v,U,this.span),this.span}}ae.UIntBE=u;class d extends r{constructor(v,N){if(super(v,N),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,N=0){return n(v).readIntLE(N,this.span)}encode(v,N,U=0){return n(N).writeIntLE(v,U,this.span),this.span}}ae.Int=d;class h extends r{constructor(v,N){if(super(v,N),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,N=0){return n(v).readIntBE(N,this.span)}encode(v,N,U=0){return n(N).writeIntBE(v,U,this.span),this.span}}ae.IntBE=h;const p=Math.pow(2,32);function b(m){const v=Math.floor(m/p),N=m-v*p;return{hi32:v,lo32:N}}function g(m,v){return m*p+v}class w extends r{constructor(v){super(8,v)}decode(v,N=0){const U=n(v),Q=U.readUInt32LE(N),ee=U.readUInt32LE(N+4);return g(ee,Q)}encode(v,N,U=0){const Q=b(v),ee=n(N);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,N=0){const U=n(v),Q=U.readUInt32BE(N),ee=U.readUInt32BE(N+4);return g(Q,ee)}encode(v,N,U=0){const Q=b(v),ee=n(N);return ee.writeUInt32BE(Q.hi32,U),ee.writeUInt32BE(Q.lo32,U+4),8}}ae.NearUInt64BE=S;class P extends r{constructor(v){super(8,v)}decode(v,N=0){const U=n(v),Q=U.readUInt32LE(N),ee=U.readInt32LE(N+4);return g(ee,Q)}encode(v,N,U=0){const Q=b(v),ee=n(N);return ee.writeUInt32LE(Q.lo32,U),ee.writeInt32LE(Q.hi32,U+4),8}}ae.NearInt64=P;class O extends r{constructor(v){super(8,v)}decode(v,N=0){const U=n(v),Q=U.readInt32BE(N),ee=U.readUInt32BE(N+4);return g(Q,ee)}encode(v,N,U=0){const Q=b(v),ee=n(N);return ee.writeInt32BE(Q.hi32,U),ee.writeUInt32BE(Q.lo32,U+4),8}}ae.NearInt64BE=O;class $ extends r{constructor(v){super(4,v)}decode(v,N=0){return n(v).readFloatLE(N)}encode(v,N,U=0){return n(N).writeFloatLE(v,U),4}}ae.Float=$;class R extends r{constructor(v){super(4,v)}decode(v,N=0){return n(v).readFloatBE(N)}encode(v,N,U=0){return n(N).writeFloatBE(v,U),4}}ae.FloatBE=R;class j extends r{constructor(v){super(8,v)}decode(v,N=0){return n(v).readDoubleLE(N)}encode(v,N,U=0){return n(N).writeDoubleLE(v,U),8}}ae.Double=j;class q extends r{constructor(v){super(8,v)}decode(v,N=0){return n(v).readDoubleBE(N)}encode(v,N,U=0){return n(N).writeDoubleBE(v,U),8}}ae.DoubleBE=q;class W extends r{constructor(v,N,U){if(!(v instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(N instanceof s&&N.isCount()||Number.isInteger(N)&&0<=N))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let Q=-1;!(N instanceof s)&&0<v.span&&(Q=N*v.span),super(Q,U),this.elementLayout=v,this.count=N}getSpan(v,N=0){if(0<=this.span)return this.span;let U=0,Q=this.count;if(Q instanceof s&&(Q=Q.decode(v,N)),0<this.elementLayout.span)U=Q*this.elementLayout.span;else{let ee=0;for(;ee<Q;)U+=this.elementLayout.getSpan(v,N+U),++ee}return U}decode(v,N=0){const U=[];let Q=0,ee=this.count;for(ee instanceof s&&(ee=ee.decode(v,N));Q<ee;)U.push(this.elementLayout.decode(v,N)),N+=this.elementLayout.getSpan(v,N),Q+=1;return U}encode(v,N,U=0){const Q=this.elementLayout,ee=v.reduce((Z,Y)=>Z+Q.encode(Y,N,U+Z),0);return this.count instanceof s&&this.count.encode(v.length,N,U),ee}}ae.Sequence=W;class F extends r{constructor(v,N,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 N=="boolean"&&U===void 0&&(U=N,N=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,N),this.fields=v,this.decodePrefixes=!!U}getSpan(v,N=0){if(0<=this.span)return this.span;let U=0;try{U=this.fields.reduce((Q,ee)=>{const Z=ee.getSpan(v,N);return N+=Z,Q+Z},0)}catch(Q){throw new RangeError("indeterminate span")}return U}decode(v,N=0){e(v);const U=this.makeDestinationObject();for(const Q of this.fields)if(Q.property!==void 0&&(U[Q.property]=Q.decode(v,N)),N+=Q.getSpan(v,N),this.decodePrefixes&&v.length===N)break;return U}encode(v,N,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,N,U),0>re&&(re=Y.getSpan(N,U)))}ee=U,U+=re}return ee+Z-Q}fromArray(v){const N=this.makeDestinationObject();for(const U of this.fields)U.property!==void 0&&0<v.length&&(N[U.property]=v.shift());return N}layoutFor(v){if(typeof v!="string")throw new TypeError("property must be string");for(const N of this.fields)if(N.property===v)return N}offsetOf(v){if(typeof v!="string")throw new TypeError("property must be string");let N=0;for(const U of this.fields){if(U.property===v)return N;0>U.span?N=-1:0<=N&&(N+=U.span)}}}ae.Structure=F;class V{constructor(v){this.property=v}decode(v,N){throw new Error("UnionDiscriminator is abstract")}encode(v,N,U){throw new Error("UnionDiscriminator is abstract")}}ae.UnionDiscriminator=V;class G extends V{constructor(v,N){if(!(v instanceof s&&v.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(N||v.property||"variant"),this.layout=v}decode(v,N){return this.layout.decode(v,N)}encode(v,N,U){return this.layout.encode(v,N,U)}}ae.UnionLayoutDiscriminator=G;class z extends r{constructor(v,N,U){let Q;if(v instanceof c||v instanceof u)Q=new G(new l(v));else if(v instanceof s&&v.isCount())Q=new G(v);else if(v instanceof V)Q=v;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(N===void 0&&(N=null),!(N===null||N instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(N!==null){if(0>N.span)throw new Error("defaultLayout must have constant span");N.property===void 0&&(N=N.replicate("content"))}let ee=-1;N&&(ee=N.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=N,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,N=0){if(0<=this.span)return this.span;const U=this.getVariant(v,N);if(!U)throw new Error("unable to determine span for unrecognized variant");return U.getSpan(v,N)}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 N=this.registry[v[this.discriminator.property]];if(N&&(!N.layout||N.property&&Object.prototype.hasOwnProperty.call(v,N.property)))return N}else for(const N in this.registry){const U=this.registry[N];if(U.property&&Object.prototype.hasOwnProperty.call(v,U.property))return U}throw new Error("unable to infer src variant")}decode(v,N=0){let U;const Q=this.discriminator,ee=Q.decode(v,N),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,N+re)}else U=Z.decode(v,N);return U}encode(v,N,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],N,U),Y+Z.encode(v[Z.property],N,U+Y)}return Q.encode(v,N,U)}addVariant(v,N,U){const Q=new k(this,v,N,U);return this.registry[v]=Q,Q}getVariant(v,N=0){let U;return v instanceof Uint8Array?U=this.discriminator.decode(v,N):U=v,this.registry[U]}}ae.Union=z;class k extends r{constructor(v,N,U,Q){if(!(v instanceof z))throw new TypeError("union must be a Union");if(!Number.isInteger(N)||0>N)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=N,this.layout=U||null}getSpan(v,N=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,N+U)),U+Q}decode(v,N=0){const U=this.makeDestinationObject();if(this!==this.union.getVariant(v,N))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,N+Q):this.property?U[this.property]=!0:this.union.usesPrefixDiscriminator&&(U[this.union.discriminator.property]=this.variant),U}encode(v,N,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,N,U);let ee=Q;if(this.layout&&(this.layout.encode(v[this.property],N,U+Q),ee+=this.layout.getSpan(N,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=k;function f(m){return 0>m&&(m+=4294967296),m}class y extends r{constructor(v,N,U){if(!(v instanceof c||v instanceof u))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof N=="string"&&U===void 0&&(U=N,N=!1),4<v.span)throw new RangeError("word cannot exceed 32 bits");super(v.span,U),this.word=v,this.msb=!!N,this.fields=[];let Q=0;this._packedSetValue=function(ee){return Q=f(ee),this},this._packedGetValue=function(){return Q}}decode(v,N=0){const U=this.makeDestinationObject(),Q=this.word.decode(v,N);this._packedSetValue(Q);for(const ee of this.fields)ee.property!==void 0&&(U[ee.property]=ee.decode(v));return U}encode(v,N,U=0){const Q=this.word.decode(N,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(),N,U)}addField(v,N){const U=new E(this,v,N);return this.fields.push(U),U}addBoolean(v){const N=new I(this,v);return this.fields.push(N),N}fieldFor(v){if(typeof v!="string")throw new TypeError("property must be string");for(const N of this.fields)if(N.property===v)return N}}ae.BitStructure=y;class E{constructor(v,N,U){if(!(v instanceof y))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(N)||0>=N)throw new TypeError("bits must be positive integer");const Q=8*v.span,ee=v.fields.reduce((Z,Y)=>Z+Y.bits,0);if(N+ee>Q)throw new Error("bits too long for span remainder ("+(Q-ee)+" of "+Q+" remain)");this.container=v,this.bits=N,this.valueMask=(1<<N)-1,N===32&&(this.valueMask=4294967295),this.start=ee,this.container.msb&&(this.start=Q-ee-N),this.wordMask=f(this.valueMask<<this.start),this.property=U}decode(v,N){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 N=this.container._packedGetValue(),U=f(v<<this.start);this.container._packedSetValue(f(N&~this.wordMask)|U)}}ae.BitField=E;class I extends E{constructor(v,N){super(v,1,N)}decode(v,N){return!!super.decode(v,N)}encode(v){typeof v=="boolean"&&(v=+v),super.encode(v)}}ae.Boolean=I;class B extends r{constructor(v,N){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,N),this.length=v}getSpan(v,N){let U=this.span;return 0>U&&(U=this.length.decode(v,N)),U}decode(v,N=0){let U=this.span;return 0>U&&(U=this.length.decode(v,N)),n(v).slice(N,N+U)}encode(v,N,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>N.length)throw new RangeError("encoding overruns Uint8Array");const ee=n(v);return n(N).write(ee.toString("hex"),U,Q,"hex"),this.length instanceof s&&this.length.encode(Q,N,U),Q}}ae.Blob=B;class D extends r{constructor(v){super(-1,v)}getSpan(v,N=0){e(v);let U=N;for(;U<v.length&&v[U]!==0;)U+=1;return 1+U-N}decode(v,N=0){const U=this.getSpan(v,N);return n(v).slice(N,N+U-1).toString("utf-8")}encode(v,N,U=0){typeof v!="string"&&(v=String(v));const Q=t.Buffer.from(v,"utf8"),ee=Q.length;if(U+ee>N.length)throw new RangeError("encoding overruns Buffer");const Z=n(N);return Q.copy(Z,U),Z[U+ee]=0,ee+1}}ae.CString=D;class M extends r{constructor(v,N){if(typeof v=="string"&&N===void 0&&(N=v,v=void 0),v===void 0)v=-1;else if(!Number.isInteger(v))throw new TypeError("maxSpan must be an integer");super(-1,N),this.maxSpan=v}getSpan(v,N=0){return e(v),v.length-N}decode(v,N=0){const U=this.getSpan(v,N);if(0<=this.maxSpan&&this.maxSpan<U)throw new RangeError("text length exceeds maxSpan");return n(v).slice(N,N+U).toString("utf-8")}encode(v,N,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>N.length)throw new RangeError("encoding overruns Buffer");return Q.copy(n(N),U),ee}}ae.UTF8=M;class T extends r{constructor(v,N){super(0,N),this.value=v}decode(v,N){return this.value}encode(v,N,U){return 0}}return ae.Constant=T,ae.greedy=(m,v)=>new a(m,v),ae.offset=(m,v,N)=>new l(m,v,N),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 P(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 O(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,N)=>new F(m,v,N),ae.bits=(m,v,N)=>new y(m,v,N),ae.seq=(m,v,N)=>new W(m,v,N),ae.union=(m,v,N)=>new z(m,v,N),ae.unionLayoutDiscriminator=(m,v)=>new G(m,v),ae.blob=(m,v)=>new B(m,v),ae.cstr=m=>new D(m),ae.utf8=(m,v)=>new M(m,v),ae.constant=(m,v)=>new T(m,v),ae}var X=vG();class wG 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 xG(t){return kd(t)&&typeof t[Symbol.iterator]=="function"}function kd(t){return typeof t=="object"&&t!=null}function Sp(t){return kd(t)&&!Array.isArray(t)}function oi(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function EG(t){const{done:e,value:n}=t.next();return e?void 0:n}function AG(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*hI(t,e,n,r){xG(t)||(t=[t]);for(const i of t){const o=AG(i,e,n,r);o&&(yield o)}}function*jy(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=jy(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 p of h)p[0]?(l=p[0].refinement!=null?"not_refined":"not_valid",yield[p[0],void 0]):o&&(u=p[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 Li=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 hI(u,c,this,l)}:this.validator=()=>[],o?this.refiner=(l,c)=>{const u=o(l,c);return hI(u,c,this,l)}:this.refiner=()=>[]}assert(e,n){return SG(e,this,n)}create(e,n){return Cd(e,this,n)}is(e){return pI(e,this)}mask(e,n){return kG(e,this,n)}validate(e,n={}){return Id(e,this,n)}};function SG(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 kG(t,e,n){const r=Id(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function pI(t,e){return!Id(t,e)[0]}function Id(t,e,n={}){const r=jy(t,e,n),i=EG(r);return i[0]?[new wG(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 Li({type:t,schema:null,validator:e})}function CG(){return Oa("any",()=>!0)}function we(t){return new Li({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 Fi(){return Oa("boolean",t=>typeof t=="boolean")}function Ky(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 Li({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 IG(){return Oa("never",()=>!1)}function xe(t){return new Li({...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 Li({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function gI(t,e){return new Li({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 Sp(n)||`Expected an object, but received: ${oi(n)}`},coercer(n){return Sp(n)?{...n}:n}})}function ge(){return Oa("string",t=>typeof t=="string"||`Expected a string, but received: ${oi(t)}`)}function qy(t){const e=IG();return new Li({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 Li({type:"type",schema:t,*entries(n){if(kd(n))for(const r of e)yield[r,n[r],t[r]]},validator(n){return Sp(n)||`Expected an object, but received: ${oi(n)}`},coercer(n){return Sp(n)?{...n}:n}})}function Hn(t){const e=t.map(n=>n.type).join(" | ");return new Li({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]=jy(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 Li({...t,coercer:(r,i)=>pI(r,e)?t.coercer(n(r,i),i):t.coercer(r,i)})}var kp,OG=new Uint8Array(16);function mI(){if(!kp&&(kp=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!kp))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return kp(OG)}const TG=/^(?:[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 Cp(t){return typeof t=="string"&&TG.test(t)}for(var En=[],Yy=0;Yy<256;++Yy)En.push((Yy+256).toString(16).substr(1));function Ip(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(!Cp(n))throw TypeError("Stringified UUID is invalid");return n}var yI,Qy,Xy=0,Jy=0;function PG(t,e,n){var r=e&&n||0,i=e||new Array(16);t=t||{};var o=t.node||yI,s=t.clockseq!==void 0?t.clockseq:Qy;if(o==null||s==null){var a=t.random||(t.rng||mI)();o==null&&(o=yI=[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:Jy+1,u=l-Xy+(c-Jy)/1e4;if(u<0&&t.clockseq===void 0&&(s=s+1&16383),(u<0||l>Xy)&&t.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Xy=l,Jy=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 p=0;p<6;++p)i[r+p]=o[p];return e||Ip(i)}function bI(t){if(!Cp(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 NG(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var BG="6ba7b810-9dad-11d1-80b4-00c04fd430c8",RG="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function vI(t,e,n){function r(i,o,s,a){if(typeof i=="string"&&(i=NG(i)),typeof o=="string"&&(o=bI(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 Ip(l)}try{r.name=t}catch(i){}return r.DNS=BG,r.URL=RG,r}function MG(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 LG(FG(_G(t),t.length*8))}function LG(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 wI(t){return(t+64>>>9<<4)+14+1}function FG(t,e){t[e>>5]|=128<<e%32,t[wI(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=ms(n,a),r=ms(r,l),i=ms(i,c),o=ms(o,u)}return[n,r,i,o]}function _G(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(wI(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function ms(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function VG(t,e){return t<<e|t>>>32-e}function Op(t,e,n,r,i,o){return ms(VG(ms(ms(e,t),ms(r,o)),i),n)}function On(t,e,n,r,i,o,s){return Op(e&n|~e&r,t,e,i,o,s)}function Tn(t,e,n,r,i,o,s){return Op(e&r|n&~r,t,e,i,o,s)}function Pn(t,e,n,r,i,o,s){return Op(e^n^r,t,e,i,o,s)}function Nn(t,e,n,r,i,o,s){return Op(n^(e|~r),t,e,i,o,s)}var DG=vI("v3",48,MG);function zG(t,e,n){t=t||{};var r=t.random||(t.rng||mI)();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 Ip(r)}function UG(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 Zy(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),p=0;p<16;++p)h[p]=a[d][p];for(var b=16;b<80;++b)h[b]=Zy(h[b-3]^h[b-8]^h[b-14]^h[b-16],1);for(var g=n[0],w=n[1],S=n[2],P=n[3],O=n[4],$=0;$<80;++$){var R=Math.floor($/20),j=Zy(g,5)+UG(R,w,S,P)+O+e[R]+h[$]>>>0;O=P,P=S,S=Zy(w,30)>>>0,w=g,g=j}n[0]=n[0]+g>>>0,n[1]=n[1]+w>>>0,n[2]=n[2]+S>>>0,n[3]=n[3]+P>>>0,n[4]=n[4]+O>>>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 HG=vI("v5",80,$G);const WG="00000000-0000-0000-0000-000000000000";function GG(t){if(!Cp(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const xI=lu(Object.freeze(Object.defineProperty({__proto__:null,NIL:WG,parse:bI,stringify:Ip,v1:PG,v3:DG,v4:zG,v5:HG,validate:Cp,version:GG},Symbol.toStringTag,{value:"Module"})));var eb,EI;function jG(){if(EI)return eb;EI=1;const t=xI.v4;return eb=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},eb}var tb,AI;function KG(){if(AI)return tb;AI=1;const t=xI.v4,e=jG(),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 tb=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(p){if(h)return s(p);throw p}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,p){a._parseResponse(h,p,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)},tb}KG();var nb={exports:{}},SI;function qG(){return SI||(SI=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 p=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],p]:l._events[b].push(p):(l._events[b]=p,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,p=d.length,b=new Array(p);h<p;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,p,b){var g=n?n+c:c;if(!this._events[g])return!1;var w=this._events[g],S=arguments.length,P,O;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,p),!0;case 6:return w.fn.call(w.context,u,d,h,p,b),!0}for(O=1,P=new Array(S-1);O<S;O++)P[O-1]=arguments[O];w.fn.apply(w.context,P)}else{var $=w.length,R;for(O=0;O<$;O++)switch(w[O].once&&this.removeListener(c,w[O].fn,void 0,!0),S){case 1:w[O].fn.call(w[O].context);break;case 2:w[O].fn.call(w[O].context,u);break;case 3:w[O].fn.call(w[O].context,u,d);break;case 4:w[O].fn.call(w[O].context,u,d,h);break;default:if(!P)for(R=1,P=new Array(S-1);R<S;R++)P[R-1]=arguments[R];w[O].fn.apply(w[O].context,P)}}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 p=n?n+c:c;if(!this._events[p])return this;if(!u)return s(this,p),this;var b=this._events[p];if(b.fn)b.fn===u&&(!h||b.once)&&(!d||b.context===d)&&s(this,p);else{for(var g=0,w=[],S=b.length;g<S;g++)(b[g].fn!==u||h&&!b[g].once||d&&b[g].context!==d)&&w.push(b[g]);w.length?this._events[p]=w.length===1?w[0]:w:s(this,p)}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}(nb)),nb.exports}qG();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kI=(t,e)=>(t+(t>=0?e:-e)/CI)/e;function YG(t,e,n){const[[r,i],[o,s]]=e,a=kI(s*t,n),l=kI(-i*t,n);let c=t-a*r-l*o,u=-a*i-l*s;const d=c<Oo,h=u<Oo;d&&(c=-c),h&&(u=-u);const p=Ed(Math.ceil(RC(n)/2))+oc;if(c<Oo||c>=p||u<Oo||u>=p)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:c,k2neg:h,k2:u}}function rb(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function ib(t,e){const n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return Aa(n.lowS,"lowS"),Aa(n.prehash,"prehash"),n.format!==void 0&&rb(n.format),n}class QG extends Error{constructor(e=""){super(e)}}const Io={Err:QG,_tlv:{encode:(t,e)=>{const{Err:n}=Io;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=hp(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?hp(i.length/2|128):"";return hp(t)+o+i+e},decode(t,e){const{Err:n}=Io;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}=Io;if(t<Oo)throw new e("integer: negative integers are not allowed");let n=hp(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}=Io;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 pp(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=Io,i=At("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}=Io,r=e.encode(2,n.encode(t.r)),i=e.encode(2,n.encode(t.s)),o=r+i;return e.encode(48,o)}},Oo=BigInt(0),oc=BigInt(1),CI=BigInt(2),Tp=BigInt(3),XG=BigInt(4);function sc(t,e){const{BYTES:n}=t;let r;if(typeof e=="bigint")r=e;else{let i=At("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 JG(t,e={}){const n=eI("weierstrass",t,e),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s,n:a}=o;Ad(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=OI(r,i);function u(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function d(z,k,f){const{x:y,y:E}=k.toAffine(),I=r.toBytes(y);if(Aa(f,"isCompressed"),f){u();const B=!r.isOdd(E);return Ii(II(B),I)}else return Ii(Uint8Array.of(4),I,r.toBytes(E))}function h(z){ii(z,void 0,"Point");const{publicKey:k,publicKeyUncompressed:f}=c,y=z.length,E=z[0],I=z.subarray(1);if(y===k&&(E===2||E===3)){const B=r.fromBytes(I);if(!r.isValid(B))throw new Error("bad point: is not on curve, wrong x");const D=g(B);let M;try{M=r.sqrt(D)}catch(v){const N=v instanceof Error?": "+v.message:"";throw new Error("bad point: is not on curve, sqrt error"+N)}u();const T=r.isOdd(M);return(E&1)===1!==T&&(M=r.neg(M)),{x:B,y:M}}else if(y===f&&E===4){const B=r.BYTES,D=r.fromBytes(I.subarray(0,B)),M=r.fromBytes(I.subarray(B,B*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=${k} or uncompressed=${f}`)}const p=e.toBytes||d,b=e.fromBytes||h;function g(z){const k=r.sqr(z),f=r.mul(k,z);return r.add(r.add(f,r.mul(z,o.a)),o.b)}function w(z,k){const f=r.sqr(k),y=g(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,Tp),XG),P=r.mul(r.sqr(o.b),BigInt(27));if(r.is0(r.add(S,P)))throw new Error("bad curve params: a or b");function O(z,k,f=!1){if(!r.isValid(k)||f&&r.is0(k))throw new Error(`bad point coordinate ${z}`);return k}function $(z){if(!(z instanceof F))throw new Error("ProjectivePoint expected")}function R(z){if(!l||!l.basises)throw new Error("no endo");return YG(z,l.basises,i.ORDER)}const j=gp((z,k)=>{const{X:f,Y:y,Z:E}=z;if(r.eql(E,r.ONE))return{x:f,y};const I=z.is0();k==null&&(k=I?r.ONE:r.inv(E));const B=r.mul(f,k),D=r.mul(y,k),M=r.mul(E,k);if(I)return{x:r.ZERO,y:r.ZERO};if(!r.eql(M,r.ONE))throw new Error("invZ was invalid");return{x:B,y:D}}),q=gp(z=>{if(z.is0()){if(e.allowInfinityPoint&&!r.is0(z.Y))return;throw new Error("bad point: ZERO")}const{x:k,y:f}=z.toAffine();if(!r.isValid(k)||!r.isValid(f))throw new Error("bad point: x or y not field elements");if(!w(k,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 W(z,k,f,y,E){return f=new F(r.mul(f.X,z),f.Y,f.Z),k=mp(y,k),f=mp(E,f),k.add(f)}class F{constructor(k,f,y){this.X=O("x",k),this.Y=O("y",f,!0),this.Z=O("z",y),Object.freeze(this)}static CURVE(){return o}static fromAffine(k){const{x:f,y}=k||{};if(!k||!r.isValid(f)||!r.isValid(y))throw new Error("invalid affine point");if(k instanceof F)throw new Error("projective point not allowed");return r.is0(f)&&r.is0(y)?F.ZERO:new F(f,y,r.ONE)}static fromBytes(k){const f=F.fromAffine(b(ii(k,void 0,"point")));return f.assertValidity(),f}static fromHex(k){return F.fromBytes(At("pointHex",k))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=8,f=!0){return G.createCache(this,k),f||this.multiply(Tp),this}assertValidity(){q(this)}hasEvenY(){const{y:k}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(k)}equals(k){$(k);const{X:f,Y:y,Z:E}=this,{X:I,Y:B,Z:D}=k,M=r.eql(r.mul(f,D),r.mul(I,E)),T=r.eql(r.mul(y,D),r.mul(B,E));return M&&T}negate(){return new F(this.X,r.neg(this.Y),this.Z)}double(){const{a:k,b:f}=o,y=r.mul(f,Tp),{X:E,Y:I,Z:B}=this;let D=r.ZERO,M=r.ZERO,T=r.ZERO,m=r.mul(E,E),v=r.mul(I,I),N=r.mul(B,B),U=r.mul(E,I);return U=r.add(U,U),T=r.mul(E,B),T=r.add(T,T),D=r.mul(k,T),M=r.mul(y,N),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),T=r.mul(y,T),N=r.mul(k,N),U=r.sub(m,N),U=r.mul(k,U),U=r.add(U,T),T=r.add(m,m),m=r.add(T,m),m=r.add(m,N),m=r.mul(m,U),M=r.add(M,m),N=r.mul(I,B),N=r.add(N,N),m=r.mul(N,U),D=r.sub(D,m),T=r.mul(N,v),T=r.add(T,T),T=r.add(T,T),new F(D,M,T)}add(k){$(k);const{X:f,Y:y,Z:E}=this,{X:I,Y:B,Z:D}=k;let M=r.ZERO,T=r.ZERO,m=r.ZERO;const v=o.a,N=r.mul(o.b,Tp);let U=r.mul(f,I),Q=r.mul(y,B),ee=r.mul(E,D),Z=r.add(f,y),Y=r.add(I,B);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(B,D),re=r.mul(re,M),M=r.add(Q,ee),re=r.sub(re,M),m=r.mul(v,Y),M=r.mul(N,ee),m=r.add(M,m),M=r.sub(Q,m),m=r.add(Q,m),T=r.mul(M,m),Q=r.add(U,U),Q=r.add(Q,U),ee=r.mul(v,ee),Y=r.mul(N,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),T=r.add(T,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 F(M,T,m)}subtract(k){return this.add(k.negate())}is0(){return this.equals(F.ZERO)}multiply(k){const{endo:f}=e;if(!i.isValidNot0(k))throw new Error("invalid scalar: out of range");let y,E;const I=B=>G.cached(this,B,D=>Ia(F,D));if(f){const{k1neg:B,k1:D,k2neg:M,k2:T}=R(k),{p:m,f:v}=I(D),{p:N,f:U}=I(T);E=v.add(U),y=W(f.beta,m,N,B,M)}else{const{p:B,f:D}=I(k);y=B,E=D}return Ia(F,[y,E])[0]}multiplyUnsafe(k){const{endo:f}=e,y=this;if(!i.isValid(k))throw new Error("invalid scalar: out of range");if(k===Oo||y.is0())return F.ZERO;if(k===oc)return y;if(G.hasCache(this))return this.multiply(k);if(f){const{k1neg:E,k1:I,k2neg:B,k2:D}=R(k),{p1:M,p2:T}=GW(F,y,I,D);return W(f.beta,M,T,E,B)}else return G.unsafe(y,k)}multiplyAndAddUnsafe(k,f,y){const E=this.multiplyUnsafe(f).add(k.multiplyUnsafe(y));return E.is0()?void 0:E}toAffine(k){return j(this,k)}isTorsionFree(){const{isTorsionFree:k}=e;return s===oc?!0:k?k(F,this):G.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:k}=e;return s===oc?this:k?k(F,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(k=!0){return Aa(k,"isCompressed"),this.assertValidity(),p(F,this,k)}toHex(k=!0){return ra(this.toBytes(k))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(k=!0){return this.toBytes(k)}_setWindowSize(k){this.precompute(k)}static normalizeZ(k){return Ia(F,k)}static msm(k,f){return JC(F,i,k,f)}static fromPrivateKey(k){return F.BASE.multiply(sc(i,k))}}F.BASE=new F(o.Gx,o.Gy,r.ONE),F.ZERO=new F(r.ZERO,r.ONE,r.ZERO),F.Fp=r,F.Fn=i;const V=i.BITS,G=new XC(F,e.endo?Math.ceil(V/2):V);return F.BASE.precompute(8),F}function II(t){return Uint8Array.of(t?2:3)}function OI(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function ZG(t,e={}){const{Fn:n}=t,r=e.randomBytes||om,i=Object.assign(OI(t.Fp,n),{seed:jC(n.ORDER)});function o(p){try{return!!sc(n,p)}catch(b){return!1}}function s(p,b){const{publicKey:g,publicKeyUncompressed:w}=i;try{const S=p.length;return b===!0&&S!==g||b===!1&&S!==w?!1:!!t.fromBytes(p)}catch(S){return!1}}function a(p=r(i.seed)){return $W(ii(p,i.seed,"seed"),n.ORDER)}function l(p,b=!0){return t.BASE.multiply(sc(n,p)).toBytes(b)}function c(p){const b=a(p);return{secretKey:b,publicKey:l(b)}}function u(p){if(typeof p=="bigint")return!1;if(p instanceof t)return!0;const{secretKey:b,publicKey:g,publicKeyUncompressed:w}=i;if(n.allowedLengths||b===g)return;const S=At("key",p).length;return S===g||S===w}function d(p,b,g=!0){if(u(p)===!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,p);return t.fromHex(b).multiply(w).toBytes(g)}return Object.freeze({getPublicKey:l,getSharedSecret:d,keygen:c,Point:t,utils:{isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a,isValidPrivateKey:o,randomPrivateKey:a,normPrivateKeyToScalar:p=>sc(n,p),precompute(p=8,b=t.BASE){return b.precompute(p,!1)}},lengths:i})}function ej(t,e,n={}){IE(e),Ad(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||om,i=n.hmac||((f,...y)=>qE(e,f,Ii(...y))),{Fp:o,Fn:s}=t,{ORDER:a,BITS:l}=s,{keygen:c,getPublicKey:u,getSharedSecret:d,utils:h,lengths:p}=ZG(t,n),b={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},g="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 P(f,y){rb(y);const E=p.signature,I=y==="compact"?E:y==="recovered"?E+1:void 0;return ii(f,I,`${y} signature`)}class O{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=g){P(y,E);let I;if(E==="der"){const{r:T,s:m}=Io.toSig(ii(y));return new O(T,m)}E==="recovered"&&(I=y[0],E="compact",y=y.subarray(1));const B=s.BYTES,D=y.subarray(0,B),M=y.subarray(B,B*2);return new O(s.fromBytes(D),s.fromBytes(M),I)}static fromHex(y,E){return this.fromBytes(wh(y),E)}addRecoveryBit(y){return new O(this.r,this.s,y)}recoverPublicKey(y){const E=o.ORDER,{r:I,s:B,recovery:D}=this;if(D==null||![0,1,2,3].includes(D))throw new Error("recovery id invalid");if(a*CI<E&&D>1)throw new Error("recovery id is ambiguous for h>1 curve");const T=D===2||D===3?I+a:I;if(!o.isValid(T))throw new Error("recovery id 2 or 3 invalid");const m=o.toBytes(T),v=t.fromBytes(Ii(II((D&1)===0),m)),N=s.inv(T),U=R(At("msgHash",y)),Q=s.create(-U*N),ee=s.create(B*N),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=g){if(rb(y),y==="der")return wh(Io.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 ra(this.toBytes(y))}assertValidity(){}static fromCompact(y){return O.fromBytes(At("sig",y),"compact")}static fromDER(y){return O.fromBytes(At("sig",y),"der")}normalizeS(){return this.hasHighS()?new O(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return ra(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return ra(this.toBytes("compact"))}}const $=n.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const E=pp(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 My("num < 2^"+l,f,Oo,j),s.toBytes(f)}function W(f,y){return ii(f,void 0,"message"),y?ii(e(f),void 0,"prehashed message"):f}function F(f,y,E){if(["recovered","canonical"].some(Q=>Q in E))throw new Error("sign() legacy options not supported");const{lowS:I,prehash:B,extraEntropy:D}=ib(E,b);f=W(f,B);const M=R(f),T=sc(s,y),m=[q(T),q(M)];if(D!=null&&D!==!1){const Q=D===!0?r(p.secretKey):D;m.push(At("extraEntropy",Q))}const v=Ii(...m),N=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===Oo)return;const de=s.create(Z*s.create(N+re*T));if(de===Oo)return;let se=(Y.x===re?0:2)|Number(Y.y&oc),ye=de;return I&&w(de)&&(ye=s.neg(de),se^=1),new O(re,ye,se)}return{seed:v,k2sig:U}}function V(f,y,E={}){f=At("message",f);const{seed:I,k2sig:B}=F(f,y,E);return BW(e.outputLen,s.BYTES,i)(I,B)}function G(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 O(f.r,f.s);else if(E){try{y=O.fromBytes(At("sig",f),"der")}catch(B){if(!(B instanceof Io.Err))throw B}if(!y)try{y=O.fromBytes(At("sig",f),"compact")}catch(B){return!1}}return y||!1}function z(f,y,E,I={}){const{lowS:B,prehash:D,format:M}=ib(I,b);if(E=At("publicKey",E),y=W(At("message",y),D),"strict"in I)throw new Error("options.strict was renamed to lowS");const T=M===void 0?G(f):O.fromBytes(At("sig",f),M);if(T===!1)return!1;try{const m=t.fromBytes(E);if(B&&T.hasHighS())return!1;const{r:v,s:N}=T,U=R(y),Q=s.inv(N),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 k(f,y,E={}){const{prehash:I}=ib(E,b);return y=W(y,I),O.fromBytes(f,"recovered").recoverPublicKey(y).toBytes()}return Object.freeze({keygen:c,getPublicKey:u,getSharedSecret:d,utils:h,lengths:p,Point:t,sign:V,verify:z,recoverPublicKey:k,Signature:O,hash:e})}function tj(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 nj(t){const{CURVE:e,curveOpts:n}=tj(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 rj(t,e){const n=e.Point;return Object.assign({},e,{ProjectivePoint:n,CURVE:Object.assign({},t,WC(n.Fn.ORDER,n.Fn.BITS))})}function ij(t){const{CURVE:e,curveOpts:n,hash:r,ecdsaOpts:i}=nj(t),o=JG(e,n),s=ej(o,r,i);return rj(t,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function oj(t,e){const n=r=>ij({...t,hash:r});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ob={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},sj={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},TI=BigInt(2);function aj(t){const e=ob.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=St(u,n,e)*u%e,h=St(d,n,e)*u%e,p=St(h,TI,e)*c%e,b=St(p,i,e)*p%e,g=St(b,o,e)*b%e,w=St(g,a,e)*g%e,S=St(w,l,e)*w%e,P=St(S,a,e)*g%e,O=St(P,n,e)*u%e,$=St(O,s,e)*b%e,R=St($,r,e)*c%e,j=St(R,TI,e);if(!sb.eql(sb.sqr(j),t))throw new Error("Cannot find square root");return j}const sb=ka(ob.p,{sqrt:aj}),lj=oj({...ob,Fp:sb,lowS:!0,endo:sj},WE);Sd.utils.randomPrivateKey,Sd.getPublicKey;function PI(t){try{return Sd.ExtendedPoint.fromHex(t),!0}catch(e){return!1}}const NI=(t,e)=>Sd.sign(t,e.slice(0,32)),cj=Sd.verify,Wn=t=>_e.Buffer.isBuffer(t)?t:t instanceof Uint8Array?_e.Buffer.from(t.buffer,t.byteOffset,t.byteLength):_e.Buffer.from(t);class uj{constructor(e){Object.assign(this,e)}encode(){return _e.Buffer.from(Gy.serialize(Pp,this))}static decode(e){return Gy.deserialize(Pp,this,e)}static decodeUnchecked(e){return Gy.deserializeUnchecked(Pp,this,e)}}const Pp=new Map;var BI;const dj=32,ys=32;function fj(t){return t._bn!==void 0}let RI=1;class ke extends uj{constructor(e){if(super({}),this._bn=void 0,fj(e))this._bn=e._bn;else{if(typeof e=="string"){const n=$n.decode(e);if(n.length!=ys)throw new Error("Invalid public key input");this._bn=new sI(n)}else this._bn=new sI(e);if(this._bn.byteLength()>ys)throw new Error("Invalid public key input")}}static unique(){const e=new ke(RI);return RI+=1,new ke(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return $n.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(_e.Buffer);if(e.length===ys)return e;const n=_e.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=_e.Buffer.concat([e.toBuffer(),_e.Buffer.from(n),r.toBuffer()]),o=GE(i);return new ke(o)}static createProgramAddressSync(e,n){let r=_e.Buffer.alloc(0);e.forEach(function(o){if(o.length>dj)throw new TypeError("Max seed length exceeded");r=_e.Buffer.concat([r,Wn(o)])}),r=_e.Buffer.concat([r,n.toBuffer(),_e.Buffer.from("ProgramDerivedAddress")]);const i=GE(r);if(PI(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(_e.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 PI(n.toBytes())}}BI=ke,ke.default=new BI("11111111111111111111111111111111"),Pp.set(ke,{kind:"struct",fields:[["_bn","u256"]]}),new ke("BPFLoader1111111111111111111111111111111111");const ac=1232,ab=127,Np=64;class Bp{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 Ge=(t="publicKey")=>X.blob(32,t),hj=(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:_e.Buffer.from(o,"utf8")};return r(l,s,a)},i.alloc=o=>X.u32().span+X.u32().span+_e.Buffer.from(o,"utf8").length,i},pj=(t="authorized")=>X.struct([Ge("staker"),Ge("withdrawer")],t),gj=(t="lockup")=>X.struct([X.ns64("unixTimestamp"),X.ns64("epoch"),Ge("custodian")],t),mj=(t="voteInit")=>X.struct([Ge("nodePubkey"),Ge("authorizedVoter"),Ge("authorizedWithdrawer"),X.u8("commission")],t),yj=(t="voteAuthorizeWithSeedArgs")=>X.struct([X.u32("voteAuthorizationType"),Ge("currentAuthorityDerivedKeyOwnerPubkey"),lc("currentAuthorityDerivedKeySeed"),Ge("newAuthorized")],t);function MI(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 MI({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 Rp{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 Rp(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 LI="Reached end of buffer unexpectedly";function To(t){if(t.length===0)throw new Error(LI);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(LI);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:$n.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Bp(this.staticAccountKeys)}static compile(e){const n=Rp.compile(e.instructions,e.payerKey),[r,i]=n.getMessageComponents(),s=new Bp(i).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:$n.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:p}=d,b=Array.from($n.decode(d.data));let g=[];vr(g,h.length);let w=[];return vr(w,b.length),{programIdIndex:p,keyIndicesCount:_e.Buffer.from(g),keyIndices:h,dataLength:_e.Buffer.from(w),data:b}});let i=[];vr(i,r.length);let o=_e.Buffer.alloc(ac);_e.Buffer.from(i).copy(o);let s=i.length;r.forEach(d=>{const p=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+=p}),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(Ge("key"),e,"keys"),Ge("recentBlockhash")]),l={numRequiredSignatures:_e.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:_e.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:_e.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:_e.Buffer.from(n),keys:this.accountKeys.map(d=>Wn(d.toBytes())),recentBlockhash:$n.decode(this.recentBlockhash)};let c=_e.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=To(n);if(r!==(r&ab))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=To(n),o=To(n),s=br(n);let a=[];for(let h=0;h<s;h++){const p=wr(n,0,ys);a.push(new ke(_e.Buffer.from(p)))}const l=wr(n,0,ys),c=br(n);let u=[];for(let h=0;h<c;h++){const p=To(n),b=br(n),g=wr(n,0,b),w=br(n),S=wr(n,0,w),P=$n.encode(_e.Buffer.from(S));u.push({programIdIndex:p,accounts:g,data:P})}const d={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:o},recentBlockhash:$n.encode(_e.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 Bp(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=Rp.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:p,readonly:b}]=d;r.push(h),i.writable.push(...p),i.readonly.push(...b)}}const[s,a]=n.getMessageComponents(),c=new Bp(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(Ge(),this.staticAccountKeys.length,"staticAccountKeys"),Ge("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:$n.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([Ge("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=To(n),i=r&ab;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:To(n),numReadonlySignedAccounts:To(n),numReadonlyUnsignedAccounts:To(n)},a=[],l=br(n);for(let b=0;b<l;b++)a.push(new ke(wr(n,0,ys)));const c=$n.encode(wr(n,0,ys)),u=br(n),d=[];for(let b=0;b<u;b++){const g=To(n),w=br(n),S=wr(n,0,w),P=br(n),O=new Uint8Array(wr(n,0,P));d.push({programIdIndex:g,accountKeyIndexes:S,data:O})}const h=br(n),p=[];for(let b=0;b<h;b++){const g=new ke(wr(n,0,ys)),w=br(n),S=wr(n,0,w),P=br(n),O=wr(n,0,P);p.push({accountKey:g,writableIndexes:S,readonlyIndexes:O})}return new Td({header:s,staticAccountKeys:a,recentBlockhash:c,compiledInstructions:d,addressTableLookups:p})}}const FI={deserializeMessageVersion(t){const e=t[0],n=e&ab;return n===e?"legacy":n},deserialize:t=>{const e=FI.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`)}},bj=_e.Buffer.alloc(Np).fill(0);class Bn{constructor(e){this.keys=void 0,this.programId=void 0,this.data=_e.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 Mp{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 g=0;g<n.length;g++)if(n[g].programId===void 0)throw new Error(`Transaction instruction index ${g} has undefined program id`);const i=[],o=[];n.forEach(g=>{g.keys.forEach(S=>{o.push({...S})});const w=g.programId.toString();i.includes(w)||i.push(w)}),i.forEach(g=>{o.push({pubkey:new ke(g),isSigner:!1,isWritable:!1})});const s=[];o.forEach(g=>{const w=g.pubkey.toString(),S=s.findIndex(P=>P.pubkey.toString()===w);S>-1?(s[S].isWritable=s[S].isWritable||g.isWritable,s[S].isSigner=s[S].isSigner||g.isSigner):s.push(g)}),s.sort(function(g,w){if(g.isSigner!==w.isSigner)return g.isSigner?-1:1;if(g.isWritable!==w.isWritable)return g.isWritable?-1:1;const S={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return g.pubkey.toBase58().localeCompare(w.pubkey.toBase58(),"en",S)});const a=s.findIndex(g=>g.pubkey.equals(r));if(a>-1){const[g]=s.splice(a,1);g.isSigner=!0,g.isWritable=!0,s.unshift(g)}else s.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const g of this.signatures){const w=s.findIndex(S=>S.pubkey.equals(g.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: ${g.publicKey.toString()}`)}let l=0,c=0,u=0;const d=[],h=[];s.forEach(({pubkey:g,isSigner:w,isWritable:S})=>{w?(d.push(g.toString()),l+=1,S||(c+=1)):(h.push(g.toString()),S||(u+=1))});const p=d.concat(h),b=n.map(g=>{const{data:w,programId:S}=g;return{programIdIndex:p.indexOf(S.toString()),accounts:g.keys.map(P=>p.indexOf(P.pubkey.toString())),data:$n.encode(w)}});return b.forEach(g=>{Nt(g.programIdIndex>=0),g.accounts.forEach(w=>Nt(w>=0))}),new Ta({header:{numRequiredSignatures:l,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:u},accountKeys:p,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=NI(r,i.secretKey);this._addSignature(i.publicKey,Wn(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=_e.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):cj(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=_e.Buffer.alloc(i);return Nt(n.length<256),_e.Buffer.from(r).copy(o,0),n.forEach(({signature:s},a)=>{s!==null&&(Nt(s.length===64,"signature has invalid length"),_e.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,Np);i.push($n.encode(_e.Buffer.from(s)))}return Mp.populate(Ta.from(n),i)}static populate(e,n=[]){const r=new Mp;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((i,o)=>{const s={signature:i==$n.encode(bj)?null:$n.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:$n.decode(i.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Lp{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 p=[];for(const b of i){const g=[];for(const S of b.accountKeyIndexes){const P=d.get(S);if(P===void 0)throw new Error(`Failed to find key for account key index ${S}`);const O=S<s;let $;O?$=S<c:S<d.staticAccountKeys.length?$=S-s<u:$=S-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,g.push({pubkey:P,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}`);p.push(new Bn({programId:w,data:Wn(b.data),keys:g}))}return new Lp({payerKey:h,instructions:p,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 Fp{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(Np));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(hj(),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,Np)));const o=FI.deserialize(new Uint8Array(n));return new Fp(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]=NI(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 lb=new ke("SysvarRecentB1ockHashes11111111111111111111"),_I=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:MI(t,e),r=_e.Buffer.alloc(n),i=Object.assign({instruction:t.index},e);return t.layout.encode(i,r),r}const vj=X.nu64("lamportsPerSignature"),VI=X.struct([X.u32("version"),X.u32("state"),Ge("authorizedPubkey"),Ge("nonce"),X.struct([vj],"feeCalculator")]).span;function wj(t,e){const n=_e.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 xj(t){return t.reduceRight((e,n)=>(e<<BigInt(8))+BigInt(n),BigInt(0))}const Ej=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}=Ej(n),o=n;return o.decode=(s,a)=>{const l=i(s,a);return xj(_e.Buffer.from(l))},o.encode=(s,a,l)=>{const c=wj(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"),Ge("programId")])},Assign:{index:1,layout:X.struct([X.u32("instruction"),Ge("programId")])},Transfer:{index:2,layout:X.struct([X.u32("instruction"),cc("lamports")])},CreateWithSeed:{index:3,layout:X.struct([X.u32("instruction"),Ge("base"),lc("seed"),X.ns64("lamports"),X.ns64("space"),Ge("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"),Ge("authorized")])},AuthorizeNonceAccount:{index:7,layout:X.struct([X.u32("instruction"),Ge("authorized")])},Allocate:{index:8,layout:X.struct([X.u32("instruction"),X.ns64("space")])},AllocateWithSeed:{index:9,layout:X.struct([X.u32("instruction"),Ge("base"),lc("seed"),X.ns64("space"),Ge("programId")])},AssignWithSeed:{index:10,layout:X.struct([X.u32("instruction"),Ge("base"),lc("seed"),Ge("programId")])},TransferWithSeed:{index:11,layout:X.struct([X.u32("instruction"),cc("lamports"),lc("seed"),Ge("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:Wn(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:Wn(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:Wn(e.basePubkey.toBuffer()),seed:e.seed,programId:Wn(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:Wn(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:Wn(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:Wn(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 Mp;"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:VI,programId:this.programId})):n.add(uc.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:VI,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:Wn(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:lb,isSigner:!1,isWritable:!1},{pubkey:_I,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:lb,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:lb,isSigner:!1,isWritable:!1},{pubkey:_I,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:Wn(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:Wn(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:Wn(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(Ge(),X.offset(X.u8(),-1),"authority")]);const kt=Od(Ky(ke),ge(),t=>new ke(t)),DI=qy([ge(),wt("base64")]),cb=Od(Ky(_e.Buffer),DI,t=>_e.Buffer.from(t[0],"base64"));function zI(t){return Hn([he({jsonrpc:wt("2.0"),id:ge(),result:t}),he({jsonrpc:wt("2.0"),id:ge(),error:he({code:ic(),message:ge(),data:Ce(CG())})})])}const Aj=zI(ic());function gt(t){return Od(zI(t),Aj,e=>"error"in e?e:{...e,result:Cd(e.result,t)})}function si(t){return gt(he({context:he({slot:le()}),value:t}))}function _p(t){return he({context:he({slot:le()}),value:t})}const Sj=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 kj=we(he({slot:le(),prioritizationFee:le()})),Cj=he({total:le(),validator:le(),foundation:le(),epoch:le()}),Ij=he({epoch:le(),slotIndex:le(),slotsInEpoch:le(),absoluteSlot:le(),blockHeight:Ce(le()),transactionCount:Ce(le())}),Oj=he({slotsPerEpoch:le(),leaderScheduleSlotOffset:le(),warmup:Fi(),firstNormalEpoch:le(),firstNormalSlot:le()}),Tj=gI(ge(),we(le())),Pa=xe(Hn([he({}),ge()])),Pj=he({err:Pa}),Nj=wt("receivedSignature");he({"solana-core":ge(),"feature-set":Ce(le())});const Bj=he({program:ge(),programId:kt,parsed:ic()}),Rj=he({programId:kt,accounts:we(kt),data:ge()});si(he({err:xe(Hn([he({}),ge()])),logs:xe(we(ge())),accounts:Ce(xe(we(xe(he({executable:Fi(),owner:ge(),lamports:le(),data:we(ge()),rentEpoch:Ce(le())}))))),unitsConsumed:Ce(le()),returnData:Ce(xe(he({programId:ge(),data:qy([ge(),wt("base64")])}))),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(Hn([Bj,Rj]))}))))})),si(he({byIdentity:gI(ge(),we(le())),range:he({firstSlot:le(),lastSlot:le()})})),gt(Sj),gt(Cj),gt(kj),gt(Ij),gt(Oj),gt(Tj),gt(le()),si(he({total:le(),circulating:le(),nonCirculating:le(),nonCirculatingAccounts:we(kt)}));const Mj=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:Fi(),owner:kt,lamports:le(),data:cb,rentEpoch:le()})})));const ub=he({program:ge(),parsed:ic(),space:le()});si(we(he({pubkey:kt,account:he({executable:Fi(),owner:kt,lamports:le(),data:ub,rentEpoch:le()})}))),si(we(he({lamports:le(),address:kt})));const db=he({executable:Fi(),owner:kt,lamports:le(),data:cb,rentEpoch:le()});he({pubkey:kt,account:db});const Lj=Od(Hn([Ky(_e.Buffer),ub]),Hn([DI,ub]),t=>Array.isArray(t)?Cd(t,cb):t),Fj=he({executable:Fi(),owner:kt,lamports:le(),data:Lj,rentEpoch:le()});he({pubkey:kt,account:Fj}),he({state:Hn([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:_p(db)});const _j=he({pubkey:kt,account:db});he({subscription:le(),result:_p(_j)});const Vj=he({parent:le(),slot:le(),root:le()});he({subscription:le(),result:Vj});const Dj=Hn([he({type:Hn([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:Dj}),he({subscription:le(),result:_p(Hn([Pj,Nj]))}),he({subscription:le(),result:le()}),he({pubkey:ge(),gossip:xe(ge()),tpu:xe(ge()),rpc:xe(ge()),version:xe(ge())});const UI=he({votePubkey:ge(),nodePubkey:ge(),activatedStake:le(),epochVoteAccount:Fi(),epochCredits:we(qy([le(),le(),le()])),commission:le(),lastVote:le(),rootSlot:xe(le())});gt(he({current:we(UI),delinquent:we(UI)}));const zj=Hn([wt("processed"),wt("confirmed"),wt("finalized")]),Uj=he({slot:le(),confirmations:xe(le()),err:Pa,confirmationStatus:Ce(zj)});si(we(xe(Uj))),gt(le());const $I=he({accountKey:kt,writableIndexes:we(le()),readonlyIndexes:we(le())}),fb=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($I))})}),HI=he({pubkey:kt,signer:Fi(),writable:Fi(),source:Ce(Hn([wt("transaction"),wt("lookupTable")]))}),WI=he({accountKeys:we(HI),signatures:we(ge())}),GI=he({parsed:ic(),program:ge(),programId:kt}),jI=he({accounts:we(kt),data:ge(),programId:kt}),$j=Hn([jI,GI]),Hj=Hn([he({parsed:ic(),program:ge(),programId:ge()}),he({accounts:we(ge()),data:ge(),programId:ge()})]),KI=Od($j,Hj,t=>"accounts"in t?Cd(t,jI):Cd(t,GI)),qI=he({signatures:we(ge()),message:he({accountKeys:we(HI),instructions:we(KI),recentBlockhash:ge(),addressTableLookups:Ce(xe(we($I)))})}),Vp=he({accountIndex:le(),mint:ge(),owner:Ce(ge()),programId:Ce(ge()),uiTokenAmount:Mj}),YI=he({writable:we(kt),readonly:we(kt)}),Dp=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(Vp))),postTokenBalances:Ce(xe(we(Vp))),loadedAddresses:Ce(YI),computeUnitsConsumed:Ce(le())}),hb=he({err:Pa,fee:le(),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(KI)})))),preBalances:we(le()),postBalances:we(le()),logMessages:Ce(xe(we(ge()))),preTokenBalances:Ce(xe(we(Vp))),postTokenBalances:Ce(xe(we(Vp))),loadedAddresses:Ce(YI),computeUnitsConsumed:Ce(le())}),dc=Hn([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:fb,meta:xe(Dp),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:WI,meta:xe(Dp),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:qI,meta:xe(hb),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:WI,meta:xe(hb),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:fb,meta:xe(Dp)})),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(Dp),blockTime:Ce(xe(le())),transaction:fb,version:Ce(dc)}))),gt(xe(he({slot:le(),transaction:qI,meta:xe(hb),blockTime:Ce(xe(le())),version:Ce(dc)}))),si(he({blockhash:ge(),lastValidBlockHeight:le()})),si(Fi());const Wj=he({slot:le(),numTransactions:le(),numSlots:le(),samplePeriodSecs:le()});gt(we(Wj)),si(xe(he({feeCalculator:he({lamportsPerSignature:le()})}))),gt(ge()),gt(ge());const Gj=he({err:Pa,logs:we(ge()),signature:ge()});he({result:_p(Gj),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(Ge(),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"),lj.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 QI;new ke("StakeConfig11111111111111111111111111111111");class XI{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}}QI=XI,XI.default=new QI(0,0,ke.default),Object.freeze({Initialize:{index:0,layout:X.struct([X.u32("instruction"),pj(),gj()])},Authorize:{index:1,layout:X.struct([X.u32("instruction"),Ge("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"),Ge("newAuthorized"),X.u32("stakeAuthorizationType"),lc("authoritySeed"),Ge("authorityOwner")])}}),new ke("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:X.struct([X.u32("instruction"),mj()])},Authorize:{index:1,layout:X.struct([X.u32("instruction"),Ge("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"),yj()])}}),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([Ge("nodePubkey"),Ge("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"),Ge("authorizedVoter")]),X.offset(X.u32(),-8),"authorizedVoters"),X.struct([X.seq(X.struct([Ge("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 bs=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())})},vs=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}}},zp=new ke("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),JI=new ke("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),ZI=new ke("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),Up=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 eO(t,e){return bs(this,arguments,void 0,function(n,r,i){var o;return i===void 0&&(i=zp.toBase58()),vs(this,function(s){switch(s.label){case 0:return[4,ke.findProgramAddress([r.toBuffer(),new ke(i).toBuffer(),n.toBuffer()],ZI)];case 1:return o=s.sent()[0],[2,o]}})})}function jj(t,e,n,r,i){i===void 0&&(i=zp);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:ZI,data:Buffer.alloc(0)})}function Kj(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 qj(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:zp,data:o})}function Yj(t){return bs(this,void 0,void 0,function(){var e,n,r;return vs(this,function(i){switch(i.label){case 0:return[4,tO(t)];case 1:return e=i.sent(),n=new ke(t.fromAddress),r=new Lp({payerKey:n,recentBlockhash:t.blockhash,instructions:e}).compileToV0Message(),[2,new Fp(r)]}})})}function tO(t){return bs(this,void 0,void 0,function(){var e,n,r,i,o,s;return vs(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,eO(i,e,t.tokenProgram)];case 2:return o=a.sent(),[4,eO(i,n,t.tokenProgram)];case 3:s=a.sent(),t.createATA&&r.push(jj(e,s,n,i,t.tokenProgram?new ke(t.tokenProgram):zp)),t.tokenProgram===JI.toBase58()?r.push(Kj(o,s,e,BigInt(t.amount),t.tokenDecimals,i)):r.push(qj({fromTokenAccount:o,toTokenAccount:s,owner:e,amount:BigInt(t.amount)})),a.label=4;case 4:return[2,r]}})})}function fc(t,e){return bs(this,void 0,void 0,function(){var r,n,r,i,o;return vs(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 Qj(t){return bs(this,void 0,void 0,function(){var e,n,r;return vs(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 nO=function(t){return bs(void 0,void 0,void 0,function(){var e,n,r,i,o,s;return vs(this,function(a){switch(a.label){case 0:return a.trys.push([0,8,,9]),e=Ea(t.walletName),[4,Yj(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(),Up(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(),Up(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]}})})},Xj=function(t,e){return bs(void 0,void 0,void 0,function(){var n,r,i,o,s,a;return vs(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,Qj(t.transactionInstructions.instructions)];case 2:return r=l.sent(),i=new ke(e.fromAddress),[4,tO(e)];case 3:return o=l.sent(),r.push.apply(r,o),s=new Fp(new Lp({payerKey:i,recentBlockhash:t.transactionInstructions.blockhash,instructions:r}).compileToV0Message()),[4,Jj(n,s)];case 4:return[2,l.sent()];case 5:throw a=l.sent(),Up(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]}})})},Jj=function(t,e){return bs(void 0,void 0,void 0,function(){var n,r,i,o;return vs(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(),Up(o))throw new Error("Transaction was rejected by user");return[2,fc(e,n)];case 6:return[2,fc(e,n)]}})})},pb,rO;function Zj(){if(rO)return pb;rO=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 g=0,w=0,S=0,P=b.length;S!==P&&b[S]===0;)S++,g++;for(var O=(P-S)*u+1>>>0,$=new Uint8Array(O);S!==P;){for(var R=b[S],j=0,q=O-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 W=O-w;W!==O&&$[W]===0;)W++;for(var F=l.repeat(g);W<O;++W)F+=e.charAt($[W]);return F}function h(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;for(var g=0,w=0,S=0;b[g]===l;)w++,g++;for(var P=(b.length-g)*c+1>>>0,O=new Uint8Array(P);b[g];){var $=b.charCodeAt(g);if($>255)return;var R=n[$];if(R===255)return;for(var j=0,q=P-1;(R!==0||j<S)&&q!==-1;q--,j++)R+=a*O[q]>>>0,O[q]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");S=j,g++}for(var W=P-S;W!==P&&O[W]===0;)W++;for(var F=new Uint8Array(w+(P-W)),V=w;W!==P;)F[V++]=O[W++];return F}function p(b){var g=h(b);if(g)return g;throw new Error("Non-base"+a+" character")}return{encode:d,decodeUnsafe:h,decode:p}}return pb=t,pb}var gb,iO;function eK(){return iO||(iO=1,gb=Zj()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),gb}var tK=eK();const nK=sl(tK);var rK=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())})},iK=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}}},oK=function(t,e){return rK(void 0,void 0,void 0,function(){var n,r,i,o;return iK(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,nK.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]}})})},sK=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)}}(),ws=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())})},xs=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}}},aK=function(t){sK(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.connect=function(n){return ws(this,void 0,void 0,function(){var r,i;return xs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,TW(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 ws(this,void 0,void 0,function(){var r,i;return xs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,PW(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 ws(this,void 0,void 0,function(){var r,i;return xs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,oK(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 ws(this,void 0,void 0,function(){return xs(this,function(r){return[2,{chainId:"101",accounts:[]}]})})},e.prototype.sendNativeTransfer=function(n){return ws(this,void 0,void 0,function(){var r,i;return xs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,nO({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 ws(this,void 0,void 0,function(){var r,i,o,s,a,l,c;return xs(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,nO({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 ws(this,void 0,void 0,function(){var r,i,o,s,a,l,c,u,d;return xs(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,Xj(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 ws(this,void 0,void 0,function(){return xs(this,function(n){return[2,{atomic:{status:"ready"}}]})})},e.prototype.getProviders=function(){var n=SC();return Object.keys(n).map(function(r){return{id:r,type:"solana"}})},e}(fA),oO=function(){function t(){this.strategies=new Map,this.strategies.set("evm",new CW),this.strategies.set("solana",new aK)}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}(),mb=function(){return mb=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},mb.apply(this,arguments)},yb=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())})},bb=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,sO,$p,vb=mm,lK=function(){return document.getElementById(vb)};function Gn(t){var e,n=lK();if(!n){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no iframe element found"));return}if(!$p){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,$p)}catch(r){console.error("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe")),console.error(r)}}function cK(t){return yb(this,void 0,void 0,function(){var e,e,e,e,n,r,i,o,s,a,l,c,u,d,h,p;return bb(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),ym();break}case"loaded":{Gn({type:"meshSDKSpecs",payload:mb({},MU)}),n=oO.getInstance(),r=n.getAllProviders(),Gn({type:"SDKinjectedWalletProviders",payload:r}),Pe!=null&&Pe.accessTokens&&Gn({type:"frontAccessTokens",payload:Pe.accessTokens}),Pe!=null&&Pe.transferDestinationTokens&&Gn({type:"frontTransferDestinationTokens",payload:Pe.transferDestinationTokens}),(h=Pe==null?void 0:Pe.onEvent)===null||h===void 0||h.call(Pe,{type:"pageLoaded"});break}default:{IU(t.data.type)&&((p=Pe==null?void 0:Pe.onEvent)===null||p===void 0||p.call(Pe,t.data));break}}return[2]})})}function uK(t){return yb(this,void 0,void 0,function(){var e,n,g,w,S,P,r,g,w,S,P,i,g,w,S,P,o,g,w,S,P,s,g,l,w,S,P,h,a,u,g,l,w,S,P,h,c,u,g,h,w,S,P,d,g,h,w,S,P,p,g,w,S,b,g,w,S,P,O,$;return bb(this,function(R){switch(R.label){case 0:switch(e=oO.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:g=t.data.payload,R.label=2;case 2:return R.trys.push([2,4,,5]),w=!(($=g.networkType)===null||$===void 0)&&$.includes("solana")?"solana":"evm",S=e.getStrategy(w),[4,S.connect(g)];case 3:return P=R.sent(),Gn({type:"SDKinjectedConnectionCompleted",payload:{accounts:P.accounts,chainId:P.chainId,networkType:w}}),[3,5];case 4:return r=R.sent(),console.error("Connection error:",r),_i(r,"SDKinjectedConnectionCompleted"),[3,5];case 5:return[3,54];case 6:g=t.data.payload,R.label=7;case 7:return R.trys.push([7,9,,10]),w=g.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.signMessage(g)];case 8:return P=R.sent(),Gn({type:"SDKsignRequestCompleted",payload:P}),[3,10];case 9:return i=R.sent(),_i(i,"SDKsignRequestCompleted"),[3,10];case 10:return[3,54];case 11:g=t.data.payload,R.label=12;case 12:return R.trys.push([12,14,,15]),w=g.networkType==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.switchChain(g)];case 13:return P=R.sent(),Gn({type:"SDKswitchChainCompleted",payload:{chainId:P.chainId,accounts:P.accounts,networkType:w}}),[3,15];case 14:return o=R.sent(),console.error("Chain switch failed:",o),_i(o,"SDKswitchChainCompleted"),[3,15];case 15:return[3,54];case 16:g=t.data.payload,R.label=17;case 17:return R.trys.push([17,19,,20]),w=g.network==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.sendNativeTransfer(g)];case 18:return P=R.sent(),Gn({type:"SDKnativeTransferCompleted",payload:P}),[3,20];case 19:return s=R.sent(),_i(s,"SDKnativeTransferCompleted"),[3,20];case 20:return[3,54];case 21:g=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=g.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendSmartContractInteraction(g)];case 23:return P=R.sent(),h=l(t.data.type),Gn({type:h,payload:{txHash:P}}),[3,25];case 24:return a=R.sent(),u=l(t.data.type),_i(a,u),[3,25];case 25:return[3,54];case 26:g=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=g.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendNativeSmartContractInteraction(g)];case 28:return P=R.sent(),h=l(t.data.type),Gn({type:h,payload:{txHash:P}}),[3,30];case 29:return c=R.sent(),u=l(t.data.type),_i(c,u),[3,30];case 30:return[3,54];case 31:g=t.data.payload,h="SDKtransactionBatchCompleted",R.label=32;case 32:return R.trys.push([32,34,,35]),w=g.from.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendTransactionBatch(g)];case 33:return P=R.sent(),Gn({type:h,payload:{txHash:P}}),[3,35];case 34:return d=R.sent(),_i(d,h),[3,35];case 35:return[3,54];case 36:g=t.data.payload,h="SDKwalletCapabilitiesCompleted",R.label=37;case 37:return R.trys.push([37,39,,40]),w=g.from.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.getWalletCapabilities(g)];case 38:return P=R.sent(),Gn({type:h,payload:P}),[3,40];case 39:return p=R.sent(),_i(p,h),[3,40];case 40:return[3,54];case 41:g=t.data.payload,R.label=42;case 42:return R.trys.push([42,47,,48]),g!=null&&g.networkType?(w=g.networkType==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.disconnect(g)]):[3,44];case 43:return R.sent(),[3,46];case 44:return[4,Promise.all([e.getStrategy("solana").disconnect(g),e.getStrategy("evm").disconnect(g)])];case 45:R.sent(),R.label=46;case 46:return Gn({type:"SDKdisconnectSuccess"}),[3,48];case 47:return b=R.sent(),console.error("Error during disconnect:",b),_i(b,"SDKdisconnectSuccess"),[3,48];case 48:return[3,54];case 49:g=t.data.payload,R.label=50;case 50:return R.trys.push([50,52,,53]),w="solana",S=e.getStrategy(w),[4,S.sendTransactionWithInstructions(g)];case 51:return P=R.sent(),Gn({type:"SDKnonNativeTransferCompleted",payload:{txHash:P}}),[3,53];case 52:return O=R.sent(),_i(O,"SDKdisconnectSuccess"),[3,53];case 53:return[3,54];case 54:return[2]}})})}function wb(t){return yb(this,void 0,void 0,function(){return bb(this,function(e){switch(e.label){case 0:return t.origin!==sO&&t.origin!==$p?(console.warn("Received message from untrusted origin:",t.origin),[3,5]):[3,1];case 1:return BU(t.data.type)?[4,uK(t)]:[3,3];case 2:return e.sent(),[3,5];case 3:return[4,cK(t)];case 4:e.sent(),e.label=5;case 5:return[2]}})})}function _i(t,e){Gn({type:e,payload:{error:t}})}var aO=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=dK(s,Pe==null?void 0:Pe.language),$p=new URL(s).origin,window.removeEventListener("message",wb),i){var a=document.getElementById(i);a?(a.allow="clipboard-read *; clipboard-write *",a.src=s,vb=i):console.warn("Mesh SDK: No iframe found with id ".concat(i))}else vb=mm,PU(s);window.addEventListener("message",wb),sO=window.location.origin},n=function(){var r;ym(),window.removeEventListener("message",wb),(r=t.onExit)===null||r===void 0||r.call(t)};return{openLink:e,closeLink:n}};function dK(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 fK="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 xb=({icon:t,title:e,description:n})=>C.jsxs(me,{display:"flex",flexDirection:"row",gap:"16px",width:"100%",alignItems:"flex-start",children:[C.jsx(Lt,{as:t,color:"fg.muted",width:"20px",height:"20px",marginTop:"2px"}),C.jsxs(me,{display:"flex",flexDirection:"column",gap:"4px",flex:"1",children:[C.jsx(me,{fontWeight:"600",fontSize:"14px",lineHeight:"120%",color:"fg",children:e}),C.jsx(me,{fontWeight:"400",fontSize:"12px",lineHeight:"140%",color:"fg.subtle",children:n})]})]}),hK=({onConfirm:t})=>C.jsxs(gr,{children:[C.jsx(me,{display:"flex",justifyContent:"center",width:"100%",children:C.jsx(me,{height:"48px",width:"48px",backgroundColor:"gray.200",borderRadius:"90%"})}),C.jsx(me,{fontWeight:"600",fontSize:"16px",lineHeight:"140%",color:"fg",textAlign:"center",children:"Enso Checkout uses a 3rd party to connect your Binance account."}),C.jsxs(me,{display:"flex",flexDirection:"column",gap:"12px",width:"100%",children:[C.jsx(xb,{icon:$_,title:"Your sign-in credentials are never stored",description:"All data is encrypted between enso and Binance"}),C.jsx(xb,{icon:W_,title:"2fa always required",description:"Transfers cannot be made without your approval."}),C.jsx(xb,{icon:H_,title:"Assets never touch 3rd parties",description:"Your funds are transferred directly to your wallet."}),C.jsxs(cV,{children:[C.jsx(pr,{src:fK,color:"gray",w:"24px"}),"Enso securely encrypts all user data."]})]}),C.jsx(Zn,{onClick:t,children:"Continue to 3rd Party"})]}),pK="0x0000000071727de22e5e9d8baf0edac6f37da032",Hp="https://mesh-bff.enso-checkout.workers.dev",lO=[0,1,2,3,4],Eb="9226e5c2-ebc3-4fdd-94f6-ed52cdce1420",Ab={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"},cO=Object.keys(Ab).map(Number),gK=t=>Ab[t]||Ab[8453],uO=()=>{const{setMeshAccessToken:t}=qe(),e=Wp();return J.useCallback(n=>{t(n),sessionStorage.setItem(e,JSON.stringify({accessToken:n.accessToken,sessionId:n.content.sessionId,timestamp:Date.now()}))},[])},mK=({setStep:t})=>{const{chainIdOut:e,setMeshAccessToken:n,setSessionId:r}=qe(),{address:i}=it.useAccount(),o=Wp(),[s,a]=J.useState(!1),l=e&&!cO.includes(e),c=uO();J.useEffect(()=>{if(l)return;const d=sessionStorage.getItem(o);if(d)try{const h=JSON.parse(d);if(h!=null&&h.accessToken&&(h!=null&&h.sessionId)){n(h.accessToken),r(h.sessionId),t(1);return}}catch(h){console.error("Failed to parse saved Mesh connection",h)}a(!0)},[o,l]);const u=()=>{fetch(`${Hp}/linktoken`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:o,integrationId:Eb,address:i})}).then(d=>d.json()).then(d=>{r(d.content.sessionId);const h=aO({clientId:i,onIntegrationConnected:p=>{console.log("onIntegrationConnected",p),t(1),c(p.accessToken),h.closeLink()},onExit:p=>{console.log("onExit",p)},onTransferFinished:p=>{console.log("onTransferFinished",p)},onEvent:p=>{console.log(p)}});h.openLink(d.content.linkToken)}).catch(d=>console.error(d))};return l?C.jsx(gr,{children:C.jsxs(me,{textAlign:"center",py:8,children:[C.jsx(Ke,{fontSize:"lg",fontWeight:"bold",color:"red.500",mb:4,children:"Unsupported Network"}),C.jsxs(Ke,{color:"fg.muted",mb:6,children:["The selected network (Chain ID: ",e,") is not supported for exchange transactions. Please switch to a supported network such as: ",cO.join(", ")]})]})}):s?C.jsx(hK,{onConfirm:u}):C.jsx(oh,{m:5})},Wp=()=>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},[]),yK=({setStep:t,onTokenSelect:e})=>{const[n,r]=J.useState([]),[i,o]=J.useState(null),[s,a]=J.useState(!0),[l,c]=J.useState(null),{address:u}=it.useAccount(),{chainIdOut:d,meshAccessToken:h,sessionId:p,setMeshAccessToken:b,setSessionId:g,setTokenIn:w,chainIdIn:S}=qe(),P=Wp();J.useEffect(()=>{h&&p&&d&&(async()=>{var R,j;try{const W=await(await fetch(`${Hp}/holdings`,{method:"POST",headers:{"Content-Type":"application/json","x-session-id":p},body:JSON.stringify({authToken:h.accountTokens[0].accessToken,brokerType:"binanceInternationalDirect"})})).json();if(console.log("Holdings data:",W),W.status!=="ok"||!((R=W.content)!=null&&R.cryptocurrencyPositions))throw W.errorType==="invalidIntegrationToken"&&(console.log("Invalid integration token"),t(0),b(null),g(null),sessionStorage.removeItem(P)),new Error(W.message||"Failed to fetch holdings");const V=await(await fetch(`${Hp}/tokens?chainId=${S}`)).json();if(console.log("Tokens data:",V),V.status==="success"&&((j=V.content)!=null&&j.tokens)){const G=V.content.tokens.map(z=>{const k=W.content.cryptocurrencyPositions.find(f=>f.symbol===z.symbol);return k?{...z,balance:k.amount,marketValue:k.marketValue,holding:k}:null}).filter(z=>z!==null&&z.marketValue>5).sort((z,k)=>k.marketValue-z.marketValue);console.log("Matched tokens with balances:",G),r(G)}else throw new Error(V.message||"Failed to fetch supported tokens")}catch(q){debugger;console.error("Error fetching data:",q),c(q instanceof Error?q.message:"Failed to fetch data")}finally{a(!1)}})()},[u,d,h,p]);const O=_z(n.map($=>$.symbol),S);return console.log("geckoTokens",O),s?C.jsx(sh,{children:C.jsx(oh,{m:5})}):l?C.jsxs(me,{p:5,color:"red.500",children:["Error: ",l]}):C.jsxs(gr,{children:[C.jsxs(me,{mb:4,width:"100%",textAlign:"left",children:[C.jsx(Qo,{children:"Your Holdings"}),C.jsxs(em,{children:["Found ",n.length," tokens with balances"]})]}),C.jsx(me,{overflowY:"scroll",maxH:"400px",children:C.jsx(ph,{children:n.map(($,R)=>{var j,q;return C.jsx(XE,{chainId:d||1,icon:(q=(j=O==null?void 0:O[R])==null?void 0:j.logoURI)==null?void 0:q.replace("/thumb/","/large/"),title:$.name,balance:`${Ti($.balance)} ${$.symbol}`,usdBalance:po($.marketValue||0),tag:"",loading:!1,selected:i===$.symbol,onClick:()=>{var W;o($.symbol),e($),w((W=O==null?void 0:O[R])==null?void 0:W.address)}},`${$.symbol}-${R}`)})})}),n.length===0&&C.jsx(me,{textAlign:"center",color:"fg.subtle",py:8,children:"No tokens with balances found for this chain"}),C.jsx(Zn,{disabled:!i,onClick:()=>{t(2)},children:"Continue"})]})},bK=({setStep:t,selectedToken:e})=>{const[n,r]=J.useState(""),[i,o]=J.useState("usd"),[s,a]=J.useState(""),{setAmountIn:l}=qe(),{tokenInData:c}=Jr(),d=(e==null?void 0:e.symbol.toLowerCase().includes("USD"))?2:6,h=e?(e.marketValue-lE).toFixed(2):0,p=J.useCallback(V=>{if(!e)return;const G=aE[e.symbol]||0,z=e.marketValue*V/100,k=Math.max(G,Math.min(z,+h)),f=e.marketValue/e.balance,y=Math.min(k/f,e.balance);r(hm(y,d)),a(k.toFixed(2))},[e]);J.useEffect(()=>{e&&p(100)},[e,p]),J.useEffect(()=>{c!=null&&c.decimals&&l(Number(um(n||"0",c==null?void 0:c.decimals)).toFixed())},[n,c==null?void 0:c.decimals]);const b=V=>{if(e)if(i==="usd"){const G=V.replace("$","")||"";a(G);const z=e.marketValue/e.balance,k=parseFloat(G||"0")/z;r(hm(k,d))}else{r(hm(V,d));const G=e.marketValue/e.balance,z=parseFloat(V)*G;a(z.toFixed(2))}},g=()=>{o(i==="usd"?"token":"usd")},w=()=>i==="usd"?{placeholder:"$10.00",displayValue:s?`$${s}`:"",equivalentValue:n?`${Ti(parseFloat(n))} ${e==null?void 0:e.symbol}`:"—"}:{placeholder:"0.00",displayValue:n,equivalentValue:s?`$${s}`:"—"},{placeholder:S,displayValue:P,equivalentValue:O}=w(),$=e?parseFloat(n)>e.balance:!0,R=parseFloat(s),j=e?aE[e.symbol]:0,q=e&&R>0&&j&&+n<j,W=e&&R>0&&R>+h,F=q||W||$;return e?C.jsxs(gr,{children:[C.jsxs(me,{mb:4,width:"100%",textAlign:"left",children:[C.jsx(Qo,{children:"Enter Amount"}),C.jsxs(em,{children:["Available: ",Ti(e.balance)," ",e.symbol," (",po(e.marketValue),")"]})]}),C.jsxs(me,{display:"flex",flexDirection:"column",gap:"8px",width:"100%",children:[C.jsxs(me,{display:"flex",flexDirection:"column",gap:"8px",alignItems:"center",padding:"25.5px",children:[C.jsx(hh,{inputMode:"decimal",marginY:"8px",variant:"text",placeholder:S,value:P,onChange:V=>b(V.target.value)}),C.jsxs(me,{display:"flex",gap:"3",alignItems:"center",onClick:g,_hover:{background:"bg.subtle"},cursor:"pointer",borderRadius:"lg",px:"3",children:[C.jsx(er,{minWidth:"24px",minHeight:"24px",maxWidth:"24px",background:"transparent",children:C.jsx(Lt,{as:H2,color:"gray",width:"16px",height:"16px"})}),C.jsx(Ke,{fontSize:"sm",color:"fg.muted",children:O})]})]}),C.jsx(me,{display:"flex",gap:"4px",justifyContent:"center",paddingBottom:"35px",children:[25,50,75,100].map(V=>C.jsx(nE,{onClick:()=>p(V),children:V===100?"Max":`${V}%`},V))})]}),C.jsx(me,{textAlign:"center",color:"fg.subtle",fontSize:"xs",h:3,m:-1,visibility:F||!n?"visible":"hidden",children:n?q?`Minimum amount is ${Ti(j)} ${e.symbol}`:W?`Maximum amount is ${po(h)} (balance - $${lE})`:$?"Amount exceeds available balance":"":"Please enter an amount"}),C.jsx(Zn,{onClick:()=>F||!n?void 0:t(3),disabled:F||!n,children:"Continue"})]}):C.jsx(gr,{children:C.jsx(me,{textAlign:"center",color:"fg.subtle",py:8,children:"No token selected"})})},vK=({setStep:t,setUserOp:e})=>{const{chainIdIn:n}=Jr(),{routeLoading:r,usdAmountIn:i,routeData:o}=Ml(),{signMessageAsync:s}=it.useSignMessage(),{address:a}=it.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=kU({userOperation:d,entryPointAddress:pK,entryPointVersion:"0.7",chainId:n});console.log("Signing userOpHash:",h);const p=await s({account:a,message:{raw:h}}),b={...d,signature:p};console.log("signedUserOp",JSON.stringify(b)),e(b),t(4)}catch(d){console.error("Failed to sign userOperation:",d)}finally{c(!1)}};return C.jsxs(gr,{children:[C.jsxs(oo,{flexDirection:"column",gap:"16px",alignItems:"center",width:"100%",children:[C.jsx(so,{loading:r,width:r?"156px":"auto",children:C.jsx(hh,{readOnly:!0,marginY:"8px",variant:"text",placeholder:"$10.00",value:i})}),C.jsx(Ch,{})]}),C.jsx(kh,{}),C.jsx(Zn,{disabled:!!(o!=null&&o.message)||r||l,loading:r||l,onClick:u,children:r?"Loading quote":l?"Signing...":"Sign Transaction"})]})},wK=({selectedToken:t,userOp:e,setStep:n})=>{const{meshAccessToken:r,amountIn:i,chainIdOut:o}=qe(),{address:s}=it.useAccount(),{tokenInData:a}=Jr(),[l,c]=J.useState(!0),u=uO(),d=Wp();return J.useEffect(()=>{if(!t||!e||!r){console.error("Missing required data for withdrawal initiation");return}const h=a!=null&&a.decimals?Oi(i,a.decimals):0;console.log("transferAmount",h),(async()=>{try{const b=[{networkId:gK(o),symbol:t.symbol,address:e.sender,amount:h}];console.log("link request body",{restrictMultipleAccounts:!0,userId:d,integrationId:Eb,transferOptions:{toAddresses:b}});const S=await(await fetch(`${Hp}/linktoken`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({restrictMultipleAccounts:!0,userId:d,integrationId:Eb,transferOptions:{toAddresses:b}})})).json();console.log("Link token response:",S);const P=r.accountTokens.map($=>({...$,accountId:$.account.accountId,accountName:$.account.accountName,brokerName:"Binance",brokerType:"binanceInternationalDirect"}));console.log("accessTokens",P);const O=aO({clientId:s,accessTokens:P,onIntegrationConnected:$=>{u($.accessToken),console.log("Integration connected",$)},onTransferFinished:$=>{console.log("Transfer finished:",$),c(!1)},onExit:$=>{console.log("Mesh link exited:",$),c(!1),n(1)},onEvent:$=>{console.log("Mesh event:",$),$.type==="transferExecuted"&&(console.log("Transfer executed, closing mesh link and moving to TrackUserOp step"),O.closeLink(),n(5))}});O.openLink(S.content.linkToken)}catch(b){console.error("Failed to fetch link token:",b),c(!1)}})()},[t,e]),C.jsx(gr,{children:C.jsx(sh,{children:C.jsx(Ke,{mt:4,children:l?C.jsxs(oo,{alignItems:"center",gap:2,children:[C.jsx(oh,{m:5}),C.jsx(Ke,{children:"Intiating Mesh"})]}):"Transfer completed"})})})},xK=({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,p]=J.useState(!1),[b,g]=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,W;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),g(null))):((W=V.operation)==null?void 0:W.status)==="failed"&&(c("failed"),d("Operation failed"),b&&(clearInterval(b),g(null)))}catch(F){console.error("Failed to fetch operation status:",F)}},3e3);return g(j),()=>{j&&clearInterval(j)}},[s]);const w=()=>{p(!0)},S=()=>{switch(l){case"completed":return"#14AE5C";case"failed":return"#E84142";default:return"#1E171F"}},P=()=>{switch(l){case"sending":case"tracking":return C.jsx(aA,{start:l==="tracking",onFinish:w,duration:120});case"completed":return C.jsx(me,{display:"flex",flexDirection:"column",alignItems:"center",children:C.jsx(pr,{src:lA,boxShadow:"0px 0px 20px #14AE5C",borderRadius:"90%",width:"58px",height:"58px"})});case"failed":return C.jsx(me,{display:"flex",flexDirection:"column",alignItems:"center",children:C.jsx(pr,{src:cA,boxShadow:"0px 0px 20px #E84142",borderRadius:"90%",width:"58px",height:"58px"})})}},O=()=>l==="tracking"&&h?C.jsxs(me,{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",textAlign:"center",children:[C.jsx(Ke,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"8px",children:u}),C.jsx(Ke,{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 C.jsxs(gr,{children:[C.jsxs(me,{display:"flex",flexDirection:"column",paddingBottom:"16px",alignItems:"center",width:"100%",children:[P(),O()]}),C.jsx(lh,{size:"sm",variant:"outline",width:"100%",children:C.jsxs(ch,{children:[C.jsxs(lo,{children:[C.jsx(ln,{children:"Status"}),C.jsx(ln,{display:"flex",textAlign:"end",justifyContent:"end",children:C.jsx(Ke,{color:S(),children:$()})})]}),s&&C.jsxs(lo,{children:[C.jsx(ln,{children:"Operation ID"}),C.jsx(ln,{display:"flex",textAlign:"end",justifyContent:"end",children:C.jsx(Ke,{fontSize:"sm",color:"fg.muted",children:s})})]})]})},"status"),C.jsx(Ch,{}),C.jsx(kh,{}),(l==="completed"||l==="failed")&&C.jsx(Zn,{onClick:()=>n(0),visual:"solid",children:l==="completed"?"New Deposit":"Retry Deposit"})]})},EK=()=>{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(b=>b.setIsCheckout),d=qe(b=>b.setChainIdIn),h=b=>{s(b),console.log("Selected token:",b)};J.useEffect(()=>{d(c),u(!0)},[c]);const p=(()=>{switch(r){case 0:return C.jsx(mK,{setStep:i});case 1:return C.jsx(yK,{setStep:i,onTokenSelect:h});case 2:return C.jsx(bK,{setStep:i,selectedToken:o});case 3:return C.jsx(vK,{setStep:i,setUserOp:l});case 4:return C.jsx(wK,{selectedToken:o,userOp:a,setStep:i});case 5:return C.jsx(xK,{selectedToken:o,userOp:a,setStep:i});default:return null}})();return C.jsxs(C.Fragment,{children:[C.jsx(Fn.Header,{children:C.jsxs(Du,{children:[C.jsx(er,{minWidth:"16px",minHeight:"16px",maxWidth:"16px",onClick:()=>{const b=lO.findIndex(g=>g===r)-1;b>0?i(lO[b]):(e(""),n(""))},children:C.jsx(Lt,{as:Vu,color:"gray",width:"16px",height:"16px"})}),C.jsx(me,{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"100%",children:C.jsx(Qo,{children:"Deposit from Binance"})}),t&&C.jsx(er,{onClick:t,minWidth:"16px",minHeight:"16px",maxWidth:"16px",marginLeft:"auto",children:C.jsx(Lt,{as:na,color:"gray",width:"16px",height:"16px"})})]})}),C.jsx(Fn.Body,{children:p})]})},AK={mainFlow:{steps:{selectToken:C.jsx(Yz,{}),selectAmount:C.jsx(nU,{}),quote:C.jsx(aU,{}),confirmTransfer:C.jsx(EU,{})}},exchangeFlow:{steps:{connectExchange:C.jsx(EK,{})}}},Ba=J.createContext({}),dO=({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),p=qe(w=>w.setChainIdOut),b=J.useMemo(()=>o?()=>{o&&o(),l(""),u("")}:void 0,[o]);J.useEffect(()=>{h(e),p(n)},[e,n]),J.useEffect(()=>{d(t)},[t]);const g=J.useMemo(()=>s!=null?s:({children:w,...S})=>C.jsx(me,{p:4,w:"374px",...S,children:w}),[s]);return C.jsx(Ba.Provider,{value:{step:a,setStep:l,flow:c,setFlow:u,handleClose:b,enableExchanges:i},children:C.jsx(sV,{themeConfig:r,children:C.jsxs(g,{children:[C.jsx(wU,{}),!c&&!a?C.jsx(qz,{}):AK[c].steps[a]]})})})},SK=({config:t,setIsActive:e,isActive:n,onClose:r})=>{const i=J.useCallback(()=>{e(!1),r==null||r()},[e,r]);return n?C.jsx(dO,{wrapper:Fn,config:t,onClose:i}):null};Fe.Checkout=dO,Fe.CheckoutModal=SK,Object.defineProperty(Fe,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=_e.Buffer.alloc(i);return Nt(n.length<256),_e.Buffer.from(r).copy(o,0),n.forEach(({signature:s},a)=>{s!==null&&(Nt(s.length===64,"signature has invalid length"),_e.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,Np);i.push($n.encode(_e.Buffer.from(s)))}return Mp.populate(Ta.from(n),i)}static populate(e,n=[]){const r=new Mp;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((i,o)=>{const s={signature:i==$n.encode(bj)?null:$n.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:$n.decode(i.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Lp{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 p=[];for(const b of i){const g=[];for(const S of b.accountKeyIndexes){const P=d.get(S);if(P===void 0)throw new Error(`Failed to find key for account key index ${S}`);const O=S<s;let $;O?$=S<c:S<d.staticAccountKeys.length?$=S-s<u:$=S-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,g.push({pubkey:P,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}`);p.push(new Bn({programId:w,data:Wn(b.data),keys:g}))}return new Lp({payerKey:h,instructions:p,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 Fp{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(Np));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(hj(),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,Np)));const o=FI.deserialize(new Uint8Array(n));return new Fp(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]=NI(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 lb=new ke("SysvarRecentB1ockHashes11111111111111111111"),_I=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:MI(t,e),r=_e.Buffer.alloc(n),i=Object.assign({instruction:t.index},e);return t.layout.encode(i,r),r}const vj=X.nu64("lamportsPerSignature"),VI=X.struct([X.u32("version"),X.u32("state"),Ge("authorizedPubkey"),Ge("nonce"),X.struct([vj],"feeCalculator")]).span;function wj(t,e){const n=_e.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 xj(t){return t.reduceRight((e,n)=>(e<<BigInt(8))+BigInt(n),BigInt(0))}const Ej=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}=Ej(n),o=n;return o.decode=(s,a)=>{const l=i(s,a);return xj(_e.Buffer.from(l))},o.encode=(s,a,l)=>{const c=wj(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"),Ge("programId")])},Assign:{index:1,layout:X.struct([X.u32("instruction"),Ge("programId")])},Transfer:{index:2,layout:X.struct([X.u32("instruction"),cc("lamports")])},CreateWithSeed:{index:3,layout:X.struct([X.u32("instruction"),Ge("base"),lc("seed"),X.ns64("lamports"),X.ns64("space"),Ge("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"),Ge("authorized")])},AuthorizeNonceAccount:{index:7,layout:X.struct([X.u32("instruction"),Ge("authorized")])},Allocate:{index:8,layout:X.struct([X.u32("instruction"),X.ns64("space")])},AllocateWithSeed:{index:9,layout:X.struct([X.u32("instruction"),Ge("base"),lc("seed"),X.ns64("space"),Ge("programId")])},AssignWithSeed:{index:10,layout:X.struct([X.u32("instruction"),Ge("base"),lc("seed"),Ge("programId")])},TransferWithSeed:{index:11,layout:X.struct([X.u32("instruction"),cc("lamports"),lc("seed"),Ge("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:Wn(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:Wn(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:Wn(e.basePubkey.toBuffer()),seed:e.seed,programId:Wn(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:Wn(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:Wn(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:Wn(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 Mp;"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:VI,programId:this.programId})):n.add(uc.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:VI,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:Wn(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:lb,isSigner:!1,isWritable:!1},{pubkey:_I,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:lb,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:lb,isSigner:!1,isWritable:!1},{pubkey:_I,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:Wn(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:Wn(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:Wn(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(Ge(),X.offset(X.u8(),-1),"authority")]);const kt=Od(Ky(ke),ge(),t=>new ke(t)),DI=qy([ge(),wt("base64")]),cb=Od(Ky(_e.Buffer),DI,t=>_e.Buffer.from(t[0],"base64"));function zI(t){return Hn([he({jsonrpc:wt("2.0"),id:ge(),result:t}),he({jsonrpc:wt("2.0"),id:ge(),error:he({code:ic(),message:ge(),data:Ce(CG())})})])}const Aj=zI(ic());function gt(t){return Od(zI(t),Aj,e=>"error"in e?e:{...e,result:Cd(e.result,t)})}function si(t){return gt(he({context:he({slot:le()}),value:t}))}function _p(t){return he({context:he({slot:le()}),value:t})}const Sj=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 kj=we(he({slot:le(),prioritizationFee:le()})),Cj=he({total:le(),validator:le(),foundation:le(),epoch:le()}),Ij=he({epoch:le(),slotIndex:le(),slotsInEpoch:le(),absoluteSlot:le(),blockHeight:Ce(le()),transactionCount:Ce(le())}),Oj=he({slotsPerEpoch:le(),leaderScheduleSlotOffset:le(),warmup:Fi(),firstNormalEpoch:le(),firstNormalSlot:le()}),Tj=gI(ge(),we(le())),Pa=xe(Hn([he({}),ge()])),Pj=he({err:Pa}),Nj=wt("receivedSignature");he({"solana-core":ge(),"feature-set":Ce(le())});const Bj=he({program:ge(),programId:kt,parsed:ic()}),Rj=he({programId:kt,accounts:we(kt),data:ge()});si(he({err:xe(Hn([he({}),ge()])),logs:xe(we(ge())),accounts:Ce(xe(we(xe(he({executable:Fi(),owner:ge(),lamports:le(),data:we(ge()),rentEpoch:Ce(le())}))))),unitsConsumed:Ce(le()),returnData:Ce(xe(he({programId:ge(),data:qy([ge(),wt("base64")])}))),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(Hn([Bj,Rj]))}))))})),si(he({byIdentity:gI(ge(),we(le())),range:he({firstSlot:le(),lastSlot:le()})})),gt(Sj),gt(Cj),gt(kj),gt(Ij),gt(Oj),gt(Tj),gt(le()),si(he({total:le(),circulating:le(),nonCirculating:le(),nonCirculatingAccounts:we(kt)}));const Mj=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:Fi(),owner:kt,lamports:le(),data:cb,rentEpoch:le()})})));const ub=he({program:ge(),parsed:ic(),space:le()});si(we(he({pubkey:kt,account:he({executable:Fi(),owner:kt,lamports:le(),data:ub,rentEpoch:le()})}))),si(we(he({lamports:le(),address:kt})));const db=he({executable:Fi(),owner:kt,lamports:le(),data:cb,rentEpoch:le()});he({pubkey:kt,account:db});const Lj=Od(Hn([Ky(_e.Buffer),ub]),Hn([DI,ub]),t=>Array.isArray(t)?Cd(t,cb):t),Fj=he({executable:Fi(),owner:kt,lamports:le(),data:Lj,rentEpoch:le()});he({pubkey:kt,account:Fj}),he({state:Hn([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:_p(db)});const _j=he({pubkey:kt,account:db});he({subscription:le(),result:_p(_j)});const Vj=he({parent:le(),slot:le(),root:le()});he({subscription:le(),result:Vj});const Dj=Hn([he({type:Hn([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:Dj}),he({subscription:le(),result:_p(Hn([Pj,Nj]))}),he({subscription:le(),result:le()}),he({pubkey:ge(),gossip:xe(ge()),tpu:xe(ge()),rpc:xe(ge()),version:xe(ge())});const UI=he({votePubkey:ge(),nodePubkey:ge(),activatedStake:le(),epochVoteAccount:Fi(),epochCredits:we(qy([le(),le(),le()])),commission:le(),lastVote:le(),rootSlot:xe(le())});gt(he({current:we(UI),delinquent:we(UI)}));const zj=Hn([wt("processed"),wt("confirmed"),wt("finalized")]),Uj=he({slot:le(),confirmations:xe(le()),err:Pa,confirmationStatus:Ce(zj)});si(we(xe(Uj))),gt(le());const $I=he({accountKey:kt,writableIndexes:we(le()),readonlyIndexes:we(le())}),fb=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($I))})}),HI=he({pubkey:kt,signer:Fi(),writable:Fi(),source:Ce(Hn([wt("transaction"),wt("lookupTable")]))}),WI=he({accountKeys:we(HI),signatures:we(ge())}),GI=he({parsed:ic(),program:ge(),programId:kt}),jI=he({accounts:we(kt),data:ge(),programId:kt}),$j=Hn([jI,GI]),Hj=Hn([he({parsed:ic(),program:ge(),programId:ge()}),he({accounts:we(ge()),data:ge(),programId:ge()})]),KI=Od($j,Hj,t=>"accounts"in t?Cd(t,jI):Cd(t,GI)),qI=he({signatures:we(ge()),message:he({accountKeys:we(HI),instructions:we(KI),recentBlockhash:ge(),addressTableLookups:Ce(xe(we($I)))})}),Vp=he({accountIndex:le(),mint:ge(),owner:Ce(ge()),programId:Ce(ge()),uiTokenAmount:Mj}),YI=he({writable:we(kt),readonly:we(kt)}),Dp=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(Vp))),postTokenBalances:Ce(xe(we(Vp))),loadedAddresses:Ce(YI),computeUnitsConsumed:Ce(le())}),hb=he({err:Pa,fee:le(),innerInstructions:Ce(xe(we(he({index:le(),instructions:we(KI)})))),preBalances:we(le()),postBalances:we(le()),logMessages:Ce(xe(we(ge()))),preTokenBalances:Ce(xe(we(Vp))),postTokenBalances:Ce(xe(we(Vp))),loadedAddresses:Ce(YI),computeUnitsConsumed:Ce(le())}),dc=Hn([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:fb,meta:xe(Dp),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:WI,meta:xe(Dp),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:qI,meta:xe(hb),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:WI,meta:xe(hb),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:fb,meta:xe(Dp)})),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(Dp),blockTime:Ce(xe(le())),transaction:fb,version:Ce(dc)}))),gt(xe(he({slot:le(),transaction:qI,meta:xe(hb),blockTime:Ce(xe(le())),version:Ce(dc)}))),si(he({blockhash:ge(),lastValidBlockHeight:le()})),si(Fi());const Wj=he({slot:le(),numTransactions:le(),numSlots:le(),samplePeriodSecs:le()});gt(we(Wj)),si(xe(he({feeCalculator:he({lamportsPerSignature:le()})}))),gt(ge()),gt(ge());const Gj=he({err:Pa,logs:we(ge()),signature:ge()});he({result:_p(Gj),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(Ge(),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"),lj.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 QI;new ke("StakeConfig11111111111111111111111111111111");class XI{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}}QI=XI,XI.default=new QI(0,0,ke.default),Object.freeze({Initialize:{index:0,layout:X.struct([X.u32("instruction"),pj(),gj()])},Authorize:{index:1,layout:X.struct([X.u32("instruction"),Ge("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"),Ge("newAuthorized"),X.u32("stakeAuthorizationType"),lc("authoritySeed"),Ge("authorityOwner")])}}),new ke("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:X.struct([X.u32("instruction"),mj()])},Authorize:{index:1,layout:X.struct([X.u32("instruction"),Ge("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"),yj()])}}),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([Ge("nodePubkey"),Ge("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"),Ge("authorizedVoter")]),X.offset(X.u32(),-8),"authorizedVoters"),X.struct([X.seq(X.struct([Ge("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 bs=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())})},vs=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}}},zp=new ke("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),JI=new ke("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),ZI=new ke("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),Up=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 eO(t,e){return bs(this,arguments,void 0,function(n,r,i){var o;return i===void 0&&(i=zp.toBase58()),vs(this,function(s){switch(s.label){case 0:return[4,ke.findProgramAddress([r.toBuffer(),new ke(i).toBuffer(),n.toBuffer()],ZI)];case 1:return o=s.sent()[0],[2,o]}})})}function jj(t,e,n,r,i){i===void 0&&(i=zp);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:ZI,data:Buffer.alloc(0)})}function Kj(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 qj(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:zp,data:o})}function Yj(t){return bs(this,void 0,void 0,function(){var e,n,r;return vs(this,function(i){switch(i.label){case 0:return[4,tO(t)];case 1:return e=i.sent(),n=new ke(t.fromAddress),r=new Lp({payerKey:n,recentBlockhash:t.blockhash,instructions:e}).compileToV0Message(),[2,new Fp(r)]}})})}function tO(t){return bs(this,void 0,void 0,function(){var e,n,r,i,o,s;return vs(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,eO(i,e,t.tokenProgram)];case 2:return o=a.sent(),[4,eO(i,n,t.tokenProgram)];case 3:s=a.sent(),t.createATA&&r.push(jj(e,s,n,i,t.tokenProgram?new ke(t.tokenProgram):zp)),t.tokenProgram===JI.toBase58()?r.push(Kj(o,s,e,BigInt(t.amount),t.tokenDecimals,i)):r.push(qj({fromTokenAccount:o,toTokenAccount:s,owner:e,amount:BigInt(t.amount)})),a.label=4;case 4:return[2,r]}})})}function fc(t,e){return bs(this,void 0,void 0,function(){var r,n,r,i,o;return vs(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 Qj(t){return bs(this,void 0,void 0,function(){var e,n,r;return vs(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 nO=function(t){return bs(void 0,void 0,void 0,function(){var e,n,r,i,o,s;return vs(this,function(a){switch(a.label){case 0:return a.trys.push([0,8,,9]),e=Ea(t.walletName),[4,Yj(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(),Up(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(),Up(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]}})})},Xj=function(t,e){return bs(void 0,void 0,void 0,function(){var n,r,i,o,s,a;return vs(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,Qj(t.transactionInstructions.instructions)];case 2:return r=l.sent(),i=new ke(e.fromAddress),[4,tO(e)];case 3:return o=l.sent(),r.push.apply(r,o),s=new Fp(new Lp({payerKey:i,recentBlockhash:t.transactionInstructions.blockhash,instructions:r}).compileToV0Message()),[4,Jj(n,s)];case 4:return[2,l.sent()];case 5:throw a=l.sent(),Up(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]}})})},Jj=function(t,e){return bs(void 0,void 0,void 0,function(){var n,r,i,o;return vs(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(),Up(o))throw new Error("Transaction was rejected by user");return[2,fc(e,n)];case 6:return[2,fc(e,n)]}})})},pb,rO;function Zj(){if(rO)return pb;rO=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 g=0,w=0,S=0,P=b.length;S!==P&&b[S]===0;)S++,g++;for(var O=(P-S)*u+1>>>0,$=new Uint8Array(O);S!==P;){for(var R=b[S],j=0,q=O-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 W=O-w;W!==O&&$[W]===0;)W++;for(var F=l.repeat(g);W<O;++W)F+=e.charAt($[W]);return F}function h(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;for(var g=0,w=0,S=0;b[g]===l;)w++,g++;for(var P=(b.length-g)*c+1>>>0,O=new Uint8Array(P);b[g];){var $=b.charCodeAt(g);if($>255)return;var R=n[$];if(R===255)return;for(var j=0,q=P-1;(R!==0||j<S)&&q!==-1;q--,j++)R+=a*O[q]>>>0,O[q]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");S=j,g++}for(var W=P-S;W!==P&&O[W]===0;)W++;for(var F=new Uint8Array(w+(P-W)),V=w;W!==P;)F[V++]=O[W++];return F}function p(b){var g=h(b);if(g)return g;throw new Error("Non-base"+a+" character")}return{encode:d,decodeUnsafe:h,decode:p}}return pb=t,pb}var gb,iO;function eK(){return iO||(iO=1,gb=Zj()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),gb}var tK=eK();const nK=sl(tK);var rK=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())})},iK=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}}},oK=function(t,e){return rK(void 0,void 0,void 0,function(){var n,r,i,o;return iK(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,nK.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]}})})},sK=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)}}(),ws=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())})},xs=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}}},aK=function(t){sK(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.connect=function(n){return ws(this,void 0,void 0,function(){var r,i;return xs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,TW(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 ws(this,void 0,void 0,function(){var r,i;return xs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,PW(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 ws(this,void 0,void 0,function(){var r,i;return xs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,oK(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 ws(this,void 0,void 0,function(){return xs(this,function(r){return[2,{chainId:"101",accounts:[]}]})})},e.prototype.sendNativeTransfer=function(n){return ws(this,void 0,void 0,function(){var r,i;return xs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,nO({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 ws(this,void 0,void 0,function(){var r,i,o,s,a,l,c;return xs(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,nO({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 ws(this,void 0,void 0,function(){var r,i,o,s,a,l,c,u,d;return xs(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,Xj(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 ws(this,void 0,void 0,function(){return xs(this,function(n){return[2,{atomic:{status:"ready"}}]})})},e.prototype.getProviders=function(){var n=SC();return Object.keys(n).map(function(r){return{id:r,type:"solana"}})},e}(fA),oO=function(){function t(){this.strategies=new Map,this.strategies.set("evm",new CW),this.strategies.set("solana",new aK)}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}(),mb=function(){return mb=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},mb.apply(this,arguments)},yb=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())})},bb=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,sO,$p,vb=mm,lK=function(){return document.getElementById(vb)};function Gn(t){var e,n=lK();if(!n){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no iframe element found"));return}if(!$p){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,$p)}catch(r){console.error("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe")),console.error(r)}}function cK(t){return yb(this,void 0,void 0,function(){var e,e,e,e,n,r,i,o,s,a,l,c,u,d,h,p;return bb(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),ym();break}case"loaded":{Gn({type:"meshSDKSpecs",payload:mb({},MU)}),n=oO.getInstance(),r=n.getAllProviders(),Gn({type:"SDKinjectedWalletProviders",payload:r}),Pe!=null&&Pe.accessTokens&&Gn({type:"frontAccessTokens",payload:Pe.accessTokens}),Pe!=null&&Pe.transferDestinationTokens&&Gn({type:"frontTransferDestinationTokens",payload:Pe.transferDestinationTokens}),(h=Pe==null?void 0:Pe.onEvent)===null||h===void 0||h.call(Pe,{type:"pageLoaded"});break}default:{IU(t.data.type)&&((p=Pe==null?void 0:Pe.onEvent)===null||p===void 0||p.call(Pe,t.data));break}}return[2]})})}function uK(t){return yb(this,void 0,void 0,function(){var e,n,g,w,S,P,r,g,w,S,P,i,g,w,S,P,o,g,w,S,P,s,g,l,w,S,P,h,a,u,g,l,w,S,P,h,c,u,g,h,w,S,P,d,g,h,w,S,P,p,g,w,S,b,g,w,S,P,O,$;return bb(this,function(R){switch(R.label){case 0:switch(e=oO.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:g=t.data.payload,R.label=2;case 2:return R.trys.push([2,4,,5]),w=!(($=g.networkType)===null||$===void 0)&&$.includes("solana")?"solana":"evm",S=e.getStrategy(w),[4,S.connect(g)];case 3:return P=R.sent(),Gn({type:"SDKinjectedConnectionCompleted",payload:{accounts:P.accounts,chainId:P.chainId,networkType:w}}),[3,5];case 4:return r=R.sent(),console.error("Connection error:",r),_i(r,"SDKinjectedConnectionCompleted"),[3,5];case 5:return[3,54];case 6:g=t.data.payload,R.label=7;case 7:return R.trys.push([7,9,,10]),w=g.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.signMessage(g)];case 8:return P=R.sent(),Gn({type:"SDKsignRequestCompleted",payload:P}),[3,10];case 9:return i=R.sent(),_i(i,"SDKsignRequestCompleted"),[3,10];case 10:return[3,54];case 11:g=t.data.payload,R.label=12;case 12:return R.trys.push([12,14,,15]),w=g.networkType==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.switchChain(g)];case 13:return P=R.sent(),Gn({type:"SDKswitchChainCompleted",payload:{chainId:P.chainId,accounts:P.accounts,networkType:w}}),[3,15];case 14:return o=R.sent(),console.error("Chain switch failed:",o),_i(o,"SDKswitchChainCompleted"),[3,15];case 15:return[3,54];case 16:g=t.data.payload,R.label=17;case 17:return R.trys.push([17,19,,20]),w=g.network==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.sendNativeTransfer(g)];case 18:return P=R.sent(),Gn({type:"SDKnativeTransferCompleted",payload:P}),[3,20];case 19:return s=R.sent(),_i(s,"SDKnativeTransferCompleted"),[3,20];case 20:return[3,54];case 21:g=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=g.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendSmartContractInteraction(g)];case 23:return P=R.sent(),h=l(t.data.type),Gn({type:h,payload:{txHash:P}}),[3,25];case 24:return a=R.sent(),u=l(t.data.type),_i(a,u),[3,25];case 25:return[3,54];case 26:g=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=g.address.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendNativeSmartContractInteraction(g)];case 28:return P=R.sent(),h=l(t.data.type),Gn({type:h,payload:{txHash:P}}),[3,30];case 29:return c=R.sent(),u=l(t.data.type),_i(c,u),[3,30];case 30:return[3,54];case 31:g=t.data.payload,h="SDKtransactionBatchCompleted",R.label=32;case 32:return R.trys.push([32,34,,35]),w=g.from.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.sendTransactionBatch(g)];case 33:return P=R.sent(),Gn({type:h,payload:{txHash:P}}),[3,35];case 34:return d=R.sent(),_i(d,h),[3,35];case 35:return[3,54];case 36:g=t.data.payload,h="SDKwalletCapabilitiesCompleted",R.label=37;case 37:return R.trys.push([37,39,,40]),w=g.from.startsWith("0x")?"evm":"solana",S=e.getStrategy(w),[4,S.getWalletCapabilities(g)];case 38:return P=R.sent(),Gn({type:h,payload:P}),[3,40];case 39:return p=R.sent(),_i(p,h),[3,40];case 40:return[3,54];case 41:g=t.data.payload,R.label=42;case 42:return R.trys.push([42,47,,48]),g!=null&&g.networkType?(w=g.networkType==="solana"?"solana":"evm",S=e.getStrategy(w),[4,S.disconnect(g)]):[3,44];case 43:return R.sent(),[3,46];case 44:return[4,Promise.all([e.getStrategy("solana").disconnect(g),e.getStrategy("evm").disconnect(g)])];case 45:R.sent(),R.label=46;case 46:return Gn({type:"SDKdisconnectSuccess"}),[3,48];case 47:return b=R.sent(),console.error("Error during disconnect:",b),_i(b,"SDKdisconnectSuccess"),[3,48];case 48:return[3,54];case 49:g=t.data.payload,R.label=50;case 50:return R.trys.push([50,52,,53]),w="solana",S=e.getStrategy(w),[4,S.sendTransactionWithInstructions(g)];case 51:return P=R.sent(),Gn({type:"SDKnonNativeTransferCompleted",payload:{txHash:P}}),[3,53];case 52:return O=R.sent(),_i(O,"SDKdisconnectSuccess"),[3,53];case 53:return[3,54];case 54:return[2]}})})}function wb(t){return yb(this,void 0,void 0,function(){return bb(this,function(e){switch(e.label){case 0:return t.origin!==sO&&t.origin!==$p?(console.warn("Received message from untrusted origin:",t.origin),[3,5]):[3,1];case 1:return BU(t.data.type)?[4,uK(t)]:[3,3];case 2:return e.sent(),[3,5];case 3:return[4,cK(t)];case 4:e.sent(),e.label=5;case 5:return[2]}})})}function _i(t,e){Gn({type:e,payload:{error:t}})}var aO=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=dK(s,Pe==null?void 0:Pe.language),$p=new URL(s).origin,window.removeEventListener("message",wb),i){var a=document.getElementById(i);a?(a.allow="clipboard-read *; clipboard-write *",a.src=s,vb=i):console.warn("Mesh SDK: No iframe found with id ".concat(i))}else vb=mm,PU(s);window.addEventListener("message",wb),sO=window.location.origin},n=function(){var r;ym(),window.removeEventListener("message",wb),(r=t.onExit)===null||r===void 0||r.call(t)};return{openLink:e,closeLink:n}};function dK(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 fK="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 xb=({icon:t,title:e,description:n})=>C.jsxs(me,{display:"flex",flexDirection:"row",gap:"16px",width:"100%",alignItems:"flex-start",children:[C.jsx(Lt,{as:t,color:"fg.muted",width:"20px",height:"20px",marginTop:"2px"}),C.jsxs(me,{display:"flex",flexDirection:"column",gap:"4px",flex:"1",children:[C.jsx(me,{fontWeight:"600",fontSize:"14px",lineHeight:"120%",color:"fg",children:e}),C.jsx(me,{fontWeight:"400",fontSize:"12px",lineHeight:"140%",color:"fg.subtle",children:n})]})]}),hK=({onConfirm:t})=>C.jsxs(gr,{children:[C.jsx(me,{display:"flex",justifyContent:"center",width:"100%",children:C.jsx(me,{height:"48px",width:"48px",backgroundColor:"gray.200",borderRadius:"90%"})}),C.jsx(me,{fontWeight:"600",fontSize:"16px",lineHeight:"140%",color:"fg",textAlign:"center",children:"Enso Checkout uses a 3rd party to connect your Binance account."}),C.jsxs(me,{display:"flex",flexDirection:"column",gap:"12px",width:"100%",children:[C.jsx(xb,{icon:$_,title:"Your sign-in credentials are never stored",description:"All data is encrypted between enso and Binance"}),C.jsx(xb,{icon:W_,title:"2fa always required",description:"Transfers cannot be made without your approval."}),C.jsx(xb,{icon:H_,title:"Assets never touch 3rd parties",description:"Your funds are transferred directly to your wallet."}),C.jsxs(cV,{children:[C.jsx(pr,{src:fK,color:"gray",w:"24px"}),"Enso securely encrypts all user data."]})]}),C.jsx(Zn,{onClick:t,children:"Continue to 3rd Party"})]}),pK="0x0000000071727de22e5e9d8baf0edac6f37da032",Hp="https://mesh-bff.enso-checkout.workers.dev",lO=[0,1,2,3,4],Eb="9226e5c2-ebc3-4fdd-94f6-ed52cdce1420",Ab={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"},cO=Object.keys(Ab).map(Number),gK=t=>Ab[t]||Ab[8453],uO=()=>{const{setMeshAccessToken:t}=qe(),e=Wp();return J.useCallback(n=>{t(n),sessionStorage.setItem(e,JSON.stringify({accessToken:n.accessToken,sessionId:n.content.sessionId,timestamp:Date.now()}))},[])},mK=({setStep:t})=>{const{chainIdOut:e,setMeshAccessToken:n,setSessionId:r}=qe(),{address:i}=it.useAccount(),o=Wp(),[s,a]=J.useState(!1),l=e&&!cO.includes(e),c=uO();J.useEffect(()=>{if(l)return;const d=sessionStorage.getItem(o);if(d)try{const h=JSON.parse(d);if(h!=null&&h.accessToken&&(h!=null&&h.sessionId)){n(h.accessToken),r(h.sessionId),t(1);return}}catch(h){console.error("Failed to parse saved Mesh connection",h)}a(!0)},[o,l]);const u=()=>{fetch(`${Hp}/linktoken`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:o,integrationId:Eb,address:i})}).then(d=>d.json()).then(d=>{r(d.content.sessionId);const h=aO({clientId:i,onIntegrationConnected:p=>{console.log("onIntegrationConnected",p),h.closeLink(),t(1),c(p.accessToken)},onExit:p=>{console.log("onExit",p)},onTransferFinished:p=>{console.log("onTransferFinished",p)},onEvent:p=>{console.log(p)}});h.openLink(d.content.linkToken)}).catch(d=>console.error(d))};return l?C.jsx(gr,{children:C.jsxs(me,{textAlign:"center",py:8,children:[C.jsx(Ke,{fontSize:"lg",fontWeight:"bold",color:"red.500",mb:4,children:"Unsupported Network"}),C.jsxs(Ke,{color:"fg.muted",mb:6,children:["The selected network (Chain ID: ",e,") is not supported for exchange transactions. Please switch to a supported network such as: ",cO.join(", ")]})]})}):s?C.jsx(hK,{onConfirm:u}):C.jsx(oh,{m:5})},Wp=()=>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},[]),yK=({setStep:t,onTokenSelect:e})=>{const[n,r]=J.useState([]),[i,o]=J.useState(null),[s,a]=J.useState(!0),[l,c]=J.useState(null),{address:u}=it.useAccount(),{chainIdOut:d,meshAccessToken:h,sessionId:p,setMeshAccessToken:b,setSessionId:g,setTokenIn:w,chainIdIn:S}=qe(),P=Wp();J.useEffect(()=>{h&&p&&d&&(async()=>{var R,j;try{const W=await(await fetch(`${Hp}/holdings`,{method:"POST",headers:{"Content-Type":"application/json","x-session-id":p},body:JSON.stringify({authToken:h.accountTokens[0].accessToken,brokerType:"binanceInternationalDirect"})})).json();if(console.log("Holdings data:",W),W.status!=="ok"||!((R=W.content)!=null&&R.cryptocurrencyPositions))throw W.errorType==="invalidIntegrationToken"&&(console.log("Invalid integration token"),t(0),b(null),g(null),sessionStorage.removeItem(P)),new Error(W.message||"Failed to fetch holdings");const V=await(await fetch(`${Hp}/tokens?chainId=${S}`)).json();if(console.log("Tokens data:",V),V.status==="success"&&((j=V.content)!=null&&j.tokens)){const G=V.content.tokens.map(z=>{const k=W.content.cryptocurrencyPositions.find(f=>f.symbol===z.symbol);return k?{...z,balance:k.amount,marketValue:k.marketValue,holding:k}:null}).filter(z=>z!==null&&z.marketValue>5).sort((z,k)=>k.marketValue-z.marketValue);console.log("Matched tokens with balances:",G),r(G)}else throw new Error(V.message||"Failed to fetch supported tokens")}catch(q){debugger;console.error("Error fetching data:",q),c(q instanceof Error?q.message:"Failed to fetch data")}finally{a(!1)}})()},[u,d,h,p]);const O=_z(n.map($=>$.symbol),S);return console.log("geckoTokens",O),s?C.jsx(sh,{children:C.jsx(oh,{m:5})}):l?C.jsxs(me,{p:5,color:"red.500",children:["Error: ",l]}):C.jsxs(gr,{children:[C.jsxs(me,{mb:4,width:"100%",textAlign:"left",children:[C.jsx(Qo,{children:"Your Holdings"}),C.jsxs(em,{children:["Found ",n.length," tokens with balances"]})]}),C.jsx(me,{overflowY:"scroll",maxH:"400px",children:C.jsx(ph,{children:n.map(($,R)=>{var j,q;return C.jsx(XE,{chainId:d||1,icon:(q=(j=O==null?void 0:O[R])==null?void 0:j.logoURI)==null?void 0:q.replace("/thumb/","/large/"),title:$.name,balance:`${Ti($.balance)} ${$.symbol}`,usdBalance:po($.marketValue||0),tag:"",loading:!1,selected:i===$.symbol,onClick:()=>{var W;o($.symbol),e($),w((W=O==null?void 0:O[R])==null?void 0:W.address)}},`${$.symbol}-${R}`)})})}),n.length===0&&C.jsx(me,{textAlign:"center",color:"fg.subtle",py:8,children:"No tokens with balances found for this chain"}),C.jsx(Zn,{disabled:!i,onClick:()=>{t(2)},children:"Continue"})]})},bK=({setStep:t,selectedToken:e})=>{const[n,r]=J.useState(""),[i,o]=J.useState("usd"),[s,a]=J.useState(""),{setAmountIn:l}=qe(),{tokenInData:c}=Jr(),d=(e==null?void 0:e.symbol.toLowerCase().includes("USD"))?2:6,h=e?(e.marketValue-lE).toFixed(2):0,p=J.useCallback(V=>{if(!e)return;const G=aE[e.symbol]||0,z=e.marketValue*V/100,k=Math.max(G,Math.min(z,+h)),f=e.marketValue/e.balance,y=Math.min(k/f,e.balance);r(hm(y,d)),a(k.toFixed(2))},[e]);J.useEffect(()=>{e&&p(100)},[e,p]),J.useEffect(()=>{c!=null&&c.decimals&&l(Number(um(n||"0",c==null?void 0:c.decimals)).toFixed())},[n,c==null?void 0:c.decimals]);const b=V=>{if(e)if(i==="usd"){const G=V.replace("$","")||"";a(G);const z=e.marketValue/e.balance,k=parseFloat(G||"0")/z;r(hm(k,d))}else{r(hm(V,d));const G=e.marketValue/e.balance,z=parseFloat(V)*G;a(z.toFixed(2))}},g=()=>{o(i==="usd"?"token":"usd")},w=()=>i==="usd"?{placeholder:"$10.00",displayValue:s?`$${s}`:"",equivalentValue:n?`${Ti(parseFloat(n))} ${e==null?void 0:e.symbol}`:"—"}:{placeholder:"0.00",displayValue:n,equivalentValue:s?`$${s}`:"—"},{placeholder:S,displayValue:P,equivalentValue:O}=w(),$=e?parseFloat(n)>e.balance:!0,R=parseFloat(s),j=e?aE[e.symbol]:0,q=e&&R>0&&j&&+n<j,W=e&&R>0&&R>+h,F=q||W||$;return e?C.jsxs(gr,{children:[C.jsxs(me,{mb:4,width:"100%",textAlign:"left",children:[C.jsx(Qo,{children:"Enter Amount"}),C.jsxs(em,{children:["Available: ",Ti(e.balance)," ",e.symbol," (",po(e.marketValue),")"]})]}),C.jsxs(me,{display:"flex",flexDirection:"column",gap:"8px",width:"100%",children:[C.jsxs(me,{display:"flex",flexDirection:"column",gap:"8px",alignItems:"center",padding:"25.5px",children:[C.jsx(hh,{inputMode:"decimal",marginY:"8px",variant:"text",placeholder:S,value:P,onChange:V=>b(V.target.value)}),C.jsxs(me,{display:"flex",gap:"3",alignItems:"center",onClick:g,_hover:{background:"bg.subtle"},cursor:"pointer",borderRadius:"lg",px:"3",children:[C.jsx(er,{minWidth:"24px",minHeight:"24px",maxWidth:"24px",background:"transparent",children:C.jsx(Lt,{as:H2,color:"gray",width:"16px",height:"16px"})}),C.jsx(Ke,{fontSize:"sm",color:"fg.muted",children:O})]})]}),C.jsx(me,{display:"flex",gap:"4px",justifyContent:"center",paddingBottom:"35px",children:[25,50,75,100].map(V=>C.jsx(nE,{onClick:()=>p(V),children:V===100?"Max":`${V}%`},V))})]}),C.jsx(me,{textAlign:"center",color:"fg.subtle",fontSize:"xs",h:3,m:-1,visibility:F||!n?"visible":"hidden",children:n?q?`Minimum amount is ${Ti(j)} ${e.symbol}`:W?`Maximum amount is ${po(h)} (balance - $${lE})`:$?"Amount exceeds available balance":"":"Please enter an amount"}),C.jsx(Zn,{onClick:()=>F||!n?void 0:t(3),disabled:F||!n,children:"Continue"})]}):C.jsx(gr,{children:C.jsx(me,{textAlign:"center",color:"fg.subtle",py:8,children:"No token selected"})})},vK=({setStep:t,setUserOp:e})=>{const{chainIdIn:n}=Jr(),{routeLoading:r,usdAmountIn:i,routeData:o}=Ml(),{signMessageAsync:s}=it.useSignMessage(),{address:a}=it.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=kU({userOperation:d,entryPointAddress:pK,entryPointVersion:"0.7",chainId:n});console.log("Signing userOpHash:",h);const p=await s({account:a,message:{raw:h}}),b={...d,signature:p};console.log("signedUserOp",JSON.stringify(b)),e(b),t(4)}catch(d){console.error("Failed to sign userOperation:",d)}finally{c(!1)}};return C.jsxs(gr,{children:[C.jsxs(oo,{flexDirection:"column",gap:"16px",alignItems:"center",width:"100%",children:[C.jsx(so,{loading:r,width:r?"156px":"auto",children:C.jsx(hh,{readOnly:!0,marginY:"8px",variant:"text",placeholder:"$10.00",value:i})}),C.jsx(Ch,{})]}),C.jsx(kh,{}),C.jsx(Zn,{disabled:!!(o!=null&&o.message)||r||l,loading:r||l,onClick:u,children:r?"Loading quote":l?"Signing...":"Sign Transaction"})]})},wK=({selectedToken:t,userOp:e,setStep:n})=>{const{meshAccessToken:r,amountIn:i,chainIdOut:o}=qe(),{address:s}=it.useAccount(),{tokenInData:a}=Jr(),[l,c]=J.useState(!0),u=uO(),d=Wp();return J.useEffect(()=>{if(!t||!e||!r){console.error("Missing required data for withdrawal initiation");return}const h=a!=null&&a.decimals?Oi(i,a.decimals):0;console.log("transferAmount",h),(async()=>{try{const b=[{networkId:gK(o),symbol:t.symbol,address:e.sender,amount:h}];console.log("link request body",{restrictMultipleAccounts:!0,userId:d,integrationId:Eb,transferOptions:{toAddresses:b}});const S=await(await fetch(`${Hp}/linktoken`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({restrictMultipleAccounts:!0,userId:d,integrationId:Eb,transferOptions:{toAddresses:b}})})).json();console.log("Link token response:",S);const P=r.accountTokens.map($=>({...$,accountId:$.account.accountId,accountName:$.account.accountName,brokerName:"Binance",brokerType:"binanceInternationalDirect"}));console.log("accessTokens",P);const O=aO({clientId:s,accessTokens:P,onIntegrationConnected:$=>{u($.accessToken),console.log("Integration connected",$)},onTransferFinished:$=>{console.log("Transfer finished:",$),c(!1)},onExit:$=>{console.log("Mesh link exited:",$),c(!1),n(1)},onEvent:$=>{console.log("Mesh event:",$),$.type==="transferExecuted"&&(console.log("Transfer executed, closing mesh link and moving to TrackUserOp step"),O.closeLink(),n(5))}});O.openLink(S.content.linkToken)}catch(b){console.error("Failed to fetch link token:",b),c(!1)}})()},[t,e]),C.jsx(gr,{children:C.jsx(sh,{children:C.jsx(Ke,{mt:4,children:l?C.jsxs(oo,{alignItems:"center",gap:2,children:[C.jsx(oh,{m:5}),C.jsx(Ke,{children:"Intiating Mesh"})]}):"Transfer completed"})})})},xK=({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,p]=J.useState(!1),[b,g]=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,W;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),g(null))):((W=V.operation)==null?void 0:W.status)==="failed"&&(c("failed"),d("Operation failed"),b&&(clearInterval(b),g(null)))}catch(F){console.error("Failed to fetch operation status:",F)}},3e3);return g(j),()=>{j&&clearInterval(j)}},[s]);const w=()=>{p(!0)},S=()=>{switch(l){case"completed":return"#14AE5C";case"failed":return"#E84142";default:return"#1E171F"}},P=()=>{switch(l){case"sending":case"tracking":return C.jsx(aA,{start:l==="tracking",onFinish:w,duration:120});case"completed":return C.jsx(me,{display:"flex",flexDirection:"column",alignItems:"center",children:C.jsx(pr,{src:lA,boxShadow:"0px 0px 20px #14AE5C",borderRadius:"90%",width:"58px",height:"58px"})});case"failed":return C.jsx(me,{display:"flex",flexDirection:"column",alignItems:"center",children:C.jsx(pr,{src:cA,boxShadow:"0px 0px 20px #E84142",borderRadius:"90%",width:"58px",height:"58px"})})}},O=()=>l==="tracking"&&h?C.jsxs(me,{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",textAlign:"center",children:[C.jsx(Ke,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"8px",children:u}),C.jsx(Ke,{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 C.jsxs(gr,{children:[C.jsxs(me,{display:"flex",flexDirection:"column",paddingBottom:"16px",alignItems:"center",width:"100%",children:[P(),O()]}),C.jsx(lh,{size:"sm",variant:"outline",width:"100%",children:C.jsxs(ch,{children:[C.jsxs(lo,{children:[C.jsx(ln,{children:"Status"}),C.jsx(ln,{display:"flex",textAlign:"end",justifyContent:"end",children:C.jsx(Ke,{color:S(),children:$()})})]}),s&&C.jsxs(lo,{children:[C.jsx(ln,{children:"Operation ID"}),C.jsx(ln,{display:"flex",textAlign:"end",justifyContent:"end",children:C.jsx(Ke,{fontSize:"sm",color:"fg.muted",children:s})})]})]})},"status"),C.jsx(Ch,{}),C.jsx(kh,{}),(l==="completed"||l==="failed")&&C.jsx(Zn,{onClick:()=>n(0),visual:"solid",children:l==="completed"?"New Deposit":"Retry Deposit"})]})},EK=()=>{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(b=>b.setIsCheckout),d=qe(b=>b.setChainIdIn),h=b=>{s(b),console.log("Selected token:",b)};J.useEffect(()=>{d(c),u(!0)},[c]);const p=(()=>{switch(r){case 0:return C.jsx(mK,{setStep:i});case 1:return C.jsx(yK,{setStep:i,onTokenSelect:h});case 2:return C.jsx(bK,{setStep:i,selectedToken:o});case 3:return C.jsx(vK,{setStep:i,setUserOp:l});case 4:return C.jsx(wK,{selectedToken:o,userOp:a,setStep:i});case 5:return C.jsx(xK,{selectedToken:o,userOp:a,setStep:i});default:return null}})();return C.jsxs(C.Fragment,{children:[C.jsx(Fn.Header,{children:C.jsxs(Du,{children:[C.jsx(er,{minWidth:"16px",minHeight:"16px",maxWidth:"16px",onClick:()=>{const b=lO.findIndex(g=>g===r)-1;b>0?i(lO[b]):(e(""),n(""))},children:C.jsx(Lt,{as:Vu,color:"gray",width:"16px",height:"16px"})}),C.jsx(me,{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"100%",children:C.jsx(Qo,{children:"Deposit from Binance"})}),t&&C.jsx(er,{onClick:t,minWidth:"16px",minHeight:"16px",maxWidth:"16px",marginLeft:"auto",children:C.jsx(Lt,{as:na,color:"gray",width:"16px",height:"16px"})})]})}),C.jsx(Fn.Body,{children:p})]})},AK={mainFlow:{steps:{selectToken:C.jsx(Yz,{}),selectAmount:C.jsx(nU,{}),quote:C.jsx(aU,{}),confirmTransfer:C.jsx(EU,{})}},exchangeFlow:{steps:{connectExchange:C.jsx(EK,{})}}},Ba=J.createContext({}),dO=({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),p=qe(w=>w.setChainIdOut),b=J.useMemo(()=>o?()=>{o&&o(),l(""),u("")}:void 0,[o]);J.useEffect(()=>{h(e),p(n)},[e,n]),J.useEffect(()=>{d(t)},[t]);const g=J.useMemo(()=>s!=null?s:({children:w,...S})=>C.jsx(me,{p:4,w:"374px",...S,children:w}),[s]);return C.jsx(Ba.Provider,{value:{step:a,setStep:l,flow:c,setFlow:u,handleClose:b,enableExchanges:i},children:C.jsx(sV,{themeConfig:r,children:C.jsxs(g,{children:[C.jsx(wU,{}),!c&&!a?C.jsx(qz,{}):AK[c].steps[a]]})})})},SK=({config:t,setIsActive:e,isActive:n,onClose:r})=>{const i=J.useCallback(()=>{e(!1),r==null||r()},[e,r]);return n?C.jsx(dO,{wrapper:Fn,config:t,onClose:i}):null};Fe.Checkout=dO,Fe.CheckoutModal=SK,Object.defineProperty(Fe,Symbol.toStringTag,{value:"Module"})});
203
203
  //# sourceMappingURL=checkout-widget.umd.js.map