@farcaster/frame-sdk 0.0.44 → 0.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,16 +1,18 @@
1
- "use strict";var frame=(()=>{var Zh=Object.create;var Ns=Object.defineProperty;var Yh=Object.getOwnPropertyDescriptor;var Xh=Object.getOwnPropertyNames;var Jh=Object.getPrototypeOf,Qh=Object.prototype.hasOwnProperty;var Ct=(r,e)=>()=>(r&&(e=r(r=0)),e);var zt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),dn=(r,e)=>{for(var t in e)Ns(r,t,{get:e[t],enumerable:!0})},tf=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Xh(e))!Qh.call(r,i)&&i!==t&&Ns(r,i,{get:()=>e[i],enumerable:!(n=Yh(e,i))||n.enumerable});return r};var br=(r,e,t)=>(t=r!=null?Zh(Jh(r)):{},tf(e||!r||!r.__esModule?Ns(t,"default",{value:r,enumerable:!0}):t,r)),Oa=r=>tf(Ns({},"__esModule",{value:!0}),r);var Mf=zt(Fs=>{"use strict";Fs.byteLength=wp;Fs.toByteArray=Ep;Fs.fromByteArray=Ap;var dr=[],tr=[],bp=typeof Uint8Array<"u"?Uint8Array:Array,$a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(kn=0,Cf=$a.length;kn<Cf;++kn)dr[kn]=$a[kn],tr[$a.charCodeAt(kn)]=kn;var kn,Cf;tr[45]=62;tr[95]=63;function Pf(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function wp(r){var e=Pf(r),t=e[0],n=e[1];return(t+n)*3/4-n}function vp(r,e,t){return(e+t)*3/4-t}function Ep(r){var e,t=Pf(r),n=t[0],i=t[1],s=new bp(vp(r,n,i)),o=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)e=tr[r.charCodeAt(u)]<<18|tr[r.charCodeAt(u+1)]<<12|tr[r.charCodeAt(u+2)]<<6|tr[r.charCodeAt(u+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[r.charCodeAt(u)]<<2|tr[r.charCodeAt(u+1)]>>4,s[o++]=e&255),i===1&&(e=tr[r.charCodeAt(u)]<<10|tr[r.charCodeAt(u+1)]<<4|tr[r.charCodeAt(u+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Rp(r){return dr[r>>18&63]+dr[r>>12&63]+dr[r>>6&63]+dr[r&63]}function Sp(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(Rp(n));return i.join("")}function Ap(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,c=t-n;o<c;o+=s)i.push(Sp(r,o,o+s>c?c:o+s));return n===1?(e=r[t-1],i.push(dr[e>>2]+dr[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(dr[e>>10]+dr[e>>4&63]+dr[e<<2&63]+"=")),i.join("")}});var Uf=zt(Wa=>{Wa.read=function(r,e,t,n,i){var s,o,c=i*8-n-1,u=(1<<c)-1,p=u>>1,m=-7,b=t?i-1:0,A=t?-1:1,S=r[e+b];for(b+=A,s=S&(1<<-m)-1,S>>=-m,m+=c;m>0;s=s*256+r[e+b],b+=A,m-=8);for(o=s&(1<<-m)-1,s>>=-m,m+=n;m>0;o=o*256+r[e+b],b+=A,m-=8);if(s===0)s=1-p;else{if(s===u)return o?NaN:(S?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-p}return(S?-1:1)*o*Math.pow(2,s-n)};Wa.write=function(r,e,t,n,i,s){var o,c,u,p=s*8-i-1,m=(1<<p)-1,b=m>>1,A=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:s-1,T=n?1:-1,I=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=m):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+b>=1?e+=A/u:e+=A*Math.pow(2,1-b),e*u>=2&&(o++,u/=2),o+b>=m?(c=0,o=m):o+b>=1?(c=(e*u-1)*Math.pow(2,i),o=o+b):(c=e*Math.pow(2,b-1)*Math.pow(2,i),o=0));i>=8;r[t+S]=c&255,S+=T,c/=256,i-=8);for(o=o<<i|c,p+=i;p>0;r[t+S]=o&255,S+=T,o/=256,p-=8);r[t+S-T]|=I*128}});var Di=zt(ui=>{"use strict";var qa=Mf(),ai=Uf(),Df=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ui.Buffer=N;ui.SlowBuffer=Np;ui.INSPECT_MAX_BYTES=50;var Vs=2147483647;ui.kMaxLength=Vs;N.TYPED_ARRAY_SUPPORT=xp();!N.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function xp(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(N.prototype,"parent",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.buffer}});Object.defineProperty(N.prototype,"offset",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.byteOffset}});function Sr(r){if(r>Vs)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,N.prototype),e}function N(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ga(r)}return $f(r,e,t)}N.poolSize=8192;function $f(r,e,t){if(typeof r=="string")return Op(r,e);if(ArrayBuffer.isView(r))return kp(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(hr(r,ArrayBuffer)||r&&hr(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(hr(r,SharedArrayBuffer)||r&&hr(r.buffer,SharedArrayBuffer)))return Ka(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return N.from(n,e,t);let i=Tp(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return N.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}N.from=function(r,e,t){return $f(r,e,t)};Object.setPrototypeOf(N.prototype,Uint8Array.prototype);Object.setPrototypeOf(N,Uint8Array);function Wf(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Ip(r,e,t){return Wf(r),r<=0?Sr(r):e!==void 0?typeof t=="string"?Sr(r).fill(e,t):Sr(r).fill(e):Sr(r)}N.alloc=function(r,e,t){return Ip(r,e,t)};function Ga(r){return Wf(r),Sr(r<0?0:Za(r)|0)}N.allocUnsafe=function(r){return Ga(r)};N.allocUnsafeSlow=function(r){return Ga(r)};function Op(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!N.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=qf(r,e)|0,n=Sr(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function ja(r){let e=r.length<0?0:Za(r.length)|0,t=Sr(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function kp(r){if(hr(r,Uint8Array)){let e=new Uint8Array(r);return Ka(e.buffer,e.byteOffset,e.byteLength)}return ja(r)}function Ka(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,N.prototype),n}function Tp(r){if(N.isBuffer(r)){let e=Za(r.length)|0,t=Sr(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Xa(r.length)?Sr(0):ja(r);if(r.type==="Buffer"&&Array.isArray(r.data))return ja(r.data)}function Za(r){if(r>=Vs)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Vs.toString(16)+" bytes");return r|0}function Np(r){return+r!=r&&(r=0),N.alloc(+r)}N.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==N.prototype};N.compare=function(e,t){if(hr(e,Uint8Array)&&(e=N.from(e,e.offset,e.byteLength)),hr(t,Uint8Array)&&(t=N.from(t,t.offset,t.byteLength)),!N.isBuffer(e)||!N.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==t[s]){n=e[s],i=t[s];break}return n<i?-1:i<n?1:0};N.isEncoding=function(e){switch(String(e).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}};N.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return N.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=N.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){let o=e[n];if(hr(o,Uint8Array))s+o.length>i.length?(N.isBuffer(o)||(o=N.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(N.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function qf(r,e){if(N.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||hr(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Ha(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Qf(r).length;default:if(i)return n?-1:Ha(r).length;e=(""+e).toLowerCase(),i=!0}}N.byteLength=qf;function Bp(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return $p(this,e,t);case"utf8":case"utf-8":return Kf(this,e,t);case"ascii":return Fp(this,e,t);case"latin1":case"binary":return Vp(this,e,t);case"base64":return Dp(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wp(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}N.prototype._isBuffer=!0;function Tn(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}N.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Tn(this,t,t+1);return this};N.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Tn(this,t,t+3),Tn(this,t+1,t+2);return this};N.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Tn(this,t,t+7),Tn(this,t+1,t+6),Tn(this,t+2,t+5),Tn(this,t+3,t+4);return this};N.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Kf(this,0,e):Bp.apply(this,arguments)};N.prototype.toLocaleString=N.prototype.toString;N.prototype.equals=function(e){if(!N.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:N.compare(this,e)===0};N.prototype.inspect=function(){let e="",t=ui.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Df&&(N.prototype[Df]=N.prototype.inspect);N.prototype.compare=function(e,t,n,i,s){if(hr(e,Uint8Array)&&(e=N.from(e,e.offset,e.byteLength)),!N.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),t<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,c=n-t,u=Math.min(o,c),p=this.slice(i,s),m=e.slice(t,n);for(let b=0;b<u;++b)if(p[b]!==m[b]){o=p[b],c=m[b];break}return o<c?-1:c<o?1:0};function jf(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Xa(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=N.from(e,n)),N.isBuffer(e))return e.length===0?-1:zf(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):zf(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function zf(r,e,t,n,i){let s=1,o=r.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2,c/=2,t/=2}function u(m,b){return s===1?m[b]:m.readUInt16BE(b*s)}let p;if(i){let m=-1;for(p=t;p<o;p++)if(u(r,p)===u(e,m===-1?0:p-m)){if(m===-1&&(m=p),p-m+1===c)return m*s}else m!==-1&&(p-=p-m),m=-1}else for(t+c>o&&(t=o-c),p=t;p>=0;p--){let m=!0;for(let b=0;b<c;b++)if(u(r,p+b)!==u(e,b)){m=!1;break}if(m)return p}return-1}N.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};N.prototype.indexOf=function(e,t,n){return jf(this,e,t,n,!0)};N.prototype.lastIndexOf=function(e,t,n){return jf(this,e,t,n,!1)};function Lp(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let c=parseInt(e.substr(o*2,2),16);if(Xa(c))return o;r[t+o]=c}return o}function Cp(r,e,t,n){return $s(Ha(e,r.length-t),r,t,n)}function Pp(r,e,t,n){return $s(Hp(e),r,t,n)}function Mp(r,e,t,n){return $s(Qf(e),r,t,n)}function Up(r,e,t,n){return $s(Gp(e,r.length-t),r,t,n)}N.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Lp(this,e,t,n);case"utf8":case"utf-8":return Cp(this,e,t,n);case"ascii":case"latin1":case"binary":return Pp(this,e,t,n);case"base64":return Mp(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Up(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Dp(r,e,t){return e===0&&t===r.length?qa.fromByteArray(r):qa.fromByteArray(r.slice(e,t))}function Kf(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=t){let u,p,m,b;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(b=(s&31)<<6|u&63,b>127&&(o=b));break;case 3:u=r[i+1],p=r[i+2],(u&192)===128&&(p&192)===128&&(b=(s&15)<<12|(u&63)<<6|p&63,b>2047&&(b<55296||b>57343)&&(o=b));break;case 4:u=r[i+1],p=r[i+2],m=r[i+3],(u&192)===128&&(p&192)===128&&(m&192)===128&&(b=(s&15)<<18|(u&63)<<12|(p&63)<<6|m&63,b>65535&&b<1114112&&(o=b))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return zp(n)}var Ff=4096;function zp(r){let e=r.length;if(e<=Ff)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Ff));return t}function Fp(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function Vp(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function $p(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let s=e;s<t;++s)i+=Zp[r[s]];return i}function Wp(r,e,t){let n=r.slice(e,t),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}N.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,N.prototype),i};function bt(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}N.prototype.readUintLE=N.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return i};N.prototype.readUintBE=N.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let i=this[e+--t],s=1;for(;t>0&&(s*=256);)i+=this[e+--t]*s;return i};N.prototype.readUint8=N.prototype.readUInt8=function(e,t){return e=e>>>0,t||bt(e,1,this.length),this[e]};N.prototype.readUint16LE=N.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||bt(e,2,this.length),this[e]|this[e+1]<<8};N.prototype.readUint16BE=N.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||bt(e,2,this.length),this[e]<<8|this[e+1]};N.prototype.readUint32LE=N.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};N.prototype.readUint32BE=N.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};N.prototype.readBigUInt64LE=Vr(function(e){e=e>>>0,ci(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ui(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});N.prototype.readBigUInt64BE=Vr(function(e){e=e>>>0,ci(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ui(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});N.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*t)),i};N.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let i=t,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};N.prototype.readInt8=function(e,t){return e=e>>>0,t||bt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};N.prototype.readInt16LE=function(e,t){e=e>>>0,t||bt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};N.prototype.readInt16BE=function(e,t){e=e>>>0,t||bt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};N.prototype.readInt32LE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};N.prototype.readInt32BE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};N.prototype.readBigInt64LE=Vr(function(e){e=e>>>0,ci(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ui(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});N.prototype.readBigInt64BE=Vr(function(e){e=e>>>0,ci(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ui(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});N.prototype.readFloatLE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),ai.read(this,e,!0,23,4)};N.prototype.readFloatBE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),ai.read(this,e,!1,23,4)};N.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||bt(e,8,this.length),ai.read(this,e,!0,52,8)};N.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||bt(e,8,this.length),ai.read(this,e,!1,52,8)};function Vt(r,e,t,n,i,s){if(!N.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}N.prototype.writeUintLE=N.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;Vt(this,e,t,n,c,0)}let s=1,o=0;for(this[t]=e&255;++o<n&&(s*=256);)this[t+o]=e/s&255;return t+n};N.prototype.writeUintBE=N.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;Vt(this,e,t,n,c,0)}let s=n-1,o=1;for(this[t+s]=e&255;--s>=0&&(o*=256);)this[t+s]=e/o&255;return t+n};N.prototype.writeUint8=N.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,1,255,0),this[t]=e&255,t+1};N.prototype.writeUint16LE=N.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};N.prototype.writeUint16BE=N.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};N.prototype.writeUint32LE=N.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};N.prototype.writeUint32BE=N.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Hf(r,e,t,n,i){Jf(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,t}function Gf(r,e,t,n,i){Jf(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t+7]=s,s=s>>8,r[t+6]=s,s=s>>8,r[t+5]=s,s=s>>8,r[t+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=o,o=o>>8,r[t+2]=o,o=o>>8,r[t+1]=o,o=o>>8,r[t]=o,t+8}N.prototype.writeBigUInt64LE=Vr(function(e,t=0){return Hf(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});N.prototype.writeBigUInt64BE=Vr(function(e,t=0){return Gf(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});N.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);Vt(this,e,t,n,u-1,-u)}let s=0,o=1,c=0;for(this[t]=e&255;++s<n&&(o*=256);)e<0&&c===0&&this[t+s-1]!==0&&(c=1),this[t+s]=(e/o>>0)-c&255;return t+n};N.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);Vt(this,e,t,n,u-1,-u)}let s=n-1,o=1,c=0;for(this[t+s]=e&255;--s>=0&&(o*=256);)e<0&&c===0&&this[t+s+1]!==0&&(c=1),this[t+s]=(e/o>>0)-c&255;return t+n};N.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};N.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};N.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};N.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};N.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||Vt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};N.prototype.writeBigInt64LE=Vr(function(e,t=0){return Hf(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});N.prototype.writeBigInt64BE=Vr(function(e,t=0){return Gf(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Zf(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Yf(r,e,t,n,i){return e=+e,t=t>>>0,i||Zf(r,e,t,4,34028234663852886e22,-34028234663852886e22),ai.write(r,e,t,n,23,4),t+4}N.prototype.writeFloatLE=function(e,t,n){return Yf(this,e,t,!0,n)};N.prototype.writeFloatBE=function(e,t,n){return Yf(this,e,t,!1,n)};function Xf(r,e,t,n,i){return e=+e,t=t>>>0,i||Zf(r,e,t,8,17976931348623157e292,-17976931348623157e292),ai.write(r,e,t,n,52,8),t+8}N.prototype.writeDoubleLE=function(e,t,n){return Xf(this,e,t,!0,n)};N.prototype.writeDoubleBE=function(e,t,n){return Xf(this,e,t,!1,n)};N.prototype.copy=function(e,t,n,i){if(!N.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),s};N.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!N.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=t;s<n;++s)this[s]=e;else{let o=N.isBuffer(e)?e:N.from(e,i),c=o.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-t;++s)this[s+t]=o[s%c]}return this};var oi={};function Ya(r,e,t){oi[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Ya("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ya("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Ya("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=Vf(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=Vf(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Vf(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function qp(r,e,t){ci(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Ui(e,r.length-(t+1))}function Jf(r,e,t,n,i,s){if(r>t||r<e){let o=typeof e=="bigint"?"n":"",c;throw s>3?e===0||e===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${e}${o} and <= ${t}${o}`,new oi.ERR_OUT_OF_RANGE("value",c,r)}qp(n,i,s)}function ci(r,e){if(typeof r!="number")throw new oi.ERR_INVALID_ARG_TYPE(e,"number",r)}function Ui(r,e,t){throw Math.floor(r)!==r?(ci(r,t),new oi.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new oi.ERR_BUFFER_OUT_OF_BOUNDS:new oi.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var jp=/[^+/0-9A-Za-z-_]/g;function Kp(r){if(r=r.split("=")[0],r=r.trim().replace(jp,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Ha(r,e){e=e||1/0;let t,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Hp(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Gp(r,e){let t,n,i,s=[];for(let o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),n=t>>8,i=t%256,s.push(i),s.push(n);return s}function Qf(r){return qa.toByteArray(Kp(r))}function $s(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function hr(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Xa(r){return r!==r}var Zp=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function Vr(r){return typeof BigInt>"u"?Yp:r}function Yp(){throw new Error("BigInt not supported")}});var vl=zt(()=>{});var Rc=zt((El,Ec)=>{(function(r,e){"use strict";function t(v,a){if(!v)throw new Error(a||"Assertion failed")}function n(v,a){v.super_=a;var l=function(){};l.prototype=a.prototype,v.prototype=new l,v.prototype.constructor=v}function i(v,a,l){if(i.isBN(v))return v;this.negative=0,this.words=null,this.length=0,this.red=null,v!==null&&((a==="le"||a==="be")&&(l=a,a=10),this._init(v||0,a||10,l||"be"))}typeof r=="object"?r.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=vl().Buffer}catch{}i.isBN=function(a){return a instanceof i?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===i.wordSize&&Array.isArray(a.words)},i.max=function(a,l){return a.cmp(l)>0?a:l},i.min=function(a,l){return a.cmp(l)<0?a:l},i.prototype._init=function(a,l,d){if(typeof a=="number")return this._initNumber(a,l,d);if(typeof a=="object")return this._initArray(a,l,d);l==="hex"&&(l=16),t(l===(l|0)&&l>=2&&l<=36),a=a.toString().replace(/\s+/g,"");var h=0;a[0]==="-"&&(h++,this.negative=1),h<a.length&&(l===16?this._parseHex(a,h,d):(this._parseBase(a,l,h),d==="le"&&this._initArray(this.toArray(),l,d)))},i.prototype._initNumber=function(a,l,d){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(t(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),d==="le"&&this._initArray(this.toArray(),l,d)},i.prototype._initArray=function(a,l,d){if(t(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var h=0;h<this.length;h++)this.words[h]=0;var g,w,R=0;if(d==="be")for(h=a.length-1,g=0;h>=0;h-=3)w=a[h]|a[h-1]<<8|a[h-2]<<16,this.words[g]|=w<<R&67108863,this.words[g+1]=w>>>26-R&67108863,R+=24,R>=26&&(R-=26,g++);else if(d==="le")for(h=0,g=0;h<a.length;h+=3)w=a[h]|a[h+1]<<8|a[h+2]<<16,this.words[g]|=w<<R&67108863,this.words[g+1]=w>>>26-R&67108863,R+=24,R>=26&&(R-=26,g++);return this._strip()};function o(v,a){var l=v.charCodeAt(a);if(l>=48&&l<=57)return l-48;if(l>=65&&l<=70)return l-55;if(l>=97&&l<=102)return l-87;t(!1,"Invalid character in "+v)}function c(v,a,l){var d=o(v,l);return l-1>=a&&(d|=o(v,l-1)<<4),d}i.prototype._parseHex=function(a,l,d){this.length=Math.ceil((a.length-l)/6),this.words=new Array(this.length);for(var h=0;h<this.length;h++)this.words[h]=0;var g=0,w=0,R;if(d==="be")for(h=a.length-1;h>=l;h-=2)R=c(a,l,h)<<g,this.words[w]|=R&67108863,g>=18?(g-=18,w+=1,this.words[w]|=R>>>26):g+=8;else{var y=a.length-l;for(h=y%2===0?l+1:l;h<a.length;h+=2)R=c(a,l,h)<<g,this.words[w]|=R&67108863,g>=18?(g-=18,w+=1,this.words[w]|=R>>>26):g+=8}this._strip()};function u(v,a,l,d){for(var h=0,g=0,w=Math.min(v.length,l),R=a;R<w;R++){var y=v.charCodeAt(R)-48;h*=d,y>=49?g=y-49+10:y>=17?g=y-17+10:g=y,t(y>=0&&g<d,"Invalid character"),h+=g}return h}i.prototype._parseBase=function(a,l,d){this.words=[0],this.length=1;for(var h=0,g=1;g<=67108863;g*=l)h++;h--,g=g/l|0;for(var w=a.length-d,R=w%h,y=Math.min(w,w-R)+d,f=0,_=d;_<y;_+=h)f=u(a,_,_+h,l),this.imuln(g),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(R!==0){var C=1;for(f=u(a,_,a.length,l),_=0;_<R;_++)C*=l;this.imuln(C),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},i.prototype.copy=function(a){a.words=new Array(this.length);for(var l=0;l<this.length;l++)a.words[l]=this.words[l];a.length=this.length,a.negative=this.negative,a.red=this.red};function p(v,a){v.words=a.words,v.length=a.length,v.negative=a.negative,v.red=a.red}if(i.prototype._move=function(a){p(a,this)},i.prototype.clone=function(){var a=new i(null);return this.copy(a),a},i.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch{i.prototype.inspect=m}else i.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var b=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],A=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],S=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(a,l){a=a||10,l=l|0||1;var d;if(a===16||a==="hex"){d="";for(var h=0,g=0,w=0;w<this.length;w++){var R=this.words[w],y=((R<<h|g)&16777215).toString(16);g=R>>>24-h&16777215,h+=2,h>=26&&(h-=26,w--),g!==0||w!==this.length-1?d=b[6-y.length]+y+d:d=y+d}for(g!==0&&(d=g.toString(16)+d);d.length%l!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}if(a===(a|0)&&a>=2&&a<=36){var f=A[a],_=S[a];d="";var C=this.clone();for(C.negative=0;!C.isZero();){var D=C.modrn(_).toString(a);C=C.idivn(_),C.isZero()?d=D+d:d=b[f-D.length]+D+d}for(this.isZero()&&(d="0"+d);d.length%l!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}t(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},i.prototype.toJSON=function(){return this.toString(16,2)},s&&(i.prototype.toBuffer=function(a,l){return this.toArrayLike(s,a,l)}),i.prototype.toArray=function(a,l){return this.toArrayLike(Array,a,l)};var T=function(a,l){return a.allocUnsafe?a.allocUnsafe(l):new a(l)};i.prototype.toArrayLike=function(a,l,d){this._strip();var h=this.byteLength(),g=d||Math.max(1,h);t(h<=g,"byte array longer than desired length"),t(g>0,"Requested array length <= 0");var w=T(a,g),R=l==="le"?"LE":"BE";return this["_toArrayLike"+R](w,h),w},i.prototype._toArrayLikeLE=function(a,l){for(var d=0,h=0,g=0,w=0;g<this.length;g++){var R=this.words[g]<<w|h;a[d++]=R&255,d<a.length&&(a[d++]=R>>8&255),d<a.length&&(a[d++]=R>>16&255),w===6?(d<a.length&&(a[d++]=R>>24&255),h=0,w=0):(h=R>>>24,w+=2)}if(d<a.length)for(a[d++]=h;d<a.length;)a[d++]=0},i.prototype._toArrayLikeBE=function(a,l){for(var d=a.length-1,h=0,g=0,w=0;g<this.length;g++){var R=this.words[g]<<w|h;a[d--]=R&255,d>=0&&(a[d--]=R>>8&255),d>=0&&(a[d--]=R>>16&255),w===6?(d>=0&&(a[d--]=R>>24&255),h=0,w=0):(h=R>>>24,w+=2)}if(d>=0)for(a[d--]=h;d>=0;)a[d--]=0},Math.clz32?i.prototype._countBits=function(a){return 32-Math.clz32(a)}:i.prototype._countBits=function(a){var l=a,d=0;return l>=4096&&(d+=13,l>>>=13),l>=64&&(d+=7,l>>>=7),l>=8&&(d+=4,l>>>=4),l>=2&&(d+=2,l>>>=2),d+l},i.prototype._zeroBits=function(a){if(a===0)return 26;var l=a,d=0;return(l&8191)===0&&(d+=13,l>>>=13),(l&127)===0&&(d+=7,l>>>=7),(l&15)===0&&(d+=4,l>>>=4),(l&3)===0&&(d+=2,l>>>=2),(l&1)===0&&d++,d},i.prototype.bitLength=function(){var a=this.words[this.length-1],l=this._countBits(a);return(this.length-1)*26+l};function I(v){for(var a=new Array(v.bitLength()),l=0;l<a.length;l++){var d=l/26|0,h=l%26;a[l]=v.words[d]>>>h&1}return a}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,l=0;l<this.length;l++){var d=this._zeroBits(this.words[l]);if(a+=d,d!==26)break}return a},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},i.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var l=0;l<a.length;l++)this.words[l]=this.words[l]|a.words[l];return this._strip()},i.prototype.ior=function(a){return t((this.negative|a.negative)===0),this.iuor(a)},i.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},i.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},i.prototype.iuand=function(a){var l;this.length>a.length?l=a:l=this;for(var d=0;d<l.length;d++)this.words[d]=this.words[d]&a.words[d];return this.length=l.length,this._strip()},i.prototype.iand=function(a){return t((this.negative|a.negative)===0),this.iuand(a)},i.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},i.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},i.prototype.iuxor=function(a){var l,d;this.length>a.length?(l=this,d=a):(l=a,d=this);for(var h=0;h<d.length;h++)this.words[h]=l.words[h]^d.words[h];if(this!==l)for(;h<l.length;h++)this.words[h]=l.words[h];return this.length=l.length,this._strip()},i.prototype.ixor=function(a){return t((this.negative|a.negative)===0),this.iuxor(a)},i.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},i.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},i.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var l=Math.ceil(a/26)|0,d=a%26;this._expand(l),d>0&&l--;for(var h=0;h<l;h++)this.words[h]=~this.words[h]&67108863;return d>0&&(this.words[h]=~this.words[h]&67108863>>26-d),this._strip()},i.prototype.notn=function(a){return this.clone().inotn(a)},i.prototype.setn=function(a,l){t(typeof a=="number"&&a>=0);var d=a/26|0,h=a%26;return this._expand(d+1),l?this.words[d]=this.words[d]|1<<h:this.words[d]=this.words[d]&~(1<<h),this._strip()},i.prototype.iadd=function(a){var l;if(this.negative!==0&&a.negative===0)return this.negative=0,l=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,l=this.isub(a),a.negative=1,l._normSign();var d,h;this.length>a.length?(d=this,h=a):(d=a,h=this);for(var g=0,w=0;w<h.length;w++)l=(d.words[w]|0)+(h.words[w]|0)+g,this.words[w]=l&67108863,g=l>>>26;for(;g!==0&&w<d.length;w++)l=(d.words[w]|0)+g,this.words[w]=l&67108863,g=l>>>26;if(this.length=d.length,g!==0)this.words[this.length]=g,this.length++;else if(d!==this)for(;w<d.length;w++)this.words[w]=d.words[w];return this},i.prototype.add=function(a){var l;return a.negative!==0&&this.negative===0?(a.negative=0,l=this.sub(a),a.negative^=1,l):a.negative===0&&this.negative!==0?(this.negative=0,l=a.sub(this),this.negative=1,l):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},i.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var l=this.iadd(a);return a.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var d=this.cmp(a);if(d===0)return this.negative=0,this.length=1,this.words[0]=0,this;var h,g;d>0?(h=this,g=a):(h=a,g=this);for(var w=0,R=0;R<g.length;R++)l=(h.words[R]|0)-(g.words[R]|0)+w,w=l>>26,this.words[R]=l&67108863;for(;w!==0&&R<h.length;R++)l=(h.words[R]|0)+w,w=l>>26,this.words[R]=l&67108863;if(w===0&&R<h.length&&h!==this)for(;R<h.length;R++)this.words[R]=h.words[R];return this.length=Math.max(this.length,R),h!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(a){return this.clone().isub(a)};function x(v,a,l){l.negative=a.negative^v.negative;var d=v.length+a.length|0;l.length=d,d=d-1|0;var h=v.words[0]|0,g=a.words[0]|0,w=h*g,R=w&67108863,y=w/67108864|0;l.words[0]=R;for(var f=1;f<d;f++){for(var _=y>>>26,C=y&67108863,D=Math.min(f,a.length-1),V=Math.max(0,f-v.length+1);V<=D;V++){var X=f-V|0;h=v.words[X]|0,g=a.words[V]|0,w=h*g+C,_+=w/67108864|0,C=w&67108863}l.words[f]=C|0,y=_|0}return y!==0?l.words[f]=y|0:l.length--,l._strip()}var B=function(a,l,d){var h=a.words,g=l.words,w=d.words,R=0,y,f,_,C=h[0]|0,D=C&8191,V=C>>>13,X=h[1]|0,ie=X&8191,ue=X>>>13,Le=h[2]|0,he=Le&8191,me=Le>>>13,jt=h[3]|0,Ae=jt&8191,Ne=jt>>>13,Is=h[4]|0,je=Is&8191,Ke=Is>>>13,Os=h[5]|0,Ue=Os&8191,De=Os>>>13,Yn=h[6]|0,ze=Yn&8191,Fe=Yn>>>13,xi=h[7]|0,Ve=xi&8191,$e=xi>>>13,ks=h[8]|0,He=ks&8191,Ge=ks>>>13,Ts=h[9]|0,Ye=Ts&8191,Xe=Ts>>>13,ju=g[0]|0,Je=ju&8191,Qe=ju>>>13,Ku=g[1]|0,et=Ku&8191,tt=Ku>>>13,Hu=g[2]|0,rt=Hu&8191,nt=Hu>>>13,Gu=g[3]|0,it=Gu&8191,st=Gu>>>13,Zu=g[4]|0,ot=Zu&8191,at=Zu>>>13,Yu=g[5]|0,ct=Yu&8191,ut=Yu>>>13,Xu=g[6]|0,ft=Xu&8191,lt=Xu>>>13,Ju=g[7]|0,dt=Ju&8191,ht=Ju>>>13,Qu=g[8]|0,pt=Qu&8191,mt=Qu>>>13,ef=g[9]|0,gt=ef&8191,yt=ef>>>13;d.negative=a.negative^l.negative,d.length=19,y=Math.imul(D,Je),f=Math.imul(D,Qe),f=f+Math.imul(V,Je)|0,_=Math.imul(V,Qe);var ua=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ua>>>26)|0,ua&=67108863,y=Math.imul(ie,Je),f=Math.imul(ie,Qe),f=f+Math.imul(ue,Je)|0,_=Math.imul(ue,Qe),y=y+Math.imul(D,et)|0,f=f+Math.imul(D,tt)|0,f=f+Math.imul(V,et)|0,_=_+Math.imul(V,tt)|0;var fa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(fa>>>26)|0,fa&=67108863,y=Math.imul(he,Je),f=Math.imul(he,Qe),f=f+Math.imul(me,Je)|0,_=Math.imul(me,Qe),y=y+Math.imul(ie,et)|0,f=f+Math.imul(ie,tt)|0,f=f+Math.imul(ue,et)|0,_=_+Math.imul(ue,tt)|0,y=y+Math.imul(D,rt)|0,f=f+Math.imul(D,nt)|0,f=f+Math.imul(V,rt)|0,_=_+Math.imul(V,nt)|0;var la=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(la>>>26)|0,la&=67108863,y=Math.imul(Ae,Je),f=Math.imul(Ae,Qe),f=f+Math.imul(Ne,Je)|0,_=Math.imul(Ne,Qe),y=y+Math.imul(he,et)|0,f=f+Math.imul(he,tt)|0,f=f+Math.imul(me,et)|0,_=_+Math.imul(me,tt)|0,y=y+Math.imul(ie,rt)|0,f=f+Math.imul(ie,nt)|0,f=f+Math.imul(ue,rt)|0,_=_+Math.imul(ue,nt)|0,y=y+Math.imul(D,it)|0,f=f+Math.imul(D,st)|0,f=f+Math.imul(V,it)|0,_=_+Math.imul(V,st)|0;var da=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(da>>>26)|0,da&=67108863,y=Math.imul(je,Je),f=Math.imul(je,Qe),f=f+Math.imul(Ke,Je)|0,_=Math.imul(Ke,Qe),y=y+Math.imul(Ae,et)|0,f=f+Math.imul(Ae,tt)|0,f=f+Math.imul(Ne,et)|0,_=_+Math.imul(Ne,tt)|0,y=y+Math.imul(he,rt)|0,f=f+Math.imul(he,nt)|0,f=f+Math.imul(me,rt)|0,_=_+Math.imul(me,nt)|0,y=y+Math.imul(ie,it)|0,f=f+Math.imul(ie,st)|0,f=f+Math.imul(ue,it)|0,_=_+Math.imul(ue,st)|0,y=y+Math.imul(D,ot)|0,f=f+Math.imul(D,at)|0,f=f+Math.imul(V,ot)|0,_=_+Math.imul(V,at)|0;var ha=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ha>>>26)|0,ha&=67108863,y=Math.imul(Ue,Je),f=Math.imul(Ue,Qe),f=f+Math.imul(De,Je)|0,_=Math.imul(De,Qe),y=y+Math.imul(je,et)|0,f=f+Math.imul(je,tt)|0,f=f+Math.imul(Ke,et)|0,_=_+Math.imul(Ke,tt)|0,y=y+Math.imul(Ae,rt)|0,f=f+Math.imul(Ae,nt)|0,f=f+Math.imul(Ne,rt)|0,_=_+Math.imul(Ne,nt)|0,y=y+Math.imul(he,it)|0,f=f+Math.imul(he,st)|0,f=f+Math.imul(me,it)|0,_=_+Math.imul(me,st)|0,y=y+Math.imul(ie,ot)|0,f=f+Math.imul(ie,at)|0,f=f+Math.imul(ue,ot)|0,_=_+Math.imul(ue,at)|0,y=y+Math.imul(D,ct)|0,f=f+Math.imul(D,ut)|0,f=f+Math.imul(V,ct)|0,_=_+Math.imul(V,ut)|0;var pa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(pa>>>26)|0,pa&=67108863,y=Math.imul(ze,Je),f=Math.imul(ze,Qe),f=f+Math.imul(Fe,Je)|0,_=Math.imul(Fe,Qe),y=y+Math.imul(Ue,et)|0,f=f+Math.imul(Ue,tt)|0,f=f+Math.imul(De,et)|0,_=_+Math.imul(De,tt)|0,y=y+Math.imul(je,rt)|0,f=f+Math.imul(je,nt)|0,f=f+Math.imul(Ke,rt)|0,_=_+Math.imul(Ke,nt)|0,y=y+Math.imul(Ae,it)|0,f=f+Math.imul(Ae,st)|0,f=f+Math.imul(Ne,it)|0,_=_+Math.imul(Ne,st)|0,y=y+Math.imul(he,ot)|0,f=f+Math.imul(he,at)|0,f=f+Math.imul(me,ot)|0,_=_+Math.imul(me,at)|0,y=y+Math.imul(ie,ct)|0,f=f+Math.imul(ie,ut)|0,f=f+Math.imul(ue,ct)|0,_=_+Math.imul(ue,ut)|0,y=y+Math.imul(D,ft)|0,f=f+Math.imul(D,lt)|0,f=f+Math.imul(V,ft)|0,_=_+Math.imul(V,lt)|0;var ma=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ma>>>26)|0,ma&=67108863,y=Math.imul(Ve,Je),f=Math.imul(Ve,Qe),f=f+Math.imul($e,Je)|0,_=Math.imul($e,Qe),y=y+Math.imul(ze,et)|0,f=f+Math.imul(ze,tt)|0,f=f+Math.imul(Fe,et)|0,_=_+Math.imul(Fe,tt)|0,y=y+Math.imul(Ue,rt)|0,f=f+Math.imul(Ue,nt)|0,f=f+Math.imul(De,rt)|0,_=_+Math.imul(De,nt)|0,y=y+Math.imul(je,it)|0,f=f+Math.imul(je,st)|0,f=f+Math.imul(Ke,it)|0,_=_+Math.imul(Ke,st)|0,y=y+Math.imul(Ae,ot)|0,f=f+Math.imul(Ae,at)|0,f=f+Math.imul(Ne,ot)|0,_=_+Math.imul(Ne,at)|0,y=y+Math.imul(he,ct)|0,f=f+Math.imul(he,ut)|0,f=f+Math.imul(me,ct)|0,_=_+Math.imul(me,ut)|0,y=y+Math.imul(ie,ft)|0,f=f+Math.imul(ie,lt)|0,f=f+Math.imul(ue,ft)|0,_=_+Math.imul(ue,lt)|0,y=y+Math.imul(D,dt)|0,f=f+Math.imul(D,ht)|0,f=f+Math.imul(V,dt)|0,_=_+Math.imul(V,ht)|0;var ga=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ga>>>26)|0,ga&=67108863,y=Math.imul(He,Je),f=Math.imul(He,Qe),f=f+Math.imul(Ge,Je)|0,_=Math.imul(Ge,Qe),y=y+Math.imul(Ve,et)|0,f=f+Math.imul(Ve,tt)|0,f=f+Math.imul($e,et)|0,_=_+Math.imul($e,tt)|0,y=y+Math.imul(ze,rt)|0,f=f+Math.imul(ze,nt)|0,f=f+Math.imul(Fe,rt)|0,_=_+Math.imul(Fe,nt)|0,y=y+Math.imul(Ue,it)|0,f=f+Math.imul(Ue,st)|0,f=f+Math.imul(De,it)|0,_=_+Math.imul(De,st)|0,y=y+Math.imul(je,ot)|0,f=f+Math.imul(je,at)|0,f=f+Math.imul(Ke,ot)|0,_=_+Math.imul(Ke,at)|0,y=y+Math.imul(Ae,ct)|0,f=f+Math.imul(Ae,ut)|0,f=f+Math.imul(Ne,ct)|0,_=_+Math.imul(Ne,ut)|0,y=y+Math.imul(he,ft)|0,f=f+Math.imul(he,lt)|0,f=f+Math.imul(me,ft)|0,_=_+Math.imul(me,lt)|0,y=y+Math.imul(ie,dt)|0,f=f+Math.imul(ie,ht)|0,f=f+Math.imul(ue,dt)|0,_=_+Math.imul(ue,ht)|0,y=y+Math.imul(D,pt)|0,f=f+Math.imul(D,mt)|0,f=f+Math.imul(V,pt)|0,_=_+Math.imul(V,mt)|0;var ya=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ya>>>26)|0,ya&=67108863,y=Math.imul(Ye,Je),f=Math.imul(Ye,Qe),f=f+Math.imul(Xe,Je)|0,_=Math.imul(Xe,Qe),y=y+Math.imul(He,et)|0,f=f+Math.imul(He,tt)|0,f=f+Math.imul(Ge,et)|0,_=_+Math.imul(Ge,tt)|0,y=y+Math.imul(Ve,rt)|0,f=f+Math.imul(Ve,nt)|0,f=f+Math.imul($e,rt)|0,_=_+Math.imul($e,nt)|0,y=y+Math.imul(ze,it)|0,f=f+Math.imul(ze,st)|0,f=f+Math.imul(Fe,it)|0,_=_+Math.imul(Fe,st)|0,y=y+Math.imul(Ue,ot)|0,f=f+Math.imul(Ue,at)|0,f=f+Math.imul(De,ot)|0,_=_+Math.imul(De,at)|0,y=y+Math.imul(je,ct)|0,f=f+Math.imul(je,ut)|0,f=f+Math.imul(Ke,ct)|0,_=_+Math.imul(Ke,ut)|0,y=y+Math.imul(Ae,ft)|0,f=f+Math.imul(Ae,lt)|0,f=f+Math.imul(Ne,ft)|0,_=_+Math.imul(Ne,lt)|0,y=y+Math.imul(he,dt)|0,f=f+Math.imul(he,ht)|0,f=f+Math.imul(me,dt)|0,_=_+Math.imul(me,ht)|0,y=y+Math.imul(ie,pt)|0,f=f+Math.imul(ie,mt)|0,f=f+Math.imul(ue,pt)|0,_=_+Math.imul(ue,mt)|0,y=y+Math.imul(D,gt)|0,f=f+Math.imul(D,yt)|0,f=f+Math.imul(V,gt)|0,_=_+Math.imul(V,yt)|0;var _a=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(_a>>>26)|0,_a&=67108863,y=Math.imul(Ye,et),f=Math.imul(Ye,tt),f=f+Math.imul(Xe,et)|0,_=Math.imul(Xe,tt),y=y+Math.imul(He,rt)|0,f=f+Math.imul(He,nt)|0,f=f+Math.imul(Ge,rt)|0,_=_+Math.imul(Ge,nt)|0,y=y+Math.imul(Ve,it)|0,f=f+Math.imul(Ve,st)|0,f=f+Math.imul($e,it)|0,_=_+Math.imul($e,st)|0,y=y+Math.imul(ze,ot)|0,f=f+Math.imul(ze,at)|0,f=f+Math.imul(Fe,ot)|0,_=_+Math.imul(Fe,at)|0,y=y+Math.imul(Ue,ct)|0,f=f+Math.imul(Ue,ut)|0,f=f+Math.imul(De,ct)|0,_=_+Math.imul(De,ut)|0,y=y+Math.imul(je,ft)|0,f=f+Math.imul(je,lt)|0,f=f+Math.imul(Ke,ft)|0,_=_+Math.imul(Ke,lt)|0,y=y+Math.imul(Ae,dt)|0,f=f+Math.imul(Ae,ht)|0,f=f+Math.imul(Ne,dt)|0,_=_+Math.imul(Ne,ht)|0,y=y+Math.imul(he,pt)|0,f=f+Math.imul(he,mt)|0,f=f+Math.imul(me,pt)|0,_=_+Math.imul(me,mt)|0,y=y+Math.imul(ie,gt)|0,f=f+Math.imul(ie,yt)|0,f=f+Math.imul(ue,gt)|0,_=_+Math.imul(ue,yt)|0;var ba=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ba>>>26)|0,ba&=67108863,y=Math.imul(Ye,rt),f=Math.imul(Ye,nt),f=f+Math.imul(Xe,rt)|0,_=Math.imul(Xe,nt),y=y+Math.imul(He,it)|0,f=f+Math.imul(He,st)|0,f=f+Math.imul(Ge,it)|0,_=_+Math.imul(Ge,st)|0,y=y+Math.imul(Ve,ot)|0,f=f+Math.imul(Ve,at)|0,f=f+Math.imul($e,ot)|0,_=_+Math.imul($e,at)|0,y=y+Math.imul(ze,ct)|0,f=f+Math.imul(ze,ut)|0,f=f+Math.imul(Fe,ct)|0,_=_+Math.imul(Fe,ut)|0,y=y+Math.imul(Ue,ft)|0,f=f+Math.imul(Ue,lt)|0,f=f+Math.imul(De,ft)|0,_=_+Math.imul(De,lt)|0,y=y+Math.imul(je,dt)|0,f=f+Math.imul(je,ht)|0,f=f+Math.imul(Ke,dt)|0,_=_+Math.imul(Ke,ht)|0,y=y+Math.imul(Ae,pt)|0,f=f+Math.imul(Ae,mt)|0,f=f+Math.imul(Ne,pt)|0,_=_+Math.imul(Ne,mt)|0,y=y+Math.imul(he,gt)|0,f=f+Math.imul(he,yt)|0,f=f+Math.imul(me,gt)|0,_=_+Math.imul(me,yt)|0;var wa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(wa>>>26)|0,wa&=67108863,y=Math.imul(Ye,it),f=Math.imul(Ye,st),f=f+Math.imul(Xe,it)|0,_=Math.imul(Xe,st),y=y+Math.imul(He,ot)|0,f=f+Math.imul(He,at)|0,f=f+Math.imul(Ge,ot)|0,_=_+Math.imul(Ge,at)|0,y=y+Math.imul(Ve,ct)|0,f=f+Math.imul(Ve,ut)|0,f=f+Math.imul($e,ct)|0,_=_+Math.imul($e,ut)|0,y=y+Math.imul(ze,ft)|0,f=f+Math.imul(ze,lt)|0,f=f+Math.imul(Fe,ft)|0,_=_+Math.imul(Fe,lt)|0,y=y+Math.imul(Ue,dt)|0,f=f+Math.imul(Ue,ht)|0,f=f+Math.imul(De,dt)|0,_=_+Math.imul(De,ht)|0,y=y+Math.imul(je,pt)|0,f=f+Math.imul(je,mt)|0,f=f+Math.imul(Ke,pt)|0,_=_+Math.imul(Ke,mt)|0,y=y+Math.imul(Ae,gt)|0,f=f+Math.imul(Ae,yt)|0,f=f+Math.imul(Ne,gt)|0,_=_+Math.imul(Ne,yt)|0;var va=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(va>>>26)|0,va&=67108863,y=Math.imul(Ye,ot),f=Math.imul(Ye,at),f=f+Math.imul(Xe,ot)|0,_=Math.imul(Xe,at),y=y+Math.imul(He,ct)|0,f=f+Math.imul(He,ut)|0,f=f+Math.imul(Ge,ct)|0,_=_+Math.imul(Ge,ut)|0,y=y+Math.imul(Ve,ft)|0,f=f+Math.imul(Ve,lt)|0,f=f+Math.imul($e,ft)|0,_=_+Math.imul($e,lt)|0,y=y+Math.imul(ze,dt)|0,f=f+Math.imul(ze,ht)|0,f=f+Math.imul(Fe,dt)|0,_=_+Math.imul(Fe,ht)|0,y=y+Math.imul(Ue,pt)|0,f=f+Math.imul(Ue,mt)|0,f=f+Math.imul(De,pt)|0,_=_+Math.imul(De,mt)|0,y=y+Math.imul(je,gt)|0,f=f+Math.imul(je,yt)|0,f=f+Math.imul(Ke,gt)|0,_=_+Math.imul(Ke,yt)|0;var Ea=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ea>>>26)|0,Ea&=67108863,y=Math.imul(Ye,ct),f=Math.imul(Ye,ut),f=f+Math.imul(Xe,ct)|0,_=Math.imul(Xe,ut),y=y+Math.imul(He,ft)|0,f=f+Math.imul(He,lt)|0,f=f+Math.imul(Ge,ft)|0,_=_+Math.imul(Ge,lt)|0,y=y+Math.imul(Ve,dt)|0,f=f+Math.imul(Ve,ht)|0,f=f+Math.imul($e,dt)|0,_=_+Math.imul($e,ht)|0,y=y+Math.imul(ze,pt)|0,f=f+Math.imul(ze,mt)|0,f=f+Math.imul(Fe,pt)|0,_=_+Math.imul(Fe,mt)|0,y=y+Math.imul(Ue,gt)|0,f=f+Math.imul(Ue,yt)|0,f=f+Math.imul(De,gt)|0,_=_+Math.imul(De,yt)|0;var Ra=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ra>>>26)|0,Ra&=67108863,y=Math.imul(Ye,ft),f=Math.imul(Ye,lt),f=f+Math.imul(Xe,ft)|0,_=Math.imul(Xe,lt),y=y+Math.imul(He,dt)|0,f=f+Math.imul(He,ht)|0,f=f+Math.imul(Ge,dt)|0,_=_+Math.imul(Ge,ht)|0,y=y+Math.imul(Ve,pt)|0,f=f+Math.imul(Ve,mt)|0,f=f+Math.imul($e,pt)|0,_=_+Math.imul($e,mt)|0,y=y+Math.imul(ze,gt)|0,f=f+Math.imul(ze,yt)|0,f=f+Math.imul(Fe,gt)|0,_=_+Math.imul(Fe,yt)|0;var Sa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Sa>>>26)|0,Sa&=67108863,y=Math.imul(Ye,dt),f=Math.imul(Ye,ht),f=f+Math.imul(Xe,dt)|0,_=Math.imul(Xe,ht),y=y+Math.imul(He,pt)|0,f=f+Math.imul(He,mt)|0,f=f+Math.imul(Ge,pt)|0,_=_+Math.imul(Ge,mt)|0,y=y+Math.imul(Ve,gt)|0,f=f+Math.imul(Ve,yt)|0,f=f+Math.imul($e,gt)|0,_=_+Math.imul($e,yt)|0;var Aa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Aa>>>26)|0,Aa&=67108863,y=Math.imul(Ye,pt),f=Math.imul(Ye,mt),f=f+Math.imul(Xe,pt)|0,_=Math.imul(Xe,mt),y=y+Math.imul(He,gt)|0,f=f+Math.imul(He,yt)|0,f=f+Math.imul(Ge,gt)|0,_=_+Math.imul(Ge,yt)|0;var xa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(xa>>>26)|0,xa&=67108863,y=Math.imul(Ye,gt),f=Math.imul(Ye,yt),f=f+Math.imul(Xe,gt)|0,_=Math.imul(Xe,yt);var Ia=(R+y|0)+((f&8191)<<13)|0;return R=(_+(f>>>13)|0)+(Ia>>>26)|0,Ia&=67108863,w[0]=ua,w[1]=fa,w[2]=la,w[3]=da,w[4]=ha,w[5]=pa,w[6]=ma,w[7]=ga,w[8]=ya,w[9]=_a,w[10]=ba,w[11]=wa,w[12]=va,w[13]=Ea,w[14]=Ra,w[15]=Sa,w[16]=Aa,w[17]=xa,w[18]=Ia,R!==0&&(w[19]=R,d.length++),d};Math.imul||(B=x);function U(v,a,l){l.negative=a.negative^v.negative,l.length=v.length+a.length;for(var d=0,h=0,g=0;g<l.length-1;g++){var w=h;h=0;for(var R=d&67108863,y=Math.min(g,a.length-1),f=Math.max(0,g-v.length+1);f<=y;f++){var _=g-f,C=v.words[_]|0,D=a.words[f]|0,V=C*D,X=V&67108863;w=w+(V/67108864|0)|0,X=X+R|0,R=X&67108863,w=w+(X>>>26)|0,h+=w>>>26,w&=67108863}l.words[g]=R,d=w,w=h}return d!==0?l.words[g]=d:l.length--,l._strip()}function L(v,a,l){return U(v,a,l)}i.prototype.mulTo=function(a,l){var d,h=this.length+a.length;return this.length===10&&a.length===10?d=B(this,a,l):h<63?d=x(this,a,l):h<1024?d=U(this,a,l):d=L(this,a,l),d};function F(v,a){this.x=v,this.y=a}F.prototype.makeRBT=function(a){for(var l=new Array(a),d=i.prototype._countBits(a)-1,h=0;h<a;h++)l[h]=this.revBin(h,d,a);return l},F.prototype.revBin=function(a,l,d){if(a===0||a===d-1)return a;for(var h=0,g=0;g<l;g++)h|=(a&1)<<l-g-1,a>>=1;return h},F.prototype.permute=function(a,l,d,h,g,w){for(var R=0;R<w;R++)h[R]=l[a[R]],g[R]=d[a[R]]},F.prototype.transform=function(a,l,d,h,g,w){this.permute(w,a,l,d,h,g);for(var R=1;R<g;R<<=1)for(var y=R<<1,f=Math.cos(2*Math.PI/y),_=Math.sin(2*Math.PI/y),C=0;C<g;C+=y)for(var D=f,V=_,X=0;X<R;X++){var ie=d[C+X],ue=h[C+X],Le=d[C+X+R],he=h[C+X+R],me=D*Le-V*he;he=D*he+V*Le,Le=me,d[C+X]=ie+Le,h[C+X]=ue+he,d[C+X+R]=ie-Le,h[C+X+R]=ue-he,X!==y&&(me=f*D-_*V,V=f*V+_*D,D=me)}},F.prototype.guessLen13b=function(a,l){var d=Math.max(l,a)|1,h=d&1,g=0;for(d=d/2|0;d;d=d>>>1)g++;return 1<<g+1+h},F.prototype.conjugate=function(a,l,d){if(!(d<=1))for(var h=0;h<d/2;h++){var g=a[h];a[h]=a[d-h-1],a[d-h-1]=g,g=l[h],l[h]=-l[d-h-1],l[d-h-1]=-g}},F.prototype.normalize13b=function(a,l){for(var d=0,h=0;h<l/2;h++){var g=Math.round(a[2*h+1]/l)*8192+Math.round(a[2*h]/l)+d;a[h]=g&67108863,g<67108864?d=0:d=g/67108864|0}return a},F.prototype.convert13b=function(a,l,d,h){for(var g=0,w=0;w<l;w++)g=g+(a[w]|0),d[2*w]=g&8191,g=g>>>13,d[2*w+1]=g&8191,g=g>>>13;for(w=2*l;w<h;++w)d[w]=0;t(g===0),t((g&-8192)===0)},F.prototype.stub=function(a){for(var l=new Array(a),d=0;d<a;d++)l[d]=0;return l},F.prototype.mulp=function(a,l,d){var h=2*this.guessLen13b(a.length,l.length),g=this.makeRBT(h),w=this.stub(h),R=new Array(h),y=new Array(h),f=new Array(h),_=new Array(h),C=new Array(h),D=new Array(h),V=d.words;V.length=h,this.convert13b(a.words,a.length,R,h),this.convert13b(l.words,l.length,_,h),this.transform(R,w,y,f,h,g),this.transform(_,w,C,D,h,g);for(var X=0;X<h;X++){var ie=y[X]*C[X]-f[X]*D[X];f[X]=y[X]*D[X]+f[X]*C[X],y[X]=ie}return this.conjugate(y,f,h),this.transform(y,f,V,w,h,g),this.conjugate(V,w,h),this.normalize13b(V,h),d.negative=a.negative^l.negative,d.length=a.length+l.length,d._strip()},i.prototype.mul=function(a){var l=new i(null);return l.words=new Array(this.length+a.length),this.mulTo(a,l)},i.prototype.mulf=function(a){var l=new i(null);return l.words=new Array(this.length+a.length),L(this,a,l)},i.prototype.imul=function(a){return this.clone().mulTo(a,this)},i.prototype.imuln=function(a){var l=a<0;l&&(a=-a),t(typeof a=="number"),t(a<67108864);for(var d=0,h=0;h<this.length;h++){var g=(this.words[h]|0)*a,w=(g&67108863)+(d&67108863);d>>=26,d+=g/67108864|0,d+=w>>>26,this.words[h]=w&67108863}return d!==0&&(this.words[h]=d,this.length++),l?this.ineg():this},i.prototype.muln=function(a){return this.clone().imuln(a)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(a){var l=I(a);if(l.length===0)return new i(1);for(var d=this,h=0;h<l.length&&l[h]===0;h++,d=d.sqr());if(++h<l.length)for(var g=d.sqr();h<l.length;h++,g=g.sqr())l[h]!==0&&(d=d.mul(g));return d},i.prototype.iushln=function(a){t(typeof a=="number"&&a>=0);var l=a%26,d=(a-l)/26,h=67108863>>>26-l<<26-l,g;if(l!==0){var w=0;for(g=0;g<this.length;g++){var R=this.words[g]&h,y=(this.words[g]|0)-R<<l;this.words[g]=y|w,w=R>>>26-l}w&&(this.words[g]=w,this.length++)}if(d!==0){for(g=this.length-1;g>=0;g--)this.words[g+d]=this.words[g];for(g=0;g<d;g++)this.words[g]=0;this.length+=d}return this._strip()},i.prototype.ishln=function(a){return t(this.negative===0),this.iushln(a)},i.prototype.iushrn=function(a,l,d){t(typeof a=="number"&&a>=0);var h;l?h=(l-l%26)/26:h=0;var g=a%26,w=Math.min((a-g)/26,this.length),R=67108863^67108863>>>g<<g,y=d;if(h-=w,h=Math.max(0,h),y){for(var f=0;f<w;f++)y.words[f]=this.words[f];y.length=w}if(w!==0)if(this.length>w)for(this.length-=w,f=0;f<this.length;f++)this.words[f]=this.words[f+w];else this.words[0]=0,this.length=1;var _=0;for(f=this.length-1;f>=0&&(_!==0||f>=h);f--){var C=this.words[f]|0;this.words[f]=_<<26-g|C>>>g,_=C&R}return y&&_!==0&&(y.words[y.length++]=_),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(a,l,d){return t(this.negative===0),this.iushrn(a,l,d)},i.prototype.shln=function(a){return this.clone().ishln(a)},i.prototype.ushln=function(a){return this.clone().iushln(a)},i.prototype.shrn=function(a){return this.clone().ishrn(a)},i.prototype.ushrn=function(a){return this.clone().iushrn(a)},i.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var l=a%26,d=(a-l)/26,h=1<<l;if(this.length<=d)return!1;var g=this.words[d];return!!(g&h)},i.prototype.imaskn=function(a){t(typeof a=="number"&&a>=0);var l=a%26,d=(a-l)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=d)return this;if(l!==0&&d++,this.length=Math.min(d,this.length),l!==0){var h=67108863^67108863>>>l<<l;this.words[this.length-1]&=h}return this._strip()},i.prototype.maskn=function(a){return this.clone().imaskn(a)},i.prototype.iaddn=function(a){return t(typeof a=="number"),t(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},i.prototype._iaddn=function(a){this.words[0]+=a;for(var l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},i.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+1]-=1;return this._strip()},i.prototype.addn=function(a){return this.clone().iaddn(a)},i.prototype.subn=function(a){return this.clone().isubn(a)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(a,l,d){var h=a.length+d,g;this._expand(h);var w,R=0;for(g=0;g<a.length;g++){w=(this.words[g+d]|0)+R;var y=(a.words[g]|0)*l;w-=y&67108863,R=(w>>26)-(y/67108864|0),this.words[g+d]=w&67108863}for(;g<this.length-d;g++)w=(this.words[g+d]|0)+R,R=w>>26,this.words[g+d]=w&67108863;if(R===0)return this._strip();for(t(R===-1),R=0,g=0;g<this.length;g++)w=-(this.words[g]|0)+R,R=w>>26,this.words[g]=w&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(a,l){var d=this.length-a.length,h=this.clone(),g=a,w=g.words[g.length-1]|0,R=this._countBits(w);d=26-R,d!==0&&(g=g.ushln(d),h.iushln(d),w=g.words[g.length-1]|0);var y=h.length-g.length,f;if(l!=="mod"){f=new i(null),f.length=y+1,f.words=new Array(f.length);for(var _=0;_<f.length;_++)f.words[_]=0}var C=h.clone()._ishlnsubmul(g,1,y);C.negative===0&&(h=C,f&&(f.words[y]=1));for(var D=y-1;D>=0;D--){var V=(h.words[g.length+D]|0)*67108864+(h.words[g.length+D-1]|0);for(V=Math.min(V/w|0,67108863),h._ishlnsubmul(g,V,D);h.negative!==0;)V--,h.negative=0,h._ishlnsubmul(g,1,D),h.isZero()||(h.negative^=1);f&&(f.words[D]=V)}return f&&f._strip(),h._strip(),l!=="div"&&d!==0&&h.iushrn(d),{div:f||null,mod:h}},i.prototype.divmod=function(a,l,d){if(t(!a.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var h,g,w;return this.negative!==0&&a.negative===0?(w=this.neg().divmod(a,l),l!=="mod"&&(h=w.div.neg()),l!=="div"&&(g=w.mod.neg(),d&&g.negative!==0&&g.iadd(a)),{div:h,mod:g}):this.negative===0&&a.negative!==0?(w=this.divmod(a.neg(),l),l!=="mod"&&(h=w.div.neg()),{div:h,mod:w.mod}):(this.negative&a.negative)!==0?(w=this.neg().divmod(a.neg(),l),l!=="div"&&(g=w.mod.neg(),d&&g.negative!==0&&g.isub(a)),{div:w.div,mod:g}):a.length>this.length||this.cmp(a)<0?{div:new i(0),mod:this}:a.length===1?l==="div"?{div:this.divn(a.words[0]),mod:null}:l==="mod"?{div:null,mod:new i(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new i(this.modrn(a.words[0]))}:this._wordDiv(a,l)},i.prototype.div=function(a){return this.divmod(a,"div",!1).div},i.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},i.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},i.prototype.divRound=function(a){var l=this.divmod(a);if(l.mod.isZero())return l.div;var d=l.div.negative!==0?l.mod.isub(a):l.mod,h=a.ushrn(1),g=a.andln(1),w=d.cmp(h);return w<0||g===1&&w===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},i.prototype.modrn=function(a){var l=a<0;l&&(a=-a),t(a<=67108863);for(var d=(1<<26)%a,h=0,g=this.length-1;g>=0;g--)h=(d*h+(this.words[g]|0))%a;return l?-h:h},i.prototype.modn=function(a){return this.modrn(a)},i.prototype.idivn=function(a){var l=a<0;l&&(a=-a),t(a<=67108863);for(var d=0,h=this.length-1;h>=0;h--){var g=(this.words[h]|0)+d*67108864;this.words[h]=g/a|0,d=g%a}return this._strip(),l?this.ineg():this},i.prototype.divn=function(a){return this.clone().idivn(a)},i.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var l=this,d=a.clone();l.negative!==0?l=l.umod(a):l=l.clone();for(var h=new i(1),g=new i(0),w=new i(0),R=new i(1),y=0;l.isEven()&&d.isEven();)l.iushrn(1),d.iushrn(1),++y;for(var f=d.clone(),_=l.clone();!l.isZero();){for(var C=0,D=1;(l.words[0]&D)===0&&C<26;++C,D<<=1);if(C>0)for(l.iushrn(C);C-- >0;)(h.isOdd()||g.isOdd())&&(h.iadd(f),g.isub(_)),h.iushrn(1),g.iushrn(1);for(var V=0,X=1;(d.words[0]&X)===0&&V<26;++V,X<<=1);if(V>0)for(d.iushrn(V);V-- >0;)(w.isOdd()||R.isOdd())&&(w.iadd(f),R.isub(_)),w.iushrn(1),R.iushrn(1);l.cmp(d)>=0?(l.isub(d),h.isub(w),g.isub(R)):(d.isub(l),w.isub(h),R.isub(g))}return{a:w,b:R,gcd:d.iushln(y)}},i.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var l=this,d=a.clone();l.negative!==0?l=l.umod(a):l=l.clone();for(var h=new i(1),g=new i(0),w=d.clone();l.cmpn(1)>0&&d.cmpn(1)>0;){for(var R=0,y=1;(l.words[0]&y)===0&&R<26;++R,y<<=1);if(R>0)for(l.iushrn(R);R-- >0;)h.isOdd()&&h.iadd(w),h.iushrn(1);for(var f=0,_=1;(d.words[0]&_)===0&&f<26;++f,_<<=1);if(f>0)for(d.iushrn(f);f-- >0;)g.isOdd()&&g.iadd(w),g.iushrn(1);l.cmp(d)>=0?(l.isub(d),h.isub(g)):(d.isub(l),g.isub(h))}var C;return l.cmpn(1)===0?C=h:C=g,C.cmpn(0)<0&&C.iadd(a),C},i.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var l=this.clone(),d=a.clone();l.negative=0,d.negative=0;for(var h=0;l.isEven()&&d.isEven();h++)l.iushrn(1),d.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;d.isEven();)d.iushrn(1);var g=l.cmp(d);if(g<0){var w=l;l=d,d=w}else if(g===0||d.cmpn(1)===0)break;l.isub(d)}while(!0);return d.iushln(h)},i.prototype.invm=function(a){return this.egcd(a).a.umod(a)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(a){return this.words[0]&a},i.prototype.bincn=function(a){t(typeof a=="number");var l=a%26,d=(a-l)/26,h=1<<l;if(this.length<=d)return this._expand(d+1),this.words[d]|=h,this;for(var g=h,w=d;g!==0&&w<this.length;w++){var R=this.words[w]|0;R+=g,g=R>>>26,R&=67108863,this.words[w]=R}return g!==0&&(this.words[w]=g,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(a){var l=a<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this._strip();var d;if(this.length>1)d=1;else{l&&(a=-a),t(a<=67108863,"Number is too big");var h=this.words[0]|0;d=h===a?0:h<a?-1:1}return this.negative!==0?-d|0:d},i.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var l=this.ucmp(a);return this.negative!==0?-l|0:l},i.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var l=0,d=this.length-1;d>=0;d--){var h=this.words[d]|0,g=a.words[d]|0;if(h!==g){h<g?l=-1:h>g&&(l=1);break}}return l},i.prototype.gtn=function(a){return this.cmpn(a)===1},i.prototype.gt=function(a){return this.cmp(a)===1},i.prototype.gten=function(a){return this.cmpn(a)>=0},i.prototype.gte=function(a){return this.cmp(a)>=0},i.prototype.ltn=function(a){return this.cmpn(a)===-1},i.prototype.lt=function(a){return this.cmp(a)===-1},i.prototype.lten=function(a){return this.cmpn(a)<=0},i.prototype.lte=function(a){return this.cmp(a)<=0},i.prototype.eqn=function(a){return this.cmpn(a)===0},i.prototype.eq=function(a){return this.cmp(a)===0},i.red=function(a){return new re(a)},i.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},i.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(a){return this.red=a,this},i.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},i.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},i.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},i.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},i.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},i.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},i.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},i.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},i.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var te={k256:null,p224:null,p192:null,p25519:null};function H(v,a){this.name=v,this.p=new i(a,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var a=new i(null);return a.words=new Array(Math.ceil(this.n/13)),a},H.prototype.ireduce=function(a){var l=a,d;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),d=l.bitLength();while(d>this.n);var h=d<this.n?-1:l.ucmp(this.p);return h===0?(l.words[0]=0,l.length=1):h>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},H.prototype.split=function(a,l){a.iushrn(this.n,0,l)},H.prototype.imulK=function(a){return a.imul(this.k)};function Z(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(Z,H),Z.prototype.split=function(a,l){for(var d=4194303,h=Math.min(a.length,9),g=0;g<h;g++)l.words[g]=a.words[g];if(l.length=h,a.length<=9){a.words[0]=0,a.length=1;return}var w=a.words[9];for(l.words[l.length++]=w&d,g=10;g<a.length;g++){var R=a.words[g]|0;a.words[g-10]=(R&d)<<4|w>>>22,w=R}w>>>=22,a.words[g-10]=w,w===0&&a.length>10?a.length-=10:a.length-=9},Z.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var l=0,d=0;d<a.length;d++){var h=a.words[d]|0;l+=h*977,a.words[d]=l&67108863,l=h*64+(l/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function ee(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ee,H);function Y(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(Y,H);function Ie(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Ie,H),Ie.prototype.imulK=function(a){for(var l=0,d=0;d<a.length;d++){var h=(a.words[d]|0)*19+l,g=h&67108863;h>>>=26,a.words[d]=g,l=h}return l!==0&&(a.words[a.length++]=l),a},i._prime=function(a){if(te[a])return te[a];var l;if(a==="k256")l=new Z;else if(a==="p224")l=new ee;else if(a==="p192")l=new Y;else if(a==="p25519")l=new Ie;else throw new Error("Unknown prime "+a);return te[a]=l,l};function re(v){if(typeof v=="string"){var a=i._prime(v);this.m=a.p,this.prime=a}else t(v.gtn(1),"modulus must be greater than 1"),this.m=v,this.prime=null}re.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},re.prototype._verify2=function(a,l){t((a.negative|l.negative)===0,"red works only with positives"),t(a.red&&a.red===l.red,"red works only with red numbers")},re.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(p(a,a.umod(this.m)._forceRed(this)),a)},re.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},re.prototype.add=function(a,l){this._verify2(a,l);var d=a.add(l);return d.cmp(this.m)>=0&&d.isub(this.m),d._forceRed(this)},re.prototype.iadd=function(a,l){this._verify2(a,l);var d=a.iadd(l);return d.cmp(this.m)>=0&&d.isub(this.m),d},re.prototype.sub=function(a,l){this._verify2(a,l);var d=a.sub(l);return d.cmpn(0)<0&&d.iadd(this.m),d._forceRed(this)},re.prototype.isub=function(a,l){this._verify2(a,l);var d=a.isub(l);return d.cmpn(0)<0&&d.iadd(this.m),d},re.prototype.shl=function(a,l){return this._verify1(a),this.imod(a.ushln(l))},re.prototype.imul=function(a,l){return this._verify2(a,l),this.imod(a.imul(l))},re.prototype.mul=function(a,l){return this._verify2(a,l),this.imod(a.mul(l))},re.prototype.isqr=function(a){return this.imul(a,a.clone())},re.prototype.sqr=function(a){return this.mul(a,a)},re.prototype.sqrt=function(a){if(a.isZero())return a.clone();var l=this.m.andln(3);if(t(l%2===1),l===3){var d=this.m.add(new i(1)).iushrn(2);return this.pow(a,d)}for(var h=this.m.subn(1),g=0;!h.isZero()&&h.andln(1)===0;)g++,h.iushrn(1);t(!h.isZero());var w=new i(1).toRed(this),R=w.redNeg(),y=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);this.pow(f,y).cmp(R)!==0;)f.redIAdd(R);for(var _=this.pow(f,h),C=this.pow(a,h.addn(1).iushrn(1)),D=this.pow(a,h),V=g;D.cmp(w)!==0;){for(var X=D,ie=0;X.cmp(w)!==0;ie++)X=X.redSqr();t(ie<V);var ue=this.pow(_,new i(1).iushln(V-ie-1));C=C.redMul(ue),_=ue.redSqr(),D=D.redMul(_),V=ie}return C},re.prototype.invm=function(a){var l=a._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},re.prototype.pow=function(a,l){if(l.isZero())return new i(1).toRed(this);if(l.cmpn(1)===0)return a.clone();var d=4,h=new Array(1<<d);h[0]=new i(1).toRed(this),h[1]=a;for(var g=2;g<h.length;g++)h[g]=this.mul(h[g-1],a);var w=h[0],R=0,y=0,f=l.bitLength()%26;for(f===0&&(f=26),g=l.length-1;g>=0;g--){for(var _=l.words[g],C=f-1;C>=0;C--){var D=_>>C&1;if(w!==h[0]&&(w=this.sqr(w)),D===0&&R===0){y=0;continue}R<<=1,R|=D,y++,!(y!==d&&(g!==0||C!==0))&&(w=this.mul(w,h[R]),y=0,R=0)}f=26}return w},re.prototype.convertTo=function(a){var l=a.umod(this.m);return l===a?l.clone():l},re.prototype.convertFrom=function(a){var l=a.clone();return l.red=null,l},i.mont=function(a){return new fe(a)};function fe(v){re.call(this,v),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(fe,re),fe.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},fe.prototype.convertFrom=function(a){var l=this.imod(a.mul(this.rinv));return l.red=null,l},fe.prototype.imul=function(a,l){if(a.isZero()||l.isZero())return a.words[0]=0,a.length=1,a;var d=a.imul(l),h=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),g=d.isub(h).iushrn(this.shift),w=g;return g.cmp(this.m)>=0?w=g.isub(this.m):g.cmpn(0)<0&&(w=g.iadd(this.m)),w._forceRed(this)},fe.prototype.mul=function(a,l){if(a.isZero()||l.isZero())return new i(0)._forceRed(this);var d=a.mul(l),h=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),g=d.isub(h).iushrn(this.shift),w=g;return g.cmp(this.m)>=0?w=g.isub(this.m):g.cmpn(0)<0&&(w=g.iadd(this.m)),w._forceRed(this)},fe.prototype.invm=function(a){var l=this.imod(a._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(typeof Ec>"u"||Ec,El)});var Al=zt((Sc,Sl)=>{var to=Di(),mr=to.Buffer;function Rl(r,e){for(var t in r)e[t]=r[t]}mr.from&&mr.alloc&&mr.allocUnsafe&&mr.allocUnsafeSlow?Sl.exports=to:(Rl(to,Sc),Sc.Buffer=Dn);function Dn(r,e,t){return mr(r,e,t)}Dn.prototype=Object.create(mr.prototype);Rl(mr,Dn);Dn.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return mr(r,e,t)};Dn.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=mr(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};Dn.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return mr(r)};Dn.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return to.SlowBuffer(r)}});var Il=zt((FR,xl)=>{"use strict";var ro=Al().Buffer;function Ym(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var n=0;n<r.length;n++){var i=r.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var o=r.length,c=r.charAt(0),u=Math.log(o)/Math.log(256),p=Math.log(256)/Math.log(o);function m(S){if((Array.isArray(S)||S instanceof Uint8Array)&&(S=ro.from(S)),!ro.isBuffer(S))throw new TypeError("Expected Buffer");if(S.length===0)return"";for(var T=0,I=0,x=0,B=S.length;x!==B&&S[x]===0;)x++,T++;for(var U=(B-x)*p+1>>>0,L=new Uint8Array(U);x!==B;){for(var F=S[x],te=0,H=U-1;(F!==0||te<I)&&H!==-1;H--,te++)F+=256*L[H]>>>0,L[H]=F%o>>>0,F=F/o>>>0;if(F!==0)throw new Error("Non-zero carry");I=te,x++}for(var Z=U-I;Z!==U&&L[Z]===0;)Z++;for(var ee=c.repeat(T);Z<U;++Z)ee+=r.charAt(L[Z]);return ee}function b(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return ro.alloc(0);for(var T=0,I=0,x=0;S[T]===c;)I++,T++;for(var B=(S.length-T)*u+1>>>0,U=new Uint8Array(B);T<S.length;){var L=S.charCodeAt(T);if(L>255)return;var F=e[L];if(F===255)return;for(var te=0,H=B-1;(F!==0||te<x)&&H!==-1;H--,te++)F+=o*U[H]>>>0,U[H]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");x=te,T++}for(var Z=B-x;Z!==B&&U[Z]===0;)Z++;var ee=ro.allocUnsafe(I+(B-Z));ee.fill(0,0,I);for(var Y=I;Z!==B;)ee[Y++]=U[Z++];return ee}function A(S){var T=b(S);if(T)return T;throw new Error("Non-base"+o+" character")}return{encode:m,decodeUnsafe:b,decode:A}}xl.exports=Ym});var Ac=zt((VR,Ol)=>{var Xm=Il(),Jm="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Ol.exports=Xm(Jm)});var kl=zt(kc=>{"use strict";function Tr(r,e,t){return e<=r&&r<=t}function ao(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function eg(r){for(var e=String(r),t=e.length,n=0,i=[];n<t;){var s=e.charCodeAt(n);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(n===t-1)i.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var c=s&1023,u=o&1023;i.push(65536+(c<<10)+u),n+=1}else i.push(65533)}n+=1}return i}function tg(r){for(var e="",t=0;t<r.length;++t){var n=r[t];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return e}var no=-1;function Oc(r){this.tokens=[].slice.call(r)}Oc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():no},prepend:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.push(e.shift());else this.tokens.push(r)}};var hi=-1;function Ic(r,e){if(r)throw TypeError("Decoder error");return e||65533}var io="utf-8";function so(r,e){if(!(this instanceof so))return new so(r,e);if(r=r!==void 0?String(r).toLowerCase():io,r!==io)throw new Error("Encoding not supported. Only utf-8 is supported");e=ao(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})}so.prototype={decode:function(e,t){var n;typeof e=="object"&&e instanceof ArrayBuffer?n=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):n=new Uint8Array(0),t=ao(t),this._streaming||(this._decoder=new rg({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var i=new Oc(n),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==hi);)o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===hi)break;o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o))}while(!i.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),tg(s)}};function oo(r,e){if(!(this instanceof oo))return new oo(r,e);if(r=r!==void 0?String(r).toLowerCase():io,r!==io)throw new Error("Encoding not supported. Only utf-8 is supported");e=ao(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}oo.prototype={encode:function(e,t){e=e?String(e):"",t=ao(t),this._streaming||(this._encoder=new ng(this._options)),this._streaming=!!t.stream;for(var n=[],i=new Oc(eg(e)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==hi);)Array.isArray(s)?n.push.apply(n,s):n.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==hi;)Array.isArray(s)?n.push.apply(n,s):n.push(s);this._encoder=null}return new Uint8Array(n)}};function rg(r){var e=r.fatal,t=0,n=0,i=0,s=128,o=191;this.handler=function(c,u){if(u===no&&i!==0)return i=0,Ic(e);if(u===no)return hi;if(i===0){if(Tr(u,0,127))return u;if(Tr(u,194,223))i=1,t=u-192;else if(Tr(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,t=u-224;else if(Tr(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,t=u-240;else return Ic(e);return t=t<<6*i,null}if(!Tr(u,s,o))return t=i=n=0,s=128,o=191,c.prepend(u),Ic(e);if(s=128,o=191,n+=1,t+=u-128<<6*(i-n),n!==i)return null;var p=t;return t=i=n=0,p}}function ng(r){var e=r.fatal;this.handler=function(t,n){if(n===no)return hi;if(Tr(n,0,127))return n;var i,s;Tr(n,128,2047)?(i=1,s=192):Tr(n,2048,65535)?(i=2,s=224):Tr(n,65536,1114111)&&(i=3,s=240);for(var o=[(n>>6*i)+s];i>0;){var c=n>>6*(i-1);o.push(128|c&63),i-=1}return o}}kc.TextEncoder=oo;kc.TextDecoder=so});var Cl=zt(ke=>{"use strict";var ig=ke&&ke.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t),Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[t]}})}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),sg=ke&&ke.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),gr=ke&&ke.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},og=ke&&ke.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.hasOwnProperty.call(r,t)&&ig(e,r,t);return sg(e,r),e},Tl=ke&&ke.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ke,"__esModule",{value:!0});ke.deserializeUnchecked=ke.deserialize=ke.serialize=ke.BinaryReader=ke.BinaryWriter=ke.BorshError=ke.baseDecode=ke.baseEncode=void 0;var Qr=Tl(Rc()),Nl=Tl(Ac()),ag=og(kl()),cg=typeof TextDecoder!="function"?ag.TextDecoder:TextDecoder,ug=new cg("utf-8",{fatal:!0});function fg(r){return typeof r=="string"&&(r=Buffer.from(r,"utf8")),Nl.default.encode(Buffer.from(r))}ke.baseEncode=fg;function lg(r){return Buffer.from(Nl.default.decode(r))}ke.baseDecode=lg;var Tc=1024,Et=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}};ke.BorshError=Et;var co=class{constructor(){this.buf=Buffer.alloc(Tc),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Tc)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Buffer.from(new Qr.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new Qr.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new Qr.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new Qr.default(e).toArray("le",64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(Tc)]),this.length+=e.length}writeString(e){this.maybeResize();let t=Buffer.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Buffer.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};ke.BinaryWriter=co;function yr(r,e,t){let n=t.value;t.value=function(...i){try{return n.apply(this,i)}catch(s){if(s instanceof RangeError){let o=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new Et("Reached the end of buffer when deserializing")}throw s}}}var Mt=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new Qr.default(e,"le")}readU128(){let e=this.readBuffer(16);return new Qr.default(e,"le")}readU256(){let e=this.readBuffer(32);return new Qr.default(e,"le")}readU512(){let e=this.readBuffer(64);return new Qr.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new Et(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return ug.decode(t)}catch(n){throw new Et(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=Array();for(let i=0;i<t;++i)n.push(e());return n}};gr([yr],Mt.prototype,"readU8",null);gr([yr],Mt.prototype,"readU16",null);gr([yr],Mt.prototype,"readU32",null);gr([yr],Mt.prototype,"readU64",null);gr([yr],Mt.prototype,"readU128",null);gr([yr],Mt.prototype,"readU256",null);gr([yr],Mt.prototype,"readU512",null);gr([yr],Mt.prototype,"readString",null);gr([yr],Mt.prototype,"readFixedArray",null);gr([yr],Mt.prototype,"readArray",null);ke.BinaryReader=Mt;function Bl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function zn(r,e,t,n,i){try{if(typeof n=="string")i[`write${Bl(n)}`](t);else if(n instanceof Array)if(typeof n[0]=="number"){if(t.length!==n[0])throw new Et(`Expecting byte array of length ${n[0]}, but got ${t.length} bytes`);i.writeFixedArray(t)}else if(n.length===2&&typeof n[1]=="number"){if(t.length!==n[1])throw new Et(`Expecting byte array of length ${n[1]}, but got ${t.length} bytes`);for(let s=0;s<n[1];s++)zn(r,null,t[s],n[0],i)}else i.writeArray(t,s=>{zn(r,e,s,n[0],i)});else if(n.kind!==void 0)switch(n.kind){case"option":{t==null?i.writeU8(0):(i.writeU8(1),zn(r,e,t,n.type,i));break}case"map":{i.writeU32(t.size),t.forEach((s,o)=>{zn(r,e,o,n.key,i),zn(r,e,s,n.value,i)});break}default:throw new Et(`FieldType ${n} unrecognized`)}else Ll(r,t,i)}catch(s){throw s instanceof Et&&s.addToFieldPath(e),s}}function Ll(r,e,t){if(typeof e.borshSerialize=="function"){e.borshSerialize(t);return}let n=r.get(e.constructor);if(!n)throw new Et(`Class ${e.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([i,s])=>{zn(r,i,e[i],s,t)});else if(n.kind==="enum"){let i=e[n.field];for(let s=0;s<n.values.length;++s){let[o,c]=n.values[s];if(o===i){t.writeU8(s),zn(r,o,e[o],c,t);break}}}else throw new Et(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function dg(r,e,t=co){let n=new t;return Ll(r,e,n),n.toArray()}ke.serialize=dg;function Fn(r,e,t,n){try{if(typeof t=="string")return n[`read${Bl(t)}`]();if(t instanceof Array){if(typeof t[0]=="number")return n.readFixedArray(t[0]);if(typeof t[1]=="number"){let i=[];for(let s=0;s<t[1];s++)i.push(Fn(r,null,t[0],n));return i}else return n.readArray(()=>Fn(r,e,t[0],n))}if(t.kind==="option")return n.readU8()?Fn(r,e,t.type,n):void 0;if(t.kind==="map"){let i=new Map,s=n.readU32();for(let o=0;o<s;o++){let c=Fn(r,e,t.key,n),u=Fn(r,e,t.value,n);i.set(c,u)}return i}return Nc(r,t,n)}catch(i){throw i instanceof Et&&i.addToFieldPath(e),i}}function Nc(r,e,t){if(typeof e.borshDeserialize=="function")return e.borshDeserialize(t);let n=r.get(e);if(!n)throw new Et(`Class ${e.name} is missing in schema`);if(n.kind==="struct"){let i={};for(let[s,o]of r.get(e).fields)i[s]=Fn(r,s,o,t);return new e(i)}if(n.kind==="enum"){let i=t.readU8();if(i>=n.values.length)throw new Et(`Enum index: ${i} is out of range`);let[s,o]=n.values[i],c=Fn(r,s,o,t);return new e({[s]:c})}throw new Et(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function hg(r,e,t,n=Mt){let i=new n(t),s=Nc(r,e,i);if(i.offset<t.length)throw new Et(`Unexpected ${t.length-i.offset} bytes after deserialized data`);return s}ke.deserialize=hg;function pg(r,e,t,n=Mt){let i=new n(t);return Nc(r,e,i)}ke.deserializeUnchecked=pg});var Pc=zt(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.s16=k.s8=k.nu64be=k.u48be=k.u40be=k.u32be=k.u24be=k.u16be=k.nu64=k.u48=k.u40=k.u32=k.u24=k.u16=k.u8=k.offset=k.greedy=k.Constant=k.UTF8=k.CString=k.Blob=k.Boolean=k.BitField=k.BitStructure=k.VariantLayout=k.Union=k.UnionLayoutDiscriminator=k.UnionDiscriminator=k.Structure=k.Sequence=k.DoubleBE=k.Double=k.FloatBE=k.Float=k.NearInt64BE=k.NearInt64=k.NearUInt64BE=k.NearUInt64=k.IntBE=k.Int=k.UIntBE=k.UInt=k.OffsetLayout=k.GreedyCount=k.ExternalLayout=k.bindConstructorLayout=k.nameWithProperty=k.Layout=k.uint8ArrayToBuffer=k.checkUint8Array=void 0;k.constant=k.utf8=k.cstr=k.blob=k.unionLayoutDiscriminator=k.union=k.seq=k.bits=k.struct=k.f64be=k.f64=k.f32be=k.f32=k.ns64be=k.s48be=k.s40be=k.s32be=k.s24be=k.s16be=k.ns64=k.s48=k.s40=k.s32=k.s24=void 0;var Lc=Di();function gi(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}k.checkUint8Array=gi;function ve(r){return gi(r),Lc.Buffer.from(r.buffer,r.byteOffset,r.length)}k.uint8ArrayToBuffer=ve;var Re=class{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};k.Layout=Re;function Cc(r,e){return e.property?r+"["+e.property+"]":r}k.nameWithProperty=Cc;function mg(r,e){if(typeof r!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(r,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Re))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=e,e.boundConstructor_=r,e.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(r,"decode",{value(t,n){return e.decode(t,n)},writable:!0})}k.bindConstructorLayout=mg;var It=class extends Re{isCount(){throw new Error("ExternalLayout is abstract")}};k.ExternalLayout=It;var uo=class extends It{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){gi(e);let n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}};k.GreedyCount=uo;var qi=class extends It{constructor(e,t=0,n){if(!(e instanceof Re))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof qt||this.layout instanceof Gt}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};k.OffsetLayout=qi;var qt=class extends Re{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return ve(e).readUIntLE(t,this.span)}encode(e,t,n=0){return ve(t).writeUIntLE(e,n,this.span),this.span}};k.UInt=qt;var Gt=class extends Re{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return ve(e).readUIntBE(t,this.span)}encode(e,t,n=0){return ve(t).writeUIntBE(e,n,this.span),this.span}};k.UIntBE=Gt;var Nr=class extends Re{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return ve(e).readIntLE(t,this.span)}encode(e,t,n=0){return ve(t).writeIntLE(e,n,this.span),this.span}};k.Int=Nr;var en=class extends Re{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return ve(e).readIntBE(t,this.span)}encode(e,t,n=0){return ve(t).writeIntBE(e,n,this.span),this.span}};k.IntBE=en;var Bc=Math.pow(2,32);function Io(r){let e=Math.floor(r/Bc),t=r-e*Bc;return{hi32:e,lo32:t}}function Oo(r,e){return r*Bc+e}var fo=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=ve(e),i=n.readUInt32LE(t),s=n.readUInt32LE(t+4);return Oo(s,i)}encode(e,t,n=0){let i=Io(e),s=ve(t);return s.writeUInt32LE(i.lo32,n),s.writeUInt32LE(i.hi32,n+4),8}};k.NearUInt64=fo;var lo=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=ve(e),i=n.readUInt32BE(t),s=n.readUInt32BE(t+4);return Oo(i,s)}encode(e,t,n=0){let i=Io(e),s=ve(t);return s.writeUInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};k.NearUInt64BE=lo;var ho=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=ve(e),i=n.readUInt32LE(t),s=n.readInt32LE(t+4);return Oo(s,i)}encode(e,t,n=0){let i=Io(e),s=ve(t);return s.writeUInt32LE(i.lo32,n),s.writeInt32LE(i.hi32,n+4),8}};k.NearInt64=ho;var po=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=ve(e),i=n.readInt32BE(t),s=n.readUInt32BE(t+4);return Oo(i,s)}encode(e,t,n=0){let i=Io(e),s=ve(t);return s.writeInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};k.NearInt64BE=po;var mo=class extends Re{constructor(e){super(4,e)}decode(e,t=0){return ve(e).readFloatLE(t)}encode(e,t,n=0){return ve(t).writeFloatLE(e,n),4}};k.Float=mo;var go=class extends Re{constructor(e){super(4,e)}decode(e,t=0){return ve(e).readFloatBE(t)}encode(e,t,n=0){return ve(t).writeFloatBE(e,n),4}};k.FloatBE=go;var yo=class extends Re{constructor(e){super(8,e)}decode(e,t=0){return ve(e).readDoubleLE(t)}encode(e,t,n=0){return ve(t).writeDoubleLE(e,n),8}};k.Double=yo;var _o=class extends Re{constructor(e){super(8,e)}decode(e,t=0){return ve(e).readDoubleBE(t)}encode(e,t,n=0){return ve(t).writeDoubleBE(e,n),8}};k.DoubleBE=_o;var bo=class extends Re{constructor(e,t,n){if(!(e instanceof Re))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof It&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(t instanceof It)&&0<e.span&&(i=t*e.span),super(i,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,i=this.count;if(i instanceof It&&(i=i.decode(e,t)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let s=0;for(;s<i;)n+=this.elementLayout.getSpan(e,t+n),++s}return n}decode(e,t=0){let n=[],i=0,s=this.count;for(s instanceof It&&(s=s.decode(e,t));i<s;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return n}encode(e,t,n=0){let i=this.elementLayout,s=e.reduce((o,c)=>o+i.encode(c,t,n+o),0);return this.count instanceof It&&this.count.encode(e.length,t,n),s}};k.Sequence=bo;var wo=class extends Re{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Re,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(let s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((i,s)=>{let o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t=0){gi(e);let n=this.makeDestinationObject();for(let i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){let i=n,s=0,o=0;for(let c of this.fields){let u=c.span;if(o=0<u?u:0,c.property!==void 0){let p=e[c.property];p!==void 0&&(o=c.encode(p,t,n),0>u&&(u=c.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};k.Structure=wo;var ji=class{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,n){throw new Error("UnionDiscriminator is abstract")}};k.UnionDiscriminator=ji;var mi=class extends ji{constructor(e,t){if(!(e instanceof It&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};k.UnionLayoutDiscriminator=mi;var Ki=class extends Re{constructor(e,t,n){let i;if(e instanceof qt||e instanceof Gt)i=new mi(new qi(e));else if(e instanceof It&&e.isCount())i=new mi(e);else if(e instanceof ji)i=e;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Re))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&(e instanceof qt||e instanceof Gt)&&(s+=i.layout.span)),super(s,n),this.discriminator=i,this.usesPrefixDiscriminator=e instanceof qt||e instanceof Gt,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw new Error("unable to infer src variant")}decode(e,t=0){let n,i=this.discriminator,s=i.decode(e,t),o=this.registry[s];if(o===void 0){let c=this.defaultLayout,u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[c.property]=c.decode(e,t+u)}else n=o.decode(e,t);return n}encode(e,t,n=0){let i=this.getSourceVariant(e);if(i===void 0){let s=this.discriminator,o=this.defaultLayout,c=0;return this.usesPrefixDiscriminator&&(c=s.layout.span),s.encode(e[s.property],t,n),c+o.encode(e[o.property],t,n+c)}return i.encode(e,t,n)}addVariant(e,t,n){let i=new vo(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t=0){let n;return e instanceof Uint8Array?n=this.discriminator.decode(e,t):n=e,this.registry[n]}};k.Union=Ki;var vo=class extends Re{constructor(e,t,n,i){if(!(e instanceof Ki))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Re))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(e,t+n)),n+i}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};k.VariantLayout=vo;function pi(r){return 0>r&&(r+=4294967296),r}var Hi=class extends Re{constructor(e,t,n){if(!(e instanceof qt||e instanceof Gt))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&n===void 0&&(n=t,t=!1),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(s){return i=pi(s),this},this._packedGetValue=function(){return i}}decode(e,t=0){let n=this.makeDestinationObject(),i=this.word.decode(e,t);this._packedSetValue(i);for(let s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(e));return n}encode(e,t,n=0){let i=this.word.decode(t,n);this._packedSetValue(i);for(let s of this.fields)if(s.property!==void 0){let o=e[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new Gi(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new Eo(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}};k.BitStructure=Hi;var Gi=class{constructor(e,t,n){if(!(e instanceof Hi))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");let i=8*e.span,s=e.fields.reduce((o,c)=>o+c.bits,0);if(t+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=pi(this.valueMask<<this.start),this.property=n}decode(e,t){let n=this.container._packedGetValue();return pi(n&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==pi(e&this.valueMask))throw new TypeError(Cc("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let t=this.container._packedGetValue(),n=pi(e<<this.start);this.container._packedSetValue(pi(t&~this.wordMask)|n)}};k.BitField=Gi;var Eo=class extends Gi{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e=="boolean"&&(e=+e),super.encode(e)}};k.Boolean=Eo;var Ro=class extends Re{constructor(e,t){if(!(e instanceof It&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof It||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),ve(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof It&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw new TypeError(Cc("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(n+i>t.length)throw new RangeError("encoding overruns Uint8Array");let s=ve(e);return ve(t).write(s.toString("hex"),n,i,"hex"),this.length instanceof It&&this.length.encode(i,t,n),i}};k.Blob=Ro;var So=class extends Re{constructor(e){super(-1,e)}getSpan(e,t=0){gi(e);let n=t;for(;n<e.length&&e[n]!==0;)n+=1;return 1+n-t}decode(e,t=0){let n=this.getSpan(e,t);return ve(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));let i=Lc.Buffer.from(e,"utf8"),s=i.length;if(n+s>t.length)throw new RangeError("encoding overruns Buffer");let o=ve(t);return i.copy(o,n),o[n+s]=0,s+1}};k.CString=So;var Ao=class extends Re{constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return gi(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return ve(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));let i=Lc.Buffer.from(e,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(ve(t),n),s}};k.UTF8=Ao;var xo=class extends Re{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};k.Constant=xo;k.greedy=(r,e)=>new uo(r,e);k.offset=(r,e,t)=>new qi(r,e,t);k.u8=r=>new qt(1,r);k.u16=r=>new qt(2,r);k.u24=r=>new qt(3,r);k.u32=r=>new qt(4,r);k.u40=r=>new qt(5,r);k.u48=r=>new qt(6,r);k.nu64=r=>new fo(r);k.u16be=r=>new Gt(2,r);k.u24be=r=>new Gt(3,r);k.u32be=r=>new Gt(4,r);k.u40be=r=>new Gt(5,r);k.u48be=r=>new Gt(6,r);k.nu64be=r=>new lo(r);k.s8=r=>new Nr(1,r);k.s16=r=>new Nr(2,r);k.s24=r=>new Nr(3,r);k.s32=r=>new Nr(4,r);k.s40=r=>new Nr(5,r);k.s48=r=>new Nr(6,r);k.ns64=r=>new ho(r);k.s16be=r=>new en(2,r);k.s24be=r=>new en(3,r);k.s32be=r=>new en(4,r);k.s40be=r=>new en(5,r);k.s48be=r=>new en(6,r);k.ns64be=r=>new po(r);k.f32=r=>new mo(r);k.f32be=r=>new go(r);k.f64=r=>new yo(r);k.f64be=r=>new _o(r);k.struct=(r,e,t)=>new wo(r,e,t);k.bits=(r,e,t)=>new Hi(r,e,t);k.seq=(r,e,t)=>new bo(r,e,t);k.union=(r,e,t)=>new Ki(r,e,t);k.unionLayoutDiscriminator=(r,e)=>new mi(r,e);k.blob=(r,e)=>new Ro(r,e);k.cstr=r=>new So(r);k.utf8=(r,e)=>new Ao(r,e);k.constant=(r,e)=>new xo(r,e)});function Xi(){if(!Bo&&(Bo=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Bo))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Bo(Iw)}var Bo,Iw,Kc=Ct(()=>{Iw=new Uint8Array(16)});var Ql,ed=Ct(()=>{Ql=/^(?:[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 Ow(r){return typeof r=="string"&&Ql.test(r)}var rn,Ji=Ct(()=>{ed();rn=Ow});function kw(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(Rt[r[e+0]]+Rt[r[e+1]]+Rt[r[e+2]]+Rt[r[e+3]]+"-"+Rt[r[e+4]]+Rt[r[e+5]]+"-"+Rt[r[e+6]]+Rt[r[e+7]]+"-"+Rt[r[e+8]]+Rt[r[e+9]]+"-"+Rt[r[e+10]]+Rt[r[e+11]]+Rt[r[e+12]]+Rt[r[e+13]]+Rt[r[e+14]]+Rt[r[e+15]]).toLowerCase();if(!rn(t))throw TypeError("Stringified UUID is invalid");return t}var Rt,Lo,nn,Qi=Ct(()=>{Ji();Rt=[];for(Lo=0;Lo<256;++Lo)Rt.push((Lo+256).toString(16).substr(1));nn=kw});function Tw(r,e,t){var n=e&&t||0,i=e||new Array(16);r=r||{};var s=r.node||td,o=r.clockseq!==void 0?r.clockseq:Hc;if(s==null||o==null){var c=r.random||(r.rng||Xi)();s==null&&(s=td=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),o==null&&(o=Hc=(c[6]<<8|c[7])&16383)}var u=r.msecs!==void 0?r.msecs:Date.now(),p=r.nsecs!==void 0?r.nsecs:Zc+1,m=u-Gc+(p-Zc)/1e4;if(m<0&&r.clockseq===void 0&&(o=o+1&16383),(m<0||u>Gc)&&r.nsecs===void 0&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Gc=u,Zc=p,Hc=o,u+=122192928e5;var b=((u&268435455)*1e4+p)%4294967296;i[n++]=b>>>24&255,i[n++]=b>>>16&255,i[n++]=b>>>8&255,i[n++]=b&255;var A=u/4294967296*1e4&268435455;i[n++]=A>>>8&255,i[n++]=A&255,i[n++]=A>>>24&15|16,i[n++]=A>>>16&255,i[n++]=o>>>8|128,i[n++]=o&255;for(var S=0;S<6;++S)i[n+S]=s[S];return e||nn(i)}var td,Hc,Gc,Zc,rd,nd=Ct(()=>{Kc();Qi();Gc=0,Zc=0;rd=Tw});function Nw(r){if(!rn(r))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var Co,Yc=Ct(()=>{Ji();Co=Nw});function Bw(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}function Po(r,e,t){function n(i,s,o,c){if(typeof i=="string"&&(i=Bw(i)),typeof s=="string"&&(s=Co(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(s),u.set(i,s.length),u=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){c=c||0;for(var p=0;p<16;++p)o[c+p]=u[p];return o}return nn(u)}try{n.name=r}catch{}return n.DNS=Lw,n.URL=Cw,n}var Lw,Cw,Xc=Ct(()=>{Qi();Yc();Lw="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Cw="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function Pw(r){if(typeof r=="string"){var e=unescape(encodeURIComponent(r));r=new Uint8Array(e.length);for(var t=0;t<e.length;++t)r[t]=e.charCodeAt(t)}return Mw(Uw(Dw(r),r.length*8))}function Mw(r){for(var e=[],t=r.length*32,n="0123456789abcdef",i=0;i<t;i+=8){var s=r[i>>5]>>>i%32&255,o=parseInt(n.charAt(s>>>4&15)+n.charAt(s&15),16);e.push(o)}return e}function id(r){return(r+64>>>9<<4)+14+1}function Uw(r,e){r[e>>5]|=128<<e%32,r[id(e)-1]=e;for(var t=1732584193,n=-271733879,i=-1732584194,s=271733878,o=0;o<r.length;o+=16){var c=t,u=n,p=i,m=s;t=kt(t,n,i,s,r[o],7,-680876936),s=kt(s,t,n,i,r[o+1],12,-389564586),i=kt(i,s,t,n,r[o+2],17,606105819),n=kt(n,i,s,t,r[o+3],22,-1044525330),t=kt(t,n,i,s,r[o+4],7,-176418897),s=kt(s,t,n,i,r[o+5],12,1200080426),i=kt(i,s,t,n,r[o+6],17,-1473231341),n=kt(n,i,s,t,r[o+7],22,-45705983),t=kt(t,n,i,s,r[o+8],7,1770035416),s=kt(s,t,n,i,r[o+9],12,-1958414417),i=kt(i,s,t,n,r[o+10],17,-42063),n=kt(n,i,s,t,r[o+11],22,-1990404162),t=kt(t,n,i,s,r[o+12],7,1804603682),s=kt(s,t,n,i,r[o+13],12,-40341101),i=kt(i,s,t,n,r[o+14],17,-1502002290),n=kt(n,i,s,t,r[o+15],22,1236535329),t=Tt(t,n,i,s,r[o+1],5,-165796510),s=Tt(s,t,n,i,r[o+6],9,-1069501632),i=Tt(i,s,t,n,r[o+11],14,643717713),n=Tt(n,i,s,t,r[o],20,-373897302),t=Tt(t,n,i,s,r[o+5],5,-701558691),s=Tt(s,t,n,i,r[o+10],9,38016083),i=Tt(i,s,t,n,r[o+15],14,-660478335),n=Tt(n,i,s,t,r[o+4],20,-405537848),t=Tt(t,n,i,s,r[o+9],5,568446438),s=Tt(s,t,n,i,r[o+14],9,-1019803690),i=Tt(i,s,t,n,r[o+3],14,-187363961),n=Tt(n,i,s,t,r[o+8],20,1163531501),t=Tt(t,n,i,s,r[o+13],5,-1444681467),s=Tt(s,t,n,i,r[o+2],9,-51403784),i=Tt(i,s,t,n,r[o+7],14,1735328473),n=Tt(n,i,s,t,r[o+12],20,-1926607734),t=Nt(t,n,i,s,r[o+5],4,-378558),s=Nt(s,t,n,i,r[o+8],11,-2022574463),i=Nt(i,s,t,n,r[o+11],16,1839030562),n=Nt(n,i,s,t,r[o+14],23,-35309556),t=Nt(t,n,i,s,r[o+1],4,-1530992060),s=Nt(s,t,n,i,r[o+4],11,1272893353),i=Nt(i,s,t,n,r[o+7],16,-155497632),n=Nt(n,i,s,t,r[o+10],23,-1094730640),t=Nt(t,n,i,s,r[o+13],4,681279174),s=Nt(s,t,n,i,r[o],11,-358537222),i=Nt(i,s,t,n,r[o+3],16,-722521979),n=Nt(n,i,s,t,r[o+6],23,76029189),t=Nt(t,n,i,s,r[o+9],4,-640364487),s=Nt(s,t,n,i,r[o+12],11,-421815835),i=Nt(i,s,t,n,r[o+15],16,530742520),n=Nt(n,i,s,t,r[o+2],23,-995338651),t=Bt(t,n,i,s,r[o],6,-198630844),s=Bt(s,t,n,i,r[o+7],10,1126891415),i=Bt(i,s,t,n,r[o+14],15,-1416354905),n=Bt(n,i,s,t,r[o+5],21,-57434055),t=Bt(t,n,i,s,r[o+12],6,1700485571),s=Bt(s,t,n,i,r[o+3],10,-1894986606),i=Bt(i,s,t,n,r[o+10],15,-1051523),n=Bt(n,i,s,t,r[o+1],21,-2054922799),t=Bt(t,n,i,s,r[o+8],6,1873313359),s=Bt(s,t,n,i,r[o+15],10,-30611744),i=Bt(i,s,t,n,r[o+6],15,-1560198380),n=Bt(n,i,s,t,r[o+13],21,1309151649),t=Bt(t,n,i,s,r[o+4],6,-145523070),s=Bt(s,t,n,i,r[o+11],10,-1120210379),i=Bt(i,s,t,n,r[o+2],15,718787259),n=Bt(n,i,s,t,r[o+9],21,-343485551),t=sn(t,c),n=sn(n,u),i=sn(i,p),s=sn(s,m)}return[t,n,i,s]}function Dw(r){if(r.length===0)return[];for(var e=r.length*8,t=new Uint32Array(id(e)),n=0;n<e;n+=8)t[n>>5]|=(r[n/8]&255)<<n%32;return t}function sn(r,e){var t=(r&65535)+(e&65535),n=(r>>16)+(e>>16)+(t>>16);return n<<16|t&65535}function zw(r,e){return r<<e|r>>>32-e}function Mo(r,e,t,n,i,s){return sn(zw(sn(sn(e,r),sn(n,s)),i),t)}function kt(r,e,t,n,i,s,o){return Mo(e&t|~e&n,r,e,i,s,o)}function Tt(r,e,t,n,i,s,o){return Mo(e&n|t&~n,r,e,i,s,o)}function Nt(r,e,t,n,i,s,o){return Mo(e^t^n,r,e,i,s,o)}function Bt(r,e,t,n,i,s,o){return Mo(t^(e|~n),r,e,i,s,o)}var sd,od=Ct(()=>{sd=Pw});var Fw,ad,cd=Ct(()=>{Xc();od();Fw=Po("v3",48,sd),ad=Fw});function Vw(r,e,t){r=r||{};var n=r.random||(r.rng||Xi)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var i=0;i<16;++i)e[t+i]=n[i];return e}return nn(n)}var ud,fd=Ct(()=>{Kc();Qi();ud=Vw});function $w(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function Jc(r,e){return r<<e|r>>>32-e}function Ww(r){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var i=0;i<n.length;++i)r.push(n.charCodeAt(i))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var s=r.length/4+2,o=Math.ceil(s/16),c=new Array(o),u=0;u<o;++u){for(var p=new Uint32Array(16),m=0;m<16;++m)p[m]=r[u*64+m*4]<<24|r[u*64+m*4+1]<<16|r[u*64+m*4+2]<<8|r[u*64+m*4+3];c[u]=p}c[o-1][14]=(r.length-1)*8/Math.pow(2,32),c[o-1][14]=Math.floor(c[o-1][14]),c[o-1][15]=(r.length-1)*8&4294967295;for(var b=0;b<o;++b){for(var A=new Uint32Array(80),S=0;S<16;++S)A[S]=c[b][S];for(var T=16;T<80;++T)A[T]=Jc(A[T-3]^A[T-8]^A[T-14]^A[T-16],1);for(var I=t[0],x=t[1],B=t[2],U=t[3],L=t[4],F=0;F<80;++F){var te=Math.floor(F/20),H=Jc(I,5)+$w(te,x,B,U)+L+e[te]+A[F]>>>0;L=U,U=B,B=Jc(x,30)>>>0,x=I,I=H}t[0]=t[0]+I>>>0,t[1]=t[1]+x>>>0,t[2]=t[2]+B>>>0,t[3]=t[3]+U>>>0,t[4]=t[4]+L>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var ld,dd=Ct(()=>{ld=Ww});var qw,hd,pd=Ct(()=>{Xc();dd();qw=Po("v5",80,ld),hd=qw});var md,gd=Ct(()=>{md="00000000-0000-0000-0000-000000000000"});function jw(r){if(!rn(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}var yd,_d=Ct(()=>{Ji();yd=jw});var Qc={};dn(Qc,{NIL:()=>md,parse:()=>Co,stringify:()=>nn,v1:()=>rd,v3:()=>ad,v4:()=>ud,v5:()=>hd,validate:()=>rn,version:()=>yd});var eu=Ct(()=>{nd();cd();fd();pd();gd();_d();Ji();Qi();Yc()});var wd=zt((FS,bd)=>{"use strict";var Kw=(eu(),Oa(Qc)).v4,Hw=function(r,e,t,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};let i=typeof n.version=="number"?n.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");let s={method:r};if(i===2&&(s.jsonrpc="2.0"),e){if(typeof e!="object"&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");s.params=e}if(typeof t>"u"){let o=typeof n.generator=="function"?n.generator:function(){return Kw()};s.id=o(s,n)}else i===2&&t===null?n.notificationIdNull&&(s.id=null):s.id=t;return s};bd.exports=Hw});var Ed=zt((VS,vd)=>{"use strict";var Gw=(eu(),Oa(Qc)).v4,Zw=wd(),es=function(r,e){if(!(this instanceof es))return new es(r,e);e||(e={}),this.options={reviver:typeof e.reviver<"u"?e.reviver:null,replacer:typeof e.replacer<"u"?e.replacer:null,generator:typeof e.generator<"u"?e.generator:function(){return Gw()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=r};vd.exports=es;es.prototype.request=function(r,e,t,n){let i=this,s=null,o=Array.isArray(r)&&typeof e=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&r&&typeof r=="object"&&typeof e=="function")n=e,s=r;else{typeof t=="function"&&(n=t,t=void 0);let p=typeof n=="function";try{s=Zw(r,e,t,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(m){if(p)return n(m);throw m}if(!p)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(p){return n(p)}return this.callServer(u,function(p,m){i._parseResponse(p,m,n)}),s};es.prototype._parseResponse=function(r,e,t){if(r){t(r);return}if(!e)return t();let n;try{n=JSON.parse(e,this.options.reviver)}catch(i){return t(i)}if(t.length===3)if(Array.isArray(n)){let i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return t(null,n.filter(i),n.filter(s))}else return t(null,n.error,n.result);t(null,n)}});var Sd=zt(($S,tu)=>{"use strict";var Yw=Object.prototype.hasOwnProperty,Ut="~";function ts(){}Object.create&&(ts.prototype=Object.create(null),new ts().__proto__||(Ut=!1));function Xw(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Rd(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new Xw(t,n||r,i),o=Ut?Ut+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function Uo(r,e){--r._eventsCount===0?r._events=new ts:delete r._events[e]}function Lt(){this._events=new ts,this._eventsCount=0}Lt.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Yw.call(t,n)&&e.push(Ut?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Lt.prototype.listeners=function(e){var t=Ut?Ut+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};Lt.prototype.listenerCount=function(e){var t=Ut?Ut+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Lt.prototype.emit=function(e,t,n,i,s,o){var c=Ut?Ut+e:e;if(!this._events[c])return!1;var u=this._events[c],p=arguments.length,m,b;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),p){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,s),!0;case 6:return u.fn.call(u.context,t,n,i,s,o),!0}for(b=1,m=new Array(p-1);b<p;b++)m[b-1]=arguments[b];u.fn.apply(u.context,m)}else{var A=u.length,S;for(b=0;b<A;b++)switch(u[b].once&&this.removeListener(e,u[b].fn,void 0,!0),p){case 1:u[b].fn.call(u[b].context);break;case 2:u[b].fn.call(u[b].context,t);break;case 3:u[b].fn.call(u[b].context,t,n);break;case 4:u[b].fn.call(u[b].context,t,n,i);break;default:if(!m)for(S=1,m=new Array(p-1);S<p;S++)m[S-1]=arguments[S];u[b].fn.apply(u[b].context,m)}}return!0};Lt.prototype.on=function(e,t,n){return Rd(this,e,t,n,!1)};Lt.prototype.once=function(e,t,n){return Rd(this,e,t,n,!0)};Lt.prototype.removeListener=function(e,t,n,i){var s=Ut?Ut+e:e;if(!this._events[s])return this;if(!t)return Uo(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&Uo(this,s);else{for(var c=0,u=[],p=o.length;c<p;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&u.push(o[c]);u.length?this._events[s]=u.length===1?u[0]:u:Uo(this,s)}return this};Lt.prototype.removeAllListeners=function(e){var t;return e?(t=Ut?Ut+e:e,this._events[t]&&Uo(this,t)):(this._events=new ts,this._eventsCount=0),this};Lt.prototype.off=Lt.prototype.removeListener;Lt.prototype.addListener=Lt.prototype.on;Lt.prefixed=Ut;Lt.EventEmitter=Lt;typeof tu<"u"&&(tu.exports=Lt)});var kE={};dn(kE,{AddMiniApp:()=>Xn,ComposeCast:()=>rf,Context:()=>uf,DEFAULT_READY_OPTIONS:()=>Na,Errors:()=>Ii,Ethereum:()=>cf,Manifest:()=>ff,Ready:()=>Ba,SendToken:()=>nf,SignIn:()=>Oi,SolanaConnection:()=>Xo,SwapToken:()=>sf,ViewProfile:()=>of,ViewToken:()=>af,actionLaunchFrameSchema:()=>Rf,actionSchema:()=>Af,actionViewTokenSchema:()=>Sf,aspectRatioSchema:()=>Fa,buttonSchema:()=>xf,buttonTitleSchema:()=>Pi,caip19TokenSchema:()=>za,createEmitter:()=>Gh,createSimpleStringSchema:()=>Fr,createSolanaWalletProvider:()=>Pu,default:()=>OE,domainFrameConfigSchema:()=>Lf,domainManifestSchema:()=>_p,encodedJsonFarcasterSignatureSchema:()=>Va,eventFrameAddedSchema:()=>Of,eventFrameRemovedSchema:()=>kf,eventNotificationsEnabledSchema:()=>Tf,frameEmbedNextSchema:()=>If,frameNameSchema:()=>Ci,hexColorSchema:()=>Mi,jsonFarcasterSignatureHeaderSchema:()=>dp,miniAppHostCapabilityList:()=>Bs,notificationDetailsSchema:()=>zs,notificationsDisabledSchema:()=>Nf,safeParseFrameEmbed:()=>hp,sdk:()=>qu,secureUrlSchema:()=>xt,sendNotificationRequestSchema:()=>pp,sendNotificationResponseSchema:()=>mp,serverEventSchema:()=>gp,unwrapSolanaProviderRequest:()=>Du,wrapSolanaProviderRequest:()=>oE});var Xn={};dn(Xn,{InvalidDomainManifest:()=>ka,RejectedByUser:()=>Ta});var Ii={};dn(Ii,{BaseError:()=>Mr});var Mr=class extends Error{name="BaseError";cause;constructor(e,t={}){super(e,t.cause?{cause:t.cause}:void 0),this.cause=t.cause}};var ka=class extends Mr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}},Ta=class extends Mr{name="AddMiniApp.RejectedByUser";constructor(){super("Add frame rejected by user")}};var rf={};var Ba={};dn(Ba,{DEFAULT_READY_OPTIONS:()=>Na});var Na={disableNativeGestures:!1};var Oi={};dn(Oi,{RejectedByUser:()=>La});var La=class extends Mr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};var nf={};var sf={};var of={};var af={};var cf={};var uf={};var ff={};var Bs=["wallet.getEthereumProvider","wallet.getSolanaProvider","actions.ready","actions.openUrl","actions.close","actions.setPrimaryButton","actions.addMiniApp","actions.signIn","actions.viewProfile","actions.composeCast","actions.viewToken","actions.sendToken","actions.swapToken"];var be;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},r.getValidEnumValues=i=>{let s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(let c of s)o[c]=i[c];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(let o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(be||(be={}));var Pa;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Pa||(Pa={}));var G=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),vr=r=>{switch(typeof r){case"undefined":return G.undefined;case"string":return G.string;case"number":return isNaN(r)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(r)?G.array:r===null?G.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?G.promise:typeof Map<"u"&&r instanceof Map?G.map:typeof Set<"u"&&r instanceof Set?G.set:typeof Date<"u"&&r instanceof Date?G.date:G.object;default:return G.unknown}},M=be.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),e0=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),Kt=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(let o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){let p=o.path[u];u===o.path.length-1?(c[p]=c[p]||{_errors:[]},c[p]._errors.push(t(o))):c[p]=c[p]||{_errors:[]},c=c[p],u++}}};return i(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Kt.create=r=>new Kt(r);var ei=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,be.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${be.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${be.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${be.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,be.assertNever(r)}return{message:t}},hf=ei;function t0(r){hf=r}function Ls(){return hf}var Cs=r=>{let{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="",u=n.filter(p=>!!p).slice().reverse();for(let p of u)c=p(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},r0=[];function q(r,e){let t=Ls(),n=Cs({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ei?void 0:ei].filter(i=>!!i)});r.common.issues.push(n)}var At=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let i of t){if(i.status==="aborted")return oe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let i of t){let s=await i.key,o=await i.value;n.push({key:s,value:o})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let i of t){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return oe;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}},oe=Object.freeze({status:"aborted"}),Qn=r=>({status:"dirty",value:r}),Pt=r=>({status:"valid",value:r}),Ma=r=>r.status==="aborted",Ua=r=>r.status==="dirty",hn=r=>r.status==="valid",Ni=r=>typeof Promise<"u"&&r instanceof Promise;function Ps(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function pf(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t}var J;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(J||(J={}));var ki,Ti,er=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},lf=(r,e)=>{if(hn(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new Kt(r.common.issues);return this._error=t,this._error}}};function le(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{var u,p;let{message:m}=r;return o.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(u=m??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(p=m??t)!==null&&p!==void 0?p:c.defaultError}},description:i}}var de=class{get description(){return this._def.description}_getType(e){return vr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:vr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new At,ctx:{common:e.parent.common,data:e.data,parsedType:vr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ni(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let i={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)},s=this._parseSync({data:e,path:i.path,parent:i});return lf(i,s)}"~validate"(e){var t,n;let i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:i});return hn(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((n=(t=s?.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(s=>hn(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Ni(i)?i:Promise.resolve(i));return lf(n,s)}refine(e,t){let n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{let o=e(i),c=()=>s.addIssue({code:M.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Ht({schema:this,typeName:se.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Qt.create(this,this._def)}nullable(){return lr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Rr.create(this)}promise(){return zr.create(this,this._def)}or(e){return wn.create([this,e],this._def)}and(e){return vn.create(this,e,this._def)}transform(e){return new Ht({...le(this._def),schema:this,typeName:se.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new xn({...le(this._def),innerType:this,defaultValue:t,typeName:se.ZodDefault})}brand(){return new Bi({typeName:se.ZodBranded,type:this,...le(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new In({...le(this._def),innerType:this,catchValue:t,typeName:se.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Li.create(this,e)}readonly(){return On.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},n0=/^c[^\s-]{8,}$/i,i0=/^[0-9a-z]+$/,s0=/^[0-9A-HJKMNP-TV-Z]{26}$/i,o0=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,a0=/^[a-z0-9_-]{21}$/i,c0=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,u0=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,f0=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,l0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ca,d0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,h0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,p0=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,m0=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,g0=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,y0=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mf="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_0=new RegExp(`^${mf}$`);function gf(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function b0(r){return new RegExp(`^${gf(r)}$`)}function yf(r){let e=`${mf}T${gf(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function w0(r,e){return!!((e==="v4"||!e)&&d0.test(r)||(e==="v6"||!e)&&p0.test(r))}function v0(r,e){if(!c0.test(r))return!1;try{let[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function E0(r,e){return!!((e==="v4"||!e)&&h0.test(r)||(e==="v6"||!e)&&m0.test(r))}var Ur=class r extends de{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){let s=this._getOrReturnCtx(e);return q(s,{code:M.invalid_type,expected:G.string,received:s.parsedType}),oe}let n=new At,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),q(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),q(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?q(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&q(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")f0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"email",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Ca||(Ca=new RegExp(l0,"u")),Ca.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"emoji",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")o0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"uuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")a0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"nanoid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")n0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"cuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")i0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"cuid2",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")s0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"ulid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),q(i,{validation:"url",code:M.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"regex",code:M.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),q(i,{code:M.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),q(i,{code:M.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),q(i,{code:M.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?yf(s).test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{code:M.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?_0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{code:M.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?b0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{code:M.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?u0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"duration",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?w0(e.data,s.version)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"ip",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?v0(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"jwt",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?E0(e.data,s.version)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"cidr",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?g0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"base64",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?y0.test(e.data)||(i=this._getOrReturnCtx(e,i),q(i,{validation:"base64url",code:M.invalid_string,message:s.message}),n.dirty()):be.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:M.invalid_string,...J.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...J.errToObj(e)})}url(e){return this._addCheck({kind:"url",...J.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...J.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...J.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...J.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...J.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...J.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...J.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...J.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...J.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...J.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...J.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...J.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...J.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...J.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...J.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...J.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...J.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...J.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...J.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...J.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...J.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...J.errToObj(t)})}nonempty(e){return this.min(1,J.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Ur.create=r=>{var e;return new Ur({checks:[],typeName:se.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...le(r)})};function R0(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}var pn=class r extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){let s=this._getOrReturnCtx(e);return q(s,{code:M.invalid_type,expected:G.number,received:s.parsedType}),oe}let n,i=new At;for(let s of this._def.checks)s.kind==="int"?be.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:M.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),q(n,{code:M.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),q(n,{code:M.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?R0(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),q(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:M.not_finite,message:s.message}),i.dirty()):be.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,J.toString(t))}gt(e,t){return this.setLimit("min",e,!1,J.toString(t))}lte(e,t){return this.setLimit("max",e,!0,J.toString(t))}lt(e,t){return this.setLimit("max",e,!1,J.toString(t))}setLimit(e,t,n,i){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:J.toString(i)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:J.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:J.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:J.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:J.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:J.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:J.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:J.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:J.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:J.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};pn.create=r=>new pn({checks:[],typeName:se.ZodNumber,coerce:r?.coerce||!1,...le(r)});var mn=class r extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==G.bigint)return this._getInvalidInput(e);let n,i=new At;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),q(n,{code:M.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),q(n,{code:M.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),q(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):be.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return q(t,{code:M.invalid_type,expected:G.bigint,received:t.parsedType}),oe}gte(e,t){return this.setLimit("min",e,!0,J.toString(t))}gt(e,t){return this.setLimit("min",e,!1,J.toString(t))}lte(e,t){return this.setLimit("max",e,!0,J.toString(t))}lt(e,t){return this.setLimit("max",e,!1,J.toString(t))}setLimit(e,t,n,i){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:J.toString(i)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:J.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:J.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:J.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:J.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:J.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};mn.create=r=>{var e;return new mn({checks:[],typeName:se.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...le(r)})};var gn=class extends de{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){let n=this._getOrReturnCtx(e);return q(n,{code:M.invalid_type,expected:G.boolean,received:n.parsedType}),oe}return Pt(e.data)}};gn.create=r=>new gn({typeName:se.ZodBoolean,coerce:r?.coerce||!1,...le(r)});var yn=class r extends de{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){let s=this._getOrReturnCtx(e);return q(s,{code:M.invalid_type,expected:G.date,received:s.parsedType}),oe}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return q(s,{code:M.invalid_date}),oe}let n=new At,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),q(i,{code:M.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),q(i,{code:M.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):be.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:J.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:J.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};yn.create=r=>new yn({checks:[],coerce:r?.coerce||!1,typeName:se.ZodDate,...le(r)});var ti=class extends de{_parse(e){if(this._getType(e)!==G.symbol){let n=this._getOrReturnCtx(e);return q(n,{code:M.invalid_type,expected:G.symbol,received:n.parsedType}),oe}return Pt(e.data)}};ti.create=r=>new ti({typeName:se.ZodSymbol,...le(r)});var _n=class extends de{_parse(e){if(this._getType(e)!==G.undefined){let n=this._getOrReturnCtx(e);return q(n,{code:M.invalid_type,expected:G.undefined,received:n.parsedType}),oe}return Pt(e.data)}};_n.create=r=>new _n({typeName:se.ZodUndefined,...le(r)});var bn=class extends de{_parse(e){if(this._getType(e)!==G.null){let n=this._getOrReturnCtx(e);return q(n,{code:M.invalid_type,expected:G.null,received:n.parsedType}),oe}return Pt(e.data)}};bn.create=r=>new bn({typeName:se.ZodNull,...le(r)});var Dr=class extends de{constructor(){super(...arguments),this._any=!0}_parse(e){return Pt(e.data)}};Dr.create=r=>new Dr({typeName:se.ZodAny,...le(r)});var Er=class extends de{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Pt(e.data)}};Er.create=r=>new Er({typeName:se.ZodUnknown,...le(r)});var ir=class extends de{_parse(e){let t=this._getOrReturnCtx(e);return q(t,{code:M.invalid_type,expected:G.never,received:t.parsedType}),oe}};ir.create=r=>new ir({typeName:se.ZodNever,...le(r)});var ri=class extends de{_parse(e){if(this._getType(e)!==G.undefined){let n=this._getOrReturnCtx(e);return q(n,{code:M.invalid_type,expected:G.void,received:n.parsedType}),oe}return Pt(e.data)}};ri.create=r=>new ri({typeName:se.ZodVoid,...le(r)});var Rr=class r extends de{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==G.array)return q(t,{code:M.invalid_type,expected:G.array,received:t.parsedType}),oe;if(i.exactLength!==null){let o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(q(t,{code:o?M.too_big:M.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(q(t,{code:M.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(q(t,{code:M.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>i.type._parseAsync(new er(t,o,t.path,c)))).then(o=>At.mergeArray(n,o));let s=[...t.data].map((o,c)=>i.type._parseSync(new er(t,o,t.path,c)));return At.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:J.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:J.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:J.toString(t)}})}nonempty(e){return this.min(1,e)}};Rr.create=(r,e)=>new Rr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:se.ZodArray,...le(e)});function Jn(r){if(r instanceof Ft){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=Qt.create(Jn(n))}return new Ft({...r._def,shape:()=>e})}else return r instanceof Rr?new Rr({...r._def,type:Jn(r.element)}):r instanceof Qt?Qt.create(Jn(r.unwrap())):r instanceof lr?lr.create(Jn(r.unwrap())):r instanceof fr?fr.create(r.items.map(e=>Jn(e))):r}var Ft=class r extends de{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=be.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){let p=this._getOrReturnCtx(e);return q(p,{code:M.invalid_type,expected:G.object,received:p.parsedType}),oe}let{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof ir&&this._def.unknownKeys==="strip"))for(let p in i.data)o.includes(p)||c.push(p);let u=[];for(let p of o){let m=s[p],b=i.data[p];u.push({key:{status:"valid",value:p},value:m._parse(new er(i,b,i.path,p)),alwaysSet:p in i.data})}if(this._def.catchall instanceof ir){let p=this._def.unknownKeys;if(p==="passthrough")for(let m of c)u.push({key:{status:"valid",value:m},value:{status:"valid",value:i.data[m]}});else if(p==="strict")c.length>0&&(q(i,{code:M.unrecognized_keys,keys:c}),n.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let p=this._def.catchall;for(let m of c){let b=i.data[m];u.push({key:{status:"valid",value:m},value:p._parse(new er(i,b,i.path,m)),alwaysSet:m in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let p=[];for(let m of u){let b=await m.key,A=await m.value;p.push({key:b,value:A,alwaysSet:m.alwaysSet})}return p}).then(p=>At.mergeObjectSync(n,p)):At.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return J.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,c;let u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=J.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:se.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return be.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return be.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return Jn(this)}partial(e){let t={};return be.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return be.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Qt;)s=s._def.innerType;t[n]=s}}),new r({...this._def,shape:()=>t})}keyof(){return _f(be.objectKeys(this.shape))}};Ft.create=(r,e)=>new Ft({shape:()=>r,unknownKeys:"strip",catchall:ir.create(),typeName:se.ZodObject,...le(e)});Ft.strictCreate=(r,e)=>new Ft({shape:()=>r,unknownKeys:"strict",catchall:ir.create(),typeName:se.ZodObject,...le(e)});Ft.lazycreate=(r,e)=>new Ft({shape:r,unknownKeys:"strip",catchall:ir.create(),typeName:se.ZodObject,...le(e)});var wn=class extends de{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;let o=s.map(c=>new Kt(c.ctx.common.issues));return q(t,{code:M.invalid_union,unionErrors:o}),oe}if(t.common.async)return Promise.all(n.map(async s=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s,o=[];for(let u of n){let p={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:p});if(m.status==="valid")return m;m.status==="dirty"&&!s&&(s={result:m,ctx:p}),p.common.issues.length&&o.push(p.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;let c=o.map(u=>new Kt(u));return q(t,{code:M.invalid_union,unionErrors:c}),oe}}get options(){return this._def.options}};wn.create=(r,e)=>new wn({options:r,typeName:se.ZodUnion,...le(e)});var wr=r=>r instanceof En?wr(r.schema):r instanceof Ht?wr(r.innerType()):r instanceof Rn?[r.value]:r instanceof Sn?r.options:r instanceof An?be.objectValues(r.enum):r instanceof xn?wr(r._def.innerType):r instanceof _n?[void 0]:r instanceof bn?[null]:r instanceof Qt?[void 0,...wr(r.unwrap())]:r instanceof lr?[null,...wr(r.unwrap())]:r instanceof Bi||r instanceof On?wr(r.unwrap()):r instanceof In?wr(r._def.innerType):[],Ms=class r extends de{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return q(t,{code:M.invalid_type,expected:G.object,received:t.parsedType}),oe;let n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(q(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),oe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let i=new Map;for(let s of t){let o=wr(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new r({typeName:se.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...le(n)})}};function Da(r,e){let t=vr(r),n=vr(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){let i=be.objectKeys(e),s=be.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(let c of s){let u=Da(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<r.length;s++){let o=r[s],c=e[s],u=Da(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var vn=class extends de{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(Ma(s)||Ma(o))return oe;let c=Da(s.value,o.value);return c.valid?((Ua(s)||Ua(o))&&t.dirty(),{status:t.value,value:c.data}):(q(n,{code:M.invalid_intersection_types}),oe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};vn.create=(r,e,t)=>new vn({left:r,right:e,typeName:se.ZodIntersection,...le(t)});var fr=class r extends de{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return q(n,{code:M.invalid_type,expected:G.array,received:n.parsedType}),oe;if(n.data.length<this._def.items.length)return q(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&n.data.length>this._def.items.length&&(q(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...n.data].map((o,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new er(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>At.mergeArray(t,o)):At.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};fr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fr({items:r,typeName:se.ZodTuple,rest:null,...le(e)})};var Us=class r extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return q(n,{code:M.invalid_type,expected:G.object,received:n.parsedType}),oe;let i=[],s=this._def.keyType,o=this._def.valueType;for(let c in n.data)i.push({key:s._parse(new er(n,c,n.path,c)),value:o._parse(new er(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?At.mergeObjectAsync(t,i):At.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof de?new r({keyType:e,valueType:t,typeName:se.ZodRecord,...le(n)}):new r({keyType:Ur.create(),valueType:e,typeName:se.ZodRecord,...le(t)})}},ni=class extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return q(n,{code:M.invalid_type,expected:G.map,received:n.parsedType}),oe;let i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],p)=>({key:i._parse(new er(n,c,n.path,[p,"key"])),value:s._parse(new er(n,u,n.path,[p,"value"]))}));if(n.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let u of o){let p=await u.key,m=await u.value;if(p.status==="aborted"||m.status==="aborted")return oe;(p.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(p.value,m.value)}return{status:t.value,value:c}})}else{let c=new Map;for(let u of o){let p=u.key,m=u.value;if(p.status==="aborted"||m.status==="aborted")return oe;(p.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(p.value,m.value)}return{status:t.value,value:c}}}};ni.create=(r,e,t)=>new ni({valueType:e,keyType:r,typeName:se.ZodMap,...le(t)});var ii=class r extends de{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return q(n,{code:M.invalid_type,expected:G.set,received:n.parsedType}),oe;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(q(n,{code:M.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(q(n,{code:M.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let s=this._def.valueType;function o(u){let p=new Set;for(let m of u){if(m.status==="aborted")return oe;m.status==="dirty"&&t.dirty(),p.add(m.value)}return{status:t.value,value:p}}let c=[...n.data.values()].map((u,p)=>s._parse(new er(n,u,n.path,p)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new r({...this._def,minSize:{value:e,message:J.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:J.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ii.create=(r,e)=>new ii({valueType:r,minSize:null,maxSize:null,typeName:se.ZodSet,...le(e)});var Ds=class r extends de{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return q(t,{code:M.invalid_type,expected:G.function,received:t.parsedType}),oe;function n(c,u){return Cs({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ls(),ei].filter(p=>!!p),issueData:{code:M.invalid_arguments,argumentsError:u}})}function i(c,u){return Cs({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ls(),ei].filter(p=>!!p),issueData:{code:M.invalid_return_type,returnTypeError:u}})}let s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof zr){let c=this;return Pt(async function(...u){let p=new Kt([]),m=await c._def.args.parseAsync(u,s).catch(S=>{throw p.addIssue(n(u,S)),p}),b=await Reflect.apply(o,this,m);return await c._def.returns._def.type.parseAsync(b,s).catch(S=>{throw p.addIssue(i(b,S)),p})})}else{let c=this;return Pt(function(...u){let p=c._def.args.safeParse(u,s);if(!p.success)throw new Kt([n(u,p.error)]);let m=Reflect.apply(o,this,p.data),b=c._def.returns.safeParse(m,s);if(!b.success)throw new Kt([i(m,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:fr.create(e).rest(Er.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||fr.create([]).rest(Er.create()),returns:t||Er.create(),typeName:se.ZodFunction,...le(n)})}},En=class extends de{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};En.create=(r,e)=>new En({getter:r,typeName:se.ZodLazy,...le(e)});var Rn=class extends de{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return q(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Rn.create=(r,e)=>new Rn({value:r,typeName:se.ZodLiteral,...le(e)});function _f(r,e){return new Sn({values:r,typeName:se.ZodEnum,...le(e)})}var Sn=class r extends de{constructor(){super(...arguments),ki.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{expected:be.joinValues(n),received:t.parsedType,code:M.invalid_type}),oe}if(Ps(this,ki,"f")||pf(this,ki,new Set(this._def.values),"f"),!Ps(this,ki,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{received:t.data,code:M.invalid_enum_value,options:n}),oe}return Pt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};ki=new WeakMap;Sn.create=_f;var An=class extends de{constructor(){super(...arguments),Ti.set(this,void 0)}_parse(e){let t=be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){let i=be.objectValues(t);return q(n,{expected:be.joinValues(i),received:n.parsedType,code:M.invalid_type}),oe}if(Ps(this,Ti,"f")||pf(this,Ti,new Set(be.getValidEnumValues(this._def.values)),"f"),!Ps(this,Ti,"f").has(e.data)){let i=be.objectValues(t);return q(n,{received:n.data,code:M.invalid_enum_value,options:i}),oe}return Pt(e.data)}get enum(){return this._def.values}};Ti=new WeakMap;An.create=(r,e)=>new An({values:r,typeName:se.ZodNativeEnum,...le(e)});var zr=class extends de{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return q(t,{code:M.invalid_type,expected:G.promise,received:t.parsedType}),oe;let n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return Pt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};zr.create=(r,e)=>new zr({type:r,typeName:se.ZodPromise,...le(e)});var Ht=class extends de{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===se.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{q(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return oe;let u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?oe:u.status==="dirty"||t.value==="dirty"?Qn(u.value):u});{if(t.value==="aborted")return oe;let c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?oe:c.status==="dirty"||t.value==="dirty"?Qn(c.value):c}}if(i.type==="refinement"){let o=c=>{let u=i.refinement(c,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?oe:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?oe:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!hn(o))return o;let c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>hn(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);be.assertNever(i)}};Ht.create=(r,e,t)=>new Ht({schema:r,typeName:se.ZodEffects,effect:e,...le(t)});Ht.createWithPreprocess=(r,e,t)=>new Ht({schema:e,effect:{type:"preprocess",transform:r},typeName:se.ZodEffects,...le(t)});var Qt=class extends de{_parse(e){return this._getType(e)===G.undefined?Pt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Qt.create=(r,e)=>new Qt({innerType:r,typeName:se.ZodOptional,...le(e)});var lr=class extends de{_parse(e){return this._getType(e)===G.null?Pt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};lr.create=(r,e)=>new lr({innerType:r,typeName:se.ZodNullable,...le(e)});var xn=class extends de{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};xn.create=(r,e)=>new xn({innerType:r,typeName:se.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...le(e)});var In=class extends de{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ni(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Kt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Kt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};In.create=(r,e)=>new In({innerType:r,typeName:se.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...le(e)});var si=class extends de{_parse(e){if(this._getType(e)!==G.nan){let n=this._getOrReturnCtx(e);return q(n,{code:M.invalid_type,expected:G.nan,received:n.parsedType}),oe}return{status:"valid",value:e.data}}};si.create=r=>new si({typeName:se.ZodNaN,...le(r)});var S0=Symbol("zod_brand"),Bi=class extends de{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Li=class r extends de{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?oe:s.status==="dirty"?(t.dirty(),Qn(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?oe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:se.ZodPipeline})}},On=class extends de{_parse(e){let t=this._def.innerType._parse(e),n=i=>(hn(i)&&(i.value=Object.freeze(i.value)),i);return Ni(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};On.create=(r,e)=>new On({innerType:r,typeName:se.ZodReadonly,...le(e)});function bf(r,e={},t){return r?Dr.create().superRefine((n,i)=>{var s,o;if(!r(n)){let c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,p=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...p,fatal:u})}}):Dr.create()}var A0={object:Ft.lazycreate},se;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(se||(se={}));var x0=(r,e={message:`Input not instance of ${r.name}`})=>bf(t=>t instanceof r,e),wf=Ur.create,vf=pn.create,I0=si.create,O0=mn.create,Ef=gn.create,k0=yn.create,T0=ti.create,N0=_n.create,B0=bn.create,L0=Dr.create,C0=Er.create,P0=ir.create,M0=ri.create,U0=Rr.create,D0=Ft.create,z0=Ft.strictCreate,F0=wn.create,V0=Ms.create,$0=vn.create,W0=fr.create,q0=Us.create,j0=ni.create,K0=ii.create,H0=Ds.create,G0=En.create,Z0=Rn.create,Y0=Sn.create,X0=An.create,J0=zr.create,df=Ht.create,Q0=Qt.create,ep=lr.create,tp=Ht.createWithPreprocess,rp=Li.create,np=()=>wf().optional(),ip=()=>vf().optional(),sp=()=>Ef().optional(),op={string:r=>Ur.create({...r,coerce:!0}),number:r=>pn.create({...r,coerce:!0}),boolean:r=>gn.create({...r,coerce:!0}),bigint:r=>mn.create({...r,coerce:!0}),date:r=>yn.create({...r,coerce:!0})},ap=oe,K=Object.freeze({__proto__:null,defaultErrorMap:ei,setErrorMap:t0,getErrorMap:Ls,makeIssue:Cs,EMPTY_PATH:r0,addIssueToContext:q,ParseStatus:At,INVALID:oe,DIRTY:Qn,OK:Pt,isAborted:Ma,isDirty:Ua,isValid:hn,isAsync:Ni,get util(){return be},get objectUtil(){return Pa},ZodParsedType:G,getParsedType:vr,ZodType:de,datetimeRegex:yf,ZodString:Ur,ZodNumber:pn,ZodBigInt:mn,ZodBoolean:gn,ZodDate:yn,ZodSymbol:ti,ZodUndefined:_n,ZodNull:bn,ZodAny:Dr,ZodUnknown:Er,ZodNever:ir,ZodVoid:ri,ZodArray:Rr,ZodObject:Ft,ZodUnion:wn,ZodDiscriminatedUnion:Ms,ZodIntersection:vn,ZodTuple:fr,ZodRecord:Us,ZodMap:ni,ZodSet:ii,ZodFunction:Ds,ZodLazy:En,ZodLiteral:Rn,ZodEnum:Sn,ZodNativeEnum:An,ZodPromise:zr,ZodEffects:Ht,ZodTransformer:Ht,ZodOptional:Qt,ZodNullable:lr,ZodDefault:xn,ZodCatch:In,ZodNaN:si,BRAND:S0,ZodBranded:Bi,ZodPipeline:Li,ZodReadonly:On,custom:bf,Schema:de,ZodSchema:de,late:A0,get ZodFirstPartyTypeKind(){return se},coerce:op,any:L0,array:U0,bigint:O0,boolean:Ef,date:k0,discriminatedUnion:V0,effect:df,enum:Y0,function:H0,instanceof:x0,intersection:$0,lazy:G0,literal:Z0,map:j0,nan:I0,nativeEnum:X0,never:P0,null:B0,nullable:ep,number:vf,object:D0,oboolean:sp,onumber:ip,optional:Q0,ostring:np,pipeline:rp,preprocess:tp,promise:J0,record:q0,set:K0,strictObject:z0,string:wf,symbol:T0,transformer:df,tuple:W0,undefined:N0,union:F0,unknown:C0,void:M0,NEVER:ap,ZodIssueCode:M,quotelessJson:e0,ZodError:Kt});var cp=/[@#$%^&*+=\/\\|~«»]/,up=/(!{2,}|\?{2,}|-{2,})/,fp=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,Fr=({max:r,noSpaces:e}={})=>(e?K.string().max(r??Number.POSITIVE_INFINITY).regex(/^\S*$/,"Spaces are not allowed"):K.string().max(r??Number.POSITIVE_INFINITY)).refine(n=>!fp.test(n),{message:"Emojis and symbols are not allowed"}).refine(n=>!cp.test(n),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, \xAB, \xBB) are not allowed"}).refine(n=>!up.test(n),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),xt=K.string().url().startsWith("https://",{message:"Must be an https url"}).max(1024),Ci=K.string().max(32),Pi=K.string().max(32),lp=/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/,za=K.string().regex(lp,{message:"Invalid CAIP-19 asset ID"}),Mi=K.string().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i,{message:"Invalid hex color code. It should be in the format #RRGGBB or #RGB."}),Fa=K.union([K.literal("1:1"),K.literal("3:2")]),Va=K.object({header:K.string(),payload:K.string(),signature:K.string()}),dp=K.object({fid:K.number(),type:K.literal("app_key"),key:K.string().startsWith("0x")});var Rf=K.object({type:K.literal("launch_frame"),name:Ci,url:xt.optional(),splashImageUrl:xt.optional(),splashBackgroundColor:Mi.optional()}),Sf=K.object({type:K.literal("view_token"),token:za}),Af=K.discriminatedUnion("type",[Rf,Sf]),xf=K.object({title:Pi,action:Af}),If=K.object({version:K.literal("next"),imageUrl:xt,aspectRatio:Fa.optional(),button:xf}),hp=r=>If.safeParse(r);var zs=K.object({url:K.string(),token:K.string()}),pp=K.object({notificationId:K.string().max(128),title:K.string().max(32),body:K.string().max(128),targetUrl:xt,tokens:K.string().array().max(100)}),mp=K.object({result:K.object({successfulTokens:K.array(K.string()),invalidTokens:K.array(K.string()),rateLimitedTokens:K.array(K.string())})});var Of=K.object({event:K.literal("frame_added"),notificationDetails:zs.optional()}),kf=K.object({event:K.literal("frame_removed")}),Tf=K.object({event:K.literal("notifications_enabled"),notificationDetails:zs.required()}),Nf=K.object({event:K.literal("notifications_disabled")}),gp=K.discriminatedUnion("event",[Of,kf,Tf,Nf]);var yp=K.enum(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),Bf=["eip155:1","eip155:8453","eip155:42161","eip155:421614","eip155:84532","eip155:666666666","eip155:100","eip155:10","eip155:11155420","eip155:137","eip155:11155111","eip155:7777777","eip155:130","eip155:10143","eip155:42220","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],Lf=K.object({version:K.union([K.literal("0.0.0"),K.literal("0.0.1"),K.literal("1"),K.literal("next")]),name:Ci,iconUrl:xt,homeUrl:xt,imageUrl:xt.optional(),buttonTitle:Pi.optional(),splashImageUrl:xt.optional(),splashBackgroundColor:Mi.optional(),webhookUrl:xt.optional(),subtitle:Fr({max:30}).optional(),description:Fr({max:170}).optional(),screenshotUrls:K.array(xt).max(3).optional(),primaryCategory:yp.optional(),tags:K.array(Fr({max:20,noSpaces:!0})).max(5).optional(),heroImageUrl:xt.optional(),tagline:Fr({max:30}).optional(),ogTitle:Fr({max:30}).optional(),ogDescription:Fr({max:100}).optional(),ogImageUrl:xt.optional(),noindex:K.boolean().optional(),requiredChains:K.array(K.enum(Bf)).max(Bf.length).optional(),requiredCapabilities:K.array(K.enum(Bs)).max(Bs.length).optional()}),_p=K.object({accountAssociation:Va,frame:Lf.optional()});var ae=br(Di());function zi(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Xp(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function $r(r,...e){if(!Xp(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function el(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");zi(r.outputLen),zi(r.blockLen)}function Ar(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Ws(r,e){$r(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Nn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function tl(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function qs(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function sr(r,e){return r<<32-e|r>>>e}var Ja=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Jp(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function Qa(r){for(let e=0;e<r.length;e++)r[e]=Jp(r[e])}function rl(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function qr(r){return typeof r=="string"&&(r=rl(r)),$r(r),r}function ec(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];$r(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}var Wr=class{clone(){return this._cloneInto()}};function fi(r){let e=n=>r().update(qr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function nl(r){let e=(n,i)=>r(i).update(qr(n)).digest(),t=r({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}function js(r=32){if(Nn&&typeof Nn.getRandomValues=="function")return Nn.getRandomValues(new Uint8Array(r));if(Nn&&typeof Nn.randomBytes=="function")return Nn.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Qp(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),c=Number(t&s),u=n?4:0,p=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+p,c,n)}function il(r,e,t){return r&e^~r&t}function sl(r,e,t){return r&e^r&t^e&t}var li=class extends Wr{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=qs(this.buffer)}update(e){Ar(this);let{view:t,buffer:n,blockLen:i}=this;e=qr(e);let s=e.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let u=qs(e);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(e.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ar(this),Ws(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let b=o;b<i;b++)t[b]=0;Qp(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=qs(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let p=u/4,m=this.get();if(p>m.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<p;b++)c.setUint32(4*b,m[b],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return e.length=i,e.pos=c,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}};var Ks=BigInt(4294967295),tc=BigInt(32);function ol(r,e=!1){return e?{h:Number(r&Ks),l:Number(r>>tc&Ks)}:{h:Number(r>>tc&Ks)|0,l:Number(r&Ks)|0}}function rc(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=ol(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}var em=(r,e)=>BigInt(r>>>0)<<tc|BigInt(e>>>0),tm=(r,e,t)=>r>>>t,rm=(r,e,t)=>r<<32-t|e>>>t,nm=(r,e,t)=>r>>>t|e<<32-t,im=(r,e,t)=>r<<32-t|e>>>t,sm=(r,e,t)=>r<<64-t|e>>>t-32,om=(r,e,t)=>r>>>t-32|e<<64-t,am=(r,e)=>e,cm=(r,e)=>r,nc=(r,e,t)=>r<<t|e>>>32-t,ic=(r,e,t)=>e<<t|r>>>32-t,sc=(r,e,t)=>e<<t-32|r>>>64-t,oc=(r,e,t)=>r<<t-32|e>>>64-t;function um(r,e,t,n){let i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}var fm=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),lm=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,dm=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),hm=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,pm=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),mm=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0;var gm={fromBig:ol,split:rc,toBig:em,shrSH:tm,shrSL:rm,rotrSH:nm,rotrSL:im,rotrBH:sm,rotrBL:om,rotr32H:am,rotr32L:cm,rotlSH:nc,rotlSL:ic,rotlBH:sc,rotlBL:oc,add:um,add3L:fm,add3H:lm,add4L:dm,add4H:hm,add5H:mm,add5L:pm},pe=gm;var[ym,_m]=pe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),jr=new Uint32Array(80),Kr=new Uint32Array(80),ac=class extends li{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:p,El:m,Fh:b,Fl:A,Gh:S,Gl:T,Hh:I,Hl:x}=this;return[e,t,n,i,s,o,c,u,p,m,b,A,S,T,I,x]}set(e,t,n,i,s,o,c,u,p,m,b,A,S,T,I,x){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=p|0,this.El=m|0,this.Fh=b|0,this.Fl=A|0,this.Gh=S|0,this.Gl=T|0,this.Hh=I|0,this.Hl=x|0}process(e,t){for(let L=0;L<16;L++,t+=4)jr[L]=e.getUint32(t),Kr[L]=e.getUint32(t+=4);for(let L=16;L<80;L++){let F=jr[L-15]|0,te=Kr[L-15]|0,H=pe.rotrSH(F,te,1)^pe.rotrSH(F,te,8)^pe.shrSH(F,te,7),Z=pe.rotrSL(F,te,1)^pe.rotrSL(F,te,8)^pe.shrSL(F,te,7),ee=jr[L-2]|0,Y=Kr[L-2]|0,Ie=pe.rotrSH(ee,Y,19)^pe.rotrBH(ee,Y,61)^pe.shrSH(ee,Y,6),re=pe.rotrSL(ee,Y,19)^pe.rotrBL(ee,Y,61)^pe.shrSL(ee,Y,6),fe=pe.add4L(Z,re,Kr[L-7],Kr[L-16]),v=pe.add4H(fe,H,Ie,jr[L-7],jr[L-16]);jr[L]=v|0,Kr[L]=fe|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:p,Dl:m,Eh:b,El:A,Fh:S,Fl:T,Gh:I,Gl:x,Hh:B,Hl:U}=this;for(let L=0;L<80;L++){let F=pe.rotrSH(b,A,14)^pe.rotrSH(b,A,18)^pe.rotrBH(b,A,41),te=pe.rotrSL(b,A,14)^pe.rotrSL(b,A,18)^pe.rotrBL(b,A,41),H=b&S^~b&I,Z=A&T^~A&x,ee=pe.add5L(U,te,Z,_m[L],Kr[L]),Y=pe.add5H(ee,B,F,H,ym[L],jr[L]),Ie=ee|0,re=pe.rotrSH(n,i,28)^pe.rotrBH(n,i,34)^pe.rotrBH(n,i,39),fe=pe.rotrSL(n,i,28)^pe.rotrBL(n,i,34)^pe.rotrBL(n,i,39),v=n&s^n&c^s&c,a=i&o^i&u^o&u;B=I|0,U=x|0,I=S|0,x=T|0,S=b|0,T=A|0,{h:b,l:A}=pe.add(p|0,m|0,Y|0,Ie|0),p=c|0,m=u|0,c=s|0,u=o|0,s=n|0,o=i|0;let l=pe.add3L(Ie,fe,a);n=pe.add3H(l,Y,re,v),i=l|0}({h:n,l:i}=pe.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=pe.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=pe.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:p,l:m}=pe.add(this.Dh|0,this.Dl|0,p|0,m|0),{h:b,l:A}=pe.add(this.Eh|0,this.El|0,b|0,A|0),{h:S,l:T}=pe.add(this.Fh|0,this.Fl|0,S|0,T|0),{h:I,l:x}=pe.add(this.Gh|0,this.Gl|0,I|0,x|0),{h:B,l:U}=pe.add(this.Hh|0,this.Hl|0,B|0,U|0),this.set(n,i,s,o,c,u,p,m,b,A,S,T,I,x,B,U)}roundClean(){jr.fill(0),Kr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var al=fi(()=>new ac);var Zs={};dn(Zs,{aInRange:()=>$t,abool:()=>or,abytes:()=>di,bitGet:()=>Sm,bitLen:()=>lc,bitMask:()=>Vi,bitSet:()=>Am,bytesToHex:()=>Ir,bytesToNumberBE:()=>Or,bytesToNumberLE:()=>Gr,concatBytes:()=>kr,createHmacDrbg:()=>dc,ensureBytes:()=>We,equalBytes:()=>Em,hexToBytes:()=>Ln,hexToNumber:()=>fc,inRange:()=>Fi,isBytes:()=>Hr,memoized:()=>Pn,notImplemented:()=>Im,numberToBytesBE:()=>Zr,numberToBytesLE:()=>Cn,numberToHexUnpadded:()=>Bn,numberToVarBytesBE:()=>vm,utf8ToBytes:()=>Rm,validateObject:()=>pr});var Hs=BigInt(0),Gs=BigInt(1),bm=BigInt(2);function Hr(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function di(r){if(!Hr(r))throw new Error("Uint8Array expected")}function or(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}var wm=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ir(r){di(r);let e="";for(let t=0;t<r.length;t++)e+=wm[r[t]];return e}function Bn(r){let e=r.toString(16);return e.length&1?"0"+e:e}function fc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Hs:BigInt("0x"+r)}var xr={_0:48,_9:57,A:65,F:70,a:97,f:102};function cl(r){if(r>=xr._0&&r<=xr._9)return r-xr._0;if(r>=xr.A&&r<=xr.F)return r-(xr.A-10);if(r>=xr.a&&r<=xr.f)return r-(xr.a-10)}function Ln(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){let o=cl(r.charCodeAt(s)),c=cl(r.charCodeAt(s+1));if(o===void 0||c===void 0){let u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+c}return n}function Or(r){return fc(Ir(r))}function Gr(r){return di(r),fc(Ir(Uint8Array.from(r).reverse()))}function Zr(r,e){return Ln(r.toString(16).padStart(e*2,"0"))}function Cn(r,e){return Zr(r,e).reverse()}function vm(r){return Ln(Bn(r))}function We(r,e,t){let n;if(typeof e=="string")try{n=Ln(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Hr(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}function kr(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];di(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}function Em(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Rm(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var cc=r=>typeof r=="bigint"&&Hs<=r;function Fi(r,e,t){return cc(r)&&cc(e)&&cc(t)&&e<=r&&r<t}function $t(r,e,t,n){if(!Fi(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function lc(r){let e;for(e=0;r>Hs;r>>=Gs,e+=1);return e}function Sm(r,e){return r>>BigInt(e)&Gs}function Am(r,e,t){return r|(t?Gs:Hs)<<BigInt(e)}var Vi=r=>(bm<<BigInt(r-1))-Gs,uc=r=>new Uint8Array(r),ul=r=>Uint8Array.from(r);function dc(r,e,t){if(typeof r!="number"||r<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 t!="function")throw new Error("hmacFn must be a function");let n=uc(r),i=uc(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},c=(...b)=>t(i,n,...b),u=(b=uc())=>{i=c(ul([0]),b),n=c(),b.length!==0&&(i=c(ul([1]),b),n=c())},p=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let b=0,A=[];for(;b<e;){n=c();let S=n.slice();A.push(S),b+=n.length}return kr(...A)};return(b,A)=>{o(),u(b);let S;for(;!(S=A(p()));)u();return o(),S}}var xm={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Hr(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function pr(r,e,t={}){let n=(i,s,o)=>{let c=xm[s];if(typeof c!="function")throw new Error("invalid validator function");let u=r[i];if(!(o&&u===void 0)&&!c(u,r))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(t))n(i,s,!0);return r}var Im=()=>{throw new Error("not implemented")};function Pn(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let s=r(t,...n);return e.set(t,s),s}}var _t=BigInt(0),Ce=BigInt(1),Mn=BigInt(2),Om=BigInt(3),hc=BigInt(4),fl=BigInt(5),ll=BigInt(8),km=BigInt(9),Tm=BigInt(16);function Oe(r,e){let t=r%e;return t>=_t?t:e+t}function Nm(r,e,t){if(e<_t)throw new Error("invalid exponent, negatives unsupported");if(t<=_t)throw new Error("invalid modulus");if(t===Ce)return _t;let n=Ce;for(;e>_t;)e&Ce&&(n=n*r%t),r=r*r%t,e>>=Ce;return n}function Pe(r,e,t){let n=r;for(;e-- >_t;)n*=n,n%=t;return n}function Ys(r,e){if(r===_t)throw new Error("invert: expected non-zero number");if(e<=_t)throw new Error("invert: expected positive modulus, got "+e);let t=Oe(r,e),n=e,i=_t,s=Ce,o=Ce,c=_t;for(;t!==_t;){let p=n/t,m=n%t,b=i-o*p,A=s-c*p;n=t,t=m,i=o,s=c,o=b,c=A}if(n!==Ce)throw new Error("invert: does not exist");return Oe(i,e)}function Bm(r){let e=(r-Ce)/Mn,t,n,i;for(t=r-Ce,n=0;t%Mn===_t;t/=Mn,n++);for(i=Mn;i<r&&Nm(i,e,r)!==r-Ce;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let o=(r+Ce)/hc;return function(u,p){let m=u.pow(p,o);if(!u.eql(u.sqr(m),p))throw new Error("Cannot find square root");return m}}let s=(t+Ce)/Mn;return function(c,u){if(c.pow(u,e)===c.neg(c.ONE))throw new Error("Cannot find square root");let p=n,m=c.pow(c.mul(c.ONE,i),t),b=c.pow(u,s),A=c.pow(u,t);for(;!c.eql(A,c.ONE);){if(c.eql(A,c.ZERO))return c.ZERO;let S=1;for(let I=c.sqr(A);S<p&&!c.eql(I,c.ONE);S++)I=c.sqr(I);let T=c.pow(m,Ce<<BigInt(p-S-1));m=c.sqr(T),b=c.mul(b,T),A=c.mul(A,m),p=S}return b}}function Lm(r){if(r%hc===Om){let e=(r+Ce)/hc;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%ll===fl){let e=(r-fl)/ll;return function(n,i){let s=n.mul(i,Mn),o=n.pow(s,e),c=n.mul(i,o),u=n.mul(n.mul(c,Mn),o),p=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(p),i))throw new Error("Cannot find square root");return p}}return r%Tm,Bm(r)}var dl=(r,e)=>(Oe(r,e)&Ce)===Ce,Cm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function pc(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Cm.reduce((n,i)=>(n[i]="function",n),e);return pr(r,t)}function Pm(r,e,t){if(t<_t)throw new Error("invalid exponent, negatives unsupported");if(t===_t)return r.ONE;if(t===Ce)return e;let n=r.ONE,i=e;for(;t>_t;)t&Ce&&(n=r.mul(n,i)),i=r.sqr(i),t>>=Ce;return n}function Mm(r,e){let t=new Array(e.length),n=e.reduce((s,o,c)=>r.is0(o)?s:(t[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,c)=>r.is0(o)?s:(t[c]=r.mul(s,t[c]),r.mul(s,o)),i),t}function mc(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Yr(r,e,t=!1,n={}){if(r<=_t)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:i,nByteLength:s}=mc(r,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o,c=Object.freeze({ORDER:r,isLE:t,BITS:i,BYTES:s,MASK:Vi(i),ZERO:_t,ONE:Ce,create:u=>Oe(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return _t<=u&&u<r},is0:u=>u===_t,isOdd:u=>(u&Ce)===Ce,neg:u=>Oe(-u,r),eql:(u,p)=>u===p,sqr:u=>Oe(u*u,r),add:(u,p)=>Oe(u+p,r),sub:(u,p)=>Oe(u-p,r),mul:(u,p)=>Oe(u*p,r),pow:(u,p)=>Pm(c,u,p),div:(u,p)=>Oe(u*Ys(p,r),r),sqrN:u=>u*u,addN:(u,p)=>u+p,subN:(u,p)=>u-p,mulN:(u,p)=>u*p,inv:u=>Ys(u,r),sqrt:n.sqrt||(u=>(o||(o=Lm(r)),o(c,u))),invertBatch:u=>Mm(c,u),cmov:(u,p,m)=>m?p:u,toBytes:u=>t?Cn(u,s):Zr(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return t?Gr(u):Or(u)}});return Object.freeze(c)}function hl(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function gc(r){let e=hl(r);return e+Math.ceil(e/2)}function pl(r,e,t=!1){let n=r.length,i=hl(e),s=gc(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let o=t?Gr(r):Or(r),c=Oe(o,e-Ce)+Ce;return t?Cn(c,i):Zr(c,i)}var ml=BigInt(0),Xs=BigInt(1);function yc(r,e){let t=e.negate();return r?t:e}function gl(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function _c(r,e){gl(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function Um(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function Dm(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}var bc=new WeakMap,yl=new WeakMap;function wc(r){return yl.get(r)||1}function Js(r,e){return{constTimeNegate:yc,hasPrecomputes(t){return wc(t)!==1},unsafeLadder(t,n,i=r.ZERO){let s=t;for(;n>ml;)n&Xs&&(i=i.add(s)),s=s.double(),n>>=Xs;return i},precomputeWindow(t,n){let{windows:i,windowSize:s}=_c(n,e),o=[],c=t,u=c;for(let p=0;p<i;p++){u=c,o.push(u);for(let m=1;m<s;m++)u=u.add(c),o.push(u);c=u.double()}return o},wNAF(t,n,i){let{windows:s,windowSize:o}=_c(t,e),c=r.ZERO,u=r.BASE,p=BigInt(2**t-1),m=2**t,b=BigInt(t);for(let A=0;A<s;A++){let S=A*o,T=Number(i&p);i>>=b,T>o&&(T-=m,i+=Xs);let I=S,x=S+Math.abs(T)-1,B=A%2!==0,U=T<0;T===0?u=u.add(yc(B,n[I])):c=c.add(yc(U,n[x]))}return{p:c,f:u}},wNAFUnsafe(t,n,i,s=r.ZERO){let{windows:o,windowSize:c}=_c(t,e),u=BigInt(2**t-1),p=2**t,m=BigInt(t);for(let b=0;b<o;b++){let A=b*c;if(i===ml)break;let S=Number(i&u);if(i>>=m,S>c&&(S-=p,i+=Xs),S===0)continue;let T=n[A+Math.abs(S)-1];S<0&&(T=T.negate()),s=s.add(T)}return s},getPrecomputes(t,n,i){let s=bc.get(n);return s||(s=this.precomputeWindow(n,t),t!==1&&bc.set(n,i(s))),s},wNAFCached(t,n,i){let s=wc(t);return this.wNAF(s,this.getPrecomputes(s,t,i),n)},wNAFCachedUnsafe(t,n,i,s){let o=wc(t);return o===1?this.unsafeLadder(t,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),n,s)},setWindowSize(t,n){gl(n,e),yl.set(t,n),bc.delete(t)}}}function Qs(r,e,t,n){if(Um(t,r),Dm(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,s=lc(BigInt(t.length)),o=s>12?s-3:s>4?s-2:s?2:1,c=(1<<o)-1,u=new Array(c+1).fill(i),p=Math.floor((e.BITS-1)/o)*o,m=i;for(let b=p;b>=0;b-=o){u.fill(i);for(let S=0;S<n.length;S++){let T=n[S],I=Number(T>>BigInt(b)&BigInt(c));u[I]=u[I].add(t[S])}let A=i;for(let S=u.length-1,T=i;S>0;S--)T=T.add(u[S]),A=A.add(T);if(m=m.add(A),b!==0)for(let S=0;S<o;S++)m=m.double()}return m}function $i(r){return pc(r.Fp),pr(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...mc(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var ar=BigInt(0),Wt=BigInt(1),eo=BigInt(2),zm=BigInt(8),Fm={zip215:!0};function Vm(r){let e=$i(r);return pr(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function _l(r){let e=Vm(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=e,p=eo<<BigInt(c*8)-Wt,m=t.create,b=Yr(e.n,e.nBitLength),A=e.uvRatio||((d,h)=>{try{return{isValid:!0,value:t.sqrt(d*t.inv(h))}}catch{return{isValid:!1,value:ar}}}),S=e.adjustScalarBytes||(d=>d),T=e.domain||((d,h,g)=>{if(or("phflag",g),h.length||g)throw new Error("Contexts/pre-hash are not supported");return d});function I(d,h){$t("coordinate "+d,h,ar,p)}function x(d){if(!(d instanceof L))throw new Error("ExtendedPoint expected")}let B=Pn((d,h)=>{let{ex:g,ey:w,ez:R}=d,y=d.is0();h==null&&(h=y?zm:t.inv(R));let f=m(g*h),_=m(w*h),C=m(R*h);if(y)return{x:ar,y:Wt};if(C!==Wt)throw new Error("invZ was invalid");return{x:f,y:_}}),U=Pn(d=>{let{a:h,d:g}=e;if(d.is0())throw new Error("bad point: ZERO");let{ex:w,ey:R,ez:y,et:f}=d,_=m(w*w),C=m(R*R),D=m(y*y),V=m(D*D),X=m(_*h),ie=m(D*m(X+C)),ue=m(V+m(g*m(_*C)));if(ie!==ue)throw new Error("bad point: equation left != right (1)");let Le=m(w*R),he=m(y*f);if(Le!==he)throw new Error("bad point: equation left != right (2)");return!0});class L{constructor(h,g,w,R){this.ex=h,this.ey=g,this.ez=w,this.et=R,I("x",h),I("y",g),I("z",w),I("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof L)throw new Error("extended point not allowed");let{x:g,y:w}=h||{};return I("x",g),I("y",w),new L(g,w,Wt,m(g*w))}static normalizeZ(h){let g=t.invertBatch(h.map(w=>w.ez));return h.map((w,R)=>w.toAffine(g[R])).map(L.fromAffine)}static msm(h,g){return Qs(L,b,h,g)}_setWindowSize(h){H.setWindowSize(this,h)}assertValidity(){U(this)}equals(h){x(h);let{ex:g,ey:w,ez:R}=this,{ex:y,ey:f,ez:_}=h,C=m(g*_),D=m(y*R),V=m(w*_),X=m(f*R);return C===D&&V===X}is0(){return this.equals(L.ZERO)}negate(){return new L(m(-this.ex),this.ey,this.ez,m(-this.et))}double(){let{a:h}=e,{ex:g,ey:w,ez:R}=this,y=m(g*g),f=m(w*w),_=m(eo*m(R*R)),C=m(h*y),D=g+w,V=m(m(D*D)-y-f),X=C+f,ie=X-_,ue=C-f,Le=m(V*ie),he=m(X*ue),me=m(V*ue),jt=m(ie*X);return new L(Le,he,jt,me)}add(h){x(h);let{a:g,d:w}=e,{ex:R,ey:y,ez:f,et:_}=this,{ex:C,ey:D,ez:V,et:X}=h;if(g===BigInt(-1)){let Ue=m((y-R)*(D+C)),De=m((y+R)*(D-C)),Yn=m(De-Ue);if(Yn===ar)return this.double();let ze=m(f*eo*X),Fe=m(_*eo*V),xi=Fe+ze,Ve=De+Ue,$e=Fe-ze,ks=m(xi*Yn),He=m(Ve*$e),Ge=m(xi*$e),Ts=m(Yn*Ve);return new L(ks,He,Ts,Ge)}let ie=m(R*C),ue=m(y*D),Le=m(_*w*X),he=m(f*V),me=m((R+y)*(C+D)-ie-ue),jt=he-Le,Ae=he+Le,Ne=m(ue-g*ie),Is=m(me*jt),je=m(Ae*Ne),Ke=m(me*Ne),Os=m(jt*Ae);return new L(Is,je,Os,Ke)}subtract(h){return this.add(h.negate())}wNAF(h){return H.wNAFCached(this,h,L.normalizeZ)}multiply(h){let g=h;$t("scalar",g,Wt,n);let{p:w,f:R}=this.wNAF(g);return L.normalizeZ([w,R])[0]}multiplyUnsafe(h,g=L.ZERO){let w=h;return $t("scalar",w,ar,n),w===ar?te:this.is0()||w===Wt?this:H.wNAFCachedUnsafe(this,w,L.normalizeZ,g)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return H.unsafeLadder(this,n).is0()}toAffine(h){return B(this,h)}clearCofactor(){let{h}=e;return h===Wt?this:this.multiplyUnsafe(h)}static fromHex(h,g=!1){let{d:w,a:R}=e,y=t.BYTES;h=We("pointHex",h,y),or("zip215",g);let f=h.slice(),_=h[y-1];f[y-1]=_&-129;let C=Gr(f),D=g?p:t.ORDER;$t("pointHex.y",C,ar,D);let V=m(C*C),X=m(V-Wt),ie=m(w*V-R),{isValid:ue,value:Le}=A(X,ie);if(!ue)throw new Error("Point.fromHex: invalid y coordinate");let he=(Le&Wt)===Wt,me=(_&128)!==0;if(!g&&Le===ar&&me)throw new Error("Point.fromHex: x=0 and x_0=1");return me!==he&&(Le=m(-Le)),L.fromAffine({x:Le,y:C})}static fromPrivateKey(h){return Y(h).point}toRawBytes(){let{x:h,y:g}=this.toAffine(),w=Cn(g,t.BYTES);return w[w.length-1]|=h&Wt?128:0,w}toHex(){return Ir(this.toRawBytes())}}L.BASE=new L(e.Gx,e.Gy,Wt,m(e.Gx*e.Gy)),L.ZERO=new L(ar,Wt,Wt,ar);let{BASE:F,ZERO:te}=L,H=Js(L,c*8);function Z(d){return Oe(d,n)}function ee(d){return Z(Gr(d))}function Y(d){let h=t.BYTES;d=We("private key",d,h);let g=We("hashed private key",s(d),2*h),w=S(g.slice(0,h)),R=g.slice(h,2*h),y=ee(w),f=F.multiply(y),_=f.toRawBytes();return{head:w,prefix:R,scalar:y,point:f,pointBytes:_}}function Ie(d){return Y(d).pointBytes}function re(d=new Uint8Array,...h){let g=kr(...h);return ee(s(T(g,We("context",d),!!i)))}function fe(d,h,g={}){d=We("message",d),i&&(d=i(d));let{prefix:w,scalar:R,pointBytes:y}=Y(h),f=re(g.context,w,d),_=F.multiply(f).toRawBytes(),C=re(g.context,_,y,d),D=Z(f+C*R);$t("signature.s",D,ar,n);let V=kr(_,Cn(D,t.BYTES));return We("result",V,t.BYTES*2)}let v=Fm;function a(d,h,g,w=v){let{context:R,zip215:y}=w,f=t.BYTES;d=We("signature",d,2*f),h=We("message",h),g=We("publicKey",g,f),y!==void 0&&or("zip215",y),i&&(h=i(h));let _=Gr(d.slice(f,2*f)),C,D,V;try{C=L.fromHex(g,y),D=L.fromHex(d.slice(0,f),y),V=F.multiplyUnsafe(_)}catch{return!1}if(!y&&C.isSmallOrder())return!1;let X=re(R,D.toRawBytes(),C.toRawBytes(),h);return D.add(C.multiplyUnsafe(X)).subtract(V).clearCofactor().equals(L.ZERO)}return F._setWindowSize(8),{CURVE:e,getPublicKey:Ie,sign:fe,verify:a,ExtendedPoint:L,utils:{getExtendedPublicKey:Y,randomPrivateKey:()=>o(t.BYTES),precompute(d=8,h=L.BASE){return h._setWindowSize(d),h.multiply(BigInt(3)),h}}}}var vc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),bl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),PR=BigInt(0),$m=BigInt(1),wl=BigInt(2),MR=BigInt(3),Wm=BigInt(5),qm=BigInt(8);function jm(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=vc,c=r*r%s*r%s,u=Pe(c,wl,s)*c%s,p=Pe(u,$m,s)*r%s,m=Pe(p,Wm,s)*p%s,b=Pe(m,e,s)*m%s,A=Pe(b,t,s)*b%s,S=Pe(A,n,s)*A%s,T=Pe(S,i,s)*S%s,I=Pe(T,i,s)*S%s,x=Pe(I,e,s)*m%s;return{pow_p_5_8:Pe(x,wl,s)*r%s,b2:c}}function Km(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Hm(r,e){let t=vc,n=Oe(e*e*e,t),i=Oe(n*n*e,t),s=jm(r*i).pow_p_5_8,o=Oe(r*n*s,t),c=Oe(e*o*o,t),u=o,p=Oe(o*bl,t),m=c===r,b=c===Oe(-r,t),A=c===Oe(-r*bl,t);return m&&(o=u),(b||A)&&(o=p),dl(o,t)&&(o=Oe(-o,t)),{isValid:m||b,value:o}}var Gm=Yr(vc,void 0,!0),Zm={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Gm,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:qm,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:al,randomBytes:js,adjustScalarBytes:Km,uvRatio:Hm},Un=_l(Zm);var mu=br(Rc()),vt=br(Ac());var Qm=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Xr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Jr=new Uint32Array(64),xc=class extends li{constructor(){super(64,32,8,!1),this.A=Xr[0]|0,this.B=Xr[1]|0,this.C=Xr[2]|0,this.D=Xr[3]|0,this.E=Xr[4]|0,this.F=Xr[5]|0,this.G=Xr[6]|0,this.H=Xr[7]|0}get(){let{A:e,B:t,C:n,D:i,E:s,F:o,G:c,H:u}=this;return[e,t,n,i,s,o,c,u]}set(e,t,n,i,s,o,c,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(e,t){for(let b=0;b<16;b++,t+=4)Jr[b]=e.getUint32(t,!1);for(let b=16;b<64;b++){let A=Jr[b-15],S=Jr[b-2],T=sr(A,7)^sr(A,18)^A>>>3,I=sr(S,17)^sr(S,19)^S>>>10;Jr[b]=I+Jr[b-7]+T+Jr[b-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:u,G:p,H:m}=this;for(let b=0;b<64;b++){let A=sr(c,6)^sr(c,11)^sr(c,25),S=m+A+il(c,u,p)+Qm[b]+Jr[b]|0,I=(sr(n,2)^sr(n,13)^sr(n,22))+sl(n,i,s)|0;m=p,p=u,u=c,c=o+S|0,o=s,s=i,i=n,n=S+I|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,p=p+this.G|0,m=m+this.H|0,this.set(n,i,s,o,c,u,p,m)}roundClean(){Jr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Wi=fi(()=>new xc);var Ei=br(Cl()),E=br(Pc()),sh=br(Pc());var gg=1,yg=2,_g=3,bg=4,wg=5,vg=6,Eg=7,Rg=8,Sg=9,Ag=10,xg=-32700,Ig=-32603,Og=-32602,kg=-32601,Tg=-32600,Ng=-32016,Bg=-32015,Lg=-32014,Cg=-32013,Pg=-32012,Mg=-32011,Ug=-32010,Dg=-32009,zg=-32008,Fg=-32007,Vg=-32006,$g=-32005,Wg=-32004,qg=-32003,jg=-32002,Kg=-32001,Hg=28e5,Gg=2800001,Zg=2800002,Yg=2800003,Xg=2800004,Jg=2800005,Qg=2800006,ey=2800007,ty=2800008,ry=2800009,ny=2800010,iy=323e4,sy=32300001,oy=3230002,ay=3230003,cy=3230004,uy=361e4,fy=3610001,ly=3610002,dy=3610003,hy=3610004,py=3610005,my=3610006,gy=3610007,yy=3611e3,_y=3704e3,by=3704001,wy=3704002,vy=3704003,Ey=3704004,Ry=4128e3,Sy=4128001,Ay=4128002,xy=4615e3,Iy=4615001,Oy=4615002,ky=4615003,Ty=4615004,Ny=4615005,By=4615006,Ly=4615007,Cy=4615008,Py=4615009,My=4615010,Uy=4615011,Dy=4615012,zy=4615013,Fy=4615014,Vy=4615015,$y=4615016,Wy=4615017,qy=4615018,jy=4615019,Ky=4615020,Hy=4615021,Gy=4615022,Zy=4615023,Yy=4615024,Xy=4615025,Jy=4615026,Qy=4615027,e_=4615028,t_=4615029,r_=4615030,n_=4615031,i_=4615032,s_=4615033,o_=4615034,a_=4615035,c_=4615036,u_=4615037,f_=4615038,l_=4615039,d_=4615040,h_=4615041,p_=4615042,m_=4615043,g_=4615044,y_=4615045,__=4615046,b_=4615047,w_=4615048,v_=4615049,E_=4615050,R_=4615051,S_=4615052,A_=4615053,x_=4615054,I_=5508e3,O_=5508001,k_=5508002,T_=5508003,N_=5508004,B_=5508005,L_=5508006,C_=5508007,P_=5508008,M_=5508009,U_=5508010,D_=5508011,z_=5663e3,F_=5663001,V_=5663002,$_=5663003,W_=5663004,q_=5663005,j_=5663006,K_=5663007,H_=5663008,G_=5663009,Z_=5663010,Y_=5663011,X_=5663012,J_=5663013,Q_=5663014,eb=5663015,tb=5663016,rb=5663017,nb=5663018,ib=5663019,sb=705e4,ob=7050001,ab=7050002,cb=7050003,ub=7050004,fb=7050005,lb=7050006,db=7050007,hb=7050008,pb=7050009,mb=7050010,gb=7050011,yb=7050012,_b=7050013,bb=7050014,wb=7050015,vb=7050016,Eb=7050017,Rb=7050018,Sb=7050019,Ab=7050020,xb=7050021,Ib=7050022,Ob=7050023,kb=7050024,Tb=7050025,Nb=7050026,Bb=7050027,Lb=7050028,Cb=7050029,Pb=7050030,Mb=7050031,Ub=7050032,Db=7050033,zb=7050034,Fb=7050035,Vb=7050036,Mc=8078e3,Uc=8078001,Pl=8078002,Ml=8078003,Dc=8078004,zc=8078005,Fc=8078006,$b=8078007,Wb=8078008,qb=8078009,jb=8078010,Vc=8078011,Kb=8078012,Ul=8078013,Dl=8078014,Hb=8078015,Gb=8078016,Zb=8078017,Yb=8078018,Xb=8078019,zl=8078020,Fl=8078021,Jb=8078022,Qb=81e5,ew=8100001,tw=8100002,rw=8100003,nw=819e4,iw=8190001,sw=8190002,ow=8190003,aw=8190004,cw=99e5,uw=9900001,fw=9900002,lw=9900003,dw=9900004;function Vl(r){return Array.isArray(r)?"%5B"+r.map(Vl).join("%2C%20")+"%5D":typeof r=="bigint"?`${r}n`:encodeURIComponent(String(r!=null&&Object.getPrototypeOf(r)===null?{...r}:r))}function hw([r,e]){return`${r}=${Vl(e)}`}function pw(r){let e=Object.entries(r).map(hw).join("&");return btoa(e)}var GR={[iy]:"Account not found at address: $address",[cy]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[ay]:"Expected decoded account at address: $address",[oy]:"Failed to decode account data at address: $address",[sy]:"Accounts not found at addresses: $addresses",[ry]:"Unable to find a viable program address bump seed.",[Zg]:"$putativeAddress is not a base58-encoded address.",[Hg]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Yg]:"The `CryptoKey` must be an `Ed25519` public key.",[ty]:"Invalid seeds; point must fall off the Ed25519 curve.",[Xg]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Qg]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[ey]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Jg]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[ny]:"Program address cannot end with PDA marker.",[Gg]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[bg]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[gg]:"The network has progressed past the last block for which this transaction could have been committed.",[Mc]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Jb]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[zl]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[zc]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Fc]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Dc]:"Encoder and decoder must either both be fixed-size or variable-size.",[Wb]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Pl]:"Expected a fixed-size codec, got a variable-size one.",[Ul]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Ml]:"Expected a variable-size codec, got a fixed-size one.",[Xb]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Uc]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Yb]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[qb]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[jb]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Hb]:"Invalid literal union variant. Expected one of [$variants], got $value.",[$b]:"Expected [$codecDescription] to have $expected items, got $actual.",[Kb]:"Invalid value $value for base $base with alphabet $alphabet.",[Gb]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Vc]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Dl]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Fl]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Zb]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[yy]:"No random values implementation could be found.",[Py]:"instruction requires an uninitialized account",[Zy]:"instruction tries to borrow reference for an account which is already borrowed",[Yy]:"instruction left account with an outstanding borrowed reference",[Hy]:"program other than the account's owner changed the size of the account data",[Ny]:"account data too small for instruction",[Gy]:"instruction expected an executable account",[__]:"An account does not have enough lamports to be rent-exempt",[w_]:"Program arithmetic overflowed",[y_]:"Failed to serialize or deserialize account data: $encodedData",[x_]:"Builtin programs must consume compute units",[i_]:"Cross-program invocation call depth too deep",[f_]:"Computational budget exceeded",[Jy]:"custom program error: #$code",[Wy]:"instruction contains duplicate accounts",[Xy]:"instruction modifications of multiply-passed account differ",[r_]:"executable accounts must be rent exempt",[e_]:"instruction changed executable accounts data",[t_]:"instruction changed the balance of an executable account",[qy]:"instruction changed executable bit of an account",[Fy]:"instruction modified data of an account it does not own",[zy]:"instruction spent from the balance of an account it does not own",[Iy]:"generic instruction error",[E_]:"Provided owner is not allowed",[m_]:"Account is immutable",[g_]:"Incorrect authority provided",[Ly]:"incorrect program id for instruction",[By]:"insufficient funds for instruction",[Ty]:"invalid account data for instruction",[b_]:"Invalid account owner",[Oy]:"invalid program argument",[Qy]:"program returned invalid error code",[ky]:"invalid instruction data",[u_]:"Failed to reallocate account data",[c_]:"Provided seeds do not result in a valid address",[R_]:"Accounts data allocations exceeded the maximum allowed per transaction",[S_]:"Max accounts exceeded",[A_]:"Max instruction trace length exceeded",[a_]:"Length of the seed is too long for address generation",[s_]:"An account required by the instruction is missing",[Cy]:"missing required signature for instruction",[Dy]:"instruction illegally modified the program id of an account",[Ky]:"insufficient account keys for instruction",[l_]:"Cross-program invocation with unauthorized signer or writable account",[d_]:"Failed to create program execution environment",[p_]:"Program failed to compile",[h_]:"Program failed to complete",[$y]:"instruction modified data of a read-only account",[Vy]:"instruction changed the balance of a read-only account",[o_]:"Cross-program invocation reentrancy not allowed for this instruction",[jy]:"instruction modified rent epoch of an account",[Uy]:"sum of account balances before and after instruction do not match",[My]:"instruction requires an initialized account",[xy]:"",[n_]:"Unsupported program id",[v_]:"Unsupported sysvar",[Ry]:"The instruction does not have any accounts.",[Sy]:"The instruction does not have any data.",[Ay]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[wg]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[yg]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[fw]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[dw]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[uw]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[cw]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[lw]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Ig]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Og]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Tg]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[kg]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[xg]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Pg]:"$__serverMessage",[Kg]:"$__serverMessage",[Wg]:"$__serverMessage",[Lg]:"$__serverMessage",[Ug]:"$__serverMessage",[Dg]:"$__serverMessage",[Ng]:"Minimum context slot has not been reached",[$g]:"Node is unhealthy; behind by $numSlotsBehind slots",[zg]:"No snapshot",[jg]:"Transaction simulation failed",[Fg]:"$__serverMessage",[Mg]:"Transaction history is not available from this node",[Vg]:"$__serverMessage",[Cg]:"Transaction signature length mismatch",[qg]:"Transaction signature verification failure",[Bg]:"$__serverMessage",[_y]:"Key pair bytes must be of length 64, got $byteLength.",[by]:"Expected private key bytes with length 32. Actual length: $actualLength.",[wy]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Ey]:"The provided private key does not match the provided public key.",[vy]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[vg]:"Lamports value must be in the range [0, 2e64-1]",[Eg]:"`$value` cannot be parsed as a `BigInt`",[Ag]:"$message",[Rg]:"`$value` cannot be parsed as a `Number`",[_g]:"No nonce account could be found at address `$nonceAccountAddress`",[nw]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[sw]:"WebSocket was closed before payload could be added to the send buffer",[ow]:"WebSocket connection closed",[aw]:"WebSocket failed to connect",[iw]:"Failed to obtain a subscription id from the server",[rw]:"Could not find an API plan for RPC method: `$method`",[Qb]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[tw]:"HTTP error ($statusCode): $message",[ew]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[I_]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[O_]:"The provided value does not implement the `KeyPairSigner` interface",[T_]:"The provided value does not implement the `MessageModifyingSigner` interface",[N_]:"The provided value does not implement the `MessagePartialSigner` interface",[k_]:"The provided value does not implement any of the `MessageSigner` interfaces",[L_]:"The provided value does not implement the `TransactionModifyingSigner` interface",[C_]:"The provided value does not implement the `TransactionPartialSigner` interface",[P_]:"The provided value does not implement the `TransactionSendingSigner` interface",[B_]:"The provided value does not implement any of the `TransactionSigner` interfaces",[M_]:"More than one `TransactionSendingSigner` was identified.",[U_]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[D_]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[gy]:"Cannot export a non-extractable key.",[fy]:"No digest implementation could be found.",[uy]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[ly]:`This runtime does not support the generation of Ed25519 key pairs.
1
+ "use strict";var frame=(()=>{var n0=Object.create;var Bs=Object.defineProperty;var i0=Object.getOwnPropertyDescriptor;var s0=Object.getOwnPropertyNames;var o0=Object.getPrototypeOf,a0=Object.prototype.hasOwnProperty;var Ct=(r,e)=>()=>(r&&(e=r(r=0)),e);var zt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),dn=(r,e)=>{for(var t in e)Bs(r,t,{get:e[t],enumerable:!0})},of=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of s0(e))!a0.call(r,i)&&i!==t&&Bs(r,i,{get:()=>e[i],enumerable:!(n=i0(e,i))||n.enumerable});return r};var br=(r,e,t)=>(t=r!=null?n0(o0(r)):{},of(e||!r||!r.__esModule?Bs(t,"default",{value:r,enumerable:!0}):t,r)),Ba=r=>of(Bs({},"__esModule",{value:!0}),r);var Ff=zt($s=>{"use strict";$s.byteLength=Op;$s.toByteArray=Tp;$s.fromByteArray=Lp;var dr=[],tr=[],Ip=typeof Uint8Array<"u"?Uint8Array:Array,Ka="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(kn=0,Df=Ka.length;kn<Df;++kn)dr[kn]=Ka[kn],tr[Ka.charCodeAt(kn)]=kn;var kn,Df;tr[45]=62;tr[95]=63;function zf(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function Op(r){var e=zf(r),t=e[0],n=e[1];return(t+n)*3/4-n}function kp(r,e,t){return(e+t)*3/4-t}function Tp(r){var e,t=zf(r),n=t[0],i=t[1],s=new Ip(kp(r,n,i)),o=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)e=tr[r.charCodeAt(u)]<<18|tr[r.charCodeAt(u+1)]<<12|tr[r.charCodeAt(u+2)]<<6|tr[r.charCodeAt(u+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[r.charCodeAt(u)]<<2|tr[r.charCodeAt(u+1)]>>4,s[o++]=e&255),i===1&&(e=tr[r.charCodeAt(u)]<<10|tr[r.charCodeAt(u+1)]<<4|tr[r.charCodeAt(u+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Np(r){return dr[r>>18&63]+dr[r>>12&63]+dr[r>>6&63]+dr[r&63]}function Bp(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(Np(n));return i.join("")}function Lp(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,c=t-n;o<c;o+=s)i.push(Bp(r,o,o+s>c?c:o+s));return n===1?(e=r[t-1],i.push(dr[e>>2]+dr[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(dr[e>>10]+dr[e>>4&63]+dr[e<<2&63]+"=")),i.join("")}});var $f=zt(Ha=>{Ha.read=function(r,e,t,n,i){var s,o,c=i*8-n-1,u=(1<<c)-1,p=u>>1,m=-7,b=t?i-1:0,A=t?-1:1,S=r[e+b];for(b+=A,s=S&(1<<-m)-1,S>>=-m,m+=c;m>0;s=s*256+r[e+b],b+=A,m-=8);for(o=s&(1<<-m)-1,s>>=-m,m+=n;m>0;o=o*256+r[e+b],b+=A,m-=8);if(s===0)s=1-p;else{if(s===u)return o?NaN:(S?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-p}return(S?-1:1)*o*Math.pow(2,s-n)};Ha.write=function(r,e,t,n,i,s){var o,c,u,p=s*8-i-1,m=(1<<p)-1,b=m>>1,A=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:s-1,T=n?1:-1,I=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=m):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+b>=1?e+=A/u:e+=A*Math.pow(2,1-b),e*u>=2&&(o++,u/=2),o+b>=m?(c=0,o=m):o+b>=1?(c=(e*u-1)*Math.pow(2,i),o=o+b):(c=e*Math.pow(2,b-1)*Math.pow(2,i),o=0));i>=8;r[t+S]=c&255,S+=T,c/=256,i-=8);for(o=o<<i|c,p+=i;p>0;r[t+S]=o&255,S+=T,o/=256,p-=8);r[t+S-T]|=I*128}});var zi=zt(fi=>{"use strict";var Ga=Ff(),ci=$f(),Vf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fi.Buffer=N;fi.SlowBuffer=zp;fi.INSPECT_MAX_BYTES=50;var Vs=2147483647;fi.kMaxLength=Vs;N.TYPED_ARRAY_SUPPORT=Cp();!N.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Cp(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(N.prototype,"parent",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.buffer}});Object.defineProperty(N.prototype,"offset",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.byteOffset}});function Sr(r){if(r>Vs)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,N.prototype),e}function N(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ja(r)}return Kf(r,e,t)}N.poolSize=8192;function Kf(r,e,t){if(typeof r=="string")return Mp(r,e);if(ArrayBuffer.isView(r))return Up(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(hr(r,ArrayBuffer)||r&&hr(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(hr(r,SharedArrayBuffer)||r&&hr(r.buffer,SharedArrayBuffer)))return Ya(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return N.from(n,e,t);let i=Dp(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return N.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}N.from=function(r,e,t){return Kf(r,e,t)};Object.setPrototypeOf(N.prototype,Uint8Array.prototype);Object.setPrototypeOf(N,Uint8Array);function Hf(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Pp(r,e,t){return Hf(r),r<=0?Sr(r):e!==void 0?typeof t=="string"?Sr(r).fill(e,t):Sr(r).fill(e):Sr(r)}N.alloc=function(r,e,t){return Pp(r,e,t)};function Ja(r){return Hf(r),Sr(r<0?0:Qa(r)|0)}N.allocUnsafe=function(r){return Ja(r)};N.allocUnsafeSlow=function(r){return Ja(r)};function Mp(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!N.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=Gf(r,e)|0,n=Sr(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function Za(r){let e=r.length<0?0:Qa(r.length)|0,t=Sr(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Up(r){if(hr(r,Uint8Array)){let e=new Uint8Array(r);return Ya(e.buffer,e.byteOffset,e.byteLength)}return Za(r)}function Ya(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,N.prototype),n}function Dp(r){if(N.isBuffer(r)){let e=Qa(r.length)|0,t=Sr(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||tc(r.length)?Sr(0):Za(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Za(r.data)}function Qa(r){if(r>=Vs)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Vs.toString(16)+" bytes");return r|0}function zp(r){return+r!=r&&(r=0),N.alloc(+r)}N.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==N.prototype};N.compare=function(e,t){if(hr(e,Uint8Array)&&(e=N.from(e,e.offset,e.byteLength)),hr(t,Uint8Array)&&(t=N.from(t,t.offset,t.byteLength)),!N.isBuffer(e)||!N.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==t[s]){n=e[s],i=t[s];break}return n<i?-1:i<n?1:0};N.isEncoding=function(e){switch(String(e).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}};N.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return N.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=N.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){let o=e[n];if(hr(o,Uint8Array))s+o.length>i.length?(N.isBuffer(o)||(o=N.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(N.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Gf(r,e){if(N.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||hr(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Xa(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return nl(r).length;default:if(i)return n?-1:Xa(r).length;e=(""+e).toLowerCase(),i=!0}}N.byteLength=Gf;function Fp(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Yp(this,e,t);case"utf8":case"utf-8":return Yf(this,e,t);case"ascii":return Gp(this,e,t);case"latin1":case"binary":return Zp(this,e,t);case"base64":return Kp(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xp(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}N.prototype._isBuffer=!0;function Tn(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}N.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Tn(this,t,t+1);return this};N.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Tn(this,t,t+3),Tn(this,t+1,t+2);return this};N.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Tn(this,t,t+7),Tn(this,t+1,t+6),Tn(this,t+2,t+5),Tn(this,t+3,t+4);return this};N.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Yf(this,0,e):Fp.apply(this,arguments)};N.prototype.toLocaleString=N.prototype.toString;N.prototype.equals=function(e){if(!N.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:N.compare(this,e)===0};N.prototype.inspect=function(){let e="",t=fi.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Vf&&(N.prototype[Vf]=N.prototype.inspect);N.prototype.compare=function(e,t,n,i,s){if(hr(e,Uint8Array)&&(e=N.from(e,e.offset,e.byteLength)),!N.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),t<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,c=n-t,u=Math.min(o,c),p=this.slice(i,s),m=e.slice(t,n);for(let b=0;b<u;++b)if(p[b]!==m[b]){o=p[b],c=m[b];break}return o<c?-1:c<o?1:0};function Zf(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,tc(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=N.from(e,n)),N.isBuffer(e))return e.length===0?-1:qf(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):qf(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function qf(r,e,t,n,i){let s=1,o=r.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2,c/=2,t/=2}function u(m,b){return s===1?m[b]:m.readUInt16BE(b*s)}let p;if(i){let m=-1;for(p=t;p<o;p++)if(u(r,p)===u(e,m===-1?0:p-m)){if(m===-1&&(m=p),p-m+1===c)return m*s}else m!==-1&&(p-=p-m),m=-1}else for(t+c>o&&(t=o-c),p=t;p>=0;p--){let m=!0;for(let b=0;b<c;b++)if(u(r,p+b)!==u(e,b)){m=!1;break}if(m)return p}return-1}N.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};N.prototype.indexOf=function(e,t,n){return Zf(this,e,t,n,!0)};N.prototype.lastIndexOf=function(e,t,n){return Zf(this,e,t,n,!1)};function $p(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let c=parseInt(e.substr(o*2,2),16);if(tc(c))return o;r[t+o]=c}return o}function Vp(r,e,t,n){return qs(Xa(e,r.length-t),r,t,n)}function qp(r,e,t,n){return qs(tm(e),r,t,n)}function Wp(r,e,t,n){return qs(nl(e),r,t,n)}function jp(r,e,t,n){return qs(rm(e,r.length-t),r,t,n)}N.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return $p(this,e,t,n);case"utf8":case"utf-8":return Vp(this,e,t,n);case"ascii":case"latin1":case"binary":return qp(this,e,t,n);case"base64":return Wp(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return jp(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Kp(r,e,t){return e===0&&t===r.length?Ga.fromByteArray(r):Ga.fromByteArray(r.slice(e,t))}function Yf(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=t){let u,p,m,b;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(b=(s&31)<<6|u&63,b>127&&(o=b));break;case 3:u=r[i+1],p=r[i+2],(u&192)===128&&(p&192)===128&&(b=(s&15)<<12|(u&63)<<6|p&63,b>2047&&(b<55296||b>57343)&&(o=b));break;case 4:u=r[i+1],p=r[i+2],m=r[i+3],(u&192)===128&&(p&192)===128&&(m&192)===128&&(b=(s&15)<<18|(u&63)<<12|(p&63)<<6|m&63,b>65535&&b<1114112&&(o=b))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return Hp(n)}var Wf=4096;function Hp(r){let e=r.length;if(e<=Wf)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Wf));return t}function Gp(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function Zp(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function Yp(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let s=e;s<t;++s)i+=nm[r[s]];return i}function Xp(r,e,t){let n=r.slice(e,t),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}N.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,N.prototype),i};function bt(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}N.prototype.readUintLE=N.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return i};N.prototype.readUintBE=N.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let i=this[e+--t],s=1;for(;t>0&&(s*=256);)i+=this[e+--t]*s;return i};N.prototype.readUint8=N.prototype.readUInt8=function(e,t){return e=e>>>0,t||bt(e,1,this.length),this[e]};N.prototype.readUint16LE=N.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||bt(e,2,this.length),this[e]|this[e+1]<<8};N.prototype.readUint16BE=N.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||bt(e,2,this.length),this[e]<<8|this[e+1]};N.prototype.readUint32LE=N.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};N.prototype.readUint32BE=N.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};N.prototype.readBigUInt64LE=$r(function(e){e=e>>>0,ui(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Di(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});N.prototype.readBigUInt64BE=$r(function(e){e=e>>>0,ui(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Di(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});N.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*t)),i};N.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let i=t,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};N.prototype.readInt8=function(e,t){return e=e>>>0,t||bt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};N.prototype.readInt16LE=function(e,t){e=e>>>0,t||bt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};N.prototype.readInt16BE=function(e,t){e=e>>>0,t||bt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};N.prototype.readInt32LE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};N.prototype.readInt32BE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};N.prototype.readBigInt64LE=$r(function(e){e=e>>>0,ui(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Di(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});N.prototype.readBigInt64BE=$r(function(e){e=e>>>0,ui(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Di(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});N.prototype.readFloatLE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),ci.read(this,e,!0,23,4)};N.prototype.readFloatBE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),ci.read(this,e,!1,23,4)};N.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||bt(e,8,this.length),ci.read(this,e,!0,52,8)};N.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||bt(e,8,this.length),ci.read(this,e,!1,52,8)};function $t(r,e,t,n,i,s){if(!N.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}N.prototype.writeUintLE=N.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;$t(this,e,t,n,c,0)}let s=1,o=0;for(this[t]=e&255;++o<n&&(s*=256);)this[t+o]=e/s&255;return t+n};N.prototype.writeUintBE=N.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;$t(this,e,t,n,c,0)}let s=n-1,o=1;for(this[t+s]=e&255;--s>=0&&(o*=256);)this[t+s]=e/o&255;return t+n};N.prototype.writeUint8=N.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,1,255,0),this[t]=e&255,t+1};N.prototype.writeUint16LE=N.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};N.prototype.writeUint16BE=N.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};N.prototype.writeUint32LE=N.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};N.prototype.writeUint32BE=N.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Xf(r,e,t,n,i){rl(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,t}function Jf(r,e,t,n,i){rl(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t+7]=s,s=s>>8,r[t+6]=s,s=s>>8,r[t+5]=s,s=s>>8,r[t+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=o,o=o>>8,r[t+2]=o,o=o>>8,r[t+1]=o,o=o>>8,r[t]=o,t+8}N.prototype.writeBigUInt64LE=$r(function(e,t=0){return Xf(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});N.prototype.writeBigUInt64BE=$r(function(e,t=0){return Jf(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});N.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);$t(this,e,t,n,u-1,-u)}let s=0,o=1,c=0;for(this[t]=e&255;++s<n&&(o*=256);)e<0&&c===0&&this[t+s-1]!==0&&(c=1),this[t+s]=(e/o>>0)-c&255;return t+n};N.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);$t(this,e,t,n,u-1,-u)}let s=n-1,o=1,c=0;for(this[t+s]=e&255;--s>=0&&(o*=256);)e<0&&c===0&&this[t+s+1]!==0&&(c=1),this[t+s]=(e/o>>0)-c&255;return t+n};N.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};N.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};N.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};N.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};N.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||$t(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};N.prototype.writeBigInt64LE=$r(function(e,t=0){return Xf(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});N.prototype.writeBigInt64BE=$r(function(e,t=0){return Jf(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Qf(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function el(r,e,t,n,i){return e=+e,t=t>>>0,i||Qf(r,e,t,4,34028234663852886e22,-34028234663852886e22),ci.write(r,e,t,n,23,4),t+4}N.prototype.writeFloatLE=function(e,t,n){return el(this,e,t,!0,n)};N.prototype.writeFloatBE=function(e,t,n){return el(this,e,t,!1,n)};function tl(r,e,t,n,i){return e=+e,t=t>>>0,i||Qf(r,e,t,8,17976931348623157e292,-17976931348623157e292),ci.write(r,e,t,n,52,8),t+8}N.prototype.writeDoubleLE=function(e,t,n){return tl(this,e,t,!0,n)};N.prototype.writeDoubleBE=function(e,t,n){return tl(this,e,t,!1,n)};N.prototype.copy=function(e,t,n,i){if(!N.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),s};N.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!N.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=t;s<n;++s)this[s]=e;else{let o=N.isBuffer(e)?e:N.from(e,i),c=o.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-t;++s)this[s+t]=o[s%c]}return this};var ai={};function ec(r,e,t){ai[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ec("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ec("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);ec("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=jf(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=jf(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function jf(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function Jp(r,e,t){ui(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Di(e,r.length-(t+1))}function rl(r,e,t,n,i,s){if(r>t||r<e){let o=typeof e=="bigint"?"n":"",c;throw s>3?e===0||e===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${e}${o} and <= ${t}${o}`,new ai.ERR_OUT_OF_RANGE("value",c,r)}Jp(n,i,s)}function ui(r,e){if(typeof r!="number")throw new ai.ERR_INVALID_ARG_TYPE(e,"number",r)}function Di(r,e,t){throw Math.floor(r)!==r?(ui(r,t),new ai.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new ai.ERR_BUFFER_OUT_OF_BOUNDS:new ai.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Qp=/[^+/0-9A-Za-z-_]/g;function em(r){if(r=r.split("=")[0],r=r.trim().replace(Qp,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Xa(r,e){e=e||1/0;let t,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function tm(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function rm(r,e){let t,n,i,s=[];for(let o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),n=t>>8,i=t%256,s.push(i),s.push(n);return s}function nl(r){return Ga.toByteArray(em(r))}function qs(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function hr(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function tc(r){return r!==r}var nm=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function $r(r){return typeof BigInt>"u"?im:r}function im(){throw new Error("BigInt not supported")}});var Al=zt(()=>{});var Ic=zt((xl,xc)=>{(function(r,e){"use strict";function t(v,a){if(!v)throw new Error(a||"Assertion failed")}function n(v,a){v.super_=a;var l=function(){};l.prototype=a.prototype,v.prototype=new l,v.prototype.constructor=v}function i(v,a,l){if(i.isBN(v))return v;this.negative=0,this.words=null,this.length=0,this.red=null,v!==null&&((a==="le"||a==="be")&&(l=a,a=10),this._init(v||0,a||10,l||"be"))}typeof r=="object"?r.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Al().Buffer}catch{}i.isBN=function(a){return a instanceof i?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===i.wordSize&&Array.isArray(a.words)},i.max=function(a,l){return a.cmp(l)>0?a:l},i.min=function(a,l){return a.cmp(l)<0?a:l},i.prototype._init=function(a,l,d){if(typeof a=="number")return this._initNumber(a,l,d);if(typeof a=="object")return this._initArray(a,l,d);l==="hex"&&(l=16),t(l===(l|0)&&l>=2&&l<=36),a=a.toString().replace(/\s+/g,"");var h=0;a[0]==="-"&&(h++,this.negative=1),h<a.length&&(l===16?this._parseHex(a,h,d):(this._parseBase(a,l,h),d==="le"&&this._initArray(this.toArray(),l,d)))},i.prototype._initNumber=function(a,l,d){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(t(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),d==="le"&&this._initArray(this.toArray(),l,d)},i.prototype._initArray=function(a,l,d){if(t(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var h=0;h<this.length;h++)this.words[h]=0;var g,w,R=0;if(d==="be")for(h=a.length-1,g=0;h>=0;h-=3)w=a[h]|a[h-1]<<8|a[h-2]<<16,this.words[g]|=w<<R&67108863,this.words[g+1]=w>>>26-R&67108863,R+=24,R>=26&&(R-=26,g++);else if(d==="le")for(h=0,g=0;h<a.length;h+=3)w=a[h]|a[h+1]<<8|a[h+2]<<16,this.words[g]|=w<<R&67108863,this.words[g+1]=w>>>26-R&67108863,R+=24,R>=26&&(R-=26,g++);return this._strip()};function o(v,a){var l=v.charCodeAt(a);if(l>=48&&l<=57)return l-48;if(l>=65&&l<=70)return l-55;if(l>=97&&l<=102)return l-87;t(!1,"Invalid character in "+v)}function c(v,a,l){var d=o(v,l);return l-1>=a&&(d|=o(v,l-1)<<4),d}i.prototype._parseHex=function(a,l,d){this.length=Math.ceil((a.length-l)/6),this.words=new Array(this.length);for(var h=0;h<this.length;h++)this.words[h]=0;var g=0,w=0,R;if(d==="be")for(h=a.length-1;h>=l;h-=2)R=c(a,l,h)<<g,this.words[w]|=R&67108863,g>=18?(g-=18,w+=1,this.words[w]|=R>>>26):g+=8;else{var y=a.length-l;for(h=y%2===0?l+1:l;h<a.length;h+=2)R=c(a,l,h)<<g,this.words[w]|=R&67108863,g>=18?(g-=18,w+=1,this.words[w]|=R>>>26):g+=8}this._strip()};function u(v,a,l,d){for(var h=0,g=0,w=Math.min(v.length,l),R=a;R<w;R++){var y=v.charCodeAt(R)-48;h*=d,y>=49?g=y-49+10:y>=17?g=y-17+10:g=y,t(y>=0&&g<d,"Invalid character"),h+=g}return h}i.prototype._parseBase=function(a,l,d){this.words=[0],this.length=1;for(var h=0,g=1;g<=67108863;g*=l)h++;h--,g=g/l|0;for(var w=a.length-d,R=w%h,y=Math.min(w,w-R)+d,f=0,_=d;_<y;_+=h)f=u(a,_,_+h,l),this.imuln(g),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(R!==0){var C=1;for(f=u(a,_,a.length,l),_=0;_<R;_++)C*=l;this.imuln(C),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},i.prototype.copy=function(a){a.words=new Array(this.length);for(var l=0;l<this.length;l++)a.words[l]=this.words[l];a.length=this.length,a.negative=this.negative,a.red=this.red};function p(v,a){v.words=a.words,v.length=a.length,v.negative=a.negative,v.red=a.red}if(i.prototype._move=function(a){p(a,this)},i.prototype.clone=function(){var a=new i(null);return this.copy(a),a},i.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch{i.prototype.inspect=m}else i.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var b=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],A=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],S=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(a,l){a=a||10,l=l|0||1;var d;if(a===16||a==="hex"){d="";for(var h=0,g=0,w=0;w<this.length;w++){var R=this.words[w],y=((R<<h|g)&16777215).toString(16);g=R>>>24-h&16777215,h+=2,h>=26&&(h-=26,w--),g!==0||w!==this.length-1?d=b[6-y.length]+y+d:d=y+d}for(g!==0&&(d=g.toString(16)+d);d.length%l!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}if(a===(a|0)&&a>=2&&a<=36){var f=A[a],_=S[a];d="";var C=this.clone();for(C.negative=0;!C.isZero();){var D=C.modrn(_).toString(a);C=C.idivn(_),C.isZero()?d=D+d:d=b[f-D.length]+D+d}for(this.isZero()&&(d="0"+d);d.length%l!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}t(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},i.prototype.toJSON=function(){return this.toString(16,2)},s&&(i.prototype.toBuffer=function(a,l){return this.toArrayLike(s,a,l)}),i.prototype.toArray=function(a,l){return this.toArrayLike(Array,a,l)};var T=function(a,l){return a.allocUnsafe?a.allocUnsafe(l):new a(l)};i.prototype.toArrayLike=function(a,l,d){this._strip();var h=this.byteLength(),g=d||Math.max(1,h);t(h<=g,"byte array longer than desired length"),t(g>0,"Requested array length <= 0");var w=T(a,g),R=l==="le"?"LE":"BE";return this["_toArrayLike"+R](w,h),w},i.prototype._toArrayLikeLE=function(a,l){for(var d=0,h=0,g=0,w=0;g<this.length;g++){var R=this.words[g]<<w|h;a[d++]=R&255,d<a.length&&(a[d++]=R>>8&255),d<a.length&&(a[d++]=R>>16&255),w===6?(d<a.length&&(a[d++]=R>>24&255),h=0,w=0):(h=R>>>24,w+=2)}if(d<a.length)for(a[d++]=h;d<a.length;)a[d++]=0},i.prototype._toArrayLikeBE=function(a,l){for(var d=a.length-1,h=0,g=0,w=0;g<this.length;g++){var R=this.words[g]<<w|h;a[d--]=R&255,d>=0&&(a[d--]=R>>8&255),d>=0&&(a[d--]=R>>16&255),w===6?(d>=0&&(a[d--]=R>>24&255),h=0,w=0):(h=R>>>24,w+=2)}if(d>=0)for(a[d--]=h;d>=0;)a[d--]=0},Math.clz32?i.prototype._countBits=function(a){return 32-Math.clz32(a)}:i.prototype._countBits=function(a){var l=a,d=0;return l>=4096&&(d+=13,l>>>=13),l>=64&&(d+=7,l>>>=7),l>=8&&(d+=4,l>>>=4),l>=2&&(d+=2,l>>>=2),d+l},i.prototype._zeroBits=function(a){if(a===0)return 26;var l=a,d=0;return(l&8191)===0&&(d+=13,l>>>=13),(l&127)===0&&(d+=7,l>>>=7),(l&15)===0&&(d+=4,l>>>=4),(l&3)===0&&(d+=2,l>>>=2),(l&1)===0&&d++,d},i.prototype.bitLength=function(){var a=this.words[this.length-1],l=this._countBits(a);return(this.length-1)*26+l};function I(v){for(var a=new Array(v.bitLength()),l=0;l<a.length;l++){var d=l/26|0,h=l%26;a[l]=v.words[d]>>>h&1}return a}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,l=0;l<this.length;l++){var d=this._zeroBits(this.words[l]);if(a+=d,d!==26)break}return a},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},i.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var l=0;l<a.length;l++)this.words[l]=this.words[l]|a.words[l];return this._strip()},i.prototype.ior=function(a){return t((this.negative|a.negative)===0),this.iuor(a)},i.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},i.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},i.prototype.iuand=function(a){var l;this.length>a.length?l=a:l=this;for(var d=0;d<l.length;d++)this.words[d]=this.words[d]&a.words[d];return this.length=l.length,this._strip()},i.prototype.iand=function(a){return t((this.negative|a.negative)===0),this.iuand(a)},i.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},i.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},i.prototype.iuxor=function(a){var l,d;this.length>a.length?(l=this,d=a):(l=a,d=this);for(var h=0;h<d.length;h++)this.words[h]=l.words[h]^d.words[h];if(this!==l)for(;h<l.length;h++)this.words[h]=l.words[h];return this.length=l.length,this._strip()},i.prototype.ixor=function(a){return t((this.negative|a.negative)===0),this.iuxor(a)},i.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},i.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},i.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var l=Math.ceil(a/26)|0,d=a%26;this._expand(l),d>0&&l--;for(var h=0;h<l;h++)this.words[h]=~this.words[h]&67108863;return d>0&&(this.words[h]=~this.words[h]&67108863>>26-d),this._strip()},i.prototype.notn=function(a){return this.clone().inotn(a)},i.prototype.setn=function(a,l){t(typeof a=="number"&&a>=0);var d=a/26|0,h=a%26;return this._expand(d+1),l?this.words[d]=this.words[d]|1<<h:this.words[d]=this.words[d]&~(1<<h),this._strip()},i.prototype.iadd=function(a){var l;if(this.negative!==0&&a.negative===0)return this.negative=0,l=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,l=this.isub(a),a.negative=1,l._normSign();var d,h;this.length>a.length?(d=this,h=a):(d=a,h=this);for(var g=0,w=0;w<h.length;w++)l=(d.words[w]|0)+(h.words[w]|0)+g,this.words[w]=l&67108863,g=l>>>26;for(;g!==0&&w<d.length;w++)l=(d.words[w]|0)+g,this.words[w]=l&67108863,g=l>>>26;if(this.length=d.length,g!==0)this.words[this.length]=g,this.length++;else if(d!==this)for(;w<d.length;w++)this.words[w]=d.words[w];return this},i.prototype.add=function(a){var l;return a.negative!==0&&this.negative===0?(a.negative=0,l=this.sub(a),a.negative^=1,l):a.negative===0&&this.negative!==0?(this.negative=0,l=a.sub(this),this.negative=1,l):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},i.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var l=this.iadd(a);return a.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var d=this.cmp(a);if(d===0)return this.negative=0,this.length=1,this.words[0]=0,this;var h,g;d>0?(h=this,g=a):(h=a,g=this);for(var w=0,R=0;R<g.length;R++)l=(h.words[R]|0)-(g.words[R]|0)+w,w=l>>26,this.words[R]=l&67108863;for(;w!==0&&R<h.length;R++)l=(h.words[R]|0)+w,w=l>>26,this.words[R]=l&67108863;if(w===0&&R<h.length&&h!==this)for(;R<h.length;R++)this.words[R]=h.words[R];return this.length=Math.max(this.length,R),h!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(a){return this.clone().isub(a)};function x(v,a,l){l.negative=a.negative^v.negative;var d=v.length+a.length|0;l.length=d,d=d-1|0;var h=v.words[0]|0,g=a.words[0]|0,w=h*g,R=w&67108863,y=w/67108864|0;l.words[0]=R;for(var f=1;f<d;f++){for(var _=y>>>26,C=y&67108863,D=Math.min(f,a.length-1),$=Math.max(0,f-v.length+1);$<=D;$++){var X=f-$|0;h=v.words[X]|0,g=a.words[$]|0,w=h*g+C,_+=w/67108864|0,C=w&67108863}l.words[f]=C|0,y=_|0}return y!==0?l.words[f]=y|0:l.length--,l._strip()}var B=function(a,l,d){var h=a.words,g=l.words,w=d.words,R=0,y,f,_,C=h[0]|0,D=C&8191,$=C>>>13,X=h[1]|0,ie=X&8191,ue=X>>>13,Le=h[2]|0,he=Le&8191,me=Le>>>13,jt=h[3]|0,Ae=jt&8191,Ne=jt>>>13,Os=h[4]|0,je=Os&8191,Ke=Os>>>13,ks=h[5]|0,Ue=ks&8191,De=ks>>>13,Yn=h[6]|0,ze=Yn&8191,Fe=Yn>>>13,Oi=h[7]|0,$e=Oi&8191,Ve=Oi>>>13,Ts=h[8]|0,He=Ts&8191,Ge=Ts>>>13,Ns=h[9]|0,Ye=Ns&8191,Xe=Ns>>>13,Zu=g[0]|0,Je=Zu&8191,Qe=Zu>>>13,Yu=g[1]|0,et=Yu&8191,tt=Yu>>>13,Xu=g[2]|0,rt=Xu&8191,nt=Xu>>>13,Ju=g[3]|0,it=Ju&8191,st=Ju>>>13,Qu=g[4]|0,ot=Qu&8191,at=Qu>>>13,ef=g[5]|0,ct=ef&8191,ut=ef>>>13,tf=g[6]|0,ft=tf&8191,lt=tf>>>13,rf=g[7]|0,dt=rf&8191,ht=rf>>>13,nf=g[8]|0,pt=nf&8191,mt=nf>>>13,sf=g[9]|0,gt=sf&8191,yt=sf>>>13;d.negative=a.negative^l.negative,d.length=19,y=Math.imul(D,Je),f=Math.imul(D,Qe),f=f+Math.imul($,Je)|0,_=Math.imul($,Qe);var ha=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ha>>>26)|0,ha&=67108863,y=Math.imul(ie,Je),f=Math.imul(ie,Qe),f=f+Math.imul(ue,Je)|0,_=Math.imul(ue,Qe),y=y+Math.imul(D,et)|0,f=f+Math.imul(D,tt)|0,f=f+Math.imul($,et)|0,_=_+Math.imul($,tt)|0;var pa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(pa>>>26)|0,pa&=67108863,y=Math.imul(he,Je),f=Math.imul(he,Qe),f=f+Math.imul(me,Je)|0,_=Math.imul(me,Qe),y=y+Math.imul(ie,et)|0,f=f+Math.imul(ie,tt)|0,f=f+Math.imul(ue,et)|0,_=_+Math.imul(ue,tt)|0,y=y+Math.imul(D,rt)|0,f=f+Math.imul(D,nt)|0,f=f+Math.imul($,rt)|0,_=_+Math.imul($,nt)|0;var ma=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ma>>>26)|0,ma&=67108863,y=Math.imul(Ae,Je),f=Math.imul(Ae,Qe),f=f+Math.imul(Ne,Je)|0,_=Math.imul(Ne,Qe),y=y+Math.imul(he,et)|0,f=f+Math.imul(he,tt)|0,f=f+Math.imul(me,et)|0,_=_+Math.imul(me,tt)|0,y=y+Math.imul(ie,rt)|0,f=f+Math.imul(ie,nt)|0,f=f+Math.imul(ue,rt)|0,_=_+Math.imul(ue,nt)|0,y=y+Math.imul(D,it)|0,f=f+Math.imul(D,st)|0,f=f+Math.imul($,it)|0,_=_+Math.imul($,st)|0;var ga=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ga>>>26)|0,ga&=67108863,y=Math.imul(je,Je),f=Math.imul(je,Qe),f=f+Math.imul(Ke,Je)|0,_=Math.imul(Ke,Qe),y=y+Math.imul(Ae,et)|0,f=f+Math.imul(Ae,tt)|0,f=f+Math.imul(Ne,et)|0,_=_+Math.imul(Ne,tt)|0,y=y+Math.imul(he,rt)|0,f=f+Math.imul(he,nt)|0,f=f+Math.imul(me,rt)|0,_=_+Math.imul(me,nt)|0,y=y+Math.imul(ie,it)|0,f=f+Math.imul(ie,st)|0,f=f+Math.imul(ue,it)|0,_=_+Math.imul(ue,st)|0,y=y+Math.imul(D,ot)|0,f=f+Math.imul(D,at)|0,f=f+Math.imul($,ot)|0,_=_+Math.imul($,at)|0;var ya=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ya>>>26)|0,ya&=67108863,y=Math.imul(Ue,Je),f=Math.imul(Ue,Qe),f=f+Math.imul(De,Je)|0,_=Math.imul(De,Qe),y=y+Math.imul(je,et)|0,f=f+Math.imul(je,tt)|0,f=f+Math.imul(Ke,et)|0,_=_+Math.imul(Ke,tt)|0,y=y+Math.imul(Ae,rt)|0,f=f+Math.imul(Ae,nt)|0,f=f+Math.imul(Ne,rt)|0,_=_+Math.imul(Ne,nt)|0,y=y+Math.imul(he,it)|0,f=f+Math.imul(he,st)|0,f=f+Math.imul(me,it)|0,_=_+Math.imul(me,st)|0,y=y+Math.imul(ie,ot)|0,f=f+Math.imul(ie,at)|0,f=f+Math.imul(ue,ot)|0,_=_+Math.imul(ue,at)|0,y=y+Math.imul(D,ct)|0,f=f+Math.imul(D,ut)|0,f=f+Math.imul($,ct)|0,_=_+Math.imul($,ut)|0;var _a=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(_a>>>26)|0,_a&=67108863,y=Math.imul(ze,Je),f=Math.imul(ze,Qe),f=f+Math.imul(Fe,Je)|0,_=Math.imul(Fe,Qe),y=y+Math.imul(Ue,et)|0,f=f+Math.imul(Ue,tt)|0,f=f+Math.imul(De,et)|0,_=_+Math.imul(De,tt)|0,y=y+Math.imul(je,rt)|0,f=f+Math.imul(je,nt)|0,f=f+Math.imul(Ke,rt)|0,_=_+Math.imul(Ke,nt)|0,y=y+Math.imul(Ae,it)|0,f=f+Math.imul(Ae,st)|0,f=f+Math.imul(Ne,it)|0,_=_+Math.imul(Ne,st)|0,y=y+Math.imul(he,ot)|0,f=f+Math.imul(he,at)|0,f=f+Math.imul(me,ot)|0,_=_+Math.imul(me,at)|0,y=y+Math.imul(ie,ct)|0,f=f+Math.imul(ie,ut)|0,f=f+Math.imul(ue,ct)|0,_=_+Math.imul(ue,ut)|0,y=y+Math.imul(D,ft)|0,f=f+Math.imul(D,lt)|0,f=f+Math.imul($,ft)|0,_=_+Math.imul($,lt)|0;var ba=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ba>>>26)|0,ba&=67108863,y=Math.imul($e,Je),f=Math.imul($e,Qe),f=f+Math.imul(Ve,Je)|0,_=Math.imul(Ve,Qe),y=y+Math.imul(ze,et)|0,f=f+Math.imul(ze,tt)|0,f=f+Math.imul(Fe,et)|0,_=_+Math.imul(Fe,tt)|0,y=y+Math.imul(Ue,rt)|0,f=f+Math.imul(Ue,nt)|0,f=f+Math.imul(De,rt)|0,_=_+Math.imul(De,nt)|0,y=y+Math.imul(je,it)|0,f=f+Math.imul(je,st)|0,f=f+Math.imul(Ke,it)|0,_=_+Math.imul(Ke,st)|0,y=y+Math.imul(Ae,ot)|0,f=f+Math.imul(Ae,at)|0,f=f+Math.imul(Ne,ot)|0,_=_+Math.imul(Ne,at)|0,y=y+Math.imul(he,ct)|0,f=f+Math.imul(he,ut)|0,f=f+Math.imul(me,ct)|0,_=_+Math.imul(me,ut)|0,y=y+Math.imul(ie,ft)|0,f=f+Math.imul(ie,lt)|0,f=f+Math.imul(ue,ft)|0,_=_+Math.imul(ue,lt)|0,y=y+Math.imul(D,dt)|0,f=f+Math.imul(D,ht)|0,f=f+Math.imul($,dt)|0,_=_+Math.imul($,ht)|0;var wa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(wa>>>26)|0,wa&=67108863,y=Math.imul(He,Je),f=Math.imul(He,Qe),f=f+Math.imul(Ge,Je)|0,_=Math.imul(Ge,Qe),y=y+Math.imul($e,et)|0,f=f+Math.imul($e,tt)|0,f=f+Math.imul(Ve,et)|0,_=_+Math.imul(Ve,tt)|0,y=y+Math.imul(ze,rt)|0,f=f+Math.imul(ze,nt)|0,f=f+Math.imul(Fe,rt)|0,_=_+Math.imul(Fe,nt)|0,y=y+Math.imul(Ue,it)|0,f=f+Math.imul(Ue,st)|0,f=f+Math.imul(De,it)|0,_=_+Math.imul(De,st)|0,y=y+Math.imul(je,ot)|0,f=f+Math.imul(je,at)|0,f=f+Math.imul(Ke,ot)|0,_=_+Math.imul(Ke,at)|0,y=y+Math.imul(Ae,ct)|0,f=f+Math.imul(Ae,ut)|0,f=f+Math.imul(Ne,ct)|0,_=_+Math.imul(Ne,ut)|0,y=y+Math.imul(he,ft)|0,f=f+Math.imul(he,lt)|0,f=f+Math.imul(me,ft)|0,_=_+Math.imul(me,lt)|0,y=y+Math.imul(ie,dt)|0,f=f+Math.imul(ie,ht)|0,f=f+Math.imul(ue,dt)|0,_=_+Math.imul(ue,ht)|0,y=y+Math.imul(D,pt)|0,f=f+Math.imul(D,mt)|0,f=f+Math.imul($,pt)|0,_=_+Math.imul($,mt)|0;var va=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(va>>>26)|0,va&=67108863,y=Math.imul(Ye,Je),f=Math.imul(Ye,Qe),f=f+Math.imul(Xe,Je)|0,_=Math.imul(Xe,Qe),y=y+Math.imul(He,et)|0,f=f+Math.imul(He,tt)|0,f=f+Math.imul(Ge,et)|0,_=_+Math.imul(Ge,tt)|0,y=y+Math.imul($e,rt)|0,f=f+Math.imul($e,nt)|0,f=f+Math.imul(Ve,rt)|0,_=_+Math.imul(Ve,nt)|0,y=y+Math.imul(ze,it)|0,f=f+Math.imul(ze,st)|0,f=f+Math.imul(Fe,it)|0,_=_+Math.imul(Fe,st)|0,y=y+Math.imul(Ue,ot)|0,f=f+Math.imul(Ue,at)|0,f=f+Math.imul(De,ot)|0,_=_+Math.imul(De,at)|0,y=y+Math.imul(je,ct)|0,f=f+Math.imul(je,ut)|0,f=f+Math.imul(Ke,ct)|0,_=_+Math.imul(Ke,ut)|0,y=y+Math.imul(Ae,ft)|0,f=f+Math.imul(Ae,lt)|0,f=f+Math.imul(Ne,ft)|0,_=_+Math.imul(Ne,lt)|0,y=y+Math.imul(he,dt)|0,f=f+Math.imul(he,ht)|0,f=f+Math.imul(me,dt)|0,_=_+Math.imul(me,ht)|0,y=y+Math.imul(ie,pt)|0,f=f+Math.imul(ie,mt)|0,f=f+Math.imul(ue,pt)|0,_=_+Math.imul(ue,mt)|0,y=y+Math.imul(D,gt)|0,f=f+Math.imul(D,yt)|0,f=f+Math.imul($,gt)|0,_=_+Math.imul($,yt)|0;var Ea=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ea>>>26)|0,Ea&=67108863,y=Math.imul(Ye,et),f=Math.imul(Ye,tt),f=f+Math.imul(Xe,et)|0,_=Math.imul(Xe,tt),y=y+Math.imul(He,rt)|0,f=f+Math.imul(He,nt)|0,f=f+Math.imul(Ge,rt)|0,_=_+Math.imul(Ge,nt)|0,y=y+Math.imul($e,it)|0,f=f+Math.imul($e,st)|0,f=f+Math.imul(Ve,it)|0,_=_+Math.imul(Ve,st)|0,y=y+Math.imul(ze,ot)|0,f=f+Math.imul(ze,at)|0,f=f+Math.imul(Fe,ot)|0,_=_+Math.imul(Fe,at)|0,y=y+Math.imul(Ue,ct)|0,f=f+Math.imul(Ue,ut)|0,f=f+Math.imul(De,ct)|0,_=_+Math.imul(De,ut)|0,y=y+Math.imul(je,ft)|0,f=f+Math.imul(je,lt)|0,f=f+Math.imul(Ke,ft)|0,_=_+Math.imul(Ke,lt)|0,y=y+Math.imul(Ae,dt)|0,f=f+Math.imul(Ae,ht)|0,f=f+Math.imul(Ne,dt)|0,_=_+Math.imul(Ne,ht)|0,y=y+Math.imul(he,pt)|0,f=f+Math.imul(he,mt)|0,f=f+Math.imul(me,pt)|0,_=_+Math.imul(me,mt)|0,y=y+Math.imul(ie,gt)|0,f=f+Math.imul(ie,yt)|0,f=f+Math.imul(ue,gt)|0,_=_+Math.imul(ue,yt)|0;var Ra=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ra>>>26)|0,Ra&=67108863,y=Math.imul(Ye,rt),f=Math.imul(Ye,nt),f=f+Math.imul(Xe,rt)|0,_=Math.imul(Xe,nt),y=y+Math.imul(He,it)|0,f=f+Math.imul(He,st)|0,f=f+Math.imul(Ge,it)|0,_=_+Math.imul(Ge,st)|0,y=y+Math.imul($e,ot)|0,f=f+Math.imul($e,at)|0,f=f+Math.imul(Ve,ot)|0,_=_+Math.imul(Ve,at)|0,y=y+Math.imul(ze,ct)|0,f=f+Math.imul(ze,ut)|0,f=f+Math.imul(Fe,ct)|0,_=_+Math.imul(Fe,ut)|0,y=y+Math.imul(Ue,ft)|0,f=f+Math.imul(Ue,lt)|0,f=f+Math.imul(De,ft)|0,_=_+Math.imul(De,lt)|0,y=y+Math.imul(je,dt)|0,f=f+Math.imul(je,ht)|0,f=f+Math.imul(Ke,dt)|0,_=_+Math.imul(Ke,ht)|0,y=y+Math.imul(Ae,pt)|0,f=f+Math.imul(Ae,mt)|0,f=f+Math.imul(Ne,pt)|0,_=_+Math.imul(Ne,mt)|0,y=y+Math.imul(he,gt)|0,f=f+Math.imul(he,yt)|0,f=f+Math.imul(me,gt)|0,_=_+Math.imul(me,yt)|0;var Sa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Sa>>>26)|0,Sa&=67108863,y=Math.imul(Ye,it),f=Math.imul(Ye,st),f=f+Math.imul(Xe,it)|0,_=Math.imul(Xe,st),y=y+Math.imul(He,ot)|0,f=f+Math.imul(He,at)|0,f=f+Math.imul(Ge,ot)|0,_=_+Math.imul(Ge,at)|0,y=y+Math.imul($e,ct)|0,f=f+Math.imul($e,ut)|0,f=f+Math.imul(Ve,ct)|0,_=_+Math.imul(Ve,ut)|0,y=y+Math.imul(ze,ft)|0,f=f+Math.imul(ze,lt)|0,f=f+Math.imul(Fe,ft)|0,_=_+Math.imul(Fe,lt)|0,y=y+Math.imul(Ue,dt)|0,f=f+Math.imul(Ue,ht)|0,f=f+Math.imul(De,dt)|0,_=_+Math.imul(De,ht)|0,y=y+Math.imul(je,pt)|0,f=f+Math.imul(je,mt)|0,f=f+Math.imul(Ke,pt)|0,_=_+Math.imul(Ke,mt)|0,y=y+Math.imul(Ae,gt)|0,f=f+Math.imul(Ae,yt)|0,f=f+Math.imul(Ne,gt)|0,_=_+Math.imul(Ne,yt)|0;var Aa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Aa>>>26)|0,Aa&=67108863,y=Math.imul(Ye,ot),f=Math.imul(Ye,at),f=f+Math.imul(Xe,ot)|0,_=Math.imul(Xe,at),y=y+Math.imul(He,ct)|0,f=f+Math.imul(He,ut)|0,f=f+Math.imul(Ge,ct)|0,_=_+Math.imul(Ge,ut)|0,y=y+Math.imul($e,ft)|0,f=f+Math.imul($e,lt)|0,f=f+Math.imul(Ve,ft)|0,_=_+Math.imul(Ve,lt)|0,y=y+Math.imul(ze,dt)|0,f=f+Math.imul(ze,ht)|0,f=f+Math.imul(Fe,dt)|0,_=_+Math.imul(Fe,ht)|0,y=y+Math.imul(Ue,pt)|0,f=f+Math.imul(Ue,mt)|0,f=f+Math.imul(De,pt)|0,_=_+Math.imul(De,mt)|0,y=y+Math.imul(je,gt)|0,f=f+Math.imul(je,yt)|0,f=f+Math.imul(Ke,gt)|0,_=_+Math.imul(Ke,yt)|0;var xa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(xa>>>26)|0,xa&=67108863,y=Math.imul(Ye,ct),f=Math.imul(Ye,ut),f=f+Math.imul(Xe,ct)|0,_=Math.imul(Xe,ut),y=y+Math.imul(He,ft)|0,f=f+Math.imul(He,lt)|0,f=f+Math.imul(Ge,ft)|0,_=_+Math.imul(Ge,lt)|0,y=y+Math.imul($e,dt)|0,f=f+Math.imul($e,ht)|0,f=f+Math.imul(Ve,dt)|0,_=_+Math.imul(Ve,ht)|0,y=y+Math.imul(ze,pt)|0,f=f+Math.imul(ze,mt)|0,f=f+Math.imul(Fe,pt)|0,_=_+Math.imul(Fe,mt)|0,y=y+Math.imul(Ue,gt)|0,f=f+Math.imul(Ue,yt)|0,f=f+Math.imul(De,gt)|0,_=_+Math.imul(De,yt)|0;var Ia=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ia>>>26)|0,Ia&=67108863,y=Math.imul(Ye,ft),f=Math.imul(Ye,lt),f=f+Math.imul(Xe,ft)|0,_=Math.imul(Xe,lt),y=y+Math.imul(He,dt)|0,f=f+Math.imul(He,ht)|0,f=f+Math.imul(Ge,dt)|0,_=_+Math.imul(Ge,ht)|0,y=y+Math.imul($e,pt)|0,f=f+Math.imul($e,mt)|0,f=f+Math.imul(Ve,pt)|0,_=_+Math.imul(Ve,mt)|0,y=y+Math.imul(ze,gt)|0,f=f+Math.imul(ze,yt)|0,f=f+Math.imul(Fe,gt)|0,_=_+Math.imul(Fe,yt)|0;var Oa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Oa>>>26)|0,Oa&=67108863,y=Math.imul(Ye,dt),f=Math.imul(Ye,ht),f=f+Math.imul(Xe,dt)|0,_=Math.imul(Xe,ht),y=y+Math.imul(He,pt)|0,f=f+Math.imul(He,mt)|0,f=f+Math.imul(Ge,pt)|0,_=_+Math.imul(Ge,mt)|0,y=y+Math.imul($e,gt)|0,f=f+Math.imul($e,yt)|0,f=f+Math.imul(Ve,gt)|0,_=_+Math.imul(Ve,yt)|0;var ka=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ka>>>26)|0,ka&=67108863,y=Math.imul(Ye,pt),f=Math.imul(Ye,mt),f=f+Math.imul(Xe,pt)|0,_=Math.imul(Xe,mt),y=y+Math.imul(He,gt)|0,f=f+Math.imul(He,yt)|0,f=f+Math.imul(Ge,gt)|0,_=_+Math.imul(Ge,yt)|0;var Ta=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ta>>>26)|0,Ta&=67108863,y=Math.imul(Ye,gt),f=Math.imul(Ye,yt),f=f+Math.imul(Xe,gt)|0,_=Math.imul(Xe,yt);var Na=(R+y|0)+((f&8191)<<13)|0;return R=(_+(f>>>13)|0)+(Na>>>26)|0,Na&=67108863,w[0]=ha,w[1]=pa,w[2]=ma,w[3]=ga,w[4]=ya,w[5]=_a,w[6]=ba,w[7]=wa,w[8]=va,w[9]=Ea,w[10]=Ra,w[11]=Sa,w[12]=Aa,w[13]=xa,w[14]=Ia,w[15]=Oa,w[16]=ka,w[17]=Ta,w[18]=Na,R!==0&&(w[19]=R,d.length++),d};Math.imul||(B=x);function U(v,a,l){l.negative=a.negative^v.negative,l.length=v.length+a.length;for(var d=0,h=0,g=0;g<l.length-1;g++){var w=h;h=0;for(var R=d&67108863,y=Math.min(g,a.length-1),f=Math.max(0,g-v.length+1);f<=y;f++){var _=g-f,C=v.words[_]|0,D=a.words[f]|0,$=C*D,X=$&67108863;w=w+($/67108864|0)|0,X=X+R|0,R=X&67108863,w=w+(X>>>26)|0,h+=w>>>26,w&=67108863}l.words[g]=R,d=w,w=h}return d!==0?l.words[g]=d:l.length--,l._strip()}function L(v,a,l){return U(v,a,l)}i.prototype.mulTo=function(a,l){var d,h=this.length+a.length;return this.length===10&&a.length===10?d=B(this,a,l):h<63?d=x(this,a,l):h<1024?d=U(this,a,l):d=L(this,a,l),d};function F(v,a){this.x=v,this.y=a}F.prototype.makeRBT=function(a){for(var l=new Array(a),d=i.prototype._countBits(a)-1,h=0;h<a;h++)l[h]=this.revBin(h,d,a);return l},F.prototype.revBin=function(a,l,d){if(a===0||a===d-1)return a;for(var h=0,g=0;g<l;g++)h|=(a&1)<<l-g-1,a>>=1;return h},F.prototype.permute=function(a,l,d,h,g,w){for(var R=0;R<w;R++)h[R]=l[a[R]],g[R]=d[a[R]]},F.prototype.transform=function(a,l,d,h,g,w){this.permute(w,a,l,d,h,g);for(var R=1;R<g;R<<=1)for(var y=R<<1,f=Math.cos(2*Math.PI/y),_=Math.sin(2*Math.PI/y),C=0;C<g;C+=y)for(var D=f,$=_,X=0;X<R;X++){var ie=d[C+X],ue=h[C+X],Le=d[C+X+R],he=h[C+X+R],me=D*Le-$*he;he=D*he+$*Le,Le=me,d[C+X]=ie+Le,h[C+X]=ue+he,d[C+X+R]=ie-Le,h[C+X+R]=ue-he,X!==y&&(me=f*D-_*$,$=f*$+_*D,D=me)}},F.prototype.guessLen13b=function(a,l){var d=Math.max(l,a)|1,h=d&1,g=0;for(d=d/2|0;d;d=d>>>1)g++;return 1<<g+1+h},F.prototype.conjugate=function(a,l,d){if(!(d<=1))for(var h=0;h<d/2;h++){var g=a[h];a[h]=a[d-h-1],a[d-h-1]=g,g=l[h],l[h]=-l[d-h-1],l[d-h-1]=-g}},F.prototype.normalize13b=function(a,l){for(var d=0,h=0;h<l/2;h++){var g=Math.round(a[2*h+1]/l)*8192+Math.round(a[2*h]/l)+d;a[h]=g&67108863,g<67108864?d=0:d=g/67108864|0}return a},F.prototype.convert13b=function(a,l,d,h){for(var g=0,w=0;w<l;w++)g=g+(a[w]|0),d[2*w]=g&8191,g=g>>>13,d[2*w+1]=g&8191,g=g>>>13;for(w=2*l;w<h;++w)d[w]=0;t(g===0),t((g&-8192)===0)},F.prototype.stub=function(a){for(var l=new Array(a),d=0;d<a;d++)l[d]=0;return l},F.prototype.mulp=function(a,l,d){var h=2*this.guessLen13b(a.length,l.length),g=this.makeRBT(h),w=this.stub(h),R=new Array(h),y=new Array(h),f=new Array(h),_=new Array(h),C=new Array(h),D=new Array(h),$=d.words;$.length=h,this.convert13b(a.words,a.length,R,h),this.convert13b(l.words,l.length,_,h),this.transform(R,w,y,f,h,g),this.transform(_,w,C,D,h,g);for(var X=0;X<h;X++){var ie=y[X]*C[X]-f[X]*D[X];f[X]=y[X]*D[X]+f[X]*C[X],y[X]=ie}return this.conjugate(y,f,h),this.transform(y,f,$,w,h,g),this.conjugate($,w,h),this.normalize13b($,h),d.negative=a.negative^l.negative,d.length=a.length+l.length,d._strip()},i.prototype.mul=function(a){var l=new i(null);return l.words=new Array(this.length+a.length),this.mulTo(a,l)},i.prototype.mulf=function(a){var l=new i(null);return l.words=new Array(this.length+a.length),L(this,a,l)},i.prototype.imul=function(a){return this.clone().mulTo(a,this)},i.prototype.imuln=function(a){var l=a<0;l&&(a=-a),t(typeof a=="number"),t(a<67108864);for(var d=0,h=0;h<this.length;h++){var g=(this.words[h]|0)*a,w=(g&67108863)+(d&67108863);d>>=26,d+=g/67108864|0,d+=w>>>26,this.words[h]=w&67108863}return d!==0&&(this.words[h]=d,this.length++),l?this.ineg():this},i.prototype.muln=function(a){return this.clone().imuln(a)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(a){var l=I(a);if(l.length===0)return new i(1);for(var d=this,h=0;h<l.length&&l[h]===0;h++,d=d.sqr());if(++h<l.length)for(var g=d.sqr();h<l.length;h++,g=g.sqr())l[h]!==0&&(d=d.mul(g));return d},i.prototype.iushln=function(a){t(typeof a=="number"&&a>=0);var l=a%26,d=(a-l)/26,h=67108863>>>26-l<<26-l,g;if(l!==0){var w=0;for(g=0;g<this.length;g++){var R=this.words[g]&h,y=(this.words[g]|0)-R<<l;this.words[g]=y|w,w=R>>>26-l}w&&(this.words[g]=w,this.length++)}if(d!==0){for(g=this.length-1;g>=0;g--)this.words[g+d]=this.words[g];for(g=0;g<d;g++)this.words[g]=0;this.length+=d}return this._strip()},i.prototype.ishln=function(a){return t(this.negative===0),this.iushln(a)},i.prototype.iushrn=function(a,l,d){t(typeof a=="number"&&a>=0);var h;l?h=(l-l%26)/26:h=0;var g=a%26,w=Math.min((a-g)/26,this.length),R=67108863^67108863>>>g<<g,y=d;if(h-=w,h=Math.max(0,h),y){for(var f=0;f<w;f++)y.words[f]=this.words[f];y.length=w}if(w!==0)if(this.length>w)for(this.length-=w,f=0;f<this.length;f++)this.words[f]=this.words[f+w];else this.words[0]=0,this.length=1;var _=0;for(f=this.length-1;f>=0&&(_!==0||f>=h);f--){var C=this.words[f]|0;this.words[f]=_<<26-g|C>>>g,_=C&R}return y&&_!==0&&(y.words[y.length++]=_),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(a,l,d){return t(this.negative===0),this.iushrn(a,l,d)},i.prototype.shln=function(a){return this.clone().ishln(a)},i.prototype.ushln=function(a){return this.clone().iushln(a)},i.prototype.shrn=function(a){return this.clone().ishrn(a)},i.prototype.ushrn=function(a){return this.clone().iushrn(a)},i.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var l=a%26,d=(a-l)/26,h=1<<l;if(this.length<=d)return!1;var g=this.words[d];return!!(g&h)},i.prototype.imaskn=function(a){t(typeof a=="number"&&a>=0);var l=a%26,d=(a-l)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=d)return this;if(l!==0&&d++,this.length=Math.min(d,this.length),l!==0){var h=67108863^67108863>>>l<<l;this.words[this.length-1]&=h}return this._strip()},i.prototype.maskn=function(a){return this.clone().imaskn(a)},i.prototype.iaddn=function(a){return t(typeof a=="number"),t(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},i.prototype._iaddn=function(a){this.words[0]+=a;for(var l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},i.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+1]-=1;return this._strip()},i.prototype.addn=function(a){return this.clone().iaddn(a)},i.prototype.subn=function(a){return this.clone().isubn(a)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(a,l,d){var h=a.length+d,g;this._expand(h);var w,R=0;for(g=0;g<a.length;g++){w=(this.words[g+d]|0)+R;var y=(a.words[g]|0)*l;w-=y&67108863,R=(w>>26)-(y/67108864|0),this.words[g+d]=w&67108863}for(;g<this.length-d;g++)w=(this.words[g+d]|0)+R,R=w>>26,this.words[g+d]=w&67108863;if(R===0)return this._strip();for(t(R===-1),R=0,g=0;g<this.length;g++)w=-(this.words[g]|0)+R,R=w>>26,this.words[g]=w&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(a,l){var d=this.length-a.length,h=this.clone(),g=a,w=g.words[g.length-1]|0,R=this._countBits(w);d=26-R,d!==0&&(g=g.ushln(d),h.iushln(d),w=g.words[g.length-1]|0);var y=h.length-g.length,f;if(l!=="mod"){f=new i(null),f.length=y+1,f.words=new Array(f.length);for(var _=0;_<f.length;_++)f.words[_]=0}var C=h.clone()._ishlnsubmul(g,1,y);C.negative===0&&(h=C,f&&(f.words[y]=1));for(var D=y-1;D>=0;D--){var $=(h.words[g.length+D]|0)*67108864+(h.words[g.length+D-1]|0);for($=Math.min($/w|0,67108863),h._ishlnsubmul(g,$,D);h.negative!==0;)$--,h.negative=0,h._ishlnsubmul(g,1,D),h.isZero()||(h.negative^=1);f&&(f.words[D]=$)}return f&&f._strip(),h._strip(),l!=="div"&&d!==0&&h.iushrn(d),{div:f||null,mod:h}},i.prototype.divmod=function(a,l,d){if(t(!a.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var h,g,w;return this.negative!==0&&a.negative===0?(w=this.neg().divmod(a,l),l!=="mod"&&(h=w.div.neg()),l!=="div"&&(g=w.mod.neg(),d&&g.negative!==0&&g.iadd(a)),{div:h,mod:g}):this.negative===0&&a.negative!==0?(w=this.divmod(a.neg(),l),l!=="mod"&&(h=w.div.neg()),{div:h,mod:w.mod}):(this.negative&a.negative)!==0?(w=this.neg().divmod(a.neg(),l),l!=="div"&&(g=w.mod.neg(),d&&g.negative!==0&&g.isub(a)),{div:w.div,mod:g}):a.length>this.length||this.cmp(a)<0?{div:new i(0),mod:this}:a.length===1?l==="div"?{div:this.divn(a.words[0]),mod:null}:l==="mod"?{div:null,mod:new i(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new i(this.modrn(a.words[0]))}:this._wordDiv(a,l)},i.prototype.div=function(a){return this.divmod(a,"div",!1).div},i.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},i.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},i.prototype.divRound=function(a){var l=this.divmod(a);if(l.mod.isZero())return l.div;var d=l.div.negative!==0?l.mod.isub(a):l.mod,h=a.ushrn(1),g=a.andln(1),w=d.cmp(h);return w<0||g===1&&w===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},i.prototype.modrn=function(a){var l=a<0;l&&(a=-a),t(a<=67108863);for(var d=(1<<26)%a,h=0,g=this.length-1;g>=0;g--)h=(d*h+(this.words[g]|0))%a;return l?-h:h},i.prototype.modn=function(a){return this.modrn(a)},i.prototype.idivn=function(a){var l=a<0;l&&(a=-a),t(a<=67108863);for(var d=0,h=this.length-1;h>=0;h--){var g=(this.words[h]|0)+d*67108864;this.words[h]=g/a|0,d=g%a}return this._strip(),l?this.ineg():this},i.prototype.divn=function(a){return this.clone().idivn(a)},i.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var l=this,d=a.clone();l.negative!==0?l=l.umod(a):l=l.clone();for(var h=new i(1),g=new i(0),w=new i(0),R=new i(1),y=0;l.isEven()&&d.isEven();)l.iushrn(1),d.iushrn(1),++y;for(var f=d.clone(),_=l.clone();!l.isZero();){for(var C=0,D=1;(l.words[0]&D)===0&&C<26;++C,D<<=1);if(C>0)for(l.iushrn(C);C-- >0;)(h.isOdd()||g.isOdd())&&(h.iadd(f),g.isub(_)),h.iushrn(1),g.iushrn(1);for(var $=0,X=1;(d.words[0]&X)===0&&$<26;++$,X<<=1);if($>0)for(d.iushrn($);$-- >0;)(w.isOdd()||R.isOdd())&&(w.iadd(f),R.isub(_)),w.iushrn(1),R.iushrn(1);l.cmp(d)>=0?(l.isub(d),h.isub(w),g.isub(R)):(d.isub(l),w.isub(h),R.isub(g))}return{a:w,b:R,gcd:d.iushln(y)}},i.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var l=this,d=a.clone();l.negative!==0?l=l.umod(a):l=l.clone();for(var h=new i(1),g=new i(0),w=d.clone();l.cmpn(1)>0&&d.cmpn(1)>0;){for(var R=0,y=1;(l.words[0]&y)===0&&R<26;++R,y<<=1);if(R>0)for(l.iushrn(R);R-- >0;)h.isOdd()&&h.iadd(w),h.iushrn(1);for(var f=0,_=1;(d.words[0]&_)===0&&f<26;++f,_<<=1);if(f>0)for(d.iushrn(f);f-- >0;)g.isOdd()&&g.iadd(w),g.iushrn(1);l.cmp(d)>=0?(l.isub(d),h.isub(g)):(d.isub(l),g.isub(h))}var C;return l.cmpn(1)===0?C=h:C=g,C.cmpn(0)<0&&C.iadd(a),C},i.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var l=this.clone(),d=a.clone();l.negative=0,d.negative=0;for(var h=0;l.isEven()&&d.isEven();h++)l.iushrn(1),d.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;d.isEven();)d.iushrn(1);var g=l.cmp(d);if(g<0){var w=l;l=d,d=w}else if(g===0||d.cmpn(1)===0)break;l.isub(d)}while(!0);return d.iushln(h)},i.prototype.invm=function(a){return this.egcd(a).a.umod(a)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(a){return this.words[0]&a},i.prototype.bincn=function(a){t(typeof a=="number");var l=a%26,d=(a-l)/26,h=1<<l;if(this.length<=d)return this._expand(d+1),this.words[d]|=h,this;for(var g=h,w=d;g!==0&&w<this.length;w++){var R=this.words[w]|0;R+=g,g=R>>>26,R&=67108863,this.words[w]=R}return g!==0&&(this.words[w]=g,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(a){var l=a<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this._strip();var d;if(this.length>1)d=1;else{l&&(a=-a),t(a<=67108863,"Number is too big");var h=this.words[0]|0;d=h===a?0:h<a?-1:1}return this.negative!==0?-d|0:d},i.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var l=this.ucmp(a);return this.negative!==0?-l|0:l},i.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var l=0,d=this.length-1;d>=0;d--){var h=this.words[d]|0,g=a.words[d]|0;if(h!==g){h<g?l=-1:h>g&&(l=1);break}}return l},i.prototype.gtn=function(a){return this.cmpn(a)===1},i.prototype.gt=function(a){return this.cmp(a)===1},i.prototype.gten=function(a){return this.cmpn(a)>=0},i.prototype.gte=function(a){return this.cmp(a)>=0},i.prototype.ltn=function(a){return this.cmpn(a)===-1},i.prototype.lt=function(a){return this.cmp(a)===-1},i.prototype.lten=function(a){return this.cmpn(a)<=0},i.prototype.lte=function(a){return this.cmp(a)<=0},i.prototype.eqn=function(a){return this.cmpn(a)===0},i.prototype.eq=function(a){return this.cmp(a)===0},i.red=function(a){return new re(a)},i.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},i.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(a){return this.red=a,this},i.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},i.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},i.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},i.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},i.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},i.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},i.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},i.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},i.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var te={k256:null,p224:null,p192:null,p25519:null};function H(v,a){this.name=v,this.p=new i(a,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var a=new i(null);return a.words=new Array(Math.ceil(this.n/13)),a},H.prototype.ireduce=function(a){var l=a,d;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),d=l.bitLength();while(d>this.n);var h=d<this.n?-1:l.ucmp(this.p);return h===0?(l.words[0]=0,l.length=1):h>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},H.prototype.split=function(a,l){a.iushrn(this.n,0,l)},H.prototype.imulK=function(a){return a.imul(this.k)};function Z(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(Z,H),Z.prototype.split=function(a,l){for(var d=4194303,h=Math.min(a.length,9),g=0;g<h;g++)l.words[g]=a.words[g];if(l.length=h,a.length<=9){a.words[0]=0,a.length=1;return}var w=a.words[9];for(l.words[l.length++]=w&d,g=10;g<a.length;g++){var R=a.words[g]|0;a.words[g-10]=(R&d)<<4|w>>>22,w=R}w>>>=22,a.words[g-10]=w,w===0&&a.length>10?a.length-=10:a.length-=9},Z.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var l=0,d=0;d<a.length;d++){var h=a.words[d]|0;l+=h*977,a.words[d]=l&67108863,l=h*64+(l/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function ee(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ee,H);function Y(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(Y,H);function Ie(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Ie,H),Ie.prototype.imulK=function(a){for(var l=0,d=0;d<a.length;d++){var h=(a.words[d]|0)*19+l,g=h&67108863;h>>>=26,a.words[d]=g,l=h}return l!==0&&(a.words[a.length++]=l),a},i._prime=function(a){if(te[a])return te[a];var l;if(a==="k256")l=new Z;else if(a==="p224")l=new ee;else if(a==="p192")l=new Y;else if(a==="p25519")l=new Ie;else throw new Error("Unknown prime "+a);return te[a]=l,l};function re(v){if(typeof v=="string"){var a=i._prime(v);this.m=a.p,this.prime=a}else t(v.gtn(1),"modulus must be greater than 1"),this.m=v,this.prime=null}re.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},re.prototype._verify2=function(a,l){t((a.negative|l.negative)===0,"red works only with positives"),t(a.red&&a.red===l.red,"red works only with red numbers")},re.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(p(a,a.umod(this.m)._forceRed(this)),a)},re.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},re.prototype.add=function(a,l){this._verify2(a,l);var d=a.add(l);return d.cmp(this.m)>=0&&d.isub(this.m),d._forceRed(this)},re.prototype.iadd=function(a,l){this._verify2(a,l);var d=a.iadd(l);return d.cmp(this.m)>=0&&d.isub(this.m),d},re.prototype.sub=function(a,l){this._verify2(a,l);var d=a.sub(l);return d.cmpn(0)<0&&d.iadd(this.m),d._forceRed(this)},re.prototype.isub=function(a,l){this._verify2(a,l);var d=a.isub(l);return d.cmpn(0)<0&&d.iadd(this.m),d},re.prototype.shl=function(a,l){return this._verify1(a),this.imod(a.ushln(l))},re.prototype.imul=function(a,l){return this._verify2(a,l),this.imod(a.imul(l))},re.prototype.mul=function(a,l){return this._verify2(a,l),this.imod(a.mul(l))},re.prototype.isqr=function(a){return this.imul(a,a.clone())},re.prototype.sqr=function(a){return this.mul(a,a)},re.prototype.sqrt=function(a){if(a.isZero())return a.clone();var l=this.m.andln(3);if(t(l%2===1),l===3){var d=this.m.add(new i(1)).iushrn(2);return this.pow(a,d)}for(var h=this.m.subn(1),g=0;!h.isZero()&&h.andln(1)===0;)g++,h.iushrn(1);t(!h.isZero());var w=new i(1).toRed(this),R=w.redNeg(),y=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);this.pow(f,y).cmp(R)!==0;)f.redIAdd(R);for(var _=this.pow(f,h),C=this.pow(a,h.addn(1).iushrn(1)),D=this.pow(a,h),$=g;D.cmp(w)!==0;){for(var X=D,ie=0;X.cmp(w)!==0;ie++)X=X.redSqr();t(ie<$);var ue=this.pow(_,new i(1).iushln($-ie-1));C=C.redMul(ue),_=ue.redSqr(),D=D.redMul(_),$=ie}return C},re.prototype.invm=function(a){var l=a._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},re.prototype.pow=function(a,l){if(l.isZero())return new i(1).toRed(this);if(l.cmpn(1)===0)return a.clone();var d=4,h=new Array(1<<d);h[0]=new i(1).toRed(this),h[1]=a;for(var g=2;g<h.length;g++)h[g]=this.mul(h[g-1],a);var w=h[0],R=0,y=0,f=l.bitLength()%26;for(f===0&&(f=26),g=l.length-1;g>=0;g--){for(var _=l.words[g],C=f-1;C>=0;C--){var D=_>>C&1;if(w!==h[0]&&(w=this.sqr(w)),D===0&&R===0){y=0;continue}R<<=1,R|=D,y++,!(y!==d&&(g!==0||C!==0))&&(w=this.mul(w,h[R]),y=0,R=0)}f=26}return w},re.prototype.convertTo=function(a){var l=a.umod(this.m);return l===a?l.clone():l},re.prototype.convertFrom=function(a){var l=a.clone();return l.red=null,l},i.mont=function(a){return new fe(a)};function fe(v){re.call(this,v),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(fe,re),fe.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},fe.prototype.convertFrom=function(a){var l=this.imod(a.mul(this.rinv));return l.red=null,l},fe.prototype.imul=function(a,l){if(a.isZero()||l.isZero())return a.words[0]=0,a.length=1,a;var d=a.imul(l),h=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),g=d.isub(h).iushrn(this.shift),w=g;return g.cmp(this.m)>=0?w=g.isub(this.m):g.cmpn(0)<0&&(w=g.iadd(this.m)),w._forceRed(this)},fe.prototype.mul=function(a,l){if(a.isZero()||l.isZero())return new i(0)._forceRed(this);var d=a.mul(l),h=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),g=d.isub(h).iushrn(this.shift),w=g;return g.cmp(this.m)>=0?w=g.isub(this.m):g.cmpn(0)<0&&(w=g.iadd(this.m)),w._forceRed(this)},fe.prototype.invm=function(a){var l=this.imod(a._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(typeof xc>"u"||xc,xl)});var kl=zt((Oc,Ol)=>{var ro=zi(),mr=ro.Buffer;function Il(r,e){for(var t in r)e[t]=r[t]}mr.from&&mr.alloc&&mr.allocUnsafe&&mr.allocUnsafeSlow?Ol.exports=ro:(Il(ro,Oc),Oc.Buffer=Dn);function Dn(r,e,t){return mr(r,e,t)}Dn.prototype=Object.create(mr.prototype);Il(mr,Dn);Dn.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return mr(r,e,t)};Dn.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=mr(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};Dn.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return mr(r)};Dn.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return ro.SlowBuffer(r)}});var Nl=zt((XR,Tl)=>{"use strict";var no=kl().Buffer;function ig(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var n=0;n<r.length;n++){var i=r.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var o=r.length,c=r.charAt(0),u=Math.log(o)/Math.log(256),p=Math.log(256)/Math.log(o);function m(S){if((Array.isArray(S)||S instanceof Uint8Array)&&(S=no.from(S)),!no.isBuffer(S))throw new TypeError("Expected Buffer");if(S.length===0)return"";for(var T=0,I=0,x=0,B=S.length;x!==B&&S[x]===0;)x++,T++;for(var U=(B-x)*p+1>>>0,L=new Uint8Array(U);x!==B;){for(var F=S[x],te=0,H=U-1;(F!==0||te<I)&&H!==-1;H--,te++)F+=256*L[H]>>>0,L[H]=F%o>>>0,F=F/o>>>0;if(F!==0)throw new Error("Non-zero carry");I=te,x++}for(var Z=U-I;Z!==U&&L[Z]===0;)Z++;for(var ee=c.repeat(T);Z<U;++Z)ee+=r.charAt(L[Z]);return ee}function b(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return no.alloc(0);for(var T=0,I=0,x=0;S[T]===c;)I++,T++;for(var B=(S.length-T)*u+1>>>0,U=new Uint8Array(B);T<S.length;){var L=S.charCodeAt(T);if(L>255)return;var F=e[L];if(F===255)return;for(var te=0,H=B-1;(F!==0||te<x)&&H!==-1;H--,te++)F+=o*U[H]>>>0,U[H]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");x=te,T++}for(var Z=B-x;Z!==B&&U[Z]===0;)Z++;var ee=no.allocUnsafe(I+(B-Z));ee.fill(0,0,I);for(var Y=I;Z!==B;)ee[Y++]=U[Z++];return ee}function A(S){var T=b(S);if(T)return T;throw new Error("Non-base"+o+" character")}return{encode:m,decodeUnsafe:b,decode:A}}Tl.exports=ig});var kc=zt((JR,Bl)=>{var sg=Nl(),og="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Bl.exports=sg(og)});var Ll=zt(Lc=>{"use strict";function Tr(r,e,t){return e<=r&&r<=t}function co(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function cg(r){for(var e=String(r),t=e.length,n=0,i=[];n<t;){var s=e.charCodeAt(n);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(n===t-1)i.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var c=s&1023,u=o&1023;i.push(65536+(c<<10)+u),n+=1}else i.push(65533)}n+=1}return i}function ug(r){for(var e="",t=0;t<r.length;++t){var n=r[t];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return e}var io=-1;function Bc(r){this.tokens=[].slice.call(r)}Bc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():io},prepend:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.push(e.shift());else this.tokens.push(r)}};var pi=-1;function Nc(r,e){if(r)throw TypeError("Decoder error");return e||65533}var so="utf-8";function oo(r,e){if(!(this instanceof oo))return new oo(r,e);if(r=r!==void 0?String(r).toLowerCase():so,r!==so)throw new Error("Encoding not supported. Only utf-8 is supported");e=co(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})}oo.prototype={decode:function(e,t){var n;typeof e=="object"&&e instanceof ArrayBuffer?n=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):n=new Uint8Array(0),t=co(t),this._streaming||(this._decoder=new fg({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var i=new Bc(n),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==pi);)o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===pi)break;o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o))}while(!i.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),ug(s)}};function ao(r,e){if(!(this instanceof ao))return new ao(r,e);if(r=r!==void 0?String(r).toLowerCase():so,r!==so)throw new Error("Encoding not supported. Only utf-8 is supported");e=co(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}ao.prototype={encode:function(e,t){e=e?String(e):"",t=co(t),this._streaming||(this._encoder=new lg(this._options)),this._streaming=!!t.stream;for(var n=[],i=new Bc(cg(e)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==pi);)Array.isArray(s)?n.push.apply(n,s):n.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==pi;)Array.isArray(s)?n.push.apply(n,s):n.push(s);this._encoder=null}return new Uint8Array(n)}};function fg(r){var e=r.fatal,t=0,n=0,i=0,s=128,o=191;this.handler=function(c,u){if(u===io&&i!==0)return i=0,Nc(e);if(u===io)return pi;if(i===0){if(Tr(u,0,127))return u;if(Tr(u,194,223))i=1,t=u-192;else if(Tr(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,t=u-224;else if(Tr(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,t=u-240;else return Nc(e);return t=t<<6*i,null}if(!Tr(u,s,o))return t=i=n=0,s=128,o=191,c.prepend(u),Nc(e);if(s=128,o=191,n+=1,t+=u-128<<6*(i-n),n!==i)return null;var p=t;return t=i=n=0,p}}function lg(r){var e=r.fatal;this.handler=function(t,n){if(n===io)return pi;if(Tr(n,0,127))return n;var i,s;Tr(n,128,2047)?(i=1,s=192):Tr(n,2048,65535)?(i=2,s=224):Tr(n,65536,1114111)&&(i=3,s=240);for(var o=[(n>>6*i)+s];i>0;){var c=n>>6*(i-1);o.push(128|c&63),i-=1}return o}}Lc.TextEncoder=ao;Lc.TextDecoder=oo});var Dl=zt(ke=>{"use strict";var dg=ke&&ke.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t),Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[t]}})}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),hg=ke&&ke.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),gr=ke&&ke.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},pg=ke&&ke.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.hasOwnProperty.call(r,t)&&dg(e,r,t);return hg(e,r),e},Cl=ke&&ke.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ke,"__esModule",{value:!0});ke.deserializeUnchecked=ke.deserialize=ke.serialize=ke.BinaryReader=ke.BinaryWriter=ke.BorshError=ke.baseDecode=ke.baseEncode=void 0;var Qr=Cl(Ic()),Pl=Cl(kc()),mg=pg(Ll()),gg=typeof TextDecoder!="function"?mg.TextDecoder:TextDecoder,yg=new gg("utf-8",{fatal:!0});function _g(r){return typeof r=="string"&&(r=Buffer.from(r,"utf8")),Pl.default.encode(Buffer.from(r))}ke.baseEncode=_g;function bg(r){return Buffer.from(Pl.default.decode(r))}ke.baseDecode=bg;var Cc=1024,Et=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}};ke.BorshError=Et;var uo=class{constructor(){this.buf=Buffer.alloc(Cc),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Cc)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Buffer.from(new Qr.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new Qr.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new Qr.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new Qr.default(e).toArray("le",64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(Cc)]),this.length+=e.length}writeString(e){this.maybeResize();let t=Buffer.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Buffer.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};ke.BinaryWriter=uo;function yr(r,e,t){let n=t.value;t.value=function(...i){try{return n.apply(this,i)}catch(s){if(s instanceof RangeError){let o=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new Et("Reached the end of buffer when deserializing")}throw s}}}var Mt=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new Qr.default(e,"le")}readU128(){let e=this.readBuffer(16);return new Qr.default(e,"le")}readU256(){let e=this.readBuffer(32);return new Qr.default(e,"le")}readU512(){let e=this.readBuffer(64);return new Qr.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new Et(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return yg.decode(t)}catch(n){throw new Et(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=Array();for(let i=0;i<t;++i)n.push(e());return n}};gr([yr],Mt.prototype,"readU8",null);gr([yr],Mt.prototype,"readU16",null);gr([yr],Mt.prototype,"readU32",null);gr([yr],Mt.prototype,"readU64",null);gr([yr],Mt.prototype,"readU128",null);gr([yr],Mt.prototype,"readU256",null);gr([yr],Mt.prototype,"readU512",null);gr([yr],Mt.prototype,"readString",null);gr([yr],Mt.prototype,"readFixedArray",null);gr([yr],Mt.prototype,"readArray",null);ke.BinaryReader=Mt;function Ml(r){return r.charAt(0).toUpperCase()+r.slice(1)}function zn(r,e,t,n,i){try{if(typeof n=="string")i[`write${Ml(n)}`](t);else if(n instanceof Array)if(typeof n[0]=="number"){if(t.length!==n[0])throw new Et(`Expecting byte array of length ${n[0]}, but got ${t.length} bytes`);i.writeFixedArray(t)}else if(n.length===2&&typeof n[1]=="number"){if(t.length!==n[1])throw new Et(`Expecting byte array of length ${n[1]}, but got ${t.length} bytes`);for(let s=0;s<n[1];s++)zn(r,null,t[s],n[0],i)}else i.writeArray(t,s=>{zn(r,e,s,n[0],i)});else if(n.kind!==void 0)switch(n.kind){case"option":{t==null?i.writeU8(0):(i.writeU8(1),zn(r,e,t,n.type,i));break}case"map":{i.writeU32(t.size),t.forEach((s,o)=>{zn(r,e,o,n.key,i),zn(r,e,s,n.value,i)});break}default:throw new Et(`FieldType ${n} unrecognized`)}else Ul(r,t,i)}catch(s){throw s instanceof Et&&s.addToFieldPath(e),s}}function Ul(r,e,t){if(typeof e.borshSerialize=="function"){e.borshSerialize(t);return}let n=r.get(e.constructor);if(!n)throw new Et(`Class ${e.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([i,s])=>{zn(r,i,e[i],s,t)});else if(n.kind==="enum"){let i=e[n.field];for(let s=0;s<n.values.length;++s){let[o,c]=n.values[s];if(o===i){t.writeU8(s),zn(r,o,e[o],c,t);break}}}else throw new Et(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function wg(r,e,t=uo){let n=new t;return Ul(r,e,n),n.toArray()}ke.serialize=wg;function Fn(r,e,t,n){try{if(typeof t=="string")return n[`read${Ml(t)}`]();if(t instanceof Array){if(typeof t[0]=="number")return n.readFixedArray(t[0]);if(typeof t[1]=="number"){let i=[];for(let s=0;s<t[1];s++)i.push(Fn(r,null,t[0],n));return i}else return n.readArray(()=>Fn(r,e,t[0],n))}if(t.kind==="option")return n.readU8()?Fn(r,e,t.type,n):void 0;if(t.kind==="map"){let i=new Map,s=n.readU32();for(let o=0;o<s;o++){let c=Fn(r,e,t.key,n),u=Fn(r,e,t.value,n);i.set(c,u)}return i}return Pc(r,t,n)}catch(i){throw i instanceof Et&&i.addToFieldPath(e),i}}function Pc(r,e,t){if(typeof e.borshDeserialize=="function")return e.borshDeserialize(t);let n=r.get(e);if(!n)throw new Et(`Class ${e.name} is missing in schema`);if(n.kind==="struct"){let i={};for(let[s,o]of r.get(e).fields)i[s]=Fn(r,s,o,t);return new e(i)}if(n.kind==="enum"){let i=t.readU8();if(i>=n.values.length)throw new Et(`Enum index: ${i} is out of range`);let[s,o]=n.values[i],c=Fn(r,s,o,t);return new e({[s]:c})}throw new Et(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function vg(r,e,t,n=Mt){let i=new n(t),s=Pc(r,e,i);if(i.offset<t.length)throw new Et(`Unexpected ${t.length-i.offset} bytes after deserialized data`);return s}ke.deserialize=vg;function Eg(r,e,t,n=Mt){let i=new n(t);return Pc(r,e,i)}ke.deserializeUnchecked=Eg});var zc=zt(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.s16=k.s8=k.nu64be=k.u48be=k.u40be=k.u32be=k.u24be=k.u16be=k.nu64=k.u48=k.u40=k.u32=k.u24=k.u16=k.u8=k.offset=k.greedy=k.Constant=k.UTF8=k.CString=k.Blob=k.Boolean=k.BitField=k.BitStructure=k.VariantLayout=k.Union=k.UnionLayoutDiscriminator=k.UnionDiscriminator=k.Structure=k.Sequence=k.DoubleBE=k.Double=k.FloatBE=k.Float=k.NearInt64BE=k.NearInt64=k.NearUInt64BE=k.NearUInt64=k.IntBE=k.Int=k.UIntBE=k.UInt=k.OffsetLayout=k.GreedyCount=k.ExternalLayout=k.bindConstructorLayout=k.nameWithProperty=k.Layout=k.uint8ArrayToBuffer=k.checkUint8Array=void 0;k.constant=k.utf8=k.cstr=k.blob=k.unionLayoutDiscriminator=k.union=k.seq=k.bits=k.struct=k.f64be=k.f64=k.f32be=k.f32=k.ns64be=k.s48be=k.s40be=k.s32be=k.s24be=k.s16be=k.ns64=k.s48=k.s40=k.s32=k.s24=void 0;var Uc=zi();function yi(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}k.checkUint8Array=yi;function Ee(r){return yi(r),Uc.Buffer.from(r.buffer,r.byteOffset,r.length)}k.uint8ArrayToBuffer=Ee;var Re=class{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};k.Layout=Re;function Dc(r,e){return e.property?r+"["+e.property+"]":r}k.nameWithProperty=Dc;function Rg(r,e){if(typeof r!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(r,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Re))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=e,e.boundConstructor_=r,e.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(r,"decode",{value(t,n){return e.decode(t,n)},writable:!0})}k.bindConstructorLayout=Rg;var It=class extends Re{isCount(){throw new Error("ExternalLayout is abstract")}};k.ExternalLayout=It;var fo=class extends It{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){yi(e);let n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}};k.GreedyCount=fo;var ji=class extends It{constructor(e,t=0,n){if(!(e instanceof Re))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof Wt||this.layout instanceof Gt}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};k.OffsetLayout=ji;var Wt=class extends Re{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return Ee(e).readUIntLE(t,this.span)}encode(e,t,n=0){return Ee(t).writeUIntLE(e,n,this.span),this.span}};k.UInt=Wt;var Gt=class extends Re{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return Ee(e).readUIntBE(t,this.span)}encode(e,t,n=0){return Ee(t).writeUIntBE(e,n,this.span),this.span}};k.UIntBE=Gt;var Nr=class extends Re{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return Ee(e).readIntLE(t,this.span)}encode(e,t,n=0){return Ee(t).writeIntLE(e,n,this.span),this.span}};k.Int=Nr;var en=class extends Re{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return Ee(e).readIntBE(t,this.span)}encode(e,t,n=0){return Ee(t).writeIntBE(e,n,this.span),this.span}};k.IntBE=en;var Mc=Math.pow(2,32);function Oo(r){let e=Math.floor(r/Mc),t=r-e*Mc;return{hi32:e,lo32:t}}function ko(r,e){return r*Mc+e}var lo=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=Ee(e),i=n.readUInt32LE(t),s=n.readUInt32LE(t+4);return ko(s,i)}encode(e,t,n=0){let i=Oo(e),s=Ee(t);return s.writeUInt32LE(i.lo32,n),s.writeUInt32LE(i.hi32,n+4),8}};k.NearUInt64=lo;var ho=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=Ee(e),i=n.readUInt32BE(t),s=n.readUInt32BE(t+4);return ko(i,s)}encode(e,t,n=0){let i=Oo(e),s=Ee(t);return s.writeUInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};k.NearUInt64BE=ho;var po=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=Ee(e),i=n.readUInt32LE(t),s=n.readInt32LE(t+4);return ko(s,i)}encode(e,t,n=0){let i=Oo(e),s=Ee(t);return s.writeUInt32LE(i.lo32,n),s.writeInt32LE(i.hi32,n+4),8}};k.NearInt64=po;var mo=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=Ee(e),i=n.readInt32BE(t),s=n.readUInt32BE(t+4);return ko(i,s)}encode(e,t,n=0){let i=Oo(e),s=Ee(t);return s.writeInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};k.NearInt64BE=mo;var go=class extends Re{constructor(e){super(4,e)}decode(e,t=0){return Ee(e).readFloatLE(t)}encode(e,t,n=0){return Ee(t).writeFloatLE(e,n),4}};k.Float=go;var yo=class extends Re{constructor(e){super(4,e)}decode(e,t=0){return Ee(e).readFloatBE(t)}encode(e,t,n=0){return Ee(t).writeFloatBE(e,n),4}};k.FloatBE=yo;var _o=class extends Re{constructor(e){super(8,e)}decode(e,t=0){return Ee(e).readDoubleLE(t)}encode(e,t,n=0){return Ee(t).writeDoubleLE(e,n),8}};k.Double=_o;var bo=class extends Re{constructor(e){super(8,e)}decode(e,t=0){return Ee(e).readDoubleBE(t)}encode(e,t,n=0){return Ee(t).writeDoubleBE(e,n),8}};k.DoubleBE=bo;var wo=class extends Re{constructor(e,t,n){if(!(e instanceof Re))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof It&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(t instanceof It)&&0<e.span&&(i=t*e.span),super(i,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,i=this.count;if(i instanceof It&&(i=i.decode(e,t)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let s=0;for(;s<i;)n+=this.elementLayout.getSpan(e,t+n),++s}return n}decode(e,t=0){let n=[],i=0,s=this.count;for(s instanceof It&&(s=s.decode(e,t));i<s;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return n}encode(e,t,n=0){let i=this.elementLayout,s=e.reduce((o,c)=>o+i.encode(c,t,n+o),0);return this.count instanceof It&&this.count.encode(e.length,t,n),s}};k.Sequence=wo;var vo=class extends Re{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Re,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(let s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((i,s)=>{let o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t=0){yi(e);let n=this.makeDestinationObject();for(let i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){let i=n,s=0,o=0;for(let c of this.fields){let u=c.span;if(o=0<u?u:0,c.property!==void 0){let p=e[c.property];p!==void 0&&(o=c.encode(p,t,n),0>u&&(u=c.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};k.Structure=vo;var Ki=class{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,n){throw new Error("UnionDiscriminator is abstract")}};k.UnionDiscriminator=Ki;var gi=class extends Ki{constructor(e,t){if(!(e instanceof It&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};k.UnionLayoutDiscriminator=gi;var Hi=class extends Re{constructor(e,t,n){let i;if(e instanceof Wt||e instanceof Gt)i=new gi(new ji(e));else if(e instanceof It&&e.isCount())i=new gi(e);else if(e instanceof Ki)i=e;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Re))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&(e instanceof Wt||e instanceof Gt)&&(s+=i.layout.span)),super(s,n),this.discriminator=i,this.usesPrefixDiscriminator=e instanceof Wt||e instanceof Gt,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw new Error("unable to infer src variant")}decode(e,t=0){let n,i=this.discriminator,s=i.decode(e,t),o=this.registry[s];if(o===void 0){let c=this.defaultLayout,u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[c.property]=c.decode(e,t+u)}else n=o.decode(e,t);return n}encode(e,t,n=0){let i=this.getSourceVariant(e);if(i===void 0){let s=this.discriminator,o=this.defaultLayout,c=0;return this.usesPrefixDiscriminator&&(c=s.layout.span),s.encode(e[s.property],t,n),c+o.encode(e[o.property],t,n+c)}return i.encode(e,t,n)}addVariant(e,t,n){let i=new Eo(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t=0){let n;return e instanceof Uint8Array?n=this.discriminator.decode(e,t):n=e,this.registry[n]}};k.Union=Hi;var Eo=class extends Re{constructor(e,t,n,i){if(!(e instanceof Hi))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Re))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(e,t+n)),n+i}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};k.VariantLayout=Eo;function mi(r){return 0>r&&(r+=4294967296),r}var Gi=class extends Re{constructor(e,t,n){if(!(e instanceof Wt||e instanceof Gt))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&n===void 0&&(n=t,t=!1),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(s){return i=mi(s),this},this._packedGetValue=function(){return i}}decode(e,t=0){let n=this.makeDestinationObject(),i=this.word.decode(e,t);this._packedSetValue(i);for(let s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(e));return n}encode(e,t,n=0){let i=this.word.decode(t,n);this._packedSetValue(i);for(let s of this.fields)if(s.property!==void 0){let o=e[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new Zi(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new Ro(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}};k.BitStructure=Gi;var Zi=class{constructor(e,t,n){if(!(e instanceof Gi))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");let i=8*e.span,s=e.fields.reduce((o,c)=>o+c.bits,0);if(t+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=mi(this.valueMask<<this.start),this.property=n}decode(e,t){let n=this.container._packedGetValue();return mi(n&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==mi(e&this.valueMask))throw new TypeError(Dc("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let t=this.container._packedGetValue(),n=mi(e<<this.start);this.container._packedSetValue(mi(t&~this.wordMask)|n)}};k.BitField=Zi;var Ro=class extends Zi{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e=="boolean"&&(e=+e),super.encode(e)}};k.Boolean=Ro;var So=class extends Re{constructor(e,t){if(!(e instanceof It&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof It||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),Ee(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof It&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw new TypeError(Dc("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(n+i>t.length)throw new RangeError("encoding overruns Uint8Array");let s=Ee(e);return Ee(t).write(s.toString("hex"),n,i,"hex"),this.length instanceof It&&this.length.encode(i,t,n),i}};k.Blob=So;var Ao=class extends Re{constructor(e){super(-1,e)}getSpan(e,t=0){yi(e);let n=t;for(;n<e.length&&e[n]!==0;)n+=1;return 1+n-t}decode(e,t=0){let n=this.getSpan(e,t);return Ee(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));let i=Uc.Buffer.from(e,"utf8"),s=i.length;if(n+s>t.length)throw new RangeError("encoding overruns Buffer");let o=Ee(t);return i.copy(o,n),o[n+s]=0,s+1}};k.CString=Ao;var xo=class extends Re{constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return yi(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return Ee(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));let i=Uc.Buffer.from(e,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(Ee(t),n),s}};k.UTF8=xo;var Io=class extends Re{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};k.Constant=Io;k.greedy=(r,e)=>new fo(r,e);k.offset=(r,e,t)=>new ji(r,e,t);k.u8=r=>new Wt(1,r);k.u16=r=>new Wt(2,r);k.u24=r=>new Wt(3,r);k.u32=r=>new Wt(4,r);k.u40=r=>new Wt(5,r);k.u48=r=>new Wt(6,r);k.nu64=r=>new lo(r);k.u16be=r=>new Gt(2,r);k.u24be=r=>new Gt(3,r);k.u32be=r=>new Gt(4,r);k.u40be=r=>new Gt(5,r);k.u48be=r=>new Gt(6,r);k.nu64be=r=>new ho(r);k.s8=r=>new Nr(1,r);k.s16=r=>new Nr(2,r);k.s24=r=>new Nr(3,r);k.s32=r=>new Nr(4,r);k.s40=r=>new Nr(5,r);k.s48=r=>new Nr(6,r);k.ns64=r=>new po(r);k.s16be=r=>new en(2,r);k.s24be=r=>new en(3,r);k.s32be=r=>new en(4,r);k.s40be=r=>new en(5,r);k.s48be=r=>new en(6,r);k.ns64be=r=>new mo(r);k.f32=r=>new go(r);k.f32be=r=>new yo(r);k.f64=r=>new _o(r);k.f64be=r=>new bo(r);k.struct=(r,e,t)=>new vo(r,e,t);k.bits=(r,e,t)=>new Gi(r,e,t);k.seq=(r,e,t)=>new wo(r,e,t);k.union=(r,e,t)=>new Hi(r,e,t);k.unionLayoutDiscriminator=(r,e)=>new gi(r,e);k.blob=(r,e)=>new So(r,e);k.cstr=r=>new Ao(r);k.utf8=(r,e)=>new xo(r,e);k.constant=(r,e)=>new Io(r,e)});function Ji(){if(!Lo&&(Lo=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Lo))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Lo(Pw)}var Lo,Pw,Yc=Ct(()=>{Pw=new Uint8Array(16)});var nd,id=Ct(()=>{nd=/^(?:[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 Mw(r){return typeof r=="string"&&nd.test(r)}var rn,Qi=Ct(()=>{id();rn=Mw});function Uw(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(Rt[r[e+0]]+Rt[r[e+1]]+Rt[r[e+2]]+Rt[r[e+3]]+"-"+Rt[r[e+4]]+Rt[r[e+5]]+"-"+Rt[r[e+6]]+Rt[r[e+7]]+"-"+Rt[r[e+8]]+Rt[r[e+9]]+"-"+Rt[r[e+10]]+Rt[r[e+11]]+Rt[r[e+12]]+Rt[r[e+13]]+Rt[r[e+14]]+Rt[r[e+15]]).toLowerCase();if(!rn(t))throw TypeError("Stringified UUID is invalid");return t}var Rt,Co,nn,es=Ct(()=>{Qi();Rt=[];for(Co=0;Co<256;++Co)Rt.push((Co+256).toString(16).substr(1));nn=Uw});function Dw(r,e,t){var n=e&&t||0,i=e||new Array(16);r=r||{};var s=r.node||sd,o=r.clockseq!==void 0?r.clockseq:Xc;if(s==null||o==null){var c=r.random||(r.rng||Ji)();s==null&&(s=sd=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),o==null&&(o=Xc=(c[6]<<8|c[7])&16383)}var u=r.msecs!==void 0?r.msecs:Date.now(),p=r.nsecs!==void 0?r.nsecs:Qc+1,m=u-Jc+(p-Qc)/1e4;if(m<0&&r.clockseq===void 0&&(o=o+1&16383),(m<0||u>Jc)&&r.nsecs===void 0&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Jc=u,Qc=p,Xc=o,u+=122192928e5;var b=((u&268435455)*1e4+p)%4294967296;i[n++]=b>>>24&255,i[n++]=b>>>16&255,i[n++]=b>>>8&255,i[n++]=b&255;var A=u/4294967296*1e4&268435455;i[n++]=A>>>8&255,i[n++]=A&255,i[n++]=A>>>24&15|16,i[n++]=A>>>16&255,i[n++]=o>>>8|128,i[n++]=o&255;for(var S=0;S<6;++S)i[n+S]=s[S];return e||nn(i)}var sd,Xc,Jc,Qc,od,ad=Ct(()=>{Yc();es();Jc=0,Qc=0;od=Dw});function zw(r){if(!rn(r))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var Po,eu=Ct(()=>{Qi();Po=zw});function Fw(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}function Mo(r,e,t){function n(i,s,o,c){if(typeof i=="string"&&(i=Fw(i)),typeof s=="string"&&(s=Po(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(s),u.set(i,s.length),u=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){c=c||0;for(var p=0;p<16;++p)o[c+p]=u[p];return o}return nn(u)}try{n.name=r}catch{}return n.DNS=$w,n.URL=Vw,n}var $w,Vw,tu=Ct(()=>{es();eu();$w="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Vw="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function qw(r){if(typeof r=="string"){var e=unescape(encodeURIComponent(r));r=new Uint8Array(e.length);for(var t=0;t<e.length;++t)r[t]=e.charCodeAt(t)}return Ww(jw(Kw(r),r.length*8))}function Ww(r){for(var e=[],t=r.length*32,n="0123456789abcdef",i=0;i<t;i+=8){var s=r[i>>5]>>>i%32&255,o=parseInt(n.charAt(s>>>4&15)+n.charAt(s&15),16);e.push(o)}return e}function cd(r){return(r+64>>>9<<4)+14+1}function jw(r,e){r[e>>5]|=128<<e%32,r[cd(e)-1]=e;for(var t=1732584193,n=-271733879,i=-1732584194,s=271733878,o=0;o<r.length;o+=16){var c=t,u=n,p=i,m=s;t=kt(t,n,i,s,r[o],7,-680876936),s=kt(s,t,n,i,r[o+1],12,-389564586),i=kt(i,s,t,n,r[o+2],17,606105819),n=kt(n,i,s,t,r[o+3],22,-1044525330),t=kt(t,n,i,s,r[o+4],7,-176418897),s=kt(s,t,n,i,r[o+5],12,1200080426),i=kt(i,s,t,n,r[o+6],17,-1473231341),n=kt(n,i,s,t,r[o+7],22,-45705983),t=kt(t,n,i,s,r[o+8],7,1770035416),s=kt(s,t,n,i,r[o+9],12,-1958414417),i=kt(i,s,t,n,r[o+10],17,-42063),n=kt(n,i,s,t,r[o+11],22,-1990404162),t=kt(t,n,i,s,r[o+12],7,1804603682),s=kt(s,t,n,i,r[o+13],12,-40341101),i=kt(i,s,t,n,r[o+14],17,-1502002290),n=kt(n,i,s,t,r[o+15],22,1236535329),t=Tt(t,n,i,s,r[o+1],5,-165796510),s=Tt(s,t,n,i,r[o+6],9,-1069501632),i=Tt(i,s,t,n,r[o+11],14,643717713),n=Tt(n,i,s,t,r[o],20,-373897302),t=Tt(t,n,i,s,r[o+5],5,-701558691),s=Tt(s,t,n,i,r[o+10],9,38016083),i=Tt(i,s,t,n,r[o+15],14,-660478335),n=Tt(n,i,s,t,r[o+4],20,-405537848),t=Tt(t,n,i,s,r[o+9],5,568446438),s=Tt(s,t,n,i,r[o+14],9,-1019803690),i=Tt(i,s,t,n,r[o+3],14,-187363961),n=Tt(n,i,s,t,r[o+8],20,1163531501),t=Tt(t,n,i,s,r[o+13],5,-1444681467),s=Tt(s,t,n,i,r[o+2],9,-51403784),i=Tt(i,s,t,n,r[o+7],14,1735328473),n=Tt(n,i,s,t,r[o+12],20,-1926607734),t=Nt(t,n,i,s,r[o+5],4,-378558),s=Nt(s,t,n,i,r[o+8],11,-2022574463),i=Nt(i,s,t,n,r[o+11],16,1839030562),n=Nt(n,i,s,t,r[o+14],23,-35309556),t=Nt(t,n,i,s,r[o+1],4,-1530992060),s=Nt(s,t,n,i,r[o+4],11,1272893353),i=Nt(i,s,t,n,r[o+7],16,-155497632),n=Nt(n,i,s,t,r[o+10],23,-1094730640),t=Nt(t,n,i,s,r[o+13],4,681279174),s=Nt(s,t,n,i,r[o],11,-358537222),i=Nt(i,s,t,n,r[o+3],16,-722521979),n=Nt(n,i,s,t,r[o+6],23,76029189),t=Nt(t,n,i,s,r[o+9],4,-640364487),s=Nt(s,t,n,i,r[o+12],11,-421815835),i=Nt(i,s,t,n,r[o+15],16,530742520),n=Nt(n,i,s,t,r[o+2],23,-995338651),t=Bt(t,n,i,s,r[o],6,-198630844),s=Bt(s,t,n,i,r[o+7],10,1126891415),i=Bt(i,s,t,n,r[o+14],15,-1416354905),n=Bt(n,i,s,t,r[o+5],21,-57434055),t=Bt(t,n,i,s,r[o+12],6,1700485571),s=Bt(s,t,n,i,r[o+3],10,-1894986606),i=Bt(i,s,t,n,r[o+10],15,-1051523),n=Bt(n,i,s,t,r[o+1],21,-2054922799),t=Bt(t,n,i,s,r[o+8],6,1873313359),s=Bt(s,t,n,i,r[o+15],10,-30611744),i=Bt(i,s,t,n,r[o+6],15,-1560198380),n=Bt(n,i,s,t,r[o+13],21,1309151649),t=Bt(t,n,i,s,r[o+4],6,-145523070),s=Bt(s,t,n,i,r[o+11],10,-1120210379),i=Bt(i,s,t,n,r[o+2],15,718787259),n=Bt(n,i,s,t,r[o+9],21,-343485551),t=sn(t,c),n=sn(n,u),i=sn(i,p),s=sn(s,m)}return[t,n,i,s]}function Kw(r){if(r.length===0)return[];for(var e=r.length*8,t=new Uint32Array(cd(e)),n=0;n<e;n+=8)t[n>>5]|=(r[n/8]&255)<<n%32;return t}function sn(r,e){var t=(r&65535)+(e&65535),n=(r>>16)+(e>>16)+(t>>16);return n<<16|t&65535}function Hw(r,e){return r<<e|r>>>32-e}function Uo(r,e,t,n,i,s){return sn(Hw(sn(sn(e,r),sn(n,s)),i),t)}function kt(r,e,t,n,i,s,o){return Uo(e&t|~e&n,r,e,i,s,o)}function Tt(r,e,t,n,i,s,o){return Uo(e&n|t&~n,r,e,i,s,o)}function Nt(r,e,t,n,i,s,o){return Uo(e^t^n,r,e,i,s,o)}function Bt(r,e,t,n,i,s,o){return Uo(t^(e|~n),r,e,i,s,o)}var ud,fd=Ct(()=>{ud=qw});var Gw,ld,dd=Ct(()=>{tu();fd();Gw=Mo("v3",48,ud),ld=Gw});function Zw(r,e,t){r=r||{};var n=r.random||(r.rng||Ji)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var i=0;i<16;++i)e[t+i]=n[i];return e}return nn(n)}var hd,pd=Ct(()=>{Yc();es();hd=Zw});function Yw(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function ru(r,e){return r<<e|r>>>32-e}function Xw(r){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var i=0;i<n.length;++i)r.push(n.charCodeAt(i))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var s=r.length/4+2,o=Math.ceil(s/16),c=new Array(o),u=0;u<o;++u){for(var p=new Uint32Array(16),m=0;m<16;++m)p[m]=r[u*64+m*4]<<24|r[u*64+m*4+1]<<16|r[u*64+m*4+2]<<8|r[u*64+m*4+3];c[u]=p}c[o-1][14]=(r.length-1)*8/Math.pow(2,32),c[o-1][14]=Math.floor(c[o-1][14]),c[o-1][15]=(r.length-1)*8&4294967295;for(var b=0;b<o;++b){for(var A=new Uint32Array(80),S=0;S<16;++S)A[S]=c[b][S];for(var T=16;T<80;++T)A[T]=ru(A[T-3]^A[T-8]^A[T-14]^A[T-16],1);for(var I=t[0],x=t[1],B=t[2],U=t[3],L=t[4],F=0;F<80;++F){var te=Math.floor(F/20),H=ru(I,5)+Yw(te,x,B,U)+L+e[te]+A[F]>>>0;L=U,U=B,B=ru(x,30)>>>0,x=I,I=H}t[0]=t[0]+I>>>0,t[1]=t[1]+x>>>0,t[2]=t[2]+B>>>0,t[3]=t[3]+U>>>0,t[4]=t[4]+L>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var md,gd=Ct(()=>{md=Xw});var Jw,yd,_d=Ct(()=>{tu();gd();Jw=Mo("v5",80,md),yd=Jw});var bd,wd=Ct(()=>{bd="00000000-0000-0000-0000-000000000000"});function Qw(r){if(!rn(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}var vd,Ed=Ct(()=>{Qi();vd=Qw});var nu={};dn(nu,{NIL:()=>bd,parse:()=>Po,stringify:()=>nn,v1:()=>od,v3:()=>ld,v4:()=>hd,v5:()=>yd,validate:()=>rn,version:()=>vd});var iu=Ct(()=>{ad();dd();pd();_d();wd();Ed();Qi();es();eu()});var Sd=zt((XS,Rd)=>{"use strict";var e1=(iu(),Ba(nu)).v4,t1=function(r,e,t,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};let i=typeof n.version=="number"?n.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");let s={method:r};if(i===2&&(s.jsonrpc="2.0"),e){if(typeof e!="object"&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");s.params=e}if(typeof t>"u"){let o=typeof n.generator=="function"?n.generator:function(){return e1()};s.id=o(s,n)}else i===2&&t===null?n.notificationIdNull&&(s.id=null):s.id=t;return s};Rd.exports=t1});var xd=zt((JS,Ad)=>{"use strict";var r1=(iu(),Ba(nu)).v4,n1=Sd(),ts=function(r,e){if(!(this instanceof ts))return new ts(r,e);e||(e={}),this.options={reviver:typeof e.reviver<"u"?e.reviver:null,replacer:typeof e.replacer<"u"?e.replacer:null,generator:typeof e.generator<"u"?e.generator:function(){return r1()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=r};Ad.exports=ts;ts.prototype.request=function(r,e,t,n){let i=this,s=null,o=Array.isArray(r)&&typeof e=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&r&&typeof r=="object"&&typeof e=="function")n=e,s=r;else{typeof t=="function"&&(n=t,t=void 0);let p=typeof n=="function";try{s=n1(r,e,t,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(m){if(p)return n(m);throw m}if(!p)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(p){return n(p)}return this.callServer(u,function(p,m){i._parseResponse(p,m,n)}),s};ts.prototype._parseResponse=function(r,e,t){if(r){t(r);return}if(!e)return t();let n;try{n=JSON.parse(e,this.options.reviver)}catch(i){return t(i)}if(t.length===3)if(Array.isArray(n)){let i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return t(null,n.filter(i),n.filter(s))}else return t(null,n.error,n.result);t(null,n)}});var Od=zt((QS,su)=>{"use strict";var i1=Object.prototype.hasOwnProperty,Ut="~";function rs(){}Object.create&&(rs.prototype=Object.create(null),new rs().__proto__||(Ut=!1));function s1(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Id(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new s1(t,n||r,i),o=Ut?Ut+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function Do(r,e){--r._eventsCount===0?r._events=new rs:delete r._events[e]}function Lt(){this._events=new rs,this._eventsCount=0}Lt.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)i1.call(t,n)&&e.push(Ut?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Lt.prototype.listeners=function(e){var t=Ut?Ut+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};Lt.prototype.listenerCount=function(e){var t=Ut?Ut+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Lt.prototype.emit=function(e,t,n,i,s,o){var c=Ut?Ut+e:e;if(!this._events[c])return!1;var u=this._events[c],p=arguments.length,m,b;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),p){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,s),!0;case 6:return u.fn.call(u.context,t,n,i,s,o),!0}for(b=1,m=new Array(p-1);b<p;b++)m[b-1]=arguments[b];u.fn.apply(u.context,m)}else{var A=u.length,S;for(b=0;b<A;b++)switch(u[b].once&&this.removeListener(e,u[b].fn,void 0,!0),p){case 1:u[b].fn.call(u[b].context);break;case 2:u[b].fn.call(u[b].context,t);break;case 3:u[b].fn.call(u[b].context,t,n);break;case 4:u[b].fn.call(u[b].context,t,n,i);break;default:if(!m)for(S=1,m=new Array(p-1);S<p;S++)m[S-1]=arguments[S];u[b].fn.apply(u[b].context,m)}}return!0};Lt.prototype.on=function(e,t,n){return Id(this,e,t,n,!1)};Lt.prototype.once=function(e,t,n){return Id(this,e,t,n,!0)};Lt.prototype.removeListener=function(e,t,n,i){var s=Ut?Ut+e:e;if(!this._events[s])return this;if(!t)return Do(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&Do(this,s);else{for(var c=0,u=[],p=o.length;c<p;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&u.push(o[c]);u.length?this._events[s]=u.length===1?u[0]:u:Do(this,s)}return this};Lt.prototype.removeAllListeners=function(e){var t;return e?(t=Ut?Ut+e:e,this._events[t]&&Do(this,t)):(this._events=new rs,this._eventsCount=0),this};Lt.prototype.off=Lt.prototype.removeListener;Lt.prototype.addListener=Lt.prototype.on;Lt.prefixed=Ut;Lt.EventEmitter=Lt;typeof su<"u"&&(su.exports=Lt)});var FE={};dn(FE,{AddMiniApp:()=>Xn,ComposeCast:()=>af,Context:()=>hf,DEFAULT_READY_OPTIONS:()=>Pa,Errors:()=>ki,Ethereum:()=>df,Manifest:()=>pf,Ready:()=>Ma,SendToken:()=>cf,SignIn:()=>Jn,SolanaConnection:()=>Jo,SwapToken:()=>uf,ViewProfile:()=>ff,ViewToken:()=>lf,actionLaunchFrameSchema:()=>If,actionSchema:()=>kf,actionViewTokenSchema:()=>Of,aspectRatioSchema:()=>Wa,buttonSchema:()=>Tf,buttonTitleSchema:()=>Mi,caip19TokenSchema:()=>qa,createEmitter:()=>r0,createSimpleStringSchema:()=>Fr,createSolanaWalletProvider:()=>zu,default:()=>zE,domainFrameConfigSchema:()=>Uf,domainManifestSchema:()=>xp,encodedJsonFarcasterSignatureSchema:()=>ja,eventFrameAddedSchema:()=>Bf,eventFrameRemovedSchema:()=>Lf,eventNotificationsEnabledSchema:()=>Cf,frameEmbedNextSchema:()=>Nf,frameNameSchema:()=>Pi,hexColorSchema:()=>Ui,jsonFarcasterSignatureHeaderSchema:()=>wp,miniAppHostCapabilityList:()=>Ls,notificationDetailsSchema:()=>Fs,notificationsDisabledSchema:()=>Pf,safeParseFrameEmbed:()=>vp,sdk:()=>Gu,secureUrlSchema:()=>xt,sendNotificationRequestSchema:()=>Ep,sendNotificationResponseSchema:()=>Rp,serverEventSchema:()=>Sp,unwrapSolanaProviderRequest:()=>Vu,wrapSolanaProviderRequest:()=>pE});var Xn={};dn(Xn,{InvalidDomainManifest:()=>La,RejectedByUser:()=>Ca});var ki={};dn(ki,{BaseError:()=>Mr});var Mr=class extends Error{name="BaseError";cause;constructor(e,t={}){super(e,t.cause?{cause:t.cause}:void 0),this.cause=t.cause}};var La=class extends Mr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}},Ca=class extends Mr{name="AddMiniApp.RejectedByUser";constructor(){super("Add frame rejected by user")}};var af={};var Ma={};dn(Ma,{DEFAULT_READY_OPTIONS:()=>Pa});var Pa={disableNativeGestures:!1};var Jn={};dn(Jn,{RejectedByUser:()=>Ua});var Ua=class extends Mr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};var cf={};var uf={};var ff={};var lf={};var df={};var hf={};var pf={};var Ls=["wallet.getEthereumProvider","wallet.getSolanaProvider","actions.ready","actions.openUrl","actions.close","actions.setPrimaryButton","actions.addMiniApp","actions.signIn","actions.viewProfile","actions.composeCast","actions.viewToken","actions.sendToken","actions.swapToken"];var be;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},r.getValidEnumValues=i=>{let s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(let c of s)o[c]=i[c];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(let o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(be||(be={}));var za;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(za||(za={}));var G=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),vr=r=>{switch(typeof r){case"undefined":return G.undefined;case"string":return G.string;case"number":return isNaN(r)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(r)?G.array:r===null?G.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?G.promise:typeof Map<"u"&&r instanceof Map?G.map:typeof Set<"u"&&r instanceof Set?G.set:typeof Date<"u"&&r instanceof Date?G.date:G.object;default:return G.unknown}},M=be.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),c0=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),Kt=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(let o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){let p=o.path[u];u===o.path.length-1?(c[p]=c[p]||{_errors:[]},c[p]._errors.push(t(o))):c[p]=c[p]||{_errors:[]},c=c[p],u++}}};return i(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Kt.create=r=>new Kt(r);var ti=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,be.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${be.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${be.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${be.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,be.assertNever(r)}return{message:t}},yf=ti;function u0(r){yf=r}function Cs(){return yf}var Ps=r=>{let{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="",u=n.filter(p=>!!p).slice().reverse();for(let p of u)c=p(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},f0=[];function W(r,e){let t=Cs(),n=Ps({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ti?void 0:ti].filter(i=>!!i)});r.common.issues.push(n)}var At=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let i of t){if(i.status==="aborted")return oe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let i of t){let s=await i.key,o=await i.value;n.push({key:s,value:o})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let i of t){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return oe;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}},oe=Object.freeze({status:"aborted"}),ei=r=>({status:"dirty",value:r}),Pt=r=>({status:"valid",value:r}),Fa=r=>r.status==="aborted",$a=r=>r.status==="dirty",hn=r=>r.status==="valid",Bi=r=>typeof Promise<"u"&&r instanceof Promise;function Ms(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function _f(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t}var J;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(J||(J={}));var Ti,Ni,er=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},mf=(r,e)=>{if(hn(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new Kt(r.common.issues);return this._error=t,this._error}}};function le(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{var u,p;let{message:m}=r;return o.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(u=m??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(p=m??t)!==null&&p!==void 0?p:c.defaultError}},description:i}}var de=class{get description(){return this._def.description}_getType(e){return vr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:vr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new At,ctx:{common:e.parent.common,data:e.data,parsedType:vr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Bi(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let i={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)},s=this._parseSync({data:e,path:i.path,parent:i});return mf(i,s)}"~validate"(e){var t,n;let i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:i});return hn(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((n=(t=s?.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(s=>hn(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vr(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Bi(i)?i:Promise.resolve(i));return mf(n,s)}refine(e,t){let n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{let o=e(i),c=()=>s.addIssue({code:M.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Ht({schema:this,typeName:se.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Qt.create(this,this._def)}nullable(){return lr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Rr.create(this)}promise(){return zr.create(this,this._def)}or(e){return wn.create([this,e],this._def)}and(e){return vn.create(this,e,this._def)}transform(e){return new Ht({...le(this._def),schema:this,typeName:se.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new xn({...le(this._def),innerType:this,defaultValue:t,typeName:se.ZodDefault})}brand(){return new Li({typeName:se.ZodBranded,type:this,...le(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new In({...le(this._def),innerType:this,catchValue:t,typeName:se.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ci.create(this,e)}readonly(){return On.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},l0=/^c[^\s-]{8,}$/i,d0=/^[0-9a-z]+$/,h0=/^[0-9A-HJKMNP-TV-Z]{26}$/i,p0=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,m0=/^[a-z0-9_-]{21}$/i,g0=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,y0=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,_0=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,b0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Da,w0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,v0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,E0=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,R0=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,S0=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,A0=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bf="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",x0=new RegExp(`^${bf}$`);function wf(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function I0(r){return new RegExp(`^${wf(r)}$`)}function vf(r){let e=`${bf}T${wf(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function O0(r,e){return!!((e==="v4"||!e)&&w0.test(r)||(e==="v6"||!e)&&E0.test(r))}function k0(r,e){if(!g0.test(r))return!1;try{let[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function T0(r,e){return!!((e==="v4"||!e)&&v0.test(r)||(e==="v6"||!e)&&R0.test(r))}var Ur=class r extends de{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){let s=this._getOrReturnCtx(e);return W(s,{code:M.invalid_type,expected:G.string,received:s.parsedType}),oe}let n=new At,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),W(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),W(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?W(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&W(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")_0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"email",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Da||(Da=new RegExp(b0,"u")),Da.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"emoji",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")p0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"uuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")m0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"nanoid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")l0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"cuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")d0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"cuid2",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")h0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"ulid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),W(i,{validation:"url",code:M.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"regex",code:M.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),W(i,{code:M.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),W(i,{code:M.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),W(i,{code:M.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?vf(s).test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{code:M.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?x0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{code:M.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?I0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{code:M.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?y0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"duration",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?O0(e.data,s.version)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"ip",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?k0(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"jwt",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?T0(e.data,s.version)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"cidr",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?S0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"base64",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?A0.test(e.data)||(i=this._getOrReturnCtx(e,i),W(i,{validation:"base64url",code:M.invalid_string,message:s.message}),n.dirty()):be.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:M.invalid_string,...J.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...J.errToObj(e)})}url(e){return this._addCheck({kind:"url",...J.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...J.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...J.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...J.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...J.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...J.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...J.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...J.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...J.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...J.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...J.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...J.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...J.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...J.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...J.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...J.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...J.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...J.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...J.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...J.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...J.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...J.errToObj(t)})}nonempty(e){return this.min(1,J.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Ur.create=r=>{var e;return new Ur({checks:[],typeName:se.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...le(r)})};function N0(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}var pn=class r extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){let s=this._getOrReturnCtx(e);return W(s,{code:M.invalid_type,expected:G.number,received:s.parsedType}),oe}let n,i=new At;for(let s of this._def.checks)s.kind==="int"?be.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?N0(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_finite,message:s.message}),i.dirty()):be.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,J.toString(t))}gt(e,t){return this.setLimit("min",e,!1,J.toString(t))}lte(e,t){return this.setLimit("max",e,!0,J.toString(t))}lt(e,t){return this.setLimit("max",e,!1,J.toString(t))}setLimit(e,t,n,i){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:J.toString(i)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:J.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:J.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:J.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:J.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:J.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:J.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:J.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:J.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:J.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};pn.create=r=>new pn({checks:[],typeName:se.ZodNumber,coerce:r?.coerce||!1,...le(r)});var mn=class r extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==G.bigint)return this._getInvalidInput(e);let n,i=new At;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):be.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:G.bigint,received:t.parsedType}),oe}gte(e,t){return this.setLimit("min",e,!0,J.toString(t))}gt(e,t){return this.setLimit("min",e,!1,J.toString(t))}lte(e,t){return this.setLimit("max",e,!0,J.toString(t))}lt(e,t){return this.setLimit("max",e,!1,J.toString(t))}setLimit(e,t,n,i){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:J.toString(i)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:J.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:J.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:J.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:J.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:J.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};mn.create=r=>{var e;return new mn({checks:[],typeName:se.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...le(r)})};var gn=class extends de{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:G.boolean,received:n.parsedType}),oe}return Pt(e.data)}};gn.create=r=>new gn({typeName:se.ZodBoolean,coerce:r?.coerce||!1,...le(r)});var yn=class r extends de{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){let s=this._getOrReturnCtx(e);return W(s,{code:M.invalid_type,expected:G.date,received:s.parsedType}),oe}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return W(s,{code:M.invalid_date}),oe}let n=new At,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),W(i,{code:M.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),W(i,{code:M.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):be.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:J.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:J.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};yn.create=r=>new yn({checks:[],coerce:r?.coerce||!1,typeName:se.ZodDate,...le(r)});var ri=class extends de{_parse(e){if(this._getType(e)!==G.symbol){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:G.symbol,received:n.parsedType}),oe}return Pt(e.data)}};ri.create=r=>new ri({typeName:se.ZodSymbol,...le(r)});var _n=class extends de{_parse(e){if(this._getType(e)!==G.undefined){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:G.undefined,received:n.parsedType}),oe}return Pt(e.data)}};_n.create=r=>new _n({typeName:se.ZodUndefined,...le(r)});var bn=class extends de{_parse(e){if(this._getType(e)!==G.null){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:G.null,received:n.parsedType}),oe}return Pt(e.data)}};bn.create=r=>new bn({typeName:se.ZodNull,...le(r)});var Dr=class extends de{constructor(){super(...arguments),this._any=!0}_parse(e){return Pt(e.data)}};Dr.create=r=>new Dr({typeName:se.ZodAny,...le(r)});var Er=class extends de{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Pt(e.data)}};Er.create=r=>new Er({typeName:se.ZodUnknown,...le(r)});var ir=class extends de{_parse(e){let t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:G.never,received:t.parsedType}),oe}};ir.create=r=>new ir({typeName:se.ZodNever,...le(r)});var ni=class extends de{_parse(e){if(this._getType(e)!==G.undefined){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:G.void,received:n.parsedType}),oe}return Pt(e.data)}};ni.create=r=>new ni({typeName:se.ZodVoid,...le(r)});var Rr=class r extends de{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==G.array)return W(t,{code:M.invalid_type,expected:G.array,received:t.parsedType}),oe;if(i.exactLength!==null){let o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(W(t,{code:o?M.too_big:M.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(W(t,{code:M.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(W(t,{code:M.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>i.type._parseAsync(new er(t,o,t.path,c)))).then(o=>At.mergeArray(n,o));let s=[...t.data].map((o,c)=>i.type._parseSync(new er(t,o,t.path,c)));return At.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:J.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:J.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:J.toString(t)}})}nonempty(e){return this.min(1,e)}};Rr.create=(r,e)=>new Rr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:se.ZodArray,...le(e)});function Qn(r){if(r instanceof Ft){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=Qt.create(Qn(n))}return new Ft({...r._def,shape:()=>e})}else return r instanceof Rr?new Rr({...r._def,type:Qn(r.element)}):r instanceof Qt?Qt.create(Qn(r.unwrap())):r instanceof lr?lr.create(Qn(r.unwrap())):r instanceof fr?fr.create(r.items.map(e=>Qn(e))):r}var Ft=class r extends de{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=be.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){let p=this._getOrReturnCtx(e);return W(p,{code:M.invalid_type,expected:G.object,received:p.parsedType}),oe}let{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof ir&&this._def.unknownKeys==="strip"))for(let p in i.data)o.includes(p)||c.push(p);let u=[];for(let p of o){let m=s[p],b=i.data[p];u.push({key:{status:"valid",value:p},value:m._parse(new er(i,b,i.path,p)),alwaysSet:p in i.data})}if(this._def.catchall instanceof ir){let p=this._def.unknownKeys;if(p==="passthrough")for(let m of c)u.push({key:{status:"valid",value:m},value:{status:"valid",value:i.data[m]}});else if(p==="strict")c.length>0&&(W(i,{code:M.unrecognized_keys,keys:c}),n.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let p=this._def.catchall;for(let m of c){let b=i.data[m];u.push({key:{status:"valid",value:m},value:p._parse(new er(i,b,i.path,m)),alwaysSet:m in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let p=[];for(let m of u){let b=await m.key,A=await m.value;p.push({key:b,value:A,alwaysSet:m.alwaysSet})}return p}).then(p=>At.mergeObjectSync(n,p)):At.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return J.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,c;let u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=J.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:se.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return be.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return be.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return Qn(this)}partial(e){let t={};return be.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return be.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Qt;)s=s._def.innerType;t[n]=s}}),new r({...this._def,shape:()=>t})}keyof(){return Ef(be.objectKeys(this.shape))}};Ft.create=(r,e)=>new Ft({shape:()=>r,unknownKeys:"strip",catchall:ir.create(),typeName:se.ZodObject,...le(e)});Ft.strictCreate=(r,e)=>new Ft({shape:()=>r,unknownKeys:"strict",catchall:ir.create(),typeName:se.ZodObject,...le(e)});Ft.lazycreate=(r,e)=>new Ft({shape:r,unknownKeys:"strip",catchall:ir.create(),typeName:se.ZodObject,...le(e)});var wn=class extends de{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;let o=s.map(c=>new Kt(c.ctx.common.issues));return W(t,{code:M.invalid_union,unionErrors:o}),oe}if(t.common.async)return Promise.all(n.map(async s=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s,o=[];for(let u of n){let p={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:p});if(m.status==="valid")return m;m.status==="dirty"&&!s&&(s={result:m,ctx:p}),p.common.issues.length&&o.push(p.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;let c=o.map(u=>new Kt(u));return W(t,{code:M.invalid_union,unionErrors:c}),oe}}get options(){return this._def.options}};wn.create=(r,e)=>new wn({options:r,typeName:se.ZodUnion,...le(e)});var wr=r=>r instanceof En?wr(r.schema):r instanceof Ht?wr(r.innerType()):r instanceof Rn?[r.value]:r instanceof Sn?r.options:r instanceof An?be.objectValues(r.enum):r instanceof xn?wr(r._def.innerType):r instanceof _n?[void 0]:r instanceof bn?[null]:r instanceof Qt?[void 0,...wr(r.unwrap())]:r instanceof lr?[null,...wr(r.unwrap())]:r instanceof Li||r instanceof On?wr(r.unwrap()):r instanceof In?wr(r._def.innerType):[],Us=class r extends de{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return W(t,{code:M.invalid_type,expected:G.object,received:t.parsedType}),oe;let n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),oe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let i=new Map;for(let s of t){let o=wr(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new r({typeName:se.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...le(n)})}};function Va(r,e){let t=vr(r),n=vr(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){let i=be.objectKeys(e),s=be.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(let c of s){let u=Va(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<r.length;s++){let o=r[s],c=e[s],u=Va(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var vn=class extends de{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(Fa(s)||Fa(o))return oe;let c=Va(s.value,o.value);return c.valid?(($a(s)||$a(o))&&t.dirty(),{status:t.value,value:c.data}):(W(n,{code:M.invalid_intersection_types}),oe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};vn.create=(r,e,t)=>new vn({left:r,right:e,typeName:se.ZodIntersection,...le(t)});var fr=class r extends de{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return W(n,{code:M.invalid_type,expected:G.array,received:n.parsedType}),oe;if(n.data.length<this._def.items.length)return W(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...n.data].map((o,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new er(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>At.mergeArray(t,o)):At.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};fr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fr({items:r,typeName:se.ZodTuple,rest:null,...le(e)})};var Ds=class r extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return W(n,{code:M.invalid_type,expected:G.object,received:n.parsedType}),oe;let i=[],s=this._def.keyType,o=this._def.valueType;for(let c in n.data)i.push({key:s._parse(new er(n,c,n.path,c)),value:o._parse(new er(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?At.mergeObjectAsync(t,i):At.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof de?new r({keyType:e,valueType:t,typeName:se.ZodRecord,...le(n)}):new r({keyType:Ur.create(),valueType:e,typeName:se.ZodRecord,...le(t)})}},ii=class extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return W(n,{code:M.invalid_type,expected:G.map,received:n.parsedType}),oe;let i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],p)=>({key:i._parse(new er(n,c,n.path,[p,"key"])),value:s._parse(new er(n,u,n.path,[p,"value"]))}));if(n.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let u of o){let p=await u.key,m=await u.value;if(p.status==="aborted"||m.status==="aborted")return oe;(p.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(p.value,m.value)}return{status:t.value,value:c}})}else{let c=new Map;for(let u of o){let p=u.key,m=u.value;if(p.status==="aborted"||m.status==="aborted")return oe;(p.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(p.value,m.value)}return{status:t.value,value:c}}}};ii.create=(r,e,t)=>new ii({valueType:e,keyType:r,typeName:se.ZodMap,...le(t)});var si=class r extends de{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return W(n,{code:M.invalid_type,expected:G.set,received:n.parsedType}),oe;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(W(n,{code:M.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(W(n,{code:M.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let s=this._def.valueType;function o(u){let p=new Set;for(let m of u){if(m.status==="aborted")return oe;m.status==="dirty"&&t.dirty(),p.add(m.value)}return{status:t.value,value:p}}let c=[...n.data.values()].map((u,p)=>s._parse(new er(n,u,n.path,p)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new r({...this._def,minSize:{value:e,message:J.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:J.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};si.create=(r,e)=>new si({valueType:r,minSize:null,maxSize:null,typeName:se.ZodSet,...le(e)});var zs=class r extends de{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return W(t,{code:M.invalid_type,expected:G.function,received:t.parsedType}),oe;function n(c,u){return Ps({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Cs(),ti].filter(p=>!!p),issueData:{code:M.invalid_arguments,argumentsError:u}})}function i(c,u){return Ps({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Cs(),ti].filter(p=>!!p),issueData:{code:M.invalid_return_type,returnTypeError:u}})}let s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof zr){let c=this;return Pt(async function(...u){let p=new Kt([]),m=await c._def.args.parseAsync(u,s).catch(S=>{throw p.addIssue(n(u,S)),p}),b=await Reflect.apply(o,this,m);return await c._def.returns._def.type.parseAsync(b,s).catch(S=>{throw p.addIssue(i(b,S)),p})})}else{let c=this;return Pt(function(...u){let p=c._def.args.safeParse(u,s);if(!p.success)throw new Kt([n(u,p.error)]);let m=Reflect.apply(o,this,p.data),b=c._def.returns.safeParse(m,s);if(!b.success)throw new Kt([i(m,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:fr.create(e).rest(Er.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||fr.create([]).rest(Er.create()),returns:t||Er.create(),typeName:se.ZodFunction,...le(n)})}},En=class extends de{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};En.create=(r,e)=>new En({getter:r,typeName:se.ZodLazy,...le(e)});var Rn=class extends de{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Rn.create=(r,e)=>new Rn({value:r,typeName:se.ZodLiteral,...le(e)});function Ef(r,e){return new Sn({values:r,typeName:se.ZodEnum,...le(e)})}var Sn=class r extends de{constructor(){super(...arguments),Ti.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:be.joinValues(n),received:t.parsedType,code:M.invalid_type}),oe}if(Ms(this,Ti,"f")||_f(this,Ti,new Set(this._def.values),"f"),!Ms(this,Ti,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:M.invalid_enum_value,options:n}),oe}return Pt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Ti=new WeakMap;Sn.create=Ef;var An=class extends de{constructor(){super(...arguments),Ni.set(this,void 0)}_parse(e){let t=be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){let i=be.objectValues(t);return W(n,{expected:be.joinValues(i),received:n.parsedType,code:M.invalid_type}),oe}if(Ms(this,Ni,"f")||_f(this,Ni,new Set(be.getValidEnumValues(this._def.values)),"f"),!Ms(this,Ni,"f").has(e.data)){let i=be.objectValues(t);return W(n,{received:n.data,code:M.invalid_enum_value,options:i}),oe}return Pt(e.data)}get enum(){return this._def.values}};Ni=new WeakMap;An.create=(r,e)=>new An({values:r,typeName:se.ZodNativeEnum,...le(e)});var zr=class extends de{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return W(t,{code:M.invalid_type,expected:G.promise,received:t.parsedType}),oe;let n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return Pt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};zr.create=(r,e)=>new zr({type:r,typeName:se.ZodPromise,...le(e)});var Ht=class extends de{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===se.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{W(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return oe;let u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?oe:u.status==="dirty"||t.value==="dirty"?ei(u.value):u});{if(t.value==="aborted")return oe;let c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?oe:c.status==="dirty"||t.value==="dirty"?ei(c.value):c}}if(i.type==="refinement"){let o=c=>{let u=i.refinement(c,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?oe:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?oe:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!hn(o))return o;let c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>hn(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);be.assertNever(i)}};Ht.create=(r,e,t)=>new Ht({schema:r,typeName:se.ZodEffects,effect:e,...le(t)});Ht.createWithPreprocess=(r,e,t)=>new Ht({schema:e,effect:{type:"preprocess",transform:r},typeName:se.ZodEffects,...le(t)});var Qt=class extends de{_parse(e){return this._getType(e)===G.undefined?Pt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Qt.create=(r,e)=>new Qt({innerType:r,typeName:se.ZodOptional,...le(e)});var lr=class extends de{_parse(e){return this._getType(e)===G.null?Pt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};lr.create=(r,e)=>new lr({innerType:r,typeName:se.ZodNullable,...le(e)});var xn=class extends de{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};xn.create=(r,e)=>new xn({innerType:r,typeName:se.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...le(e)});var In=class extends de{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Bi(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Kt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Kt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};In.create=(r,e)=>new In({innerType:r,typeName:se.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...le(e)});var oi=class extends de{_parse(e){if(this._getType(e)!==G.nan){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:G.nan,received:n.parsedType}),oe}return{status:"valid",value:e.data}}};oi.create=r=>new oi({typeName:se.ZodNaN,...le(r)});var B0=Symbol("zod_brand"),Li=class extends de{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Ci=class r extends de{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?oe:s.status==="dirty"?(t.dirty(),ei(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?oe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:se.ZodPipeline})}},On=class extends de{_parse(e){let t=this._def.innerType._parse(e),n=i=>(hn(i)&&(i.value=Object.freeze(i.value)),i);return Bi(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};On.create=(r,e)=>new On({innerType:r,typeName:se.ZodReadonly,...le(e)});function Rf(r,e={},t){return r?Dr.create().superRefine((n,i)=>{var s,o;if(!r(n)){let c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,p=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...p,fatal:u})}}):Dr.create()}var L0={object:Ft.lazycreate},se;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(se||(se={}));var C0=(r,e={message:`Input not instance of ${r.name}`})=>Rf(t=>t instanceof r,e),Sf=Ur.create,Af=pn.create,P0=oi.create,M0=mn.create,xf=gn.create,U0=yn.create,D0=ri.create,z0=_n.create,F0=bn.create,$0=Dr.create,V0=Er.create,q0=ir.create,W0=ni.create,j0=Rr.create,K0=Ft.create,H0=Ft.strictCreate,G0=wn.create,Z0=Us.create,Y0=vn.create,X0=fr.create,J0=Ds.create,Q0=ii.create,ep=si.create,tp=zs.create,rp=En.create,np=Rn.create,ip=Sn.create,sp=An.create,op=zr.create,gf=Ht.create,ap=Qt.create,cp=lr.create,up=Ht.createWithPreprocess,fp=Ci.create,lp=()=>Sf().optional(),dp=()=>Af().optional(),hp=()=>xf().optional(),pp={string:r=>Ur.create({...r,coerce:!0}),number:r=>pn.create({...r,coerce:!0}),boolean:r=>gn.create({...r,coerce:!0}),bigint:r=>mn.create({...r,coerce:!0}),date:r=>yn.create({...r,coerce:!0})},mp=oe,K=Object.freeze({__proto__:null,defaultErrorMap:ti,setErrorMap:u0,getErrorMap:Cs,makeIssue:Ps,EMPTY_PATH:f0,addIssueToContext:W,ParseStatus:At,INVALID:oe,DIRTY:ei,OK:Pt,isAborted:Fa,isDirty:$a,isValid:hn,isAsync:Bi,get util(){return be},get objectUtil(){return za},ZodParsedType:G,getParsedType:vr,ZodType:de,datetimeRegex:vf,ZodString:Ur,ZodNumber:pn,ZodBigInt:mn,ZodBoolean:gn,ZodDate:yn,ZodSymbol:ri,ZodUndefined:_n,ZodNull:bn,ZodAny:Dr,ZodUnknown:Er,ZodNever:ir,ZodVoid:ni,ZodArray:Rr,ZodObject:Ft,ZodUnion:wn,ZodDiscriminatedUnion:Us,ZodIntersection:vn,ZodTuple:fr,ZodRecord:Ds,ZodMap:ii,ZodSet:si,ZodFunction:zs,ZodLazy:En,ZodLiteral:Rn,ZodEnum:Sn,ZodNativeEnum:An,ZodPromise:zr,ZodEffects:Ht,ZodTransformer:Ht,ZodOptional:Qt,ZodNullable:lr,ZodDefault:xn,ZodCatch:In,ZodNaN:oi,BRAND:B0,ZodBranded:Li,ZodPipeline:Ci,ZodReadonly:On,custom:Rf,Schema:de,ZodSchema:de,late:L0,get ZodFirstPartyTypeKind(){return se},coerce:pp,any:$0,array:j0,bigint:M0,boolean:xf,date:U0,discriminatedUnion:Z0,effect:gf,enum:ip,function:tp,instanceof:C0,intersection:Y0,lazy:rp,literal:np,map:Q0,nan:P0,nativeEnum:sp,never:q0,null:F0,nullable:cp,number:Af,object:K0,oboolean:hp,onumber:dp,optional:ap,ostring:lp,pipeline:fp,preprocess:up,promise:op,record:J0,set:ep,strictObject:H0,string:Sf,symbol:D0,transformer:gf,tuple:X0,undefined:z0,union:G0,unknown:V0,void:W0,NEVER:mp,ZodIssueCode:M,quotelessJson:c0,ZodError:Kt});var gp=/[@#$%^&*+=\/\\|~«»]/,yp=/(!{2,}|\?{2,}|-{2,})/,_p=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,Fr=({max:r,noSpaces:e}={})=>(e?K.string().max(r??Number.POSITIVE_INFINITY).regex(/^\S*$/,"Spaces are not allowed"):K.string().max(r??Number.POSITIVE_INFINITY)).refine(n=>!_p.test(n),{message:"Emojis and symbols are not allowed"}).refine(n=>!gp.test(n),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, \xAB, \xBB) are not allowed"}).refine(n=>!yp.test(n),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),xt=K.string().url().startsWith("https://",{message:"Must be an https url"}).max(1024),Pi=K.string().max(32),Mi=K.string().max(32),bp=/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/,qa=K.string().regex(bp,{message:"Invalid CAIP-19 asset ID"}),Ui=K.string().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i,{message:"Invalid hex color code. It should be in the format #RRGGBB or #RGB."}),Wa=K.union([K.literal("1:1"),K.literal("3:2")]),ja=K.object({header:K.string(),payload:K.string(),signature:K.string()}),wp=K.object({fid:K.number(),type:K.literal("app_key"),key:K.string().startsWith("0x")});var If=K.object({type:K.literal("launch_frame"),name:Pi,url:xt.optional(),splashImageUrl:xt.optional(),splashBackgroundColor:Ui.optional()}),Of=K.object({type:K.literal("view_token"),token:qa}),kf=K.discriminatedUnion("type",[If,Of]),Tf=K.object({title:Mi,action:kf}),Nf=K.object({version:K.literal("next"),imageUrl:xt,aspectRatio:Wa.optional(),button:Tf}),vp=r=>Nf.safeParse(r);var Fs=K.object({url:K.string(),token:K.string()}),Ep=K.object({notificationId:K.string().max(128),title:K.string().max(32),body:K.string().max(128),targetUrl:xt,tokens:K.string().array().max(100)}),Rp=K.object({result:K.object({successfulTokens:K.array(K.string()),invalidTokens:K.array(K.string()),rateLimitedTokens:K.array(K.string())})});var Bf=K.object({event:K.literal("frame_added"),notificationDetails:Fs.optional()}),Lf=K.object({event:K.literal("frame_removed")}),Cf=K.object({event:K.literal("notifications_enabled"),notificationDetails:Fs.required()}),Pf=K.object({event:K.literal("notifications_disabled")}),Sp=K.discriminatedUnion("event",[Bf,Lf,Cf,Pf]);var Ap=K.enum(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),Mf=["eip155:1","eip155:8453","eip155:42161","eip155:421614","eip155:84532","eip155:666666666","eip155:100","eip155:10","eip155:11155420","eip155:137","eip155:11155111","eip155:7777777","eip155:130","eip155:10143","eip155:42220","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],Uf=K.object({version:K.union([K.literal("0.0.0"),K.literal("0.0.1"),K.literal("1"),K.literal("next")]),name:Pi,iconUrl:xt,homeUrl:xt,imageUrl:xt.optional(),buttonTitle:Mi.optional(),splashImageUrl:xt.optional(),splashBackgroundColor:Ui.optional(),webhookUrl:xt.optional(),subtitle:Fr({max:30}).optional(),description:Fr({max:170}).optional(),screenshotUrls:K.array(xt).max(3).optional(),primaryCategory:Ap.optional(),tags:K.array(Fr({max:20,noSpaces:!0})).max(5).optional(),heroImageUrl:xt.optional(),tagline:Fr({max:30}).optional(),ogTitle:Fr({max:30}).optional(),ogDescription:Fr({max:100}).optional(),ogImageUrl:xt.optional(),noindex:K.boolean().optional(),requiredChains:K.array(K.enum(Mf)).max(Mf.length).optional(),requiredCapabilities:K.array(K.enum(Ls)).max(Ls.length).optional()}),xp=K.object({accountAssociation:ja,frame:Uf.optional()});var ae=br(zi());function Fi(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function sm(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Vr(r,...e){if(!sm(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function il(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Fi(r.outputLen),Fi(r.blockLen)}function Ar(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Ws(r,e){Vr(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Nn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function sl(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function js(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function sr(r,e){return r<<32-e|r>>>e}var rc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function om(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function nc(r){for(let e=0;e<r.length;e++)r[e]=om(r[e])}function ol(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Wr(r){return typeof r=="string"&&(r=ol(r)),Vr(r),r}function ic(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];Vr(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}var qr=class{clone(){return this._cloneInto()}};function li(r){let e=n=>r().update(Wr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function al(r){let e=(n,i)=>r(i).update(Wr(n)).digest(),t=r({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}function Ks(r=32){if(Nn&&typeof Nn.getRandomValues=="function")return Nn.getRandomValues(new Uint8Array(r));if(Nn&&typeof Nn.randomBytes=="function")return Nn.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function am(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),c=Number(t&s),u=n?4:0,p=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+p,c,n)}function cl(r,e,t){return r&e^~r&t}function ul(r,e,t){return r&e^r&t^e&t}var di=class extends qr{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=js(this.buffer)}update(e){Ar(this);let{view:t,buffer:n,blockLen:i}=this;e=Wr(e);let s=e.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let u=js(e);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(e.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ar(this),Ws(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let b=o;b<i;b++)t[b]=0;am(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=js(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let p=u/4,m=this.get();if(p>m.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<p;b++)c.setUint32(4*b,m[b],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return e.length=i,e.pos=c,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}};var Hs=BigInt(4294967295),sc=BigInt(32);function fl(r,e=!1){return e?{h:Number(r&Hs),l:Number(r>>sc&Hs)}:{h:Number(r>>sc&Hs)|0,l:Number(r&Hs)|0}}function oc(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=fl(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}var cm=(r,e)=>BigInt(r>>>0)<<sc|BigInt(e>>>0),um=(r,e,t)=>r>>>t,fm=(r,e,t)=>r<<32-t|e>>>t,lm=(r,e,t)=>r>>>t|e<<32-t,dm=(r,e,t)=>r<<32-t|e>>>t,hm=(r,e,t)=>r<<64-t|e>>>t-32,pm=(r,e,t)=>r>>>t-32|e<<64-t,mm=(r,e)=>e,gm=(r,e)=>r,ac=(r,e,t)=>r<<t|e>>>32-t,cc=(r,e,t)=>e<<t|r>>>32-t,uc=(r,e,t)=>e<<t-32|r>>>64-t,fc=(r,e,t)=>r<<t-32|e>>>64-t;function ym(r,e,t,n){let i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}var _m=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),bm=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,wm=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),vm=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,Em=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),Rm=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0;var Sm={fromBig:fl,split:oc,toBig:cm,shrSH:um,shrSL:fm,rotrSH:lm,rotrSL:dm,rotrBH:hm,rotrBL:pm,rotr32H:mm,rotr32L:gm,rotlSH:ac,rotlSL:cc,rotlBH:uc,rotlBL:fc,add:ym,add3L:_m,add3H:bm,add4L:wm,add4H:vm,add5H:Rm,add5L:Em},pe=Sm;var[Am,xm]=pe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),jr=new Uint32Array(80),Kr=new Uint32Array(80),lc=class extends di{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:p,El:m,Fh:b,Fl:A,Gh:S,Gl:T,Hh:I,Hl:x}=this;return[e,t,n,i,s,o,c,u,p,m,b,A,S,T,I,x]}set(e,t,n,i,s,o,c,u,p,m,b,A,S,T,I,x){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=p|0,this.El=m|0,this.Fh=b|0,this.Fl=A|0,this.Gh=S|0,this.Gl=T|0,this.Hh=I|0,this.Hl=x|0}process(e,t){for(let L=0;L<16;L++,t+=4)jr[L]=e.getUint32(t),Kr[L]=e.getUint32(t+=4);for(let L=16;L<80;L++){let F=jr[L-15]|0,te=Kr[L-15]|0,H=pe.rotrSH(F,te,1)^pe.rotrSH(F,te,8)^pe.shrSH(F,te,7),Z=pe.rotrSL(F,te,1)^pe.rotrSL(F,te,8)^pe.shrSL(F,te,7),ee=jr[L-2]|0,Y=Kr[L-2]|0,Ie=pe.rotrSH(ee,Y,19)^pe.rotrBH(ee,Y,61)^pe.shrSH(ee,Y,6),re=pe.rotrSL(ee,Y,19)^pe.rotrBL(ee,Y,61)^pe.shrSL(ee,Y,6),fe=pe.add4L(Z,re,Kr[L-7],Kr[L-16]),v=pe.add4H(fe,H,Ie,jr[L-7],jr[L-16]);jr[L]=v|0,Kr[L]=fe|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:p,Dl:m,Eh:b,El:A,Fh:S,Fl:T,Gh:I,Gl:x,Hh:B,Hl:U}=this;for(let L=0;L<80;L++){let F=pe.rotrSH(b,A,14)^pe.rotrSH(b,A,18)^pe.rotrBH(b,A,41),te=pe.rotrSL(b,A,14)^pe.rotrSL(b,A,18)^pe.rotrBL(b,A,41),H=b&S^~b&I,Z=A&T^~A&x,ee=pe.add5L(U,te,Z,xm[L],Kr[L]),Y=pe.add5H(ee,B,F,H,Am[L],jr[L]),Ie=ee|0,re=pe.rotrSH(n,i,28)^pe.rotrBH(n,i,34)^pe.rotrBH(n,i,39),fe=pe.rotrSL(n,i,28)^pe.rotrBL(n,i,34)^pe.rotrBL(n,i,39),v=n&s^n&c^s&c,a=i&o^i&u^o&u;B=I|0,U=x|0,I=S|0,x=T|0,S=b|0,T=A|0,{h:b,l:A}=pe.add(p|0,m|0,Y|0,Ie|0),p=c|0,m=u|0,c=s|0,u=o|0,s=n|0,o=i|0;let l=pe.add3L(Ie,fe,a);n=pe.add3H(l,Y,re,v),i=l|0}({h:n,l:i}=pe.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=pe.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=pe.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:p,l:m}=pe.add(this.Dh|0,this.Dl|0,p|0,m|0),{h:b,l:A}=pe.add(this.Eh|0,this.El|0,b|0,A|0),{h:S,l:T}=pe.add(this.Fh|0,this.Fl|0,S|0,T|0),{h:I,l:x}=pe.add(this.Gh|0,this.Gl|0,I|0,x|0),{h:B,l:U}=pe.add(this.Hh|0,this.Hl|0,B|0,U|0),this.set(n,i,s,o,c,u,p,m,b,A,S,T,I,x,B,U)}roundClean(){jr.fill(0),Kr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ll=li(()=>new lc);var Ys={};dn(Ys,{aInRange:()=>Vt,abool:()=>or,abytes:()=>hi,bitGet:()=>Bm,bitLen:()=>mc,bitMask:()=>Vi,bitSet:()=>Lm,bytesToHex:()=>Ir,bytesToNumberBE:()=>Or,bytesToNumberLE:()=>Gr,concatBytes:()=>kr,createHmacDrbg:()=>gc,ensureBytes:()=>qe,equalBytes:()=>Tm,hexToBytes:()=>Ln,hexToNumber:()=>pc,inRange:()=>$i,isBytes:()=>Hr,memoized:()=>Pn,notImplemented:()=>Pm,numberToBytesBE:()=>Zr,numberToBytesLE:()=>Cn,numberToHexUnpadded:()=>Bn,numberToVarBytesBE:()=>km,utf8ToBytes:()=>Nm,validateObject:()=>pr});var Gs=BigInt(0),Zs=BigInt(1),Im=BigInt(2);function Hr(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function hi(r){if(!Hr(r))throw new Error("Uint8Array expected")}function or(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}var Om=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ir(r){hi(r);let e="";for(let t=0;t<r.length;t++)e+=Om[r[t]];return e}function Bn(r){let e=r.toString(16);return e.length&1?"0"+e:e}function pc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Gs:BigInt("0x"+r)}var xr={_0:48,_9:57,A:65,F:70,a:97,f:102};function dl(r){if(r>=xr._0&&r<=xr._9)return r-xr._0;if(r>=xr.A&&r<=xr.F)return r-(xr.A-10);if(r>=xr.a&&r<=xr.f)return r-(xr.a-10)}function Ln(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){let o=dl(r.charCodeAt(s)),c=dl(r.charCodeAt(s+1));if(o===void 0||c===void 0){let u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+c}return n}function Or(r){return pc(Ir(r))}function Gr(r){return hi(r),pc(Ir(Uint8Array.from(r).reverse()))}function Zr(r,e){return Ln(r.toString(16).padStart(e*2,"0"))}function Cn(r,e){return Zr(r,e).reverse()}function km(r){return Ln(Bn(r))}function qe(r,e,t){let n;if(typeof e=="string")try{n=Ln(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Hr(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}function kr(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];hi(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}function Tm(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Nm(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var dc=r=>typeof r=="bigint"&&Gs<=r;function $i(r,e,t){return dc(r)&&dc(e)&&dc(t)&&e<=r&&r<t}function Vt(r,e,t,n){if(!$i(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function mc(r){let e;for(e=0;r>Gs;r>>=Zs,e+=1);return e}function Bm(r,e){return r>>BigInt(e)&Zs}function Lm(r,e,t){return r|(t?Zs:Gs)<<BigInt(e)}var Vi=r=>(Im<<BigInt(r-1))-Zs,hc=r=>new Uint8Array(r),hl=r=>Uint8Array.from(r);function gc(r,e,t){if(typeof r!="number"||r<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 t!="function")throw new Error("hmacFn must be a function");let n=hc(r),i=hc(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},c=(...b)=>t(i,n,...b),u=(b=hc())=>{i=c(hl([0]),b),n=c(),b.length!==0&&(i=c(hl([1]),b),n=c())},p=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let b=0,A=[];for(;b<e;){n=c();let S=n.slice();A.push(S),b+=n.length}return kr(...A)};return(b,A)=>{o(),u(b);let S;for(;!(S=A(p()));)u();return o(),S}}var Cm={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Hr(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function pr(r,e,t={}){let n=(i,s,o)=>{let c=Cm[s];if(typeof c!="function")throw new Error("invalid validator function");let u=r[i];if(!(o&&u===void 0)&&!c(u,r))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(t))n(i,s,!0);return r}var Pm=()=>{throw new Error("not implemented")};function Pn(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let s=r(t,...n);return e.set(t,s),s}}var _t=BigInt(0),Ce=BigInt(1),Mn=BigInt(2),Mm=BigInt(3),yc=BigInt(4),pl=BigInt(5),ml=BigInt(8),Um=BigInt(9),Dm=BigInt(16);function Oe(r,e){let t=r%e;return t>=_t?t:e+t}function zm(r,e,t){if(e<_t)throw new Error("invalid exponent, negatives unsupported");if(t<=_t)throw new Error("invalid modulus");if(t===Ce)return _t;let n=Ce;for(;e>_t;)e&Ce&&(n=n*r%t),r=r*r%t,e>>=Ce;return n}function Pe(r,e,t){let n=r;for(;e-- >_t;)n*=n,n%=t;return n}function Xs(r,e){if(r===_t)throw new Error("invert: expected non-zero number");if(e<=_t)throw new Error("invert: expected positive modulus, got "+e);let t=Oe(r,e),n=e,i=_t,s=Ce,o=Ce,c=_t;for(;t!==_t;){let p=n/t,m=n%t,b=i-o*p,A=s-c*p;n=t,t=m,i=o,s=c,o=b,c=A}if(n!==Ce)throw new Error("invert: does not exist");return Oe(i,e)}function Fm(r){let e=(r-Ce)/Mn,t,n,i;for(t=r-Ce,n=0;t%Mn===_t;t/=Mn,n++);for(i=Mn;i<r&&zm(i,e,r)!==r-Ce;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let o=(r+Ce)/yc;return function(u,p){let m=u.pow(p,o);if(!u.eql(u.sqr(m),p))throw new Error("Cannot find square root");return m}}let s=(t+Ce)/Mn;return function(c,u){if(c.pow(u,e)===c.neg(c.ONE))throw new Error("Cannot find square root");let p=n,m=c.pow(c.mul(c.ONE,i),t),b=c.pow(u,s),A=c.pow(u,t);for(;!c.eql(A,c.ONE);){if(c.eql(A,c.ZERO))return c.ZERO;let S=1;for(let I=c.sqr(A);S<p&&!c.eql(I,c.ONE);S++)I=c.sqr(I);let T=c.pow(m,Ce<<BigInt(p-S-1));m=c.sqr(T),b=c.mul(b,T),A=c.mul(A,m),p=S}return b}}function $m(r){if(r%yc===Mm){let e=(r+Ce)/yc;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%ml===pl){let e=(r-pl)/ml;return function(n,i){let s=n.mul(i,Mn),o=n.pow(s,e),c=n.mul(i,o),u=n.mul(n.mul(c,Mn),o),p=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(p),i))throw new Error("Cannot find square root");return p}}return r%Dm,Fm(r)}var gl=(r,e)=>(Oe(r,e)&Ce)===Ce,Vm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function _c(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Vm.reduce((n,i)=>(n[i]="function",n),e);return pr(r,t)}function qm(r,e,t){if(t<_t)throw new Error("invalid exponent, negatives unsupported");if(t===_t)return r.ONE;if(t===Ce)return e;let n=r.ONE,i=e;for(;t>_t;)t&Ce&&(n=r.mul(n,i)),i=r.sqr(i),t>>=Ce;return n}function Wm(r,e){let t=new Array(e.length),n=e.reduce((s,o,c)=>r.is0(o)?s:(t[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,c)=>r.is0(o)?s:(t[c]=r.mul(s,t[c]),r.mul(s,o)),i),t}function bc(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Yr(r,e,t=!1,n={}){if(r<=_t)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:i,nByteLength:s}=bc(r,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o,c=Object.freeze({ORDER:r,isLE:t,BITS:i,BYTES:s,MASK:Vi(i),ZERO:_t,ONE:Ce,create:u=>Oe(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return _t<=u&&u<r},is0:u=>u===_t,isOdd:u=>(u&Ce)===Ce,neg:u=>Oe(-u,r),eql:(u,p)=>u===p,sqr:u=>Oe(u*u,r),add:(u,p)=>Oe(u+p,r),sub:(u,p)=>Oe(u-p,r),mul:(u,p)=>Oe(u*p,r),pow:(u,p)=>qm(c,u,p),div:(u,p)=>Oe(u*Xs(p,r),r),sqrN:u=>u*u,addN:(u,p)=>u+p,subN:(u,p)=>u-p,mulN:(u,p)=>u*p,inv:u=>Xs(u,r),sqrt:n.sqrt||(u=>(o||(o=$m(r)),o(c,u))),invertBatch:u=>Wm(c,u),cmov:(u,p,m)=>m?p:u,toBytes:u=>t?Cn(u,s):Zr(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return t?Gr(u):Or(u)}});return Object.freeze(c)}function yl(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function wc(r){let e=yl(r);return e+Math.ceil(e/2)}function _l(r,e,t=!1){let n=r.length,i=yl(e),s=wc(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let o=t?Gr(r):Or(r),c=Oe(o,e-Ce)+Ce;return t?Cn(c,i):Zr(c,i)}var bl=BigInt(0),Js=BigInt(1);function vc(r,e){let t=e.negate();return r?t:e}function wl(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Ec(r,e){wl(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function jm(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function Km(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}var Rc=new WeakMap,vl=new WeakMap;function Sc(r){return vl.get(r)||1}function Qs(r,e){return{constTimeNegate:vc,hasPrecomputes(t){return Sc(t)!==1},unsafeLadder(t,n,i=r.ZERO){let s=t;for(;n>bl;)n&Js&&(i=i.add(s)),s=s.double(),n>>=Js;return i},precomputeWindow(t,n){let{windows:i,windowSize:s}=Ec(n,e),o=[],c=t,u=c;for(let p=0;p<i;p++){u=c,o.push(u);for(let m=1;m<s;m++)u=u.add(c),o.push(u);c=u.double()}return o},wNAF(t,n,i){let{windows:s,windowSize:o}=Ec(t,e),c=r.ZERO,u=r.BASE,p=BigInt(2**t-1),m=2**t,b=BigInt(t);for(let A=0;A<s;A++){let S=A*o,T=Number(i&p);i>>=b,T>o&&(T-=m,i+=Js);let I=S,x=S+Math.abs(T)-1,B=A%2!==0,U=T<0;T===0?u=u.add(vc(B,n[I])):c=c.add(vc(U,n[x]))}return{p:c,f:u}},wNAFUnsafe(t,n,i,s=r.ZERO){let{windows:o,windowSize:c}=Ec(t,e),u=BigInt(2**t-1),p=2**t,m=BigInt(t);for(let b=0;b<o;b++){let A=b*c;if(i===bl)break;let S=Number(i&u);if(i>>=m,S>c&&(S-=p,i+=Js),S===0)continue;let T=n[A+Math.abs(S)-1];S<0&&(T=T.negate()),s=s.add(T)}return s},getPrecomputes(t,n,i){let s=Rc.get(n);return s||(s=this.precomputeWindow(n,t),t!==1&&Rc.set(n,i(s))),s},wNAFCached(t,n,i){let s=Sc(t);return this.wNAF(s,this.getPrecomputes(s,t,i),n)},wNAFCachedUnsafe(t,n,i,s){let o=Sc(t);return o===1?this.unsafeLadder(t,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),n,s)},setWindowSize(t,n){wl(n,e),vl.set(t,n),Rc.delete(t)}}}function eo(r,e,t,n){if(jm(t,r),Km(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,s=mc(BigInt(t.length)),o=s>12?s-3:s>4?s-2:s?2:1,c=(1<<o)-1,u=new Array(c+1).fill(i),p=Math.floor((e.BITS-1)/o)*o,m=i;for(let b=p;b>=0;b-=o){u.fill(i);for(let S=0;S<n.length;S++){let T=n[S],I=Number(T>>BigInt(b)&BigInt(c));u[I]=u[I].add(t[S])}let A=i;for(let S=u.length-1,T=i;S>0;S--)T=T.add(u[S]),A=A.add(T);if(m=m.add(A),b!==0)for(let S=0;S<o;S++)m=m.double()}return m}function qi(r){return _c(r.Fp),pr(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...bc(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var ar=BigInt(0),qt=BigInt(1),to=BigInt(2),Hm=BigInt(8),Gm={zip215:!0};function Zm(r){let e=qi(r);return pr(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function El(r){let e=Zm(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=e,p=to<<BigInt(c*8)-qt,m=t.create,b=Yr(e.n,e.nBitLength),A=e.uvRatio||((d,h)=>{try{return{isValid:!0,value:t.sqrt(d*t.inv(h))}}catch{return{isValid:!1,value:ar}}}),S=e.adjustScalarBytes||(d=>d),T=e.domain||((d,h,g)=>{if(or("phflag",g),h.length||g)throw new Error("Contexts/pre-hash are not supported");return d});function I(d,h){Vt("coordinate "+d,h,ar,p)}function x(d){if(!(d instanceof L))throw new Error("ExtendedPoint expected")}let B=Pn((d,h)=>{let{ex:g,ey:w,ez:R}=d,y=d.is0();h==null&&(h=y?Hm:t.inv(R));let f=m(g*h),_=m(w*h),C=m(R*h);if(y)return{x:ar,y:qt};if(C!==qt)throw new Error("invZ was invalid");return{x:f,y:_}}),U=Pn(d=>{let{a:h,d:g}=e;if(d.is0())throw new Error("bad point: ZERO");let{ex:w,ey:R,ez:y,et:f}=d,_=m(w*w),C=m(R*R),D=m(y*y),$=m(D*D),X=m(_*h),ie=m(D*m(X+C)),ue=m($+m(g*m(_*C)));if(ie!==ue)throw new Error("bad point: equation left != right (1)");let Le=m(w*R),he=m(y*f);if(Le!==he)throw new Error("bad point: equation left != right (2)");return!0});class L{constructor(h,g,w,R){this.ex=h,this.ey=g,this.ez=w,this.et=R,I("x",h),I("y",g),I("z",w),I("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof L)throw new Error("extended point not allowed");let{x:g,y:w}=h||{};return I("x",g),I("y",w),new L(g,w,qt,m(g*w))}static normalizeZ(h){let g=t.invertBatch(h.map(w=>w.ez));return h.map((w,R)=>w.toAffine(g[R])).map(L.fromAffine)}static msm(h,g){return eo(L,b,h,g)}_setWindowSize(h){H.setWindowSize(this,h)}assertValidity(){U(this)}equals(h){x(h);let{ex:g,ey:w,ez:R}=this,{ex:y,ey:f,ez:_}=h,C=m(g*_),D=m(y*R),$=m(w*_),X=m(f*R);return C===D&&$===X}is0(){return this.equals(L.ZERO)}negate(){return new L(m(-this.ex),this.ey,this.ez,m(-this.et))}double(){let{a:h}=e,{ex:g,ey:w,ez:R}=this,y=m(g*g),f=m(w*w),_=m(to*m(R*R)),C=m(h*y),D=g+w,$=m(m(D*D)-y-f),X=C+f,ie=X-_,ue=C-f,Le=m($*ie),he=m(X*ue),me=m($*ue),jt=m(ie*X);return new L(Le,he,jt,me)}add(h){x(h);let{a:g,d:w}=e,{ex:R,ey:y,ez:f,et:_}=this,{ex:C,ey:D,ez:$,et:X}=h;if(g===BigInt(-1)){let Ue=m((y-R)*(D+C)),De=m((y+R)*(D-C)),Yn=m(De-Ue);if(Yn===ar)return this.double();let ze=m(f*to*X),Fe=m(_*to*$),Oi=Fe+ze,$e=De+Ue,Ve=Fe-ze,Ts=m(Oi*Yn),He=m($e*Ve),Ge=m(Oi*Ve),Ns=m(Yn*$e);return new L(Ts,He,Ns,Ge)}let ie=m(R*C),ue=m(y*D),Le=m(_*w*X),he=m(f*$),me=m((R+y)*(C+D)-ie-ue),jt=he-Le,Ae=he+Le,Ne=m(ue-g*ie),Os=m(me*jt),je=m(Ae*Ne),Ke=m(me*Ne),ks=m(jt*Ae);return new L(Os,je,ks,Ke)}subtract(h){return this.add(h.negate())}wNAF(h){return H.wNAFCached(this,h,L.normalizeZ)}multiply(h){let g=h;Vt("scalar",g,qt,n);let{p:w,f:R}=this.wNAF(g);return L.normalizeZ([w,R])[0]}multiplyUnsafe(h,g=L.ZERO){let w=h;return Vt("scalar",w,ar,n),w===ar?te:this.is0()||w===qt?this:H.wNAFCachedUnsafe(this,w,L.normalizeZ,g)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return H.unsafeLadder(this,n).is0()}toAffine(h){return B(this,h)}clearCofactor(){let{h}=e;return h===qt?this:this.multiplyUnsafe(h)}static fromHex(h,g=!1){let{d:w,a:R}=e,y=t.BYTES;h=qe("pointHex",h,y),or("zip215",g);let f=h.slice(),_=h[y-1];f[y-1]=_&-129;let C=Gr(f),D=g?p:t.ORDER;Vt("pointHex.y",C,ar,D);let $=m(C*C),X=m($-qt),ie=m(w*$-R),{isValid:ue,value:Le}=A(X,ie);if(!ue)throw new Error("Point.fromHex: invalid y coordinate");let he=(Le&qt)===qt,me=(_&128)!==0;if(!g&&Le===ar&&me)throw new Error("Point.fromHex: x=0 and x_0=1");return me!==he&&(Le=m(-Le)),L.fromAffine({x:Le,y:C})}static fromPrivateKey(h){return Y(h).point}toRawBytes(){let{x:h,y:g}=this.toAffine(),w=Cn(g,t.BYTES);return w[w.length-1]|=h&qt?128:0,w}toHex(){return Ir(this.toRawBytes())}}L.BASE=new L(e.Gx,e.Gy,qt,m(e.Gx*e.Gy)),L.ZERO=new L(ar,qt,qt,ar);let{BASE:F,ZERO:te}=L,H=Qs(L,c*8);function Z(d){return Oe(d,n)}function ee(d){return Z(Gr(d))}function Y(d){let h=t.BYTES;d=qe("private key",d,h);let g=qe("hashed private key",s(d),2*h),w=S(g.slice(0,h)),R=g.slice(h,2*h),y=ee(w),f=F.multiply(y),_=f.toRawBytes();return{head:w,prefix:R,scalar:y,point:f,pointBytes:_}}function Ie(d){return Y(d).pointBytes}function re(d=new Uint8Array,...h){let g=kr(...h);return ee(s(T(g,qe("context",d),!!i)))}function fe(d,h,g={}){d=qe("message",d),i&&(d=i(d));let{prefix:w,scalar:R,pointBytes:y}=Y(h),f=re(g.context,w,d),_=F.multiply(f).toRawBytes(),C=re(g.context,_,y,d),D=Z(f+C*R);Vt("signature.s",D,ar,n);let $=kr(_,Cn(D,t.BYTES));return qe("result",$,t.BYTES*2)}let v=Gm;function a(d,h,g,w=v){let{context:R,zip215:y}=w,f=t.BYTES;d=qe("signature",d,2*f),h=qe("message",h),g=qe("publicKey",g,f),y!==void 0&&or("zip215",y),i&&(h=i(h));let _=Gr(d.slice(f,2*f)),C,D,$;try{C=L.fromHex(g,y),D=L.fromHex(d.slice(0,f),y),$=F.multiplyUnsafe(_)}catch{return!1}if(!y&&C.isSmallOrder())return!1;let X=re(R,D.toRawBytes(),C.toRawBytes(),h);return D.add(C.multiplyUnsafe(X)).subtract($).clearCofactor().equals(L.ZERO)}return F._setWindowSize(8),{CURVE:e,getPublicKey:Ie,sign:fe,verify:a,ExtendedPoint:L,utils:{getExtendedPublicKey:Y,randomPrivateKey:()=>o(t.BYTES),precompute(d=8,h=L.BASE){return h._setWindowSize(d),h.multiply(BigInt(3)),h}}}}var Ac=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Rl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),KR=BigInt(0),Ym=BigInt(1),Sl=BigInt(2),HR=BigInt(3),Xm=BigInt(5),Jm=BigInt(8);function Qm(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ac,c=r*r%s*r%s,u=Pe(c,Sl,s)*c%s,p=Pe(u,Ym,s)*r%s,m=Pe(p,Xm,s)*p%s,b=Pe(m,e,s)*m%s,A=Pe(b,t,s)*b%s,S=Pe(A,n,s)*A%s,T=Pe(S,i,s)*S%s,I=Pe(T,i,s)*S%s,x=Pe(I,e,s)*m%s;return{pow_p_5_8:Pe(x,Sl,s)*r%s,b2:c}}function eg(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function tg(r,e){let t=Ac,n=Oe(e*e*e,t),i=Oe(n*n*e,t),s=Qm(r*i).pow_p_5_8,o=Oe(r*n*s,t),c=Oe(e*o*o,t),u=o,p=Oe(o*Rl,t),m=c===r,b=c===Oe(-r,t),A=c===Oe(-r*Rl,t);return m&&(o=u),(b||A)&&(o=p),gl(o,t)&&(o=Oe(-o,t)),{isValid:m||b,value:o}}var rg=Yr(Ac,void 0,!0),ng={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:rg,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Jm,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ll,randomBytes:Ks,adjustScalarBytes:eg,uvRatio:tg},Un=El(ng);var bu=br(Ic()),vt=br(kc());var ag=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Xr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Jr=new Uint32Array(64),Tc=class extends di{constructor(){super(64,32,8,!1),this.A=Xr[0]|0,this.B=Xr[1]|0,this.C=Xr[2]|0,this.D=Xr[3]|0,this.E=Xr[4]|0,this.F=Xr[5]|0,this.G=Xr[6]|0,this.H=Xr[7]|0}get(){let{A:e,B:t,C:n,D:i,E:s,F:o,G:c,H:u}=this;return[e,t,n,i,s,o,c,u]}set(e,t,n,i,s,o,c,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(e,t){for(let b=0;b<16;b++,t+=4)Jr[b]=e.getUint32(t,!1);for(let b=16;b<64;b++){let A=Jr[b-15],S=Jr[b-2],T=sr(A,7)^sr(A,18)^A>>>3,I=sr(S,17)^sr(S,19)^S>>>10;Jr[b]=I+Jr[b-7]+T+Jr[b-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:u,G:p,H:m}=this;for(let b=0;b<64;b++){let A=sr(c,6)^sr(c,11)^sr(c,25),S=m+A+cl(c,u,p)+ag[b]+Jr[b]|0,I=(sr(n,2)^sr(n,13)^sr(n,22))+ul(n,i,s)|0;m=p,p=u,u=c,c=o+S|0,o=s,s=i,i=n,n=S+I|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,p=p+this.G|0,m=m+this.H|0,this.set(n,i,s,o,c,u,p,m)}roundClean(){Jr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Wi=li(()=>new Tc);var Ri=br(Dl()),E=br(zc()),uh=br(zc());var Sg=1,Ag=2,xg=3,Ig=4,Og=5,kg=6,Tg=7,Ng=8,Bg=9,Lg=10,Cg=-32700,Pg=-32603,Mg=-32602,Ug=-32601,Dg=-32600,zg=-32016,Fg=-32015,$g=-32014,Vg=-32013,qg=-32012,Wg=-32011,jg=-32010,Kg=-32009,Hg=-32008,Gg=-32007,Zg=-32006,Yg=-32005,Xg=-32004,Jg=-32003,Qg=-32002,ey=-32001,ty=28e5,ry=2800001,ny=2800002,iy=2800003,sy=2800004,oy=2800005,ay=2800006,cy=2800007,uy=2800008,fy=2800009,ly=2800010,dy=323e4,hy=32300001,py=3230002,my=3230003,gy=3230004,yy=361e4,_y=3610001,by=3610002,wy=3610003,vy=3610004,Ey=3610005,Ry=3610006,Sy=3610007,Ay=3611e3,xy=3704e3,Iy=3704001,Oy=3704002,ky=3704003,Ty=3704004,Ny=4128e3,By=4128001,Ly=4128002,Cy=4615e3,Py=4615001,My=4615002,Uy=4615003,Dy=4615004,zy=4615005,Fy=4615006,$y=4615007,Vy=4615008,qy=4615009,Wy=4615010,jy=4615011,Ky=4615012,Hy=4615013,Gy=4615014,Zy=4615015,Yy=4615016,Xy=4615017,Jy=4615018,Qy=4615019,e_=4615020,t_=4615021,r_=4615022,n_=4615023,i_=4615024,s_=4615025,o_=4615026,a_=4615027,c_=4615028,u_=4615029,f_=4615030,l_=4615031,d_=4615032,h_=4615033,p_=4615034,m_=4615035,g_=4615036,y_=4615037,__=4615038,b_=4615039,w_=4615040,v_=4615041,E_=4615042,R_=4615043,S_=4615044,A_=4615045,x_=4615046,I_=4615047,O_=4615048,k_=4615049,T_=4615050,N_=4615051,B_=4615052,L_=4615053,C_=4615054,P_=5508e3,M_=5508001,U_=5508002,D_=5508003,z_=5508004,F_=5508005,$_=5508006,V_=5508007,q_=5508008,W_=5508009,j_=5508010,K_=5508011,H_=5663e3,G_=5663001,Z_=5663002,Y_=5663003,X_=5663004,J_=5663005,Q_=5663006,eb=5663007,tb=5663008,rb=5663009,nb=5663010,ib=5663011,sb=5663012,ob=5663013,ab=5663014,cb=5663015,ub=5663016,fb=5663017,lb=5663018,db=5663019,hb=705e4,pb=7050001,mb=7050002,gb=7050003,yb=7050004,_b=7050005,bb=7050006,wb=7050007,vb=7050008,Eb=7050009,Rb=7050010,Sb=7050011,Ab=7050012,xb=7050013,Ib=7050014,Ob=7050015,kb=7050016,Tb=7050017,Nb=7050018,Bb=7050019,Lb=7050020,Cb=7050021,Pb=7050022,Mb=7050023,Ub=7050024,Db=7050025,zb=7050026,Fb=7050027,$b=7050028,Vb=7050029,qb=7050030,Wb=7050031,jb=7050032,Kb=7050033,Hb=7050034,Gb=7050035,Zb=7050036,Fc=8078e3,$c=8078001,zl=8078002,Fl=8078003,Vc=8078004,qc=8078005,Wc=8078006,Yb=8078007,Xb=8078008,Jb=8078009,Qb=8078010,jc=8078011,ew=8078012,$l=8078013,Vl=8078014,tw=8078015,rw=8078016,nw=8078017,iw=8078018,sw=8078019,ql=8078020,Wl=8078021,ow=8078022,aw=81e5,cw=8100001,uw=8100002,fw=8100003,lw=819e4,dw=8190001,hw=8190002,pw=8190003,mw=8190004,gw=99e5,yw=9900001,_w=9900002,bw=9900003,ww=9900004;function jl(r){return Array.isArray(r)?"%5B"+r.map(jl).join("%2C%20")+"%5D":typeof r=="bigint"?`${r}n`:encodeURIComponent(String(r!=null&&Object.getPrototypeOf(r)===null?{...r}:r))}function vw([r,e]){return`${r}=${jl(e)}`}function Ew(r){let e=Object.entries(r).map(vw).join("&");return btoa(e)}var sS={[dy]:"Account not found at address: $address",[gy]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[my]:"Expected decoded account at address: $address",[py]:"Failed to decode account data at address: $address",[hy]:"Accounts not found at addresses: $addresses",[fy]:"Unable to find a viable program address bump seed.",[ny]:"$putativeAddress is not a base58-encoded address.",[ty]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[iy]:"The `CryptoKey` must be an `Ed25519` public key.",[uy]:"Invalid seeds; point must fall off the Ed25519 curve.",[sy]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[ay]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[cy]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[oy]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[ly]:"Program address cannot end with PDA marker.",[ry]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Ig]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Sg]:"The network has progressed past the last block for which this transaction could have been committed.",[Fc]:"Codec [$codecDescription] cannot decode empty byte arrays.",[ow]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[ql]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[qc]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Wc]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Vc]:"Encoder and decoder must either both be fixed-size or variable-size.",[Xb]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[zl]:"Expected a fixed-size codec, got a variable-size one.",[$l]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Fl]:"Expected a variable-size codec, got a fixed-size one.",[sw]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[$c]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[iw]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Jb]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Qb]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[tw]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Yb]:"Expected [$codecDescription] to have $expected items, got $actual.",[ew]:"Invalid value $value for base $base with alphabet $alphabet.",[rw]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[jc]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Vl]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Wl]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[nw]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Ay]:"No random values implementation could be found.",[qy]:"instruction requires an uninitialized account",[n_]:"instruction tries to borrow reference for an account which is already borrowed",[i_]:"instruction left account with an outstanding borrowed reference",[t_]:"program other than the account's owner changed the size of the account data",[zy]:"account data too small for instruction",[r_]:"instruction expected an executable account",[x_]:"An account does not have enough lamports to be rent-exempt",[O_]:"Program arithmetic overflowed",[A_]:"Failed to serialize or deserialize account data: $encodedData",[C_]:"Builtin programs must consume compute units",[d_]:"Cross-program invocation call depth too deep",[__]:"Computational budget exceeded",[o_]:"custom program error: #$code",[Xy]:"instruction contains duplicate accounts",[s_]:"instruction modifications of multiply-passed account differ",[f_]:"executable accounts must be rent exempt",[c_]:"instruction changed executable accounts data",[u_]:"instruction changed the balance of an executable account",[Jy]:"instruction changed executable bit of an account",[Gy]:"instruction modified data of an account it does not own",[Hy]:"instruction spent from the balance of an account it does not own",[Py]:"generic instruction error",[T_]:"Provided owner is not allowed",[R_]:"Account is immutable",[S_]:"Incorrect authority provided",[$y]:"incorrect program id for instruction",[Fy]:"insufficient funds for instruction",[Dy]:"invalid account data for instruction",[I_]:"Invalid account owner",[My]:"invalid program argument",[a_]:"program returned invalid error code",[Uy]:"invalid instruction data",[y_]:"Failed to reallocate account data",[g_]:"Provided seeds do not result in a valid address",[N_]:"Accounts data allocations exceeded the maximum allowed per transaction",[B_]:"Max accounts exceeded",[L_]:"Max instruction trace length exceeded",[m_]:"Length of the seed is too long for address generation",[h_]:"An account required by the instruction is missing",[Vy]:"missing required signature for instruction",[Ky]:"instruction illegally modified the program id of an account",[e_]:"insufficient account keys for instruction",[b_]:"Cross-program invocation with unauthorized signer or writable account",[w_]:"Failed to create program execution environment",[E_]:"Program failed to compile",[v_]:"Program failed to complete",[Yy]:"instruction modified data of a read-only account",[Zy]:"instruction changed the balance of a read-only account",[p_]:"Cross-program invocation reentrancy not allowed for this instruction",[Qy]:"instruction modified rent epoch of an account",[jy]:"sum of account balances before and after instruction do not match",[Wy]:"instruction requires an initialized account",[Cy]:"",[l_]:"Unsupported program id",[k_]:"Unsupported sysvar",[Ny]:"The instruction does not have any accounts.",[By]:"The instruction does not have any data.",[Ly]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[Og]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Ag]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[_w]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ww]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[yw]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[gw]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[bw]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Pg]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Mg]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Dg]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[Ug]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Cg]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[qg]:"$__serverMessage",[ey]:"$__serverMessage",[Xg]:"$__serverMessage",[$g]:"$__serverMessage",[jg]:"$__serverMessage",[Kg]:"$__serverMessage",[zg]:"Minimum context slot has not been reached",[Yg]:"Node is unhealthy; behind by $numSlotsBehind slots",[Hg]:"No snapshot",[Qg]:"Transaction simulation failed",[Gg]:"$__serverMessage",[Wg]:"Transaction history is not available from this node",[Zg]:"$__serverMessage",[Vg]:"Transaction signature length mismatch",[Jg]:"Transaction signature verification failure",[Fg]:"$__serverMessage",[xy]:"Key pair bytes must be of length 64, got $byteLength.",[Iy]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Oy]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Ty]:"The provided private key does not match the provided public key.",[ky]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[kg]:"Lamports value must be in the range [0, 2e64-1]",[Tg]:"`$value` cannot be parsed as a `BigInt`",[Lg]:"$message",[Ng]:"`$value` cannot be parsed as a `Number`",[xg]:"No nonce account could be found at address `$nonceAccountAddress`",[lw]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[hw]:"WebSocket was closed before payload could be added to the send buffer",[pw]:"WebSocket connection closed",[mw]:"WebSocket failed to connect",[dw]:"Failed to obtain a subscription id from the server",[fw]:"Could not find an API plan for RPC method: `$method`",[aw]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[uw]:"HTTP error ($statusCode): $message",[cw]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[P_]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[M_]:"The provided value does not implement the `KeyPairSigner` interface",[D_]:"The provided value does not implement the `MessageModifyingSigner` interface",[z_]:"The provided value does not implement the `MessagePartialSigner` interface",[U_]:"The provided value does not implement any of the `MessageSigner` interfaces",[$_]:"The provided value does not implement the `TransactionModifyingSigner` interface",[V_]:"The provided value does not implement the `TransactionPartialSigner` interface",[q_]:"The provided value does not implement the `TransactionSendingSigner` interface",[F_]:"The provided value does not implement any of the `TransactionSigner` interfaces",[W_]:"More than one `TransactionSendingSigner` was identified.",[j_]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[K_]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Sy]:"Cannot export a non-extractable key.",[_y]:"No digest implementation could be found.",[yy]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[by]:`This runtime does not support the generation of Ed25519 key pairs.
2
2
 
3
3
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
4
4
 
5
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[dy]:"No signature verification implementation could be found.",[hy]:"No key generation implementation could be found.",[py]:"No signing implementation could be found.",[my]:"No key export implementation could be found.",[Sg]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[vb]:"Transaction processing left an account with an outstanding borrowed reference",[ob]:"Account in use",[ab]:"Account loaded twice",[cb]:"Attempt to debit an account but found no record of a prior credit.",[Ob]:"Transaction loads an address table account that doesn't exist",[db]:"This transaction has already been processed",[hb]:"Blockhash not found",[pb]:"Loader call chain is too deep",[wb]:"Transactions are currently disabled due to cluster maintenance",[Pb]:"Transaction contains a duplicate instruction ($index) that is not allowed",[fb]:"Insufficient funds for fee",[Mb]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[lb]:"This account may not be used to pay transaction fees",[gb]:"Transaction contains an invalid account reference",[Tb]:"Transaction loads an address table account with invalid data",[Nb]:"Transaction address table lookup uses an invalid index",[kb]:"Transaction loads an address table account with an invalid owner",[Db]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[_b]:"This program may not be used for executing instructions",[Bb]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Sb]:"Transaction loads a writable account that cannot be written",[Ub]:"Transaction exceeded max loaded accounts data size cap",[mb]:"Transaction requires a fee but has no signature present",[ub]:"Attempt to load a program that does not exist",[Fb]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[zb]:"ResanitizationNeeded",[bb]:"Transaction failed to sanitize accounts offsets correctly",[yb]:"Transaction did not pass signature verification",[Ib]:"Transaction locked too many accounts",[Vb]:"Sum of account balances before and after transaction do not match",[sb]:"The transaction failed with the error `$errorName`",[Rb]:"Transaction version is unsupported",[xb]:"Transaction would exceed account data limit within the block",[Cb]:"Transaction would exceed total account data limit",[Ab]:"Transaction would exceed max account limit within the block",[Eb]:"Transaction would exceed max Block Cost Limit",[Lb]:"Transaction would exceed max Vote Cost Limit",[eb]:"Attempted to sign a transaction with an address that is not a signer for it",[Z_]:"Transaction is missing an address at index: $index.",[tb]:"Transaction has no expected signers therefore it cannot be encoded",[V_]:"Transaction does not have a blockhash lifetime",[$_]:"Transaction is not a durable nonce transaction",[q_]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[j_]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[H_]:"No fee payer set in CompiledTransaction",[K_]:"Could not find program address at index $index",[nb]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[ib]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[Y_]:"Transaction is missing a fee payer.",[X_]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Q_]:"Transaction first instruction is not advance nonce account instruction.",[J_]:"Transaction with no instructions cannot be durable nonce transaction.",[z_]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[F_]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[rb]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[G_]:"Transaction is missing signatures for addresses: $addresses.",[W_]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"};function mw(r,e={}){{let t=`Solana error #${r}; Decode this error by running \`npx @solana/errors decode -- ${r}`;return Object.keys(e).length&&(t+=` '${pw(e)}'`),`${t}\``}}var tn=class extends Error{cause=this.cause;context;constructor(...[r,e]){let t,n;if(e){let{cause:s,...o}=e;s&&(n={cause:s}),Object.keys(o).length>0&&(t=o)}let i=mw(r,t);super(i,n),this.context={__code:r,...t},this.name="SolanaError"}};function gw(r,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(r)}function $l(r){return Object.freeze({...r,encode:e=>{let t=new Uint8Array(gw(e,r));return r.write(e,t,0),t}})}function Wl(r){return Object.freeze({...r,decode:(e,t=0)=>r.read(e,t)[0]})}function yi(r){return"fixedSize"in r&&typeof r.fixedSize=="number"}function ql(r,e){if(yi(r)!==yi(e))throw new tn(Dc);if(yi(r)&&yi(e)&&r.fixedSize!==e.fixedSize)throw new tn(zc,{decoderFixedSize:e.fixedSize,encoderFixedSize:r.fixedSize});if(!yi(r)&&!yi(e)&&r.maxSize!==e.maxSize)throw new tn(Fc,{decoderMaxSize:e.maxSize,encoderMaxSize:r.maxSize});return{...e,...r,decode:e.decode,encode:r.encode,read:e.read,write:r.write}}function jl(r,e,t=0){if(e.length-t<=0)throw new tn(Mc,{codecDescription:r})}function Kl(r,e,t,n=0){let i=t.length-n;if(i<e)throw new tn(Uc,{bytesLength:i,codecDescription:r,expected:e})}function yw(r,e,t,n){if(n<e||n>t)throw new tn(Vc,{codecDescription:r,max:t,min:e,value:n})}function Hl(r){return r?.endian!==1}function _w(r){return $l({fixedSize:r.size,write(e,t,n){r.range&&yw(r.name,r.range[0],r.range[1],e);let i=new ArrayBuffer(r.size);return r.set(new DataView(i),e,Hl(r.config)),t.set(new Uint8Array(i),n),n+r.size}})}function bw(r){return Wl({fixedSize:r.size,read(e,t=0){jl(r.name,e,t),Kl(r.name,r.size,e,t);let n=new DataView(ww(e,t,r.size));return[r.get(n,Hl(r.config)),t+r.size]}})}function ww(r,e,t){let n=r.byteOffset+(e??0),i=t??r.byteLength;return r.buffer.slice(n,n+i)}var $c=(r={})=>_w({config:r,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),vw=(r={})=>bw({config:r,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),Gl=(r={})=>ql($c(r),vw(r));var Wc=class extends TypeError{constructor(e,t){let n,{message:i,explanation:s,...o}=e,{path:c}=e,u=c.length===0?i:`At path: ${c.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}};function Ew(r){return Zi(r)&&typeof r[Symbol.iterator]=="function"}function Zi(r){return typeof r=="object"&&r!=null}function ko(r){return Zi(r)&&!Array.isArray(r)}function cr(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function Rw(r){let{done:e,value:t}=r.next();return e?void 0:t}function Sw(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});let{path:i,branch:s}=e,{type:o}=t,{refinement:c,message:u=`Expected a value of type \`${o}\`${c?` with refinement \`${c}\``:""}, but received: \`${cr(n)}\``}=r;return{value:n,type:o,refinement:c,key:i[i.length-1],path:i,branch:s,...r,message:u}}function*Zl(r,e,t,n){Ew(r)||(r=[r]);for(let i of r){let s=Sw(i,e,t,n);s&&(yield s)}}function*qc(r,e,t={}){let{path:n=[],branch:i=[r],coerce:s=!1,mask:o=!1}=t,c={path:n,branch:i,mask:o};s&&(r=e.coercer(r,c));let u="valid";for(let p of e.validator(r,c))p.explanation=t.message,u="not_valid",yield[p,void 0];for(let[p,m,b]of e.entries(r,c)){let A=qc(m,b,{path:p===void 0?n:[...n,p],branch:p===void 0?i:[...i,m],coerce:s,mask:o,message:t.message});for(let S of A)S[0]?(u=S[0].refinement!=null?"not_refined":"not_valid",yield[S[0],void 0]):s&&(m=S[1],p===void 0?r=m:r instanceof Map?r.set(p,m):r instanceof Set?r.add(m):Zi(r)&&(m!==void 0||p in r)&&(r[p]=m))}if(u!=="not_valid")for(let p of e.refiner(r,c))p.explanation=t.message,u="not_refined",yield[p,void 0];u==="valid"&&(yield[void 0,r])}var rr=class{constructor(e){let{type:t,schema:n,validator:i,refiner:s,coercer:o=u=>u,entries:c=function*(){}}=e;this.type=t,this.schema=n,this.entries=c,this.coercer=o,i?this.validator=(u,p)=>{let m=i(u,p);return Zl(m,p,this,u)}:this.validator=()=>[],s?this.refiner=(u,p)=>{let m=s(u,p);return Zl(m,p,this,u)}:this.refiner=()=>[]}assert(e,t){return Yl(e,this,t)}create(e,t){return $(e,this,t)}is(e){return Xl(e,this)}mask(e,t){return Aw(e,this,t)}validate(e,t={}){return Yi(e,this,t)}};function Yl(r,e,t){let n=Yi(r,e,{message:t});if(n[0])throw n[0]}function $(r,e,t){let n=Yi(r,e,{coerce:!0,message:t});if(n[0])throw n[0];return n[1]}function Aw(r,e,t){let n=Yi(r,e,{coerce:!0,mask:!0,message:t});if(n[0])throw n[0];return n[1]}function Xl(r,e){return!Yi(r,e)[0]}function Yi(r,e,t={}){let n=qc(r,e,t),i=Rw(n);return i[0]?[new Wc(i[0],function*(){for(let o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Vn(r,e){return new rr({type:r,schema:null,validator:e})}function Jl(){return Vn("any",()=>!0)}function W(r){return new rr({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(let[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${cr(e)}`}})}function ur(){return Vn("boolean",r=>typeof r=="boolean")}function To(r){return Vn("instance",e=>e instanceof r||`Expected a \`${r.name}\` instance, but received: ${cr(e)}`)}function Me(r){let e=cr(r),t=typeof r;return new rr({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${e}\`, but received: ${cr(n)}`}})}function xw(){return Vn("never",()=>!1)}function j(r){return new rr({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function O(){return Vn("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${cr(r)}`)}function ne(r){return new rr({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function jc(r,e){return new rr({type:"record",schema:null,*entries(t){if(Zi(t))for(let n in t){let i=t[n];yield[n,n,r],yield[n,i,e]}},validator(t){return ko(t)||`Expected an object, but received: ${cr(t)}`},coercer(t){return ko(t)?{...t}:t}})}function z(){return Vn("string",r=>typeof r=="string"||`Expected a string, but received: ${cr(r)}`)}function No(r){let e=xw();return new rr({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let n=Math.max(r.length,t.length);for(let i=0;i<n;i++)yield[i,t[i],r[i]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${cr(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function P(r){let e=Object.keys(r);return new rr({type:"type",schema:r,*entries(t){if(Zi(t))for(let n of e)yield[n,t[n],r[n]]},validator(t){return ko(t)||`Expected an object, but received: ${cr(t)}`},coercer(t){return ko(t)?{...t}:t}})}function Ot(r){let e=r.map(t=>t.type).join(" | ");return new rr({type:"union",schema:null,coercer(t,n){for(let i of r){let[s,o]=i.validate(t,{coerce:!0,mask:n.mask});if(!s)return o}return t},validator(t,n){let i=[];for(let s of r){let[...o]=qc(t,s,n),[c]=o;if(c[0])for(let[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${cr(t)}`,...i]}})}function $n(){return Vn("unknown",()=>!0)}function _i(r,e,t){return new rr({...r,coercer:(n,i)=>Xl(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}var oh=br(Ed());var Ad=br(Di(),1);var on=br(Sd(),1);var Jw=class extends on.default{socket;constructor(r,e,t){super(),this.socket=new window.WebSocket(r,t),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=n=>this.emit("message",n.data),this.socket.onerror=n=>this.emit("error",n),this.socket.onclose=n=>{this.emit("close",n.code,n.reason)}}send(r,e,t){let n=t||e;try{this.socket.send(r),n()}catch(i){n(i)}}close(r,e){this.socket.close(r,e)}addEventListener(r,e,t){this.socket.addEventListener(r,e,t)}};function xd(r,e){return new Jw(r,e)}var Qw=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},Id=class extends on.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(r,e="ws://localhost:8080",{autoconnect:t=!0,reconnect:n=!0,reconnect_interval:i=1e3,max_reconnects:s=5,...o}={},c,u){super(),this.webSocketFactory=r,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=t,this.ready=!1,this.reconnect=n,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=s,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=c||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),u?this.dataPack=u:this.dataPack=new Qw,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(r,e,t,n){return!n&&typeof t=="object"&&(n=t,t=null),new Promise((i,s)=>{if(!this.ready)return s(new Error("socket not ready"));let o=this.generate_request_id(r,e),c={jsonrpc:"2.0",method:r,params:e||void 0,id:o};this.socket.send(this.dataPack.encode(c),n,u=>{if(u)return s(u);this.queue[o]={promise:[i,s]},t&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],s(new Error("reply timeout"))},t))})})}async login(r){let e=await this.call("rpc.login",r);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(r,e){return new Promise((t,n)=>{if(!this.ready)return n(new Error("socket not ready"));let i={jsonrpc:"2.0",method:r,params:e};this.socket.send(this.dataPack.encode(i),s=>{if(s)return n(s);t()})})}async subscribe(r){typeof r=="string"&&(r=[r]);let e=await this.call("rpc.on",r);if(typeof r=="string"&&e[r]!=="ok")throw new Error("Failed subscribing to an event '"+r+"' with: "+e[r]);return e}async unsubscribe(r){typeof r=="string"&&(r=[r]);let e=await this.call("rpc.off",r);if(typeof r=="string"&&e[r]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(r,e){this.socket.close(r||1e3,e)}setAutoReconnect(r){this.reconnect=r}setReconnectInterval(r){this.reconnect_interval=r}setMaxReconnects(r){this.max_reconnects=r}_connect(r,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(r,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:t})=>{t instanceof ArrayBuffer&&(t=Ad.Buffer.from(t).toString());try{t=this.dataPack.decode(t)}catch{return}if(t.notification&&this.listeners(t.notification).length){if(!Object.keys(t.params).length)return this.emit(t.notification);let n=[t.notification];if(t.params.constructor===Object)n.push(t.params);else for(let i=0;i<t.params.length;i++)n.push(t.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,n)})}if(!this.queue[t.id])return t.method?Promise.resolve().then(()=>{this.emit(t.method,t?.params)}):void 0;"error"in t=="result"in t&&this.queue[t.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[t.id].timeout&&clearTimeout(this.queue[t.id].timeout),t.error?this.queue[t.id].promise[1](t.error):this.queue[t.id].promise[0](t.result),delete this.queue[t.id]}),this.socket.addEventListener("error",t=>this.emit("error",t)),this.socket.addEventListener("close",({code:t,reason:n})=>{this.ready&&setTimeout(()=>this.emit("close",t,n),0),this.ready=!1,this.socket=void 0,t!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(r,e),this.reconnect_interval)))})}};var Td=[],Nd=[],Bd=[],e1=BigInt(0),rs=BigInt(1),t1=BigInt(2),r1=BigInt(7),n1=BigInt(256),i1=BigInt(113);for(let r=0,e=rs,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],Td.push(2*(5*n+t)),Nd.push((r+1)*(r+2)/2%64);let i=e1;for(let s=0;s<7;s++)e=(e<<rs^(e>>r1)*i1)%n1,e&t1&&(i^=rs<<(rs<<BigInt(s))-rs);Bd.push(i)}var[s1,o1]=rc(Bd,!0),Od=(r,e,t)=>t>32?sc(r,e,t):nc(r,e,t),kd=(r,e,t)=>t>32?oc(r,e,t):ic(r,e,t);function a1(r,e=24){let t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){let c=(o+8)%10,u=(o+2)%10,p=t[u],m=t[u+1],b=Od(p,m,1)^t[c],A=kd(p,m,1)^t[c+1];for(let S=0;S<50;S+=10)r[o+S]^=b,r[o+S+1]^=A}let i=r[2],s=r[3];for(let o=0;o<24;o++){let c=Nd[o],u=Od(i,s,c),p=kd(i,s,c),m=Td[o];i=r[m],s=r[m+1],r[m]=u,r[m+1]=p}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)t[c]=r[o+c];for(let c=0;c<10;c++)r[o+c]^=~t[(c+2)%10]&t[(c+4)%10]}r[0]^=s1[n],r[1]^=o1[n]}t.fill(0)}var Do=class r extends Wr{constructor(e,t,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,zi(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=tl(this.state)}keccak(){Ja||Qa(this.state32),a1(this.state32,this.rounds),Ja||Qa(this.state32),this.posOut=0,this.pos=0}update(e){Ar(this);let{blockLen:t,state:n}=this;e=qr(e);let i=e.length;for(let s=0;s<i;){let o=Math.min(t-this.pos,i-s);for(let c=0;c<o;c++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,(t&128)!==0&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Ar(this,!1),$r(e),this.finish();let t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();let o=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return zi(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ws(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new r(t,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}},an=(r,e,t)=>fi(()=>new Do(e,r,t)),JS=an(6,144,224/8),QS=an(6,136,256/8),eA=an(6,104,384/8),tA=an(6,72,512/8),rA=an(1,144,224/8),ru=an(1,136,256/8),nA=an(1,104,384/8),iA=an(1,72,512/8),Ld=(r,e,t)=>nl((n={})=>new Do(e,r,n.dkLen===void 0?t:n.dkLen,!0)),sA=Ld(31,168,128/8),oA=Ld(31,136,256/8);var zo=class extends Wr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,el(e);let n=qr(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Ar(this),this.iHash.update(e),this}digestInto(e){Ar(this),$r(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:c}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=c,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},nu=(r,e,t)=>new zo(r,e).update(t).digest();nu.create=(r,e)=>new zo(r,e);function Cd(r){r.lowS!==void 0&&or("lowS",r.lowS),r.prehash!==void 0&&or("prehash",r.prehash)}function c1(r){let e=$i(r);pr(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:u1,hexToBytes:f1}=Zs,iu=class extends Error{constructor(e=""){super(e)}},Br={Err:iu,_tlv:{encode:(r,e)=>{let{Err:t}=Br;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,i=Bn(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");let s=n>127?Bn(i.length/2|128):"";return Bn(r)+s+i+e},decode(r,e){let{Err:t}=Br,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),o=0;if(!s)o=i;else{let u=i&127;if(!u)throw new t("tlv.decode(long): indefinite length not supported");if(u>4)throw new t("tlv.decode(long): byte length is too big");let p=e.subarray(n,n+u);if(p.length!==u)throw new t("tlv.decode: length bytes not complete");if(p[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let m of p)o=o<<8|m;if(n+=u,o<128)throw new t("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+o);if(c.length!==o)throw new t("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+o)}}},_int:{encode(r){let{Err:e}=Br;if(r<Lr)throw new e("integer: negative integers are not allowed");let t=Bn(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=Br;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return u1(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Br,i=typeof r=="string"?f1(r):r;di(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:u}=n.decode(2,s),{v:p,l:m}=n.decode(2,u);if(m.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(c),s:t.decode(p)}},hexFromSig(r){let{_tlv:e,_int:t}=Br,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),s=n+i;return e.encode(48,s)}},Lr=BigInt(0),wt=BigInt(1),pA=BigInt(2),Pd=BigInt(3),mA=BigInt(4);function l1(r){let e=c1(r),{Fp:t}=e,n=Yr(e.n,e.nBitLength),i=e.toBytes||((I,x,B)=>{let U=x.toAffine();return kr(Uint8Array.from([4]),t.toBytes(U.x),t.toBytes(U.y))}),s=e.fromBytes||(I=>{let x=I.subarray(1),B=t.fromBytes(x.subarray(0,t.BYTES)),U=t.fromBytes(x.subarray(t.BYTES,2*t.BYTES));return{x:B,y:U}});function o(I){let{a:x,b:B}=e,U=t.sqr(I),L=t.mul(U,I);return t.add(t.add(L,t.mul(I,x)),B)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function c(I){return Fi(I,wt,e.n)}function u(I){let{allowedPrivateKeyLengths:x,nByteLength:B,wrapPrivateKey:U,n:L}=e;if(x&&typeof I!="bigint"){if(Hr(I)&&(I=Ir(I)),typeof I!="string"||!x.includes(I.length))throw new Error("invalid private key");I=I.padStart(B*2,"0")}let F;try{F=typeof I=="bigint"?I:Or(We("private key",I,B))}catch{throw new Error("invalid private key, expected hex or "+B+" bytes, got "+typeof I)}return U&&(F=Oe(F,L)),$t("private key",F,wt,L),F}function p(I){if(!(I instanceof A))throw new Error("ProjectivePoint expected")}let m=Pn((I,x)=>{let{px:B,py:U,pz:L}=I;if(t.eql(L,t.ONE))return{x:B,y:U};let F=I.is0();x==null&&(x=F?t.ONE:t.inv(L));let te=t.mul(B,x),H=t.mul(U,x),Z=t.mul(L,x);if(F)return{x:t.ZERO,y:t.ZERO};if(!t.eql(Z,t.ONE))throw new Error("invZ was invalid");return{x:te,y:H}}),b=Pn(I=>{if(I.is0()){if(e.allowInfinityPoint&&!t.is0(I.py))return;throw new Error("bad point: ZERO")}let{x,y:B}=I.toAffine();if(!t.isValid(x)||!t.isValid(B))throw new Error("bad point: x or y not FE");let U=t.sqr(B),L=o(x);if(!t.eql(U,L))throw new Error("bad point: equation left != right");if(!I.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class A{constructor(x,B,U){if(this.px=x,this.py=B,this.pz=U,x==null||!t.isValid(x))throw new Error("x required");if(B==null||!t.isValid(B))throw new Error("y required");if(U==null||!t.isValid(U))throw new Error("z required");Object.freeze(this)}static fromAffine(x){let{x:B,y:U}=x||{};if(!x||!t.isValid(B)||!t.isValid(U))throw new Error("invalid affine point");if(x instanceof A)throw new Error("projective point not allowed");let L=F=>t.eql(F,t.ZERO);return L(B)&&L(U)?A.ZERO:new A(B,U,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){let B=t.invertBatch(x.map(U=>U.pz));return x.map((U,L)=>U.toAffine(B[L])).map(A.fromAffine)}static fromHex(x){let B=A.fromAffine(s(We("pointHex",x)));return B.assertValidity(),B}static fromPrivateKey(x){return A.BASE.multiply(u(x))}static msm(x,B){return Qs(A,n,x,B)}_setWindowSize(x){T.setWindowSize(this,x)}assertValidity(){b(this)}hasEvenY(){let{y:x}=this.toAffine();if(t.isOdd)return!t.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){p(x);let{px:B,py:U,pz:L}=this,{px:F,py:te,pz:H}=x,Z=t.eql(t.mul(B,H),t.mul(F,L)),ee=t.eql(t.mul(U,H),t.mul(te,L));return Z&&ee}negate(){return new A(this.px,t.neg(this.py),this.pz)}double(){let{a:x,b:B}=e,U=t.mul(B,Pd),{px:L,py:F,pz:te}=this,H=t.ZERO,Z=t.ZERO,ee=t.ZERO,Y=t.mul(L,L),Ie=t.mul(F,F),re=t.mul(te,te),fe=t.mul(L,F);return fe=t.add(fe,fe),ee=t.mul(L,te),ee=t.add(ee,ee),H=t.mul(x,ee),Z=t.mul(U,re),Z=t.add(H,Z),H=t.sub(Ie,Z),Z=t.add(Ie,Z),Z=t.mul(H,Z),H=t.mul(fe,H),ee=t.mul(U,ee),re=t.mul(x,re),fe=t.sub(Y,re),fe=t.mul(x,fe),fe=t.add(fe,ee),ee=t.add(Y,Y),Y=t.add(ee,Y),Y=t.add(Y,re),Y=t.mul(Y,fe),Z=t.add(Z,Y),re=t.mul(F,te),re=t.add(re,re),Y=t.mul(re,fe),H=t.sub(H,Y),ee=t.mul(re,Ie),ee=t.add(ee,ee),ee=t.add(ee,ee),new A(H,Z,ee)}add(x){p(x);let{px:B,py:U,pz:L}=this,{px:F,py:te,pz:H}=x,Z=t.ZERO,ee=t.ZERO,Y=t.ZERO,Ie=e.a,re=t.mul(e.b,Pd),fe=t.mul(B,F),v=t.mul(U,te),a=t.mul(L,H),l=t.add(B,U),d=t.add(F,te);l=t.mul(l,d),d=t.add(fe,v),l=t.sub(l,d),d=t.add(B,L);let h=t.add(F,H);return d=t.mul(d,h),h=t.add(fe,a),d=t.sub(d,h),h=t.add(U,L),Z=t.add(te,H),h=t.mul(h,Z),Z=t.add(v,a),h=t.sub(h,Z),Y=t.mul(Ie,d),Z=t.mul(re,a),Y=t.add(Z,Y),Z=t.sub(v,Y),Y=t.add(v,Y),ee=t.mul(Z,Y),v=t.add(fe,fe),v=t.add(v,fe),a=t.mul(Ie,a),d=t.mul(re,d),v=t.add(v,a),a=t.sub(fe,a),a=t.mul(Ie,a),d=t.add(d,a),fe=t.mul(v,d),ee=t.add(ee,fe),fe=t.mul(h,d),Z=t.mul(l,Z),Z=t.sub(Z,fe),fe=t.mul(l,v),Y=t.mul(h,Y),Y=t.add(Y,fe),new A(Z,ee,Y)}subtract(x){return this.add(x.negate())}is0(){return this.equals(A.ZERO)}wNAF(x){return T.wNAFCached(this,x,A.normalizeZ)}multiplyUnsafe(x){let{endo:B,n:U}=e;$t("scalar",x,Lr,U);let L=A.ZERO;if(x===Lr)return L;if(this.is0()||x===wt)return this;if(!B||T.hasPrecomputes(this))return T.wNAFCachedUnsafe(this,x,A.normalizeZ);let{k1neg:F,k1:te,k2neg:H,k2:Z}=B.splitScalar(x),ee=L,Y=L,Ie=this;for(;te>Lr||Z>Lr;)te&wt&&(ee=ee.add(Ie)),Z&wt&&(Y=Y.add(Ie)),Ie=Ie.double(),te>>=wt,Z>>=wt;return F&&(ee=ee.negate()),H&&(Y=Y.negate()),Y=new A(t.mul(Y.px,B.beta),Y.py,Y.pz),ee.add(Y)}multiply(x){let{endo:B,n:U}=e;$t("scalar",x,wt,U);let L,F;if(B){let{k1neg:te,k1:H,k2neg:Z,k2:ee}=B.splitScalar(x),{p:Y,f:Ie}=this.wNAF(H),{p:re,f:fe}=this.wNAF(ee);Y=T.constTimeNegate(te,Y),re=T.constTimeNegate(Z,re),re=new A(t.mul(re.px,B.beta),re.py,re.pz),L=Y.add(re),F=Ie.add(fe)}else{let{p:te,f:H}=this.wNAF(x);L=te,F=H}return A.normalizeZ([L,F])[0]}multiplyAndAddUnsafe(x,B,U){let L=A.BASE,F=(H,Z)=>Z===Lr||Z===wt||!H.equals(L)?H.multiplyUnsafe(Z):H.multiply(Z),te=F(this,B).add(F(x,U));return te.is0()?void 0:te}toAffine(x){return m(this,x)}isTorsionFree(){let{h:x,isTorsionFree:B}=e;if(x===wt)return!0;if(B)return B(A,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:x,clearCofactor:B}=e;return x===wt?this:B?B(A,this):this.multiplyUnsafe(e.h)}toRawBytes(x=!0){return or("isCompressed",x),this.assertValidity(),i(A,this,x)}toHex(x=!0){return or("isCompressed",x),Ir(this.toRawBytes(x))}}A.BASE=new A(e.Gx,e.Gy,t.ONE),A.ZERO=new A(t.ZERO,t.ONE,t.ZERO);let S=e.nBitLength,T=Js(A,e.endo?Math.ceil(S/2):S);return{CURVE:e,ProjectivePoint:A,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:c}}function d1(r){let e=$i(r);return pr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Md(r){let e=d1(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(a){return Oe(a,n)}function c(a){return Ys(a,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:p,weierstrassEquation:m,isWithinCurveOrder:b}=l1({...e,toBytes(a,l,d){let h=l.toAffine(),g=t.toBytes(h.x),w=kr;return or("isCompressed",d),d?w(Uint8Array.from([l.hasEvenY()?2:3]),g):w(Uint8Array.from([4]),g,t.toBytes(h.y))},fromBytes(a){let l=a.length,d=a[0],h=a.subarray(1);if(l===i&&(d===2||d===3)){let g=Or(h);if(!Fi(g,wt,t.ORDER))throw new Error("Point is not on curve");let w=m(g),R;try{R=t.sqrt(w)}catch(_){let C=_ instanceof Error?": "+_.message:"";throw new Error("Point is not on curve"+C)}let y=(R&wt)===wt;return(d&1)===1!==y&&(R=t.neg(R)),{x:g,y:R}}else if(l===s&&d===4){let g=t.fromBytes(h.subarray(0,t.BYTES)),w=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:g,y:w}}else{let g=i,w=s;throw new Error("invalid Point, expected length of "+g+", or uncompressed "+w+", got "+l)}}}),A=a=>Ir(Zr(a,e.nByteLength));function S(a){let l=n>>wt;return a>l}function T(a){return S(a)?o(-a):a}let I=(a,l,d)=>Or(a.slice(l,d));class x{constructor(l,d,h){this.r=l,this.s=d,this.recovery=h,this.assertValidity()}static fromCompact(l){let d=e.nByteLength;return l=We("compactSignature",l,d*2),new x(I(l,0,d),I(l,d,2*d))}static fromDER(l){let{r:d,s:h}=Br.toSig(We("DER",l));return new x(d,h)}assertValidity(){$t("r",this.r,wt,n),$t("s",this.s,wt,n)}addRecoveryBit(l){return new x(this.r,this.s,l)}recoverPublicKey(l){let{r:d,s:h,recovery:g}=this,w=H(We("msgHash",l));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let R=g===2||g===3?d+e.n:d;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let y=(g&1)===0?"02":"03",f=u.fromHex(y+A(R)),_=c(R),C=o(-w*_),D=o(h*_),V=u.BASE.multiplyAndAddUnsafe(f,C,D);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ln(this.toDERHex())}toDERHex(){return Br.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ln(this.toCompactHex())}toCompactHex(){return A(this.r)+A(this.s)}}let B={isValidPrivateKey(a){try{return p(a),!0}catch{return!1}},normPrivateKeyToScalar:p,randomPrivateKey:()=>{let a=gc(e.n);return pl(e.randomBytes(a),e.n)},precompute(a=8,l=u.BASE){return l._setWindowSize(a),l.multiply(BigInt(3)),l}};function U(a,l=!0){return u.fromPrivateKey(a).toRawBytes(l)}function L(a){let l=Hr(a),d=typeof a=="string",h=(l||d)&&a.length;return l?h===i||h===s:d?h===2*i||h===2*s:a instanceof u}function F(a,l,d=!0){if(L(a))throw new Error("first arg must be private key");if(!L(l))throw new Error("second arg must be public key");return u.fromHex(l).multiply(p(a)).toRawBytes(d)}let te=e.bits2int||function(a){if(a.length>8192)throw new Error("input is too large");let l=Or(a),d=a.length*8-e.nBitLength;return d>0?l>>BigInt(d):l},H=e.bits2int_modN||function(a){return o(te(a))},Z=Vi(e.nBitLength);function ee(a){return $t("num < 2^"+e.nBitLength,a,Lr,Z),Zr(a,e.nByteLength)}function Y(a,l,d=Ie){if(["recovered","canonical"].some(ie=>ie in d))throw new Error("sign() legacy options not supported");let{hash:h,randomBytes:g}=e,{lowS:w,prehash:R,extraEntropy:y}=d;w==null&&(w=!0),a=We("msgHash",a),Cd(d),R&&(a=We("prehashed msgHash",h(a)));let f=H(a),_=p(l),C=[ee(_),ee(f)];if(y!=null&&y!==!1){let ie=y===!0?g(t.BYTES):y;C.push(We("extraEntropy",ie))}let D=kr(...C),V=f;function X(ie){let ue=te(ie);if(!b(ue))return;let Le=c(ue),he=u.BASE.multiply(ue).toAffine(),me=o(he.x);if(me===Lr)return;let jt=o(Le*o(V+me*_));if(jt===Lr)return;let Ae=(he.x===me?0:2)|Number(he.y&wt),Ne=jt;return w&&S(jt)&&(Ne=T(jt),Ae^=1),new x(me,Ne,Ae)}return{seed:D,k2sig:X}}let Ie={lowS:e.lowS,prehash:!1},re={lowS:e.lowS,prehash:!1};function fe(a,l,d=Ie){let{seed:h,k2sig:g}=Y(a,l,d),w=e;return dc(w.hash.outputLen,w.nByteLength,w.hmac)(h,g)}u.BASE._setWindowSize(8);function v(a,l,d,h=re){let g=a;l=We("msgHash",l),d=We("publicKey",d);let{lowS:w,prehash:R,format:y}=h;if(Cd(h),"strict"in h)throw new Error("options.strict was renamed to lowS");if(y!==void 0&&y!=="compact"&&y!=="der")throw new Error("format must be compact or der");let f=typeof g=="string"||Hr(g),_=!f&&!y&&typeof g=="object"&&g!==null&&typeof g.r=="bigint"&&typeof g.s=="bigint";if(!f&&!_)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let C,D;try{if(_&&(C=new x(g.r,g.s)),f){try{y!=="compact"&&(C=x.fromDER(g))}catch(Ae){if(!(Ae instanceof Br.Err))throw Ae}!C&&y!=="der"&&(C=x.fromCompact(g))}D=u.fromHex(d)}catch{return!1}if(!C||w&&C.hasHighS())return!1;R&&(l=e.hash(l));let{r:V,s:X}=C,ie=H(l),ue=c(X),Le=o(ie*ue),he=o(V*ue),me=u.BASE.multiplyAndAddUnsafe(D,Le,he)?.toAffine();return me?o(me.x)===V:!1}return{CURVE:e,getPublicKey:U,getSharedSecret:F,sign:fe,verify:v,ProjectivePoint:u,Signature:x,utils:B}}function h1(r){return{hash:r,hmac:(e,...t)=>nu(r,e,ec(...t)),randomBytes:js}}function Ud(r,e){let t=n=>Md({...r,...h1(n)});return{...t(e),create:t}}var Fd=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Dd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),p1=BigInt(1),su=BigInt(2),zd=(r,e)=>(r+e/su)/e;function m1(r){let e=Fd,t=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),c=BigInt(44),u=BigInt(88),p=r*r*r%e,m=p*p*r%e,b=Pe(m,t,e)*m%e,A=Pe(b,t,e)*m%e,S=Pe(A,su,e)*p%e,T=Pe(S,i,e)*S%e,I=Pe(T,s,e)*T%e,x=Pe(I,c,e)*I%e,B=Pe(x,u,e)*x%e,U=Pe(B,c,e)*I%e,L=Pe(U,t,e)*m%e,F=Pe(L,o,e)*T%e,te=Pe(F,n,e)*p%e,H=Pe(te,su,e);if(!ou.eql(ou.sqr(H),r))throw new Error("Cannot find square root");return H}var ou=Yr(Fd,void 0,void 0,{sqrt:m1}),ns=Ud({a:BigInt(0),b:BigInt(7),Fp:ou,n:Dd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Dd,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-p1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),c=zd(s*r,e),u=zd(-n*r,e),p=Oe(r-c*t-u*i,e),m=Oe(-c*n-u*s,e),b=p>o,A=m>o;if(b&&(p=e-p),A&&(m=e-m),p>o||m>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:b,k1:p,k2neg:A,k2:m}}}},Wi),SA=BigInt(0);var AA=ns.ProjectivePoint;var CA=Un.utils.randomPrivateKey,Vd=()=>{let r=Un.utils.randomPrivateKey(),e=gu(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},gu=Un.getPublicKey;function $d(r){try{return Un.ExtendedPoint.fromHex(r),!0}catch{return!1}}var Tu=(r,e)=>Un.sign(r,e.slice(0,32)),g1=Un.verify,_e=r=>ae.Buffer.isBuffer(r)?r:r instanceof Uint8Array?ae.Buffer.from(r.buffer,r.byteOffset,r.byteLength):ae.Buffer.from(r),yu=class{constructor(e){Object.assign(this,e)}encode(){return ae.Buffer.from((0,Ei.serialize)($o,this))}static decode(e){return(0,Ei.deserialize)($o,this,e)}static decodeUnchecked(e){return(0,Ei.deserializeUnchecked)($o,this,e)}};var $o=new Map,ah,y1=32,fn=32;function _1(r){return r._bn!==void 0}var Wd=1,ce=class r extends yu{constructor(e){if(super({}),this._bn=void 0,_1(e))this._bn=e._bn;else{if(typeof e=="string"){let t=vt.default.decode(e);if(t.length!=fn)throw new Error("Invalid public key input");this._bn=new mu.default(t)}else this._bn=new mu.default(e);if(this._bn.byteLength()>fn)throw new Error("Invalid public key input")}}static unique(){let e=new r(Wd);return Wd+=1,new r(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return vt.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(ae.Buffer);if(e.length===fn)return e;let t=ae.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,n){let i=ae.Buffer.concat([e.toBuffer(),ae.Buffer.from(t),n.toBuffer()]),s=Wi(i);return new r(s)}static createProgramAddressSync(e,t){let n=ae.Buffer.alloc(0);e.forEach(function(s){if(s.length>y1)throw new TypeError("Max seed length exceeded");n=ae.Buffer.concat([n,_e(s)])}),n=ae.Buffer.concat([n,t.toBuffer(),ae.Buffer.from("ProgramDerivedAddress")]);let i=Wi(n);if($d(i))throw new Error("Invalid seeds, address must fall off the curve");return new r(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,i;for(;n!=0;){try{let s=e.concat(ae.Buffer.from([n]));i=this.createProgramAddressSync(s,t)}catch(s){if(s instanceof TypeError)throw s;n--;continue}return[i,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){let t=new r(e);return $d(t.toBytes())}};ah=ce;ce.default=new ah("11111111111111111111111111111111");$o.set(ce,{kind:"struct",fields:[["_bn","u256"]]});var PA=new ce("BPFLoader1111111111111111111111111111111111"),jn=1232,Nu=127,Wo=64,qo=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(qo.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});var jo=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}};Object.defineProperty(jo.prototype,"name",{value:"TransactionExpiredTimeoutError"});var qn=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}};Object.defineProperty(qn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});var wi=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");let n=new Map;this.keySegments().flat().forEach((s,o)=>{n.set(s.toBase58(),o)});let i=s=>{let o=n.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}},ye=(r="publicKey")=>E.blob(32,r),b1=(r="signature")=>E.blob(64,r),bi=(r="string")=>{let e=E.struct([E.u32("length"),E.u32("lengthPadding"),E.blob(E.offset(E.u32(),-8),"chars")],r),t=e.decode.bind(e),n=e.encode.bind(e),i=e;return i.decode=(s,o)=>t(s,o).chars.toString(),i.encode=(s,o,c)=>{let u={chars:ae.Buffer.from(s,"utf8")};return n(u,o,c)},i.alloc=s=>E.u32().span+E.u32().span+ae.Buffer.from(s,"utf8").length,i},w1=(r="authorized")=>E.struct([ye("staker"),ye("withdrawer")],r),v1=(r="lockup")=>E.struct([E.ns64("unixTimestamp"),E.ns64("epoch"),ye("custodian")],r),E1=(r="voteInit")=>E.struct([ye("nodePubkey"),ye("authorizedVoter"),ye("authorizedWithdrawer"),E.u8("commission")],r),R1=(r="voteAuthorizeWithSeedArgs")=>E.struct([E.u32("voteAuthorizationType"),ye("currentAuthorityDerivedKeyOwnerPubkey"),bi("currentAuthorityDerivedKeySeed"),ye("newAuthorized")],r);function ch(r,e){let t=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){let s=e[i.property];if(Array.isArray(s))return s.length*t(i.elementLayout)}else if("fields"in i)return ch({layout:i},e[i.property]);return 0},n=0;return r.layout.fields.forEach(i=>{n+=t(i)}),n}function Zt(r){let e=0,t=0;for(;;){let n=r.shift();if(e|=(n&127)<<t*7,t+=1,(n&128)===0)break}return e}function Yt(r,e){let t=e;for(;;){let n=t&127;if(t>>=7,t==0){r.push(n);break}else n|=128,r.push(n)}}function xe(r,e){if(!r)throw new Error(e||"Assertion failed")}var Ko=class r{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){let n=new Map,i=o=>{let c=o.toBase58(),u=n.get(c);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(c,u)),u},s=i(t);s.isSigner=!0,s.isWritable=!0;for(let o of e){i(o.programId).isInvoked=!0;for(let c of o.keys){let u=i(c.pubkey);u.isSigner||=c.isSigner,u.isWritable||=c.isWritable}}return new r(t,n)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];xe(e.length<=256,"Max static account keys length exceeded");let t=e.filter(([,u])=>u.isSigner&&u.isWritable),n=e.filter(([,u])=>u.isSigner&&!u.isWritable),i=e.filter(([,u])=>!u.isSigner&&u.isWritable),s=e.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:s.length};{xe(t.length>0,"Expected at least one writable signer key");let[u]=t[0];xe(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let c=[...t.map(([u])=>new ce(u)),...n.map(([u])=>new ce(u)),...i.map(([u])=>new ce(u)),...s.map(([u])=>new ce(u))];return[o,c]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&i.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:i},{writable:n,readonly:s}]}drainKeysFoundInLookupTable(e,t){let n=new Array,i=new Array;for(let[s,o]of this.keyMetaMap.entries())if(t(o)){let c=new ce(s),u=e.findIndex(p=>p.equals(c));u>=0&&(xe(u<256,"Max lookup table index exceeded"),n.push(u),i.push(c),this.keyMetaMap.delete(s))}return[n,i]}},uh="Reached end of buffer unexpectedly";function Pr(r){if(r.length===0)throw new Error(uh);return r.shift()}function Xt(r,...e){let[t]=e;if(e.length===2?t+(e[1]??0)>r.length:t>=r.length)throw new Error(uh);return r.splice(...e)}var ln=class r{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(t=>new ce(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:vt.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new wi(this.staticAccountKeys)}static compile(e){let t=Ko.compile(e.instructions,e.payerKey),[n,i]=t.getMessageComponents(),o=new wi(i).compileInstructions(e.instructions).map(c=>({programIdIndex:c.programIdIndex,accounts:c.accountKeyIndexes,data:vt.default.encode(c.data)}));return new r({header:n,accountKeys:i,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){let n=e-t,s=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<s}else{let n=t-this.header.numReadonlySignedAccounts;return e<n}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];Yt(t,e);let n=this.instructions.map(b=>{let{accounts:A,programIdIndex:S}=b,T=Array.from(vt.default.decode(b.data)),I=[];Yt(I,A.length);let x=[];return Yt(x,T.length),{programIdIndex:S,keyIndicesCount:ae.Buffer.from(I),keyIndices:A,dataLength:ae.Buffer.from(x),data:T}}),i=[];Yt(i,n.length);let s=ae.Buffer.alloc(jn);ae.Buffer.from(i).copy(s);let o=i.length;n.forEach(b=>{let S=E.struct([E.u8("programIdIndex"),E.blob(b.keyIndicesCount.length,"keyIndicesCount"),E.seq(E.u8("keyIndex"),b.keyIndices.length,"keyIndices"),E.blob(b.dataLength.length,"dataLength"),E.seq(E.u8("userdatum"),b.data.length,"data")]).encode(b,s,o);o+=S}),s=s.slice(0,o);let c=E.struct([E.blob(1,"numRequiredSignatures"),E.blob(1,"numReadonlySignedAccounts"),E.blob(1,"numReadonlyUnsignedAccounts"),E.blob(t.length,"keyCount"),E.seq(ye("key"),e,"keys"),ye("recentBlockhash")]),u={numRequiredSignatures:ae.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:ae.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:ae.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:ae.Buffer.from(t),keys:this.accountKeys.map(b=>_e(b.toBytes())),recentBlockhash:vt.default.decode(this.recentBlockhash)},p=ae.Buffer.alloc(2048),m=c.encode(u,p);return s.copy(p,m),p.slice(0,m+s.length)}static from(e){let t=[...e],n=Pr(t);if(n!==(n&Nu))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let i=Pr(t),s=Pr(t),o=Zt(t),c=[];for(let A=0;A<o;A++){let S=Xt(t,0,fn);c.push(new ce(ae.Buffer.from(S)))}let u=Xt(t,0,fn),p=Zt(t),m=[];for(let A=0;A<p;A++){let S=Pr(t),T=Zt(t),I=Xt(t,0,T),x=Zt(t),B=Xt(t,0,x),U=vt.default.encode(ae.Buffer.from(B));m.push({programIdIndex:S,accounts:I,data:U})}let b={header:{numRequiredSignatures:n,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:vt.default.encode(ae.Buffer.from(u)),accountKeys:c,instructions:m};return new r(b)}},Ho=class r{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(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;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");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=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 wi(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(e>=n){let i=e-n,s=this.addressTableLookups.reduce((o,c)=>o+c.writableIndexes.length,0);return i<s}else if(e>=this.header.numRequiredSignatures){let i=e-t,o=n-t-this.header.numReadonlyUnsignedAccounts;return i<o}else{let i=t-this.header.numReadonlySignedAccounts;return e<i}}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let i=e.find(s=>s.key.equals(n.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let s of n.writableIndexes)if(s<i.state.addresses.length)t.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`);for(let s of n.readonlyIndexes)if(s<i.state.addresses.length)t.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){let t=Ko.compile(e.instructions,e.payerKey),n=new Array,i={writable:new Array,readonly:new Array},s=e.addressLookupTableAccounts||[];for(let m of s){let b=t.extractTableLookup(m);if(b!==void 0){let[A,{writable:S,readonly:T}]=b;n.push(A),i.writable.push(...S),i.readonly.push(...T)}}let[o,c]=t.getMessageComponents(),p=new wi(c,i).compileInstructions(e.instructions);return new r({header:o,staticAccountKeys:c,recentBlockhash:e.recentBlockhash,compiledInstructions:p,addressTableLookups:n})}serialize(){let e=Array();Yt(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=Array();Yt(n,this.compiledInstructions.length);let i=this.serializeAddressTableLookups(),s=Array();Yt(s,this.addressTableLookups.length);let o=E.struct([E.u8("prefix"),E.struct([E.u8("numRequiredSignatures"),E.u8("numReadonlySignedAccounts"),E.u8("numReadonlyUnsignedAccounts")],"header"),E.blob(e.length,"staticAccountKeysLength"),E.seq(ye(),this.staticAccountKeys.length,"staticAccountKeys"),ye("recentBlockhash"),E.blob(n.length,"instructionsLength"),E.blob(t.length,"serializedInstructions"),E.blob(s.length,"addressTableLookupsLength"),E.blob(i.length,"serializedAddressTableLookups")]),c=new Uint8Array(jn),p=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(m=>m.toBytes()),recentBlockhash:vt.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},c);return c.slice(0,p)}serializeInstructions(){let e=0,t=new Uint8Array(jn);for(let n of this.compiledInstructions){let i=Array();Yt(i,n.accountKeyIndexes.length);let s=Array();Yt(s,n.data.length);let o=E.struct([E.u8("programIdIndex"),E.blob(i.length,"encodedAccountKeyIndexesLength"),E.seq(E.u8(),n.accountKeyIndexes.length,"accountKeyIndexes"),E.blob(s.length,"encodedDataLength"),E.blob(n.data.length,"data")]);e+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(jn);for(let n of this.addressTableLookups){let i=Array();Yt(i,n.writableIndexes.length);let s=Array();Yt(s,n.readonlyIndexes.length);let o=E.struct([ye("accountKey"),E.blob(i.length,"encodedWritableIndexesLength"),E.seq(E.u8(),n.writableIndexes.length,"writableIndexes"),E.blob(s.length,"encodedReadonlyIndexesLength"),E.seq(E.u8(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e],n=Pr(t),i=n&Nu;xe(n!==i,"Expected versioned message but received legacy message");let s=i;xe(s===0,`Expected versioned message with version 0 but found version ${s}`);let o={numRequiredSignatures:Pr(t),numReadonlySignedAccounts:Pr(t),numReadonlyUnsignedAccounts:Pr(t)},c=[],u=Zt(t);for(let T=0;T<u;T++)c.push(new ce(Xt(t,0,fn)));let p=vt.default.encode(Xt(t,0,fn)),m=Zt(t),b=[];for(let T=0;T<m;T++){let I=Pr(t),x=Zt(t),B=Xt(t,0,x),U=Zt(t),L=new Uint8Array(Xt(t,0,U));b.push({programIdIndex:I,accountKeyIndexes:B,data:L})}let A=Zt(t),S=[];for(let T=0;T<A;T++){let I=new ce(Xt(t,0,fn)),x=Zt(t),B=Xt(t,0,x),U=Zt(t),L=Xt(t,0,U);S.push({accountKey:I,writableIndexes:B,readonlyIndexes:L})}return new r({header:o,staticAccountKeys:c,recentBlockhash:p,compiledInstructions:b,addressTableLookups:S})}},fh={deserializeMessageVersion(r){let e=r[0],t=e&Nu;return t===e?"legacy":t},deserialize:r=>{let e=fh.deserializeMessageVersion(r);if(e==="legacy")return ln.from(r);if(e===0)return Ho.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},cn=function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r}({}),S1=ae.Buffer.alloc(Wo).fill(0),Te=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=ae.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:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},Se=class r{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")){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}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(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new Te(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let I=0;I<t.length;I++)if(t[I].programId===void 0)throw new Error(`Transaction instruction index ${I} has undefined program id`);let i=[],s=[];t.forEach(I=>{I.keys.forEach(B=>{s.push({...B})});let x=I.programId.toString();i.includes(x)||i.push(x)}),i.forEach(I=>{s.push({pubkey:new ce(I),isSigner:!1,isWritable:!1})});let o=[];s.forEach(I=>{let x=I.pubkey.toString(),B=o.findIndex(U=>U.pubkey.toString()===x);B>-1?(o[B].isWritable=o[B].isWritable||I.isWritable,o[B].isSigner=o[B].isSigner||I.isSigner):o.push(I)}),o.sort(function(I,x){if(I.isSigner!==x.isSigner)return I.isSigner?-1:1;if(I.isWritable!==x.isWritable)return I.isWritable?-1:1;let B={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return I.pubkey.toBase58().localeCompare(x.pubkey.toBase58(),"en",B)});let c=o.findIndex(I=>I.pubkey.equals(n));if(c>-1){let[I]=o.splice(c,1);I.isSigner=!0,I.isWritable=!0,o.unshift(I)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let I of this.signatures){let x=o.findIndex(B=>B.pubkey.equals(I.publicKey));if(x>-1)o[x].isSigner||(o[x].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: ${I.publicKey.toString()}`)}let u=0,p=0,m=0,b=[],A=[];o.forEach(({pubkey:I,isSigner:x,isWritable:B})=>{x?(b.push(I.toString()),u+=1,B||(p+=1)):(A.push(I.toString()),B||(m+=1))});let S=b.concat(A),T=t.map(I=>{let{data:x,programId:B}=I;return{programIdIndex:S.indexOf(B.toString()),accounts:I.keys.map(U=>S.indexOf(U.pubkey.toString())),data:vt.default.encode(x)}});return T.forEach(I=>{xe(I.programIdIndex>=0),I.accounts.forEach(x=>xe(x>=0))}),new ln({header:{numRequiredSignatures:u,numReadonlySignedAccounts:p,numReadonlyUnsignedAccounts:m},accountKeys:S,recentBlockhash:e,instructions:T})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((i,s)=>t[s].equals(i.publicKey))||(this.signatures=t.map(n=>({signature:null,publicKey:n}))),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");let t=new Set;this.signatures=e.filter(n=>{let i=n.toString();return t.has(i)?!1:(t.add(i),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...e){if(e.length===0)throw new Error("No signers");let t=new Set,n=[];for(let s of e){let o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}this.signatures=n.map(s=>({signature:null,publicKey:s.publicKey}));let i=this._compile();this._partialSign(i,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");let t=new Set,n=[];for(let s of e){let o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}let i=this._compile();this._partialSign(i,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(i=>{let s=Tu(n,i.secretKey);this._addSignature(i.publicKey,_e(s))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){xe(t.length===64);let n=this.signatures.findIndex(i=>e.equals(i.publicKey));if(n<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=ae.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:i,publicKey:s}of this.signatures)i===null?t&&(n.missing||=[]).push(s):g1(i,e,s.toBytes())||(n.invalid||=[]).push(s);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(n){let s=this._getMessageSignednessErrors(i,t);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[wy]:"No signature verification implementation could be found.",[vy]:"No key generation implementation could be found.",[Ey]:"No signing implementation could be found.",[Ry]:"No key export implementation could be found.",[Bg]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[kb]:"Transaction processing left an account with an outstanding borrowed reference",[pb]:"Account in use",[mb]:"Account loaded twice",[gb]:"Attempt to debit an account but found no record of a prior credit.",[Mb]:"Transaction loads an address table account that doesn't exist",[wb]:"This transaction has already been processed",[vb]:"Blockhash not found",[Eb]:"Loader call chain is too deep",[Ob]:"Transactions are currently disabled due to cluster maintenance",[qb]:"Transaction contains a duplicate instruction ($index) that is not allowed",[_b]:"Insufficient funds for fee",[Wb]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[bb]:"This account may not be used to pay transaction fees",[Sb]:"Transaction contains an invalid account reference",[Db]:"Transaction loads an address table account with invalid data",[zb]:"Transaction address table lookup uses an invalid index",[Ub]:"Transaction loads an address table account with an invalid owner",[Kb]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[xb]:"This program may not be used for executing instructions",[Fb]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Bb]:"Transaction loads a writable account that cannot be written",[jb]:"Transaction exceeded max loaded accounts data size cap",[Rb]:"Transaction requires a fee but has no signature present",[yb]:"Attempt to load a program that does not exist",[Gb]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Hb]:"ResanitizationNeeded",[Ib]:"Transaction failed to sanitize accounts offsets correctly",[Ab]:"Transaction did not pass signature verification",[Pb]:"Transaction locked too many accounts",[Zb]:"Sum of account balances before and after transaction do not match",[hb]:"The transaction failed with the error `$errorName`",[Nb]:"Transaction version is unsupported",[Cb]:"Transaction would exceed account data limit within the block",[Vb]:"Transaction would exceed total account data limit",[Lb]:"Transaction would exceed max account limit within the block",[Tb]:"Transaction would exceed max Block Cost Limit",[$b]:"Transaction would exceed max Vote Cost Limit",[cb]:"Attempted to sign a transaction with an address that is not a signer for it",[nb]:"Transaction is missing an address at index: $index.",[ub]:"Transaction has no expected signers therefore it cannot be encoded",[Z_]:"Transaction does not have a blockhash lifetime",[Y_]:"Transaction is not a durable nonce transaction",[J_]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Q_]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[tb]:"No fee payer set in CompiledTransaction",[eb]:"Could not find program address at index $index",[lb]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[db]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[ib]:"Transaction is missing a fee payer.",[sb]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[ab]:"Transaction first instruction is not advance nonce account instruction.",[ob]:"Transaction with no instructions cannot be durable nonce transaction.",[H_]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[G_]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[fb]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[rb]:"Transaction is missing signatures for addresses: $addresses.",[X_]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"};function Rw(r,e={}){{let t=`Solana error #${r}; Decode this error by running \`npx @solana/errors decode -- ${r}`;return Object.keys(e).length&&(t+=` '${Ew(e)}'`),`${t}\``}}var tn=class extends Error{cause=this.cause;context;constructor(...[r,e]){let t,n;if(e){let{cause:s,...o}=e;s&&(n={cause:s}),Object.keys(o).length>0&&(t=o)}let i=Rw(r,t);super(i,n),this.context={__code:r,...t},this.name="SolanaError"}};function Sw(r,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(r)}function Kl(r){return Object.freeze({...r,encode:e=>{let t=new Uint8Array(Sw(e,r));return r.write(e,t,0),t}})}function Hl(r){return Object.freeze({...r,decode:(e,t=0)=>r.read(e,t)[0]})}function _i(r){return"fixedSize"in r&&typeof r.fixedSize=="number"}function Gl(r,e){if(_i(r)!==_i(e))throw new tn(Vc);if(_i(r)&&_i(e)&&r.fixedSize!==e.fixedSize)throw new tn(qc,{decoderFixedSize:e.fixedSize,encoderFixedSize:r.fixedSize});if(!_i(r)&&!_i(e)&&r.maxSize!==e.maxSize)throw new tn(Wc,{decoderMaxSize:e.maxSize,encoderMaxSize:r.maxSize});return{...e,...r,decode:e.decode,encode:r.encode,read:e.read,write:r.write}}function Zl(r,e,t=0){if(e.length-t<=0)throw new tn(Fc,{codecDescription:r})}function Yl(r,e,t,n=0){let i=t.length-n;if(i<e)throw new tn($c,{bytesLength:i,codecDescription:r,expected:e})}function Aw(r,e,t,n){if(n<e||n>t)throw new tn(jc,{codecDescription:r,max:t,min:e,value:n})}function Xl(r){return r?.endian!==1}function xw(r){return Kl({fixedSize:r.size,write(e,t,n){r.range&&Aw(r.name,r.range[0],r.range[1],e);let i=new ArrayBuffer(r.size);return r.set(new DataView(i),e,Xl(r.config)),t.set(new Uint8Array(i),n),n+r.size}})}function Iw(r){return Hl({fixedSize:r.size,read(e,t=0){Zl(r.name,e,t),Yl(r.name,r.size,e,t);let n=new DataView(Ow(e,t,r.size));return[r.get(n,Xl(r.config)),t+r.size]}})}function Ow(r,e,t){let n=r.byteOffset+(e??0),i=t??r.byteLength;return r.buffer.slice(n,n+i)}var Kc=(r={})=>xw({config:r,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),kw=(r={})=>Iw({config:r,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),Jl=(r={})=>Gl(Kc(r),kw(r));var Hc=class extends TypeError{constructor(e,t){let n,{message:i,explanation:s,...o}=e,{path:c}=e,u=c.length===0?i:`At path: ${c.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}};function Tw(r){return Yi(r)&&typeof r[Symbol.iterator]=="function"}function Yi(r){return typeof r=="object"&&r!=null}function To(r){return Yi(r)&&!Array.isArray(r)}function cr(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function Nw(r){let{done:e,value:t}=r.next();return e?void 0:t}function Bw(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});let{path:i,branch:s}=e,{type:o}=t,{refinement:c,message:u=`Expected a value of type \`${o}\`${c?` with refinement \`${c}\``:""}, but received: \`${cr(n)}\``}=r;return{value:n,type:o,refinement:c,key:i[i.length-1],path:i,branch:s,...r,message:u}}function*Ql(r,e,t,n){Tw(r)||(r=[r]);for(let i of r){let s=Bw(i,e,t,n);s&&(yield s)}}function*Gc(r,e,t={}){let{path:n=[],branch:i=[r],coerce:s=!1,mask:o=!1}=t,c={path:n,branch:i,mask:o};s&&(r=e.coercer(r,c));let u="valid";for(let p of e.validator(r,c))p.explanation=t.message,u="not_valid",yield[p,void 0];for(let[p,m,b]of e.entries(r,c)){let A=Gc(m,b,{path:p===void 0?n:[...n,p],branch:p===void 0?i:[...i,m],coerce:s,mask:o,message:t.message});for(let S of A)S[0]?(u=S[0].refinement!=null?"not_refined":"not_valid",yield[S[0],void 0]):s&&(m=S[1],p===void 0?r=m:r instanceof Map?r.set(p,m):r instanceof Set?r.add(m):Yi(r)&&(m!==void 0||p in r)&&(r[p]=m))}if(u!=="not_valid")for(let p of e.refiner(r,c))p.explanation=t.message,u="not_refined",yield[p,void 0];u==="valid"&&(yield[void 0,r])}var rr=class{constructor(e){let{type:t,schema:n,validator:i,refiner:s,coercer:o=u=>u,entries:c=function*(){}}=e;this.type=t,this.schema=n,this.entries=c,this.coercer=o,i?this.validator=(u,p)=>{let m=i(u,p);return Ql(m,p,this,u)}:this.validator=()=>[],s?this.refiner=(u,p)=>{let m=s(u,p);return Ql(m,p,this,u)}:this.refiner=()=>[]}assert(e,t){return ed(e,this,t)}create(e,t){return V(e,this,t)}is(e){return td(e,this)}mask(e,t){return Lw(e,this,t)}validate(e,t={}){return Xi(e,this,t)}};function ed(r,e,t){let n=Xi(r,e,{message:t});if(n[0])throw n[0]}function V(r,e,t){let n=Xi(r,e,{coerce:!0,message:t});if(n[0])throw n[0];return n[1]}function Lw(r,e,t){let n=Xi(r,e,{coerce:!0,mask:!0,message:t});if(n[0])throw n[0];return n[1]}function td(r,e){return!Xi(r,e)[0]}function Xi(r,e,t={}){let n=Gc(r,e,t),i=Nw(n);return i[0]?[new Hc(i[0],function*(){for(let o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function $n(r,e){return new rr({type:r,schema:null,validator:e})}function rd(){return $n("any",()=>!0)}function q(r){return new rr({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(let[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${cr(e)}`}})}function ur(){return $n("boolean",r=>typeof r=="boolean")}function No(r){return $n("instance",e=>e instanceof r||`Expected a \`${r.name}\` instance, but received: ${cr(e)}`)}function Me(r){let e=cr(r),t=typeof r;return new rr({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${e}\`, but received: ${cr(n)}`}})}function Cw(){return $n("never",()=>!1)}function j(r){return new rr({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function O(){return $n("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${cr(r)}`)}function ne(r){return new rr({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function Zc(r,e){return new rr({type:"record",schema:null,*entries(t){if(Yi(t))for(let n in t){let i=t[n];yield[n,n,r],yield[n,i,e]}},validator(t){return To(t)||`Expected an object, but received: ${cr(t)}`},coercer(t){return To(t)?{...t}:t}})}function z(){return $n("string",r=>typeof r=="string"||`Expected a string, but received: ${cr(r)}`)}function Bo(r){let e=Cw();return new rr({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let n=Math.max(r.length,t.length);for(let i=0;i<n;i++)yield[i,t[i],r[i]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${cr(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function P(r){let e=Object.keys(r);return new rr({type:"type",schema:r,*entries(t){if(Yi(t))for(let n of e)yield[n,t[n],r[n]]},validator(t){return To(t)||`Expected an object, but received: ${cr(t)}`},coercer(t){return To(t)?{...t}:t}})}function Ot(r){let e=r.map(t=>t.type).join(" | ");return new rr({type:"union",schema:null,coercer(t,n){for(let i of r){let[s,o]=i.validate(t,{coerce:!0,mask:n.mask});if(!s)return o}return t},validator(t,n){let i=[];for(let s of r){let[...o]=Gc(t,s,n),[c]=o;if(c[0])for(let[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${cr(t)}`,...i]}})}function Vn(){return $n("unknown",()=>!0)}function bi(r,e,t){return new rr({...r,coercer:(n,i)=>td(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}var fh=br(xd());var kd=br(zi(),1);var on=br(Od(),1);var o1=class extends on.default{socket;constructor(r,e,t){super(),this.socket=new window.WebSocket(r,t),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=n=>this.emit("message",n.data),this.socket.onerror=n=>this.emit("error",n),this.socket.onclose=n=>{this.emit("close",n.code,n.reason)}}send(r,e,t){let n=t||e;try{this.socket.send(r),n()}catch(i){n(i)}}close(r,e){this.socket.close(r,e)}addEventListener(r,e,t){this.socket.addEventListener(r,e,t)}};function Td(r,e){return new o1(r,e)}var a1=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},Nd=class extends on.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(r,e="ws://localhost:8080",{autoconnect:t=!0,reconnect:n=!0,reconnect_interval:i=1e3,max_reconnects:s=5,...o}={},c,u){super(),this.webSocketFactory=r,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=t,this.ready=!1,this.reconnect=n,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=s,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=c||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),u?this.dataPack=u:this.dataPack=new a1,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(r,e,t,n){return!n&&typeof t=="object"&&(n=t,t=null),new Promise((i,s)=>{if(!this.ready)return s(new Error("socket not ready"));let o=this.generate_request_id(r,e),c={jsonrpc:"2.0",method:r,params:e||void 0,id:o};this.socket.send(this.dataPack.encode(c),n,u=>{if(u)return s(u);this.queue[o]={promise:[i,s]},t&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],s(new Error("reply timeout"))},t))})})}async login(r){let e=await this.call("rpc.login",r);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(r,e){return new Promise((t,n)=>{if(!this.ready)return n(new Error("socket not ready"));let i={jsonrpc:"2.0",method:r,params:e};this.socket.send(this.dataPack.encode(i),s=>{if(s)return n(s);t()})})}async subscribe(r){typeof r=="string"&&(r=[r]);let e=await this.call("rpc.on",r);if(typeof r=="string"&&e[r]!=="ok")throw new Error("Failed subscribing to an event '"+r+"' with: "+e[r]);return e}async unsubscribe(r){typeof r=="string"&&(r=[r]);let e=await this.call("rpc.off",r);if(typeof r=="string"&&e[r]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(r,e){this.socket.close(r||1e3,e)}setAutoReconnect(r){this.reconnect=r}setReconnectInterval(r){this.reconnect_interval=r}setMaxReconnects(r){this.max_reconnects=r}_connect(r,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(r,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:t})=>{t instanceof ArrayBuffer&&(t=kd.Buffer.from(t).toString());try{t=this.dataPack.decode(t)}catch{return}if(t.notification&&this.listeners(t.notification).length){if(!Object.keys(t.params).length)return this.emit(t.notification);let n=[t.notification];if(t.params.constructor===Object)n.push(t.params);else for(let i=0;i<t.params.length;i++)n.push(t.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,n)})}if(!this.queue[t.id])return t.method?Promise.resolve().then(()=>{this.emit(t.method,t?.params)}):void 0;"error"in t=="result"in t&&this.queue[t.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[t.id].timeout&&clearTimeout(this.queue[t.id].timeout),t.error?this.queue[t.id].promise[1](t.error):this.queue[t.id].promise[0](t.result),delete this.queue[t.id]}),this.socket.addEventListener("error",t=>this.emit("error",t)),this.socket.addEventListener("close",({code:t,reason:n})=>{this.ready&&setTimeout(()=>this.emit("close",t,n),0),this.ready=!1,this.socket=void 0,t!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(r,e),this.reconnect_interval)))})}};var Cd=[],Pd=[],Md=[],c1=BigInt(0),ns=BigInt(1),u1=BigInt(2),f1=BigInt(7),l1=BigInt(256),d1=BigInt(113);for(let r=0,e=ns,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],Cd.push(2*(5*n+t)),Pd.push((r+1)*(r+2)/2%64);let i=c1;for(let s=0;s<7;s++)e=(e<<ns^(e>>f1)*d1)%l1,e&u1&&(i^=ns<<(ns<<BigInt(s))-ns);Md.push(i)}var[h1,p1]=oc(Md,!0),Bd=(r,e,t)=>t>32?uc(r,e,t):ac(r,e,t),Ld=(r,e,t)=>t>32?fc(r,e,t):cc(r,e,t);function m1(r,e=24){let t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){let c=(o+8)%10,u=(o+2)%10,p=t[u],m=t[u+1],b=Bd(p,m,1)^t[c],A=Ld(p,m,1)^t[c+1];for(let S=0;S<50;S+=10)r[o+S]^=b,r[o+S+1]^=A}let i=r[2],s=r[3];for(let o=0;o<24;o++){let c=Pd[o],u=Bd(i,s,c),p=Ld(i,s,c),m=Cd[o];i=r[m],s=r[m+1],r[m]=u,r[m+1]=p}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)t[c]=r[o+c];for(let c=0;c<10;c++)r[o+c]^=~t[(c+2)%10]&t[(c+4)%10]}r[0]^=h1[n],r[1]^=p1[n]}t.fill(0)}var zo=class r extends qr{constructor(e,t,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Fi(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=sl(this.state)}keccak(){rc||nc(this.state32),m1(this.state32,this.rounds),rc||nc(this.state32),this.posOut=0,this.pos=0}update(e){Ar(this);let{blockLen:t,state:n}=this;e=Wr(e);let i=e.length;for(let s=0;s<i;){let o=Math.min(t-this.pos,i-s);for(let c=0;c<o;c++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,(t&128)!==0&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Ar(this,!1),Vr(e),this.finish();let t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();let o=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Fi(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ws(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new r(t,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}},an=(r,e,t)=>li(()=>new zo(e,r,t)),uA=an(6,144,224/8),fA=an(6,136,256/8),lA=an(6,104,384/8),dA=an(6,72,512/8),hA=an(1,144,224/8),ou=an(1,136,256/8),pA=an(1,104,384/8),mA=an(1,72,512/8),Ud=(r,e,t)=>al((n={})=>new zo(e,r,n.dkLen===void 0?t:n.dkLen,!0)),gA=Ud(31,168,128/8),yA=Ud(31,136,256/8);var Fo=class extends qr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,il(e);let n=Wr(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Ar(this),this.iHash.update(e),this}digestInto(e){Ar(this),Vr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:c}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=c,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},au=(r,e,t)=>new Fo(r,e).update(t).digest();au.create=(r,e)=>new Fo(r,e);function Dd(r){r.lowS!==void 0&&or("lowS",r.lowS),r.prehash!==void 0&&or("prehash",r.prehash)}function g1(r){let e=qi(r);pr(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:y1,hexToBytes:_1}=Ys,cu=class extends Error{constructor(e=""){super(e)}},Br={Err:cu,_tlv:{encode:(r,e)=>{let{Err:t}=Br;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,i=Bn(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");let s=n>127?Bn(i.length/2|128):"";return Bn(r)+s+i+e},decode(r,e){let{Err:t}=Br,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),o=0;if(!s)o=i;else{let u=i&127;if(!u)throw new t("tlv.decode(long): indefinite length not supported");if(u>4)throw new t("tlv.decode(long): byte length is too big");let p=e.subarray(n,n+u);if(p.length!==u)throw new t("tlv.decode: length bytes not complete");if(p[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let m of p)o=o<<8|m;if(n+=u,o<128)throw new t("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+o);if(c.length!==o)throw new t("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+o)}}},_int:{encode(r){let{Err:e}=Br;if(r<Lr)throw new e("integer: negative integers are not allowed");let t=Bn(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=Br;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return y1(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Br,i=typeof r=="string"?_1(r):r;hi(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:u}=n.decode(2,s),{v:p,l:m}=n.decode(2,u);if(m.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(c),s:t.decode(p)}},hexFromSig(r){let{_tlv:e,_int:t}=Br,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),s=n+i;return e.encode(48,s)}},Lr=BigInt(0),wt=BigInt(1),AA=BigInt(2),zd=BigInt(3),xA=BigInt(4);function b1(r){let e=g1(r),{Fp:t}=e,n=Yr(e.n,e.nBitLength),i=e.toBytes||((I,x,B)=>{let U=x.toAffine();return kr(Uint8Array.from([4]),t.toBytes(U.x),t.toBytes(U.y))}),s=e.fromBytes||(I=>{let x=I.subarray(1),B=t.fromBytes(x.subarray(0,t.BYTES)),U=t.fromBytes(x.subarray(t.BYTES,2*t.BYTES));return{x:B,y:U}});function o(I){let{a:x,b:B}=e,U=t.sqr(I),L=t.mul(U,I);return t.add(t.add(L,t.mul(I,x)),B)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function c(I){return $i(I,wt,e.n)}function u(I){let{allowedPrivateKeyLengths:x,nByteLength:B,wrapPrivateKey:U,n:L}=e;if(x&&typeof I!="bigint"){if(Hr(I)&&(I=Ir(I)),typeof I!="string"||!x.includes(I.length))throw new Error("invalid private key");I=I.padStart(B*2,"0")}let F;try{F=typeof I=="bigint"?I:Or(qe("private key",I,B))}catch{throw new Error("invalid private key, expected hex or "+B+" bytes, got "+typeof I)}return U&&(F=Oe(F,L)),Vt("private key",F,wt,L),F}function p(I){if(!(I instanceof A))throw new Error("ProjectivePoint expected")}let m=Pn((I,x)=>{let{px:B,py:U,pz:L}=I;if(t.eql(L,t.ONE))return{x:B,y:U};let F=I.is0();x==null&&(x=F?t.ONE:t.inv(L));let te=t.mul(B,x),H=t.mul(U,x),Z=t.mul(L,x);if(F)return{x:t.ZERO,y:t.ZERO};if(!t.eql(Z,t.ONE))throw new Error("invZ was invalid");return{x:te,y:H}}),b=Pn(I=>{if(I.is0()){if(e.allowInfinityPoint&&!t.is0(I.py))return;throw new Error("bad point: ZERO")}let{x,y:B}=I.toAffine();if(!t.isValid(x)||!t.isValid(B))throw new Error("bad point: x or y not FE");let U=t.sqr(B),L=o(x);if(!t.eql(U,L))throw new Error("bad point: equation left != right");if(!I.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class A{constructor(x,B,U){if(this.px=x,this.py=B,this.pz=U,x==null||!t.isValid(x))throw new Error("x required");if(B==null||!t.isValid(B))throw new Error("y required");if(U==null||!t.isValid(U))throw new Error("z required");Object.freeze(this)}static fromAffine(x){let{x:B,y:U}=x||{};if(!x||!t.isValid(B)||!t.isValid(U))throw new Error("invalid affine point");if(x instanceof A)throw new Error("projective point not allowed");let L=F=>t.eql(F,t.ZERO);return L(B)&&L(U)?A.ZERO:new A(B,U,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){let B=t.invertBatch(x.map(U=>U.pz));return x.map((U,L)=>U.toAffine(B[L])).map(A.fromAffine)}static fromHex(x){let B=A.fromAffine(s(qe("pointHex",x)));return B.assertValidity(),B}static fromPrivateKey(x){return A.BASE.multiply(u(x))}static msm(x,B){return eo(A,n,x,B)}_setWindowSize(x){T.setWindowSize(this,x)}assertValidity(){b(this)}hasEvenY(){let{y:x}=this.toAffine();if(t.isOdd)return!t.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){p(x);let{px:B,py:U,pz:L}=this,{px:F,py:te,pz:H}=x,Z=t.eql(t.mul(B,H),t.mul(F,L)),ee=t.eql(t.mul(U,H),t.mul(te,L));return Z&&ee}negate(){return new A(this.px,t.neg(this.py),this.pz)}double(){let{a:x,b:B}=e,U=t.mul(B,zd),{px:L,py:F,pz:te}=this,H=t.ZERO,Z=t.ZERO,ee=t.ZERO,Y=t.mul(L,L),Ie=t.mul(F,F),re=t.mul(te,te),fe=t.mul(L,F);return fe=t.add(fe,fe),ee=t.mul(L,te),ee=t.add(ee,ee),H=t.mul(x,ee),Z=t.mul(U,re),Z=t.add(H,Z),H=t.sub(Ie,Z),Z=t.add(Ie,Z),Z=t.mul(H,Z),H=t.mul(fe,H),ee=t.mul(U,ee),re=t.mul(x,re),fe=t.sub(Y,re),fe=t.mul(x,fe),fe=t.add(fe,ee),ee=t.add(Y,Y),Y=t.add(ee,Y),Y=t.add(Y,re),Y=t.mul(Y,fe),Z=t.add(Z,Y),re=t.mul(F,te),re=t.add(re,re),Y=t.mul(re,fe),H=t.sub(H,Y),ee=t.mul(re,Ie),ee=t.add(ee,ee),ee=t.add(ee,ee),new A(H,Z,ee)}add(x){p(x);let{px:B,py:U,pz:L}=this,{px:F,py:te,pz:H}=x,Z=t.ZERO,ee=t.ZERO,Y=t.ZERO,Ie=e.a,re=t.mul(e.b,zd),fe=t.mul(B,F),v=t.mul(U,te),a=t.mul(L,H),l=t.add(B,U),d=t.add(F,te);l=t.mul(l,d),d=t.add(fe,v),l=t.sub(l,d),d=t.add(B,L);let h=t.add(F,H);return d=t.mul(d,h),h=t.add(fe,a),d=t.sub(d,h),h=t.add(U,L),Z=t.add(te,H),h=t.mul(h,Z),Z=t.add(v,a),h=t.sub(h,Z),Y=t.mul(Ie,d),Z=t.mul(re,a),Y=t.add(Z,Y),Z=t.sub(v,Y),Y=t.add(v,Y),ee=t.mul(Z,Y),v=t.add(fe,fe),v=t.add(v,fe),a=t.mul(Ie,a),d=t.mul(re,d),v=t.add(v,a),a=t.sub(fe,a),a=t.mul(Ie,a),d=t.add(d,a),fe=t.mul(v,d),ee=t.add(ee,fe),fe=t.mul(h,d),Z=t.mul(l,Z),Z=t.sub(Z,fe),fe=t.mul(l,v),Y=t.mul(h,Y),Y=t.add(Y,fe),new A(Z,ee,Y)}subtract(x){return this.add(x.negate())}is0(){return this.equals(A.ZERO)}wNAF(x){return T.wNAFCached(this,x,A.normalizeZ)}multiplyUnsafe(x){let{endo:B,n:U}=e;Vt("scalar",x,Lr,U);let L=A.ZERO;if(x===Lr)return L;if(this.is0()||x===wt)return this;if(!B||T.hasPrecomputes(this))return T.wNAFCachedUnsafe(this,x,A.normalizeZ);let{k1neg:F,k1:te,k2neg:H,k2:Z}=B.splitScalar(x),ee=L,Y=L,Ie=this;for(;te>Lr||Z>Lr;)te&wt&&(ee=ee.add(Ie)),Z&wt&&(Y=Y.add(Ie)),Ie=Ie.double(),te>>=wt,Z>>=wt;return F&&(ee=ee.negate()),H&&(Y=Y.negate()),Y=new A(t.mul(Y.px,B.beta),Y.py,Y.pz),ee.add(Y)}multiply(x){let{endo:B,n:U}=e;Vt("scalar",x,wt,U);let L,F;if(B){let{k1neg:te,k1:H,k2neg:Z,k2:ee}=B.splitScalar(x),{p:Y,f:Ie}=this.wNAF(H),{p:re,f:fe}=this.wNAF(ee);Y=T.constTimeNegate(te,Y),re=T.constTimeNegate(Z,re),re=new A(t.mul(re.px,B.beta),re.py,re.pz),L=Y.add(re),F=Ie.add(fe)}else{let{p:te,f:H}=this.wNAF(x);L=te,F=H}return A.normalizeZ([L,F])[0]}multiplyAndAddUnsafe(x,B,U){let L=A.BASE,F=(H,Z)=>Z===Lr||Z===wt||!H.equals(L)?H.multiplyUnsafe(Z):H.multiply(Z),te=F(this,B).add(F(x,U));return te.is0()?void 0:te}toAffine(x){return m(this,x)}isTorsionFree(){let{h:x,isTorsionFree:B}=e;if(x===wt)return!0;if(B)return B(A,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:x,clearCofactor:B}=e;return x===wt?this:B?B(A,this):this.multiplyUnsafe(e.h)}toRawBytes(x=!0){return or("isCompressed",x),this.assertValidity(),i(A,this,x)}toHex(x=!0){return or("isCompressed",x),Ir(this.toRawBytes(x))}}A.BASE=new A(e.Gx,e.Gy,t.ONE),A.ZERO=new A(t.ZERO,t.ONE,t.ZERO);let S=e.nBitLength,T=Qs(A,e.endo?Math.ceil(S/2):S);return{CURVE:e,ProjectivePoint:A,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:c}}function w1(r){let e=qi(r);return pr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Fd(r){let e=w1(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(a){return Oe(a,n)}function c(a){return Xs(a,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:p,weierstrassEquation:m,isWithinCurveOrder:b}=b1({...e,toBytes(a,l,d){let h=l.toAffine(),g=t.toBytes(h.x),w=kr;return or("isCompressed",d),d?w(Uint8Array.from([l.hasEvenY()?2:3]),g):w(Uint8Array.from([4]),g,t.toBytes(h.y))},fromBytes(a){let l=a.length,d=a[0],h=a.subarray(1);if(l===i&&(d===2||d===3)){let g=Or(h);if(!$i(g,wt,t.ORDER))throw new Error("Point is not on curve");let w=m(g),R;try{R=t.sqrt(w)}catch(_){let C=_ instanceof Error?": "+_.message:"";throw new Error("Point is not on curve"+C)}let y=(R&wt)===wt;return(d&1)===1!==y&&(R=t.neg(R)),{x:g,y:R}}else if(l===s&&d===4){let g=t.fromBytes(h.subarray(0,t.BYTES)),w=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:g,y:w}}else{let g=i,w=s;throw new Error("invalid Point, expected length of "+g+", or uncompressed "+w+", got "+l)}}}),A=a=>Ir(Zr(a,e.nByteLength));function S(a){let l=n>>wt;return a>l}function T(a){return S(a)?o(-a):a}let I=(a,l,d)=>Or(a.slice(l,d));class x{constructor(l,d,h){this.r=l,this.s=d,this.recovery=h,this.assertValidity()}static fromCompact(l){let d=e.nByteLength;return l=qe("compactSignature",l,d*2),new x(I(l,0,d),I(l,d,2*d))}static fromDER(l){let{r:d,s:h}=Br.toSig(qe("DER",l));return new x(d,h)}assertValidity(){Vt("r",this.r,wt,n),Vt("s",this.s,wt,n)}addRecoveryBit(l){return new x(this.r,this.s,l)}recoverPublicKey(l){let{r:d,s:h,recovery:g}=this,w=H(qe("msgHash",l));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let R=g===2||g===3?d+e.n:d;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let y=(g&1)===0?"02":"03",f=u.fromHex(y+A(R)),_=c(R),C=o(-w*_),D=o(h*_),$=u.BASE.multiplyAndAddUnsafe(f,C,D);if(!$)throw new Error("point at infinify");return $.assertValidity(),$}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ln(this.toDERHex())}toDERHex(){return Br.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ln(this.toCompactHex())}toCompactHex(){return A(this.r)+A(this.s)}}let B={isValidPrivateKey(a){try{return p(a),!0}catch{return!1}},normPrivateKeyToScalar:p,randomPrivateKey:()=>{let a=wc(e.n);return _l(e.randomBytes(a),e.n)},precompute(a=8,l=u.BASE){return l._setWindowSize(a),l.multiply(BigInt(3)),l}};function U(a,l=!0){return u.fromPrivateKey(a).toRawBytes(l)}function L(a){let l=Hr(a),d=typeof a=="string",h=(l||d)&&a.length;return l?h===i||h===s:d?h===2*i||h===2*s:a instanceof u}function F(a,l,d=!0){if(L(a))throw new Error("first arg must be private key");if(!L(l))throw new Error("second arg must be public key");return u.fromHex(l).multiply(p(a)).toRawBytes(d)}let te=e.bits2int||function(a){if(a.length>8192)throw new Error("input is too large");let l=Or(a),d=a.length*8-e.nBitLength;return d>0?l>>BigInt(d):l},H=e.bits2int_modN||function(a){return o(te(a))},Z=Vi(e.nBitLength);function ee(a){return Vt("num < 2^"+e.nBitLength,a,Lr,Z),Zr(a,e.nByteLength)}function Y(a,l,d=Ie){if(["recovered","canonical"].some(ie=>ie in d))throw new Error("sign() legacy options not supported");let{hash:h,randomBytes:g}=e,{lowS:w,prehash:R,extraEntropy:y}=d;w==null&&(w=!0),a=qe("msgHash",a),Dd(d),R&&(a=qe("prehashed msgHash",h(a)));let f=H(a),_=p(l),C=[ee(_),ee(f)];if(y!=null&&y!==!1){let ie=y===!0?g(t.BYTES):y;C.push(qe("extraEntropy",ie))}let D=kr(...C),$=f;function X(ie){let ue=te(ie);if(!b(ue))return;let Le=c(ue),he=u.BASE.multiply(ue).toAffine(),me=o(he.x);if(me===Lr)return;let jt=o(Le*o($+me*_));if(jt===Lr)return;let Ae=(he.x===me?0:2)|Number(he.y&wt),Ne=jt;return w&&S(jt)&&(Ne=T(jt),Ae^=1),new x(me,Ne,Ae)}return{seed:D,k2sig:X}}let Ie={lowS:e.lowS,prehash:!1},re={lowS:e.lowS,prehash:!1};function fe(a,l,d=Ie){let{seed:h,k2sig:g}=Y(a,l,d),w=e;return gc(w.hash.outputLen,w.nByteLength,w.hmac)(h,g)}u.BASE._setWindowSize(8);function v(a,l,d,h=re){let g=a;l=qe("msgHash",l),d=qe("publicKey",d);let{lowS:w,prehash:R,format:y}=h;if(Dd(h),"strict"in h)throw new Error("options.strict was renamed to lowS");if(y!==void 0&&y!=="compact"&&y!=="der")throw new Error("format must be compact or der");let f=typeof g=="string"||Hr(g),_=!f&&!y&&typeof g=="object"&&g!==null&&typeof g.r=="bigint"&&typeof g.s=="bigint";if(!f&&!_)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let C,D;try{if(_&&(C=new x(g.r,g.s)),f){try{y!=="compact"&&(C=x.fromDER(g))}catch(Ae){if(!(Ae instanceof Br.Err))throw Ae}!C&&y!=="der"&&(C=x.fromCompact(g))}D=u.fromHex(d)}catch{return!1}if(!C||w&&C.hasHighS())return!1;R&&(l=e.hash(l));let{r:$,s:X}=C,ie=H(l),ue=c(X),Le=o(ie*ue),he=o($*ue),me=u.BASE.multiplyAndAddUnsafe(D,Le,he)?.toAffine();return me?o(me.x)===$:!1}return{CURVE:e,getPublicKey:U,getSharedSecret:F,sign:fe,verify:v,ProjectivePoint:u,Signature:x,utils:B}}function v1(r){return{hash:r,hmac:(e,...t)=>au(r,e,ic(...t)),randomBytes:Ks}}function $d(r,e){let t=n=>Fd({...r,...v1(n)});return{...t(e),create:t}}var Wd=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Vd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),E1=BigInt(1),uu=BigInt(2),qd=(r,e)=>(r+e/uu)/e;function R1(r){let e=Wd,t=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),c=BigInt(44),u=BigInt(88),p=r*r*r%e,m=p*p*r%e,b=Pe(m,t,e)*m%e,A=Pe(b,t,e)*m%e,S=Pe(A,uu,e)*p%e,T=Pe(S,i,e)*S%e,I=Pe(T,s,e)*T%e,x=Pe(I,c,e)*I%e,B=Pe(x,u,e)*x%e,U=Pe(B,c,e)*I%e,L=Pe(U,t,e)*m%e,F=Pe(L,o,e)*T%e,te=Pe(F,n,e)*p%e,H=Pe(te,uu,e);if(!fu.eql(fu.sqr(H),r))throw new Error("Cannot find square root");return H}var fu=Yr(Wd,void 0,void 0,{sqrt:R1}),is=$d({a:BigInt(0),b:BigInt(7),Fp:fu,n:Vd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Vd,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-E1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),c=qd(s*r,e),u=qd(-n*r,e),p=Oe(r-c*t-u*i,e),m=Oe(-c*n-u*s,e),b=p>o,A=m>o;if(b&&(p=e-p),A&&(m=e-m),p>o||m>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:b,k1:p,k2neg:A,k2:m}}}},Wi),PA=BigInt(0);var MA=is.ProjectivePoint;var jA=Un.utils.randomPrivateKey,jd=()=>{let r=Un.utils.randomPrivateKey(),e=wu(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},wu=Un.getPublicKey;function Kd(r){try{return Un.ExtendedPoint.fromHex(r),!0}catch{return!1}}var Cu=(r,e)=>Un.sign(r,e.slice(0,32)),S1=Un.verify,_e=r=>ae.Buffer.isBuffer(r)?r:r instanceof Uint8Array?ae.Buffer.from(r.buffer,r.byteOffset,r.byteLength):ae.Buffer.from(r),vu=class{constructor(e){Object.assign(this,e)}encode(){return ae.Buffer.from((0,Ri.serialize)(qo,this))}static decode(e){return(0,Ri.deserialize)(qo,this,e)}static decodeUnchecked(e){return(0,Ri.deserializeUnchecked)(qo,this,e)}};var qo=new Map,lh,A1=32,fn=32;function x1(r){return r._bn!==void 0}var Hd=1,ce=class r extends vu{constructor(e){if(super({}),this._bn=void 0,x1(e))this._bn=e._bn;else{if(typeof e=="string"){let t=vt.default.decode(e);if(t.length!=fn)throw new Error("Invalid public key input");this._bn=new bu.default(t)}else this._bn=new bu.default(e);if(this._bn.byteLength()>fn)throw new Error("Invalid public key input")}}static unique(){let e=new r(Hd);return Hd+=1,new r(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return vt.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(ae.Buffer);if(e.length===fn)return e;let t=ae.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,n){let i=ae.Buffer.concat([e.toBuffer(),ae.Buffer.from(t),n.toBuffer()]),s=Wi(i);return new r(s)}static createProgramAddressSync(e,t){let n=ae.Buffer.alloc(0);e.forEach(function(s){if(s.length>A1)throw new TypeError("Max seed length exceeded");n=ae.Buffer.concat([n,_e(s)])}),n=ae.Buffer.concat([n,t.toBuffer(),ae.Buffer.from("ProgramDerivedAddress")]);let i=Wi(n);if(Kd(i))throw new Error("Invalid seeds, address must fall off the curve");return new r(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,i;for(;n!=0;){try{let s=e.concat(ae.Buffer.from([n]));i=this.createProgramAddressSync(s,t)}catch(s){if(s instanceof TypeError)throw s;n--;continue}return[i,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){let t=new r(e);return Kd(t.toBytes())}};lh=ce;ce.default=new lh("11111111111111111111111111111111");qo.set(ce,{kind:"struct",fields:[["_bn","u256"]]});var KA=new ce("BPFLoader1111111111111111111111111111111111"),jn=1232,Pu=127,Wo=64,jo=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(jo.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});var Ko=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Ko.prototype,"name",{value:"TransactionExpiredTimeoutError"});var Wn=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Wn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});var vi=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");let n=new Map;this.keySegments().flat().forEach((s,o)=>{n.set(s.toBase58(),o)});let i=s=>{let o=n.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}},ye=(r="publicKey")=>E.blob(32,r),I1=(r="signature")=>E.blob(64,r),wi=(r="string")=>{let e=E.struct([E.u32("length"),E.u32("lengthPadding"),E.blob(E.offset(E.u32(),-8),"chars")],r),t=e.decode.bind(e),n=e.encode.bind(e),i=e;return i.decode=(s,o)=>t(s,o).chars.toString(),i.encode=(s,o,c)=>{let u={chars:ae.Buffer.from(s,"utf8")};return n(u,o,c)},i.alloc=s=>E.u32().span+E.u32().span+ae.Buffer.from(s,"utf8").length,i},O1=(r="authorized")=>E.struct([ye("staker"),ye("withdrawer")],r),k1=(r="lockup")=>E.struct([E.ns64("unixTimestamp"),E.ns64("epoch"),ye("custodian")],r),T1=(r="voteInit")=>E.struct([ye("nodePubkey"),ye("authorizedVoter"),ye("authorizedWithdrawer"),E.u8("commission")],r),N1=(r="voteAuthorizeWithSeedArgs")=>E.struct([E.u32("voteAuthorizationType"),ye("currentAuthorityDerivedKeyOwnerPubkey"),wi("currentAuthorityDerivedKeySeed"),ye("newAuthorized")],r);function dh(r,e){let t=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){let s=e[i.property];if(Array.isArray(s))return s.length*t(i.elementLayout)}else if("fields"in i)return dh({layout:i},e[i.property]);return 0},n=0;return r.layout.fields.forEach(i=>{n+=t(i)}),n}function Zt(r){let e=0,t=0;for(;;){let n=r.shift();if(e|=(n&127)<<t*7,t+=1,(n&128)===0)break}return e}function Yt(r,e){let t=e;for(;;){let n=t&127;if(t>>=7,t==0){r.push(n);break}else n|=128,r.push(n)}}function xe(r,e){if(!r)throw new Error(e||"Assertion failed")}var Ho=class r{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){let n=new Map,i=o=>{let c=o.toBase58(),u=n.get(c);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(c,u)),u},s=i(t);s.isSigner=!0,s.isWritable=!0;for(let o of e){i(o.programId).isInvoked=!0;for(let c of o.keys){let u=i(c.pubkey);u.isSigner||=c.isSigner,u.isWritable||=c.isWritable}}return new r(t,n)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];xe(e.length<=256,"Max static account keys length exceeded");let t=e.filter(([,u])=>u.isSigner&&u.isWritable),n=e.filter(([,u])=>u.isSigner&&!u.isWritable),i=e.filter(([,u])=>!u.isSigner&&u.isWritable),s=e.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:s.length};{xe(t.length>0,"Expected at least one writable signer key");let[u]=t[0];xe(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let c=[...t.map(([u])=>new ce(u)),...n.map(([u])=>new ce(u)),...i.map(([u])=>new ce(u)),...s.map(([u])=>new ce(u))];return[o,c]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&i.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:i},{writable:n,readonly:s}]}drainKeysFoundInLookupTable(e,t){let n=new Array,i=new Array;for(let[s,o]of this.keyMetaMap.entries())if(t(o)){let c=new ce(s),u=e.findIndex(p=>p.equals(c));u>=0&&(xe(u<256,"Max lookup table index exceeded"),n.push(u),i.push(c),this.keyMetaMap.delete(s))}return[n,i]}},hh="Reached end of buffer unexpectedly";function Pr(r){if(r.length===0)throw new Error(hh);return r.shift()}function Xt(r,...e){let[t]=e;if(e.length===2?t+(e[1]??0)>r.length:t>=r.length)throw new Error(hh);return r.splice(...e)}var ln=class r{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(t=>new ce(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:vt.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new vi(this.staticAccountKeys)}static compile(e){let t=Ho.compile(e.instructions,e.payerKey),[n,i]=t.getMessageComponents(),o=new vi(i).compileInstructions(e.instructions).map(c=>({programIdIndex:c.programIdIndex,accounts:c.accountKeyIndexes,data:vt.default.encode(c.data)}));return new r({header:n,accountKeys:i,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){let n=e-t,s=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<s}else{let n=t-this.header.numReadonlySignedAccounts;return e<n}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];Yt(t,e);let n=this.instructions.map(b=>{let{accounts:A,programIdIndex:S}=b,T=Array.from(vt.default.decode(b.data)),I=[];Yt(I,A.length);let x=[];return Yt(x,T.length),{programIdIndex:S,keyIndicesCount:ae.Buffer.from(I),keyIndices:A,dataLength:ae.Buffer.from(x),data:T}}),i=[];Yt(i,n.length);let s=ae.Buffer.alloc(jn);ae.Buffer.from(i).copy(s);let o=i.length;n.forEach(b=>{let S=E.struct([E.u8("programIdIndex"),E.blob(b.keyIndicesCount.length,"keyIndicesCount"),E.seq(E.u8("keyIndex"),b.keyIndices.length,"keyIndices"),E.blob(b.dataLength.length,"dataLength"),E.seq(E.u8("userdatum"),b.data.length,"data")]).encode(b,s,o);o+=S}),s=s.slice(0,o);let c=E.struct([E.blob(1,"numRequiredSignatures"),E.blob(1,"numReadonlySignedAccounts"),E.blob(1,"numReadonlyUnsignedAccounts"),E.blob(t.length,"keyCount"),E.seq(ye("key"),e,"keys"),ye("recentBlockhash")]),u={numRequiredSignatures:ae.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:ae.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:ae.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:ae.Buffer.from(t),keys:this.accountKeys.map(b=>_e(b.toBytes())),recentBlockhash:vt.default.decode(this.recentBlockhash)},p=ae.Buffer.alloc(2048),m=c.encode(u,p);return s.copy(p,m),p.slice(0,m+s.length)}static from(e){let t=[...e],n=Pr(t);if(n!==(n&Pu))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let i=Pr(t),s=Pr(t),o=Zt(t),c=[];for(let A=0;A<o;A++){let S=Xt(t,0,fn);c.push(new ce(ae.Buffer.from(S)))}let u=Xt(t,0,fn),p=Zt(t),m=[];for(let A=0;A<p;A++){let S=Pr(t),T=Zt(t),I=Xt(t,0,T),x=Zt(t),B=Xt(t,0,x),U=vt.default.encode(ae.Buffer.from(B));m.push({programIdIndex:S,accounts:I,data:U})}let b={header:{numRequiredSignatures:n,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:vt.default.encode(ae.Buffer.from(u)),accountKeys:c,instructions:m};return new r(b)}},Go=class r{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(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;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");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=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 vi(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(e>=n){let i=e-n,s=this.addressTableLookups.reduce((o,c)=>o+c.writableIndexes.length,0);return i<s}else if(e>=this.header.numRequiredSignatures){let i=e-t,o=n-t-this.header.numReadonlyUnsignedAccounts;return i<o}else{let i=t-this.header.numReadonlySignedAccounts;return e<i}}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let i=e.find(s=>s.key.equals(n.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let s of n.writableIndexes)if(s<i.state.addresses.length)t.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`);for(let s of n.readonlyIndexes)if(s<i.state.addresses.length)t.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){let t=Ho.compile(e.instructions,e.payerKey),n=new Array,i={writable:new Array,readonly:new Array},s=e.addressLookupTableAccounts||[];for(let m of s){let b=t.extractTableLookup(m);if(b!==void 0){let[A,{writable:S,readonly:T}]=b;n.push(A),i.writable.push(...S),i.readonly.push(...T)}}let[o,c]=t.getMessageComponents(),p=new vi(c,i).compileInstructions(e.instructions);return new r({header:o,staticAccountKeys:c,recentBlockhash:e.recentBlockhash,compiledInstructions:p,addressTableLookups:n})}serialize(){let e=Array();Yt(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=Array();Yt(n,this.compiledInstructions.length);let i=this.serializeAddressTableLookups(),s=Array();Yt(s,this.addressTableLookups.length);let o=E.struct([E.u8("prefix"),E.struct([E.u8("numRequiredSignatures"),E.u8("numReadonlySignedAccounts"),E.u8("numReadonlyUnsignedAccounts")],"header"),E.blob(e.length,"staticAccountKeysLength"),E.seq(ye(),this.staticAccountKeys.length,"staticAccountKeys"),ye("recentBlockhash"),E.blob(n.length,"instructionsLength"),E.blob(t.length,"serializedInstructions"),E.blob(s.length,"addressTableLookupsLength"),E.blob(i.length,"serializedAddressTableLookups")]),c=new Uint8Array(jn),p=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(m=>m.toBytes()),recentBlockhash:vt.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},c);return c.slice(0,p)}serializeInstructions(){let e=0,t=new Uint8Array(jn);for(let n of this.compiledInstructions){let i=Array();Yt(i,n.accountKeyIndexes.length);let s=Array();Yt(s,n.data.length);let o=E.struct([E.u8("programIdIndex"),E.blob(i.length,"encodedAccountKeyIndexesLength"),E.seq(E.u8(),n.accountKeyIndexes.length,"accountKeyIndexes"),E.blob(s.length,"encodedDataLength"),E.blob(n.data.length,"data")]);e+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(jn);for(let n of this.addressTableLookups){let i=Array();Yt(i,n.writableIndexes.length);let s=Array();Yt(s,n.readonlyIndexes.length);let o=E.struct([ye("accountKey"),E.blob(i.length,"encodedWritableIndexesLength"),E.seq(E.u8(),n.writableIndexes.length,"writableIndexes"),E.blob(s.length,"encodedReadonlyIndexesLength"),E.seq(E.u8(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e],n=Pr(t),i=n&Pu;xe(n!==i,"Expected versioned message but received legacy message");let s=i;xe(s===0,`Expected versioned message with version 0 but found version ${s}`);let o={numRequiredSignatures:Pr(t),numReadonlySignedAccounts:Pr(t),numReadonlyUnsignedAccounts:Pr(t)},c=[],u=Zt(t);for(let T=0;T<u;T++)c.push(new ce(Xt(t,0,fn)));let p=vt.default.encode(Xt(t,0,fn)),m=Zt(t),b=[];for(let T=0;T<m;T++){let I=Pr(t),x=Zt(t),B=Xt(t,0,x),U=Zt(t),L=new Uint8Array(Xt(t,0,U));b.push({programIdIndex:I,accountKeyIndexes:B,data:L})}let A=Zt(t),S=[];for(let T=0;T<A;T++){let I=new ce(Xt(t,0,fn)),x=Zt(t),B=Xt(t,0,x),U=Zt(t),L=Xt(t,0,U);S.push({accountKey:I,writableIndexes:B,readonlyIndexes:L})}return new r({header:o,staticAccountKeys:c,recentBlockhash:p,compiledInstructions:b,addressTableLookups:S})}},ta={deserializeMessageVersion(r){let e=r[0],t=e&Pu;return t===e?"legacy":t},deserialize:r=>{let e=ta.deserializeMessageVersion(r);if(e==="legacy")return ln.from(r);if(e===0)return Go.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},cn=function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r}({}),B1=ae.Buffer.alloc(Wo).fill(0),Te=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=ae.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:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},Se=class r{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")){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}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(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new Te(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let I=0;I<t.length;I++)if(t[I].programId===void 0)throw new Error(`Transaction instruction index ${I} has undefined program id`);let i=[],s=[];t.forEach(I=>{I.keys.forEach(B=>{s.push({...B})});let x=I.programId.toString();i.includes(x)||i.push(x)}),i.forEach(I=>{s.push({pubkey:new ce(I),isSigner:!1,isWritable:!1})});let o=[];s.forEach(I=>{let x=I.pubkey.toString(),B=o.findIndex(U=>U.pubkey.toString()===x);B>-1?(o[B].isWritable=o[B].isWritable||I.isWritable,o[B].isSigner=o[B].isSigner||I.isSigner):o.push(I)}),o.sort(function(I,x){if(I.isSigner!==x.isSigner)return I.isSigner?-1:1;if(I.isWritable!==x.isWritable)return I.isWritable?-1:1;let B={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return I.pubkey.toBase58().localeCompare(x.pubkey.toBase58(),"en",B)});let c=o.findIndex(I=>I.pubkey.equals(n));if(c>-1){let[I]=o.splice(c,1);I.isSigner=!0,I.isWritable=!0,o.unshift(I)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let I of this.signatures){let x=o.findIndex(B=>B.pubkey.equals(I.publicKey));if(x>-1)o[x].isSigner||(o[x].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: ${I.publicKey.toString()}`)}let u=0,p=0,m=0,b=[],A=[];o.forEach(({pubkey:I,isSigner:x,isWritable:B})=>{x?(b.push(I.toString()),u+=1,B||(p+=1)):(A.push(I.toString()),B||(m+=1))});let S=b.concat(A),T=t.map(I=>{let{data:x,programId:B}=I;return{programIdIndex:S.indexOf(B.toString()),accounts:I.keys.map(U=>S.indexOf(U.pubkey.toString())),data:vt.default.encode(x)}});return T.forEach(I=>{xe(I.programIdIndex>=0),I.accounts.forEach(x=>xe(x>=0))}),new ln({header:{numRequiredSignatures:u,numReadonlySignedAccounts:p,numReadonlyUnsignedAccounts:m},accountKeys:S,recentBlockhash:e,instructions:T})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((i,s)=>t[s].equals(i.publicKey))||(this.signatures=t.map(n=>({signature:null,publicKey:n}))),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");let t=new Set;this.signatures=e.filter(n=>{let i=n.toString();return t.has(i)?!1:(t.add(i),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...e){if(e.length===0)throw new Error("No signers");let t=new Set,n=[];for(let s of e){let o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}this.signatures=n.map(s=>({signature:null,publicKey:s.publicKey}));let i=this._compile();this._partialSign(i,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");let t=new Set,n=[];for(let s of e){let o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}let i=this._compile();this._partialSign(i,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(i=>{let s=Cu(n,i.secretKey);this._addSignature(i.publicKey,_e(s))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){xe(t.length===64);let n=this.signatures.findIndex(i=>e.equals(i.publicKey));if(n<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=ae.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:i,publicKey:s}of this.signatures)i===null?t&&(n.missing||=[]).push(s):S1(i,e,s.toBytes())||(n.invalid||=[]).push(s);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(n){let s=this._getMessageSignednessErrors(i,t);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
6
6
  Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(c=>c.toBase58()).join("`, `")}\`].`),s.missing&&(o+=`
7
- Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(c=>c.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(e){let{signatures:t}=this,n=[];Yt(n,t.length);let i=n.length+t.length*64+e.length,s=ae.Buffer.alloc(i);return xe(t.length<256),ae.Buffer.from(n).copy(s,0),t.forEach(({signature:o},c)=>{o!==null&&(xe(o.length===64,"signature has invalid length"),ae.Buffer.from(o).copy(s,n.length+c*64))}),e.copy(s,n.length+t.length*64),xe(s.length<=jn,`Transaction too large: ${s.length} > ${jn}`),s}get keys(){return xe(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return xe(this.instructions.length===1),this.instructions[0].programId}get data(){return xe(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e],n=Zt(t),i=[];for(let s=0;s<n;s++){let o=Xt(t,0,Wo);i.push(vt.default.encode(ae.Buffer.from(o)))}return r.populate(ln.from(t),i)}static populate(e,t=[]){let n=new r;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((i,s)=>{let o={signature:i==vt.default.encode(S1)?null:vt.default.decode(i),publicKey:e.accountKeys[s]};n.signatures.push(o)}),e.instructions.forEach(i=>{let s=i.accounts.map(o=>{let c=e.accountKeys[o];return{pubkey:c,isSigner:n.signatures.some(u=>u.publicKey.toString()===c.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});n.instructions.push(new Te({keys:s,programId:e.accountKeys[i.programIdIndex],data:vt.default.decode(i.data)}))}),n._message=e,n._json=n.toJSON(),n}};var Go=class r{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)xe(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{let n=[];for(let i=0;i<e.header.numRequiredSignatures;i++)n.push(new Uint8Array(Wo));this.signatures=n}this.message=e}serialize(){let e=this.message.serialize(),t=Array();Yt(t,this.signatures.length);let n=E.struct([E.blob(t.length,"encodedSignaturesLength"),E.seq(b1(),this.signatures.length,"signatures"),E.blob(e.length,"serializedMessage")]),i=new Uint8Array(2048),s=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,s)}static deserialize(e){let t=[...e],n=[],i=Zt(t);for(let o=0;o<i;o++)n.push(new Uint8Array(Xt(t,0,Wo)));let s=fh.deserialize(new Uint8Array(t));return new r(s,n)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let i of e){let s=n.findIndex(o=>o.equals(i.publicKey));xe(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=Tu(t,i.secretKey)}}addSignature(e,t){xe(t.byteLength===64,"Signature must be 64 bytes long");let i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(e));xe(i>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=t}},A1=160,x1=64,I1=A1/x1,lh=1e3/I1,Cr=new ce("SysvarC1ock11111111111111111111111111111111"),MA=new ce("SysvarEpochSchedu1e111111111111111111111111"),UA=new ce("Sysvar1nstructions1111111111111111111111111"),au=new ce("SysvarRecentB1ockHashes11111111111111111111"),as=new ce("SysvarRent111111111111111111111111111111111"),DA=new ce("SysvarRewards111111111111111111111111111111"),zA=new ce("SysvarS1otHashes111111111111111111111111111"),FA=new ce("SysvarS1otHistory11111111111111111111111111"),cu=new ce("SysvarStakeHistory1111111111111111111111111"),cs=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:i}){let s=i?`Logs:
7
+ Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(c=>c.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(e){let{signatures:t}=this,n=[];Yt(n,t.length);let i=n.length+t.length*64+e.length,s=ae.Buffer.alloc(i);return xe(t.length<256),ae.Buffer.from(n).copy(s,0),t.forEach(({signature:o},c)=>{o!==null&&(xe(o.length===64,"signature has invalid length"),ae.Buffer.from(o).copy(s,n.length+c*64))}),e.copy(s,n.length+t.length*64),xe(s.length<=jn,`Transaction too large: ${s.length} > ${jn}`),s}get keys(){return xe(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return xe(this.instructions.length===1),this.instructions[0].programId}get data(){return xe(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e],n=Zt(t),i=[];for(let s=0;s<n;s++){let o=Xt(t,0,Wo);i.push(vt.default.encode(ae.Buffer.from(o)))}return r.populate(ln.from(t),i)}static populate(e,t=[]){let n=new r;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((i,s)=>{let o={signature:i==vt.default.encode(B1)?null:vt.default.decode(i),publicKey:e.accountKeys[s]};n.signatures.push(o)}),e.instructions.forEach(i=>{let s=i.accounts.map(o=>{let c=e.accountKeys[o];return{pubkey:c,isSigner:n.signatures.some(u=>u.publicKey.toString()===c.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});n.instructions.push(new Te({keys:s,programId:e.accountKeys[i.programIdIndex],data:vt.default.decode(i.data)}))}),n._message=e,n._json=n.toJSON(),n}};var Zo=class r{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)xe(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{let n=[];for(let i=0;i<e.header.numRequiredSignatures;i++)n.push(new Uint8Array(Wo));this.signatures=n}this.message=e}serialize(){let e=this.message.serialize(),t=Array();Yt(t,this.signatures.length);let n=E.struct([E.blob(t.length,"encodedSignaturesLength"),E.seq(I1(),this.signatures.length,"signatures"),E.blob(e.length,"serializedMessage")]),i=new Uint8Array(2048),s=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,s)}static deserialize(e){let t=[...e],n=[],i=Zt(t);for(let o=0;o<i;o++)n.push(new Uint8Array(Xt(t,0,Wo)));let s=ta.deserialize(new Uint8Array(t));return new r(s,n)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let i of e){let s=n.findIndex(o=>o.equals(i.publicKey));xe(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=Cu(t,i.secretKey)}}addSignature(e,t){xe(t.byteLength===64,"Signature must be 64 bytes long");let i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(e));xe(i>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=t}},L1=160,C1=64,P1=L1/C1,ph=1e3/P1,Cr=new ce("SysvarC1ock11111111111111111111111111111111"),HA=new ce("SysvarEpochSchedu1e111111111111111111111111"),GA=new ce("Sysvar1nstructions1111111111111111111111111"),lu=new ce("SysvarRecentB1ockHashes11111111111111111111"),cs=new ce("SysvarRent111111111111111111111111111111111"),ZA=new ce("SysvarRewards111111111111111111111111111111"),YA=new ce("SysvarS1otHashes111111111111111111111111111"),XA=new ce("SysvarS1otHistory11111111111111111111111111"),du=new ce("SysvarStakeHistory1111111111111111111111111"),us=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:i}){let s=i?`Logs:
8
8
  ${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",c;switch(e){case"send":c=`Transaction ${t} resulted in an error.
9
9
  ${n}. `+s+o;break;case"simulate":c=`Simulation failed.
10
10
  Message: ${n}.
11
- `+s+o;break;default:c=`Unknown action '${(u=>u)(e)}'`}super(c),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){let s=i.meta.logMessages;this.transactionLogs=s,t(s)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}};var Q=class extends Error{constructor({code:e,message:t,data:n},i){super(i!=null?`${i}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}};async function qd(r,e,t,n){let i=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},s=await r.sendTransaction(e,t,i),o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await r.confirmTransaction({abortSignal:n?.abortSignal,signature:s,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){let{nonceInstruction:c}=e.nonceInfo,u=c.keys[0].pubkey;o=(await r.confirmTransaction({abortSignal:n?.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:e.nonceInfo.nonce,signature:s},n&&n.commitment)).value}else n?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await r.confirmTransaction(s,n&&n.commitment)).value;if(o.err)throw s!=null?new cs({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function Wn(r){return new Promise(e=>setTimeout(e,r))}function we(r,e){let t=r.layout.span>=0?r.layout.span:ch(r,e),n=ae.Buffer.alloc(t),i=Object.assign({instruction:r.index},e);return r.layout.encode(i,n),n}var O1=E.nu64("lamportsPerSignature"),dh=E.struct([E.u32("version"),E.u32("state"),ye("authorizedPubkey"),ye("nonce"),E.struct([O1],"feeCalculator")]),jd=dh.span,_u=class r{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){let t=dh.decode(_e(e),0);return new r({authorizedPubkey:new ce(t.authorizedPubkey),nonce:new ce(t.nonce).toString(),feeCalculator:t.feeCalculator})}};function vi(r){let e=(0,sh.blob)(8,r),t=e.decode.bind(e),n=e.encode.bind(e),i=e,s=Gl();return i.decode=(o,c)=>{let u=t(o,c);return s.decode(u)},i.encode=(o,c,u)=>{let p=s.encode(o);return n(p,c,u)},i}var nr=Object.freeze({Create:{index:0,layout:E.struct([E.u32("instruction"),E.ns64("lamports"),E.ns64("space"),ye("programId")])},Assign:{index:1,layout:E.struct([E.u32("instruction"),ye("programId")])},Transfer:{index:2,layout:E.struct([E.u32("instruction"),vi("lamports")])},CreateWithSeed:{index:3,layout:E.struct([E.u32("instruction"),ye("base"),bi("seed"),E.ns64("lamports"),E.ns64("space"),ye("programId")])},AdvanceNonceAccount:{index:4,layout:E.struct([E.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:E.struct([E.u32("instruction"),E.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:E.struct([E.u32("instruction"),ye("authorized")])},AuthorizeNonceAccount:{index:7,layout:E.struct([E.u32("instruction"),ye("authorized")])},Allocate:{index:8,layout:E.struct([E.u32("instruction"),E.ns64("space")])},AllocateWithSeed:{index:9,layout:E.struct([E.u32("instruction"),ye("base"),bi("seed"),E.ns64("space"),ye("programId")])},AssignWithSeed:{index:10,layout:E.struct([E.u32("instruction"),ye("base"),bi("seed"),ye("programId")])},TransferWithSeed:{index:11,layout:E.struct([E.u32("instruction"),vi("lamports"),bi("seed"),ye("programId")])},UpgradeNonceAccount:{index:12,layout:E.struct([E.u32("instruction")])}}),Dt=class r{constructor(){}static createAccount(e){let t=nr.Create,n=we(t,{lamports:e.lamports,space:e.space,programId:_e(e.programId.toBuffer())});return new Te({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if("basePubkey"in e){let i=nr.TransferWithSeed;t=we(i,{lamports:BigInt(e.lamports),seed:e.seed,programId:_e(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let i=nr.Transfer;t=we(i,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){let i=nr.AssignWithSeed;t=we(i,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,programId:_e(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let i=nr.Assign;t=we(i,{programId:_e(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=nr.CreateWithSeed,n=we(t,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:_e(e.programId.toBuffer())}),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 Te({keys:i,programId:this.programId,data:n})}static createNonceAccount(e){let t=new Se;"basePubkey"in e&&"seed"in e?t.add(r.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:jd,programId:this.programId})):t.add(r.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:jd,programId:this.programId}));let n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){let t=nr.InitializeNonceAccount,n=we(t,{authorized:_e(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:au,isSigner:!1,isWritable:!1},{pubkey:as,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Te(i)}static nonceAdvance(e){let t=nr.AdvanceNonceAccount,n=we(t),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:au,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Te(i)}static nonceWithdraw(e){let t=nr.WithdrawNonceAccount,n=we(t,{lamports:e.lamports});return new Te({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:au,isSigner:!1,isWritable:!1},{pubkey:as,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=nr.AuthorizeNonceAccount,n=we(t,{authorized:_e(e.newAuthorizedPubkey.toBuffer())});return new Te({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if("basePubkey"in e){let i=nr.AllocateWithSeed;t=we(i,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:_e(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let i=nr.Allocate;t=we(i,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:t})}};Dt.programId=new ce("11111111111111111111111111111111");var k1=jn-300,bu=class r{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/r.chunkSize)+1+1)}static async load(e,t,n,i,s){{let b=await e.getMinimumBalanceForRentExemption(s.length),A=await e.getAccountInfo(n.publicKey,"confirmed"),S=null;if(A!==null){if(A.executable)return console.error("Program load failed, account is already executable"),!1;A.data.length!==s.length&&(S=S||new Se,S.add(Dt.allocate({accountPubkey:n.publicKey,space:s.length}))),A.owner.equals(i)||(S=S||new Se,S.add(Dt.assign({accountPubkey:n.publicKey,programId:i}))),A.lamports<b&&(S=S||new Se,S.add(Dt.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:b-A.lamports})))}else S=new Se().add(Dt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:b>0?b:1,space:s.length,programId:i}));S!==null&&await qd(e,S,[t,n],{commitment:"confirmed"})}let o=E.struct([E.u32("instruction"),E.u32("offset"),E.u32("bytesLength"),E.u32("bytesLengthPadding"),E.seq(E.u8("byte"),E.offset(E.u32(),-8),"bytes")]),c=r.chunkSize,u=0,p=s,m=[];for(;p.length>0;){let b=p.slice(0,c),A=ae.Buffer.alloc(c+16);o.encode({instruction:0,offset:u,bytes:b,bytesLength:0,bytesLengthPadding:0},A);let S=new Se().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:A});m.push(qd(e,S,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await Wn(1e3/4),u+=c,p=p.slice(c)}await Promise.all(m);{let b=E.struct([E.u32("instruction")]),A=ae.Buffer.alloc(b.span);b.encode({instruction:1},A);let S=new Se().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:as,isSigner:!1,isWritable:!1}],programId:i,data:A}),T="processed",I=await e.sendTransaction(S,[t,n],{preflightCommitment:T}),{context:x,value:B}=await e.confirmTransaction({signature:I,lastValidBlockHeight:S.lastValidBlockHeight,blockhash:S.recentBlockhash},T);if(B.err)throw new Error(`Transaction ${I} failed (${JSON.stringify(B)})`);for(;;){try{if(await e.getSlot({commitment:T})>x.slot)break}catch{}await new Promise(U=>setTimeout(U,Math.round(lh/2)))}}return!0}};bu.chunkSize=k1;var VA=new ce("BPFLoader2111111111111111111111111111111111");function T1(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var uu,Kd;function N1(){if(Kd)return uu;Kd=1;var r=Object.prototype.toString,e=Object.keys||function(n){var i=[];for(var s in n)i.push(s);return i};function t(n,i){var s,o,c,u,p,m,b;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return t(n.toJSON(),i);if(b=r.call(n),b==="[object Array]"){for(c="[",o=n.length-1,s=0;s<o;s++)c+=t(n[s],!0)+",";return o>-1&&(c+=t(n[s],!0)),c+"]"}else if(b==="[object Object]"){for(u=e(n).sort(),o=u.length,c="",s=0;s<o;)p=u[s],m=t(n[p],!1),m!==void 0&&(c&&(c+=","),c+=JSON.stringify(p)+":"+m),s++;return"{"+c+"}"}else return JSON.stringify(n);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return uu=function(n){var i=t(n,!1);if(i!==void 0)return""+i},uu}var B1=N1(),Hd=T1(B1),is=32;function fu(r){let e=0;for(;r>1;)r/=2,e++;return e}function L1(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}var wu=class{constructor(e,t,n,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=fu(L1(e+is+1))-fu(is)-1,n=this.getSlotsInEpoch(t),i=e-(n-is);return[t,i]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),i=this.firstNormalEpoch+n,s=t%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*is:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+fu(is)):this.slotsPerEpoch}},C1=globalThis.fetch,vu=class extends Id{constructor(e,t,n){let i=s=>{let o=xd(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}};function P1(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${r.index}`);return t}var Gd=56,Zo=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){let t=P1(M1,e),n=e.length-Gd;xe(n>=0,"lookup table is invalid"),xe(n%32===0,"lookup table is invalid");let i=n/32,{addresses:s}=E.struct([E.seq(ye(),i,"addresses")]).decode(e.slice(Gd));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ce(t.authority[0]):void 0,addresses:s.map(o=>new ce(o))}}},M1={index:1,layout:E.struct([E.u32("typeIndex"),vi("deactivationSlot"),E.nu64("lastExtendedSlot"),E.u8("lastExtendedStartIndex"),E.u8(),E.seq(ye(),E.offset(E.u8(),-1),"authority")])},U1=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function D1(r){let e=r.match(U1);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);let[t,n,i,s]=e,o=r.startsWith("https:")?"wss:":"ws:",c=i==null?null:parseInt(i.slice(1),10),u=c==null?"":`:${c+1}`;return`${o}//${n}${u}${s}`}var qe=_i(To(ce),z(),r=>new ce(r)),hh=No([z(),Me("base64")]),Bu=_i(To(ae.Buffer),hh,r=>ae.Buffer.from(r[0],"base64")),z1=30*1e3;function F1(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function Be(r){let e,t;if(typeof r=="string")e=r;else if(r){let{commitment:n,...i}=r;e=n,t=i}return{commitment:e,config:t}}function Zd(r){return r.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function ph(r){return Ot([P({jsonrpc:Me("2.0"),id:z(),result:r}),P({jsonrpc:Me("2.0"),id:z(),error:P({code:$n(),message:z(),data:ne(Jl())})})])}var V1=ph($n());function ge(r){return _i(ph(r),V1,e=>"error"in e?e:{...e,result:$(e.result,r)})}function Ze(r){return ge(P({context:P({slot:O()}),value:r}))}function ea(r){return P({context:P({slot:O()}),value:r})}function lu(r,e){return r===0?new Ho({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new ce(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:vt.default.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new ln(e)}var $1=P({foundation:O(),foundationTerm:O(),initial:O(),taper:O(),terminal:O()}),W1=ge(W(j(P({epoch:O(),effectiveSlot:O(),amount:O(),postBalance:O(),commission:ne(j(O()))})))),q1=W(P({slot:O(),prioritizationFee:O()})),j1=P({total:O(),validator:O(),foundation:O(),epoch:O()}),K1=P({epoch:O(),slotIndex:O(),slotsInEpoch:O(),absoluteSlot:O(),blockHeight:ne(O()),transactionCount:ne(O())}),H1=P({slotsPerEpoch:O(),leaderScheduleSlotOffset:O(),warmup:ur(),firstNormalEpoch:O(),firstNormalSlot:O()}),G1=jc(z(),W(O())),Kn=j(Ot([P({}),z()])),Z1=P({err:Kn}),Y1=Me("receivedSignature"),X1=P({"solana-core":z(),"feature-set":ne(O())}),J1=P({program:z(),programId:qe,parsed:$n()}),Q1=P({programId:qe,accounts:W(qe),data:z()}),Yd=Ze(P({err:j(Ot([P({}),z()])),logs:j(W(z())),accounts:ne(j(W(j(P({executable:ur(),owner:z(),lamports:O(),data:W(z()),rentEpoch:ne(O())}))))),unitsConsumed:ne(O()),returnData:ne(j(P({programId:z(),data:No([z(),Me("base64")])}))),innerInstructions:ne(j(W(P({index:O(),instructions:W(Ot([J1,Q1]))}))))})),ev=Ze(P({byIdentity:jc(z(),W(O())),range:P({firstSlot:O(),lastSlot:O()})}));function tv(r,e,t,n,i,s){let o=t||C1,c;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return n&&(u=async(m,b)=>{let A=await new Promise((S,T)=>{try{n(m,b,(I,x)=>S([I,x]))}catch(I){T(I)}});return await o(...A)}),new oh.default(async(m,b)=>{let A={method:"POST",body:m,agent:c,headers:Object.assign({"Content-Type":"application/json"},e||{},tE)};try{let S=5,T,I=500;for(;u?T=await u(r,A):T=await o(r,A),!(T.status!==429||i===!0||(S-=1,S===0));)console.error(`Server responded with ${T.status} ${T.statusText}. Retrying after ${I}ms delay...`),await Wn(I),I*=2;let x=await T.text();T.ok?b(null,x):b(new Error(`${T.status} ${T.statusText}: ${x}`))}catch(S){S instanceof Error&&b(S)}},{})}function rv(r){return(e,t)=>new Promise((n,i)=>{r.request(e,t,(s,o)=>{if(s){i(s);return}n(o)})})}function nv(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);let i=e.map(s=>r.request(s.methodName,s.args));r.request(i,(s,o)=>{if(s){n(s);return}t(o)})})}var iv=ge($1),sv=ge(j1),ov=ge(q1),av=ge(K1),cv=ge(H1),uv=ge(G1),fv=ge(O()),lv=Ze(P({total:O(),circulating:O(),nonCirculating:O(),nonCirculatingAccounts:W(qe)})),Eu=P({amount:z(),uiAmount:j(O()),decimals:O(),uiAmountString:ne(z())}),dv=Ze(W(P({address:qe,amount:z(),uiAmount:j(O()),decimals:O(),uiAmountString:ne(z())}))),hv=Ze(W(P({pubkey:qe,account:P({executable:ur(),owner:qe,lamports:O(),data:Bu,rentEpoch:O()})}))),Ru=P({program:z(),parsed:$n(),space:O()}),pv=Ze(W(P({pubkey:qe,account:P({executable:ur(),owner:qe,lamports:O(),data:Ru,rentEpoch:O()})}))),mv=Ze(W(P({lamports:O(),address:qe}))),us=P({executable:ur(),owner:qe,lamports:O(),data:Bu,rentEpoch:O()}),gv=P({pubkey:qe,account:us}),yv=_i(Ot([To(ae.Buffer),Ru]),Ot([hh,Ru]),r=>Array.isArray(r)?$(r,Bu):r),Su=P({executable:ur(),owner:qe,lamports:O(),data:yv,rentEpoch:O()}),_v=P({pubkey:qe,account:Su}),bv=P({state:Ot([Me("active"),Me("inactive"),Me("activating"),Me("deactivating")]),active:O(),inactive:O()}),wv=ge(W(P({signature:z(),slot:O(),err:Kn,memo:j(z()),blockTime:ne(j(O()))}))),vv=ge(W(P({signature:z(),slot:O(),err:Kn,memo:j(z()),blockTime:ne(j(O()))}))),Ev=P({subscription:O(),result:ea(us)}),Rv=P({pubkey:qe,account:us}),Sv=P({subscription:O(),result:ea(Rv)}),Av=P({parent:O(),slot:O(),root:O()}),xv=P({subscription:O(),result:Av}),Iv=Ot([P({type:Ot([Me("firstShredReceived"),Me("completed"),Me("optimisticConfirmation"),Me("root")]),slot:O(),timestamp:O()}),P({type:Me("createdBank"),parent:O(),slot:O(),timestamp:O()}),P({type:Me("frozen"),slot:O(),timestamp:O(),stats:P({numTransactionEntries:O(),numSuccessfulTransactions:O(),numFailedTransactions:O(),maxTransactionsPerEntry:O()})}),P({type:Me("dead"),slot:O(),timestamp:O(),err:z()})]),Ov=P({subscription:O(),result:Iv}),kv=P({subscription:O(),result:ea(Ot([Z1,Y1]))}),Tv=P({subscription:O(),result:O()}),Nv=P({pubkey:z(),gossip:j(z()),tpu:j(z()),rpc:j(z()),version:j(z())}),Xd=P({votePubkey:z(),nodePubkey:z(),activatedStake:O(),epochVoteAccount:ur(),epochCredits:W(No([O(),O(),O()])),commission:O(),lastVote:O(),rootSlot:j(O())}),Bv=ge(P({current:W(Xd),delinquent:W(Xd)})),Lv=Ot([Me("processed"),Me("confirmed"),Me("finalized")]),Cv=P({slot:O(),confirmations:j(O()),err:Kn,confirmationStatus:ne(Lv)}),Pv=Ze(W(j(Cv))),Mv=ge(O()),mh=P({accountKey:qe,writableIndexes:W(O()),readonlyIndexes:W(O())}),Lu=P({signatures:W(z()),message:P({accountKeys:W(z()),header:P({numRequiredSignatures:O(),numReadonlySignedAccounts:O(),numReadonlyUnsignedAccounts:O()}),instructions:W(P({accounts:W(O()),data:z(),programIdIndex:O()})),recentBlockhash:z(),addressTableLookups:ne(W(mh))})}),gh=P({pubkey:qe,signer:ur(),writable:ur(),source:ne(Ot([Me("transaction"),Me("lookupTable")]))}),yh=P({accountKeys:W(gh),signatures:W(z())}),_h=P({parsed:$n(),program:z(),programId:qe}),bh=P({accounts:W(qe),data:z(),programId:qe}),Uv=Ot([bh,_h]),Dv=Ot([P({parsed:$n(),program:z(),programId:z()}),P({accounts:W(z()),data:z(),programId:z()})]),wh=_i(Uv,Dv,r=>"accounts"in r?$(r,bh):$(r,_h)),vh=P({signatures:W(z()),message:P({accountKeys:W(gh),instructions:W(wh),recentBlockhash:z(),addressTableLookups:ne(j(W(mh)))})}),Yo=P({accountIndex:O(),mint:z(),owner:ne(z()),programId:ne(z()),uiTokenAmount:Eu}),Eh=P({writable:W(qe),readonly:W(qe)}),ta=P({err:Kn,fee:O(),innerInstructions:ne(j(W(P({index:O(),instructions:W(P({accounts:W(O()),data:z(),programIdIndex:O()}))})))),preBalances:W(O()),postBalances:W(O()),logMessages:ne(j(W(z()))),preTokenBalances:ne(j(W(Yo))),postTokenBalances:ne(j(W(Yo))),loadedAddresses:ne(Eh),computeUnitsConsumed:ne(O())}),Cu=P({err:Kn,fee:O(),innerInstructions:ne(j(W(P({index:O(),instructions:W(wh)})))),preBalances:W(O()),postBalances:W(O()),logMessages:ne(j(W(z()))),preTokenBalances:ne(j(W(Yo))),postTokenBalances:ne(j(W(Yo))),loadedAddresses:ne(Eh),computeUnitsConsumed:ne(O())}),Ri=Ot([Me(0),Me("legacy")]),Hn=P({pubkey:z(),lamports:O(),postBalance:j(O()),rewardType:j(z()),commission:ne(j(O()))}),zv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:W(P({transaction:Lu,meta:j(ta),version:ne(Ri)})),rewards:ne(W(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Fv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),rewards:ne(W(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Vv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:W(P({transaction:yh,meta:j(ta),version:ne(Ri)})),rewards:ne(W(Hn)),blockTime:j(O()),blockHeight:j(O())}))),$v=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:W(P({transaction:vh,meta:j(Cu),version:ne(Ri)})),rewards:ne(W(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Wv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:W(P({transaction:yh,meta:j(Cu),version:ne(Ri)})),rewards:ne(W(Hn)),blockTime:j(O()),blockHeight:j(O())}))),qv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),rewards:ne(W(Hn)),blockTime:j(O()),blockHeight:j(O())}))),jv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:W(P({transaction:Lu,meta:j(ta)})),rewards:ne(W(Hn)),blockTime:j(O())}))),Jd=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),signatures:W(z()),blockTime:j(O())}))),du=ge(j(P({slot:O(),meta:j(ta),blockTime:ne(j(O())),transaction:Lu,version:ne(Ri)}))),Fo=ge(j(P({slot:O(),transaction:vh,meta:j(Cu),blockTime:ne(j(O())),version:ne(Ri)}))),Kv=Ze(P({blockhash:z(),lastValidBlockHeight:O()})),Hv=Ze(ur()),Gv=P({slot:O(),numTransactions:O(),numSlots:O(),samplePeriodSecs:O()}),Zv=ge(W(Gv)),Yv=Ze(j(P({feeCalculator:P({lamportsPerSignature:O()})}))),Xv=ge(z()),Jv=ge(z()),Qv=P({err:Kn,logs:W(z()),signature:z()}),eE=P({result:ea(Qv),subscription:O()}),tE={"solana-client":"js/1.0.0-maintenance"},Xo=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let p={};return async m=>{let{commitment:b,config:A}=Be(m),S=this._buildArgs([],b,void 0,A),T=Hd(S);return p[T]=p[T]??(async()=>{try{let I=await this._rpcRequest("getBlockHeight",S),x=$(I,ge(O()));if("error"in x)throw new Q(x.error,"failed to get block height information");return x.result}finally{delete p[T]}})(),await p[T]}})();let n,i,s,o,c,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,i=t.httpHeaders,s=t.fetch,o=t.fetchMiddleware,c=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=F1(e),this._rpcWsEndpoint=n||D1(e),this._rpcClient=tv(e,i,s,o,c,u),this._rpcRequest=rv(this._rpcClient),this._rpcBatchRequest=nv(this._rpcClient),this._rpcWebSocket=new vu(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e.toBase58()],n,void 0,i),o=await this._rpcRequest("getBalance",s),c=$(o,Ze(O()));if("error"in c)throw new Q(c.error,`failed to get balance for ${e.toBase58()}`);return c.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+n)})}async getBlockTime(e){let t=await this._rpcRequest("getBlockTime",[e]),n=$(t,ge(j(O())));if("error"in n)throw new Q(n.error,`failed to get block time for slot ${e}`);return n.result}async getMinimumLedgerSlot(){let e=await this._rpcRequest("minimumLedgerSlot",[]),t=$(e,ge(O()));if("error"in t)throw new Q(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){let e=await this._rpcRequest("getFirstAvailableBlock",[]),t=$(e,fv);if("error"in t)throw new Q(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};let n=await this._rpcRequest("getSupply",[t]),i=$(n,lv);if("error"in i)throw new Q(i.error,"failed to get supply");return i.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenSupply",n),s=$(i,Ze(Eu));if("error"in s)throw new Q(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenAccountBalance",n),s=$(i,Ze(Eu));if("error"in s)throw new Q(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(e,t,n){let{commitment:i,config:s}=Be(n),o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});let c=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",c),p=$(u,hv);if("error"in p)throw new Q(p.error,`failed to get token accounts owned by account ${e.toBase58()}`);return p.result}async getParsedTokenAccountsByOwner(e,t,n){let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});let s=this._buildArgs(i,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),c=$(o,pv);if("error"in c)throw new Q(c.error,`failed to get token accounts owned by account ${e.toBase58()}`);return c.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],i=await this._rpcRequest("getLargestAccounts",n),s=$(i,mv);if("error"in s)throw new Q(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenLargestAccounts",n),s=$(i,dv);if("error"in s)throw new Q(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e.toBase58()],n,"base64",i),o=await this._rpcRequest("getAccountInfo",s),c=$(o,Ze(j(us)));if("error"in c)throw new Q(c.error,`failed to get info about account ${e.toBase58()}`);return c.result}async getParsedAccountInfo(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),c=$(o,Ze(j(Su)));if("error"in c)throw new Q(c.error,`failed to get info about account ${e.toBase58()}`);return c.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(n){throw new Error("failed to get info about account "+e.toBase58()+": "+n)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:i}=Be(t),s=e.map(p=>p.toBase58()),o=this._buildArgs([s],n,"jsonParsed",i),c=await this._rpcRequest("getMultipleAccounts",o),u=$(c,Ze(W(j(Su))));if("error"in u)throw new Q(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:i}=Be(t),s=e.map(p=>p.toBase58()),o=this._buildArgs([s],n,"base64",i),c=await this._rpcRequest("getMultipleAccounts",o),u=$(c,Ze(W(j(us))));if("error"in u)throw new Q(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:i,config:s}=Be(t),o=this._buildArgs([e.toBase58()],i,void 0,{...s,epoch:n??s?.epoch}),c=await this._rpcRequest("getStakeActivation",o),u=$(c,ge(bv));if("error"in u)throw new Q(u.error,`failed to get Stake Activation ${e.toBase58()}`);return u.result}async getProgramAccounts(e,t){let{commitment:n,config:i}=Be(t),{encoding:s,...o}=i||{},c=this._buildArgs([e.toBase58()],n,s||"base64",{...o,...o.filters?{filters:Zd(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",c),p=W(gv),m=o.withContext===!0?$(u,Ze(p)):$(u,ge(p));if("error"in m)throw new Q(m.error,`failed to get accounts owned by program ${e.toBase58()}`);return m.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),c=$(o,ge(W(_v)));if("error"in c)throw new Q(c.error,`failed to get accounts owned by program ${e.toBase58()}`);return c.result}async confirmTransaction(e,t){let n;if(typeof e=="string")n=e;else{let s=e;if(s.abortSignal?.aborted)return Promise.reject(s.abortSignal.reason);n=s.signature}let i;try{i=vt.default.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return xe(i.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener("abort",()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,i,s=!1,o=new Promise((u,p)=>{try{n=this.onSignature(t,(b,A)=>{n=void 0;let S={context:A,value:b};u({__type:cn.PROCESSED,response:S})},e);let m=new Promise(b=>{n==null?b():i=this._onSubscriptionStateChange(n,A=>{A==="subscribed"&&b()})});(async()=>{if(await m,s)return;let b=await this.getSignatureStatus(t);if(s||b==null)return;let{context:A,value:S}=b;if(S!=null)if(S?.err)p(S.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(S.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(S.confirmationStatus==="processed"||S.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,u({__type:cn.PROCESSED,response:{context:A,value:S}})}})()}catch(m){p(m)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:i}}){let s=!1,o=new Promise(b=>{let A=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let S=await A();if(!s){for(;S<=n;)if(await Wn(1e3),s||(S=await A(),s))return;b({__type:cn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),p=this.getCancellationPromise(t),m;try{let b=await Promise.race([p,u,o]);if(b.__type===cn.PROCESSED)m=b.response;else throw new qo(i)}finally{s=!0,c()}return m}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let c=!1,u=new Promise(S=>{let T=s,I=null,x=async()=>{try{let{context:B,value:U}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:n});return I=B.slot,U?.nonce}catch{return T}};(async()=>{if(T=await x(),!c)for(;;){if(s!==T){S({__type:cn.NONCE_INVALID,slotInWhichNonceDidAdvance:I});return}if(await Wn(2e3),c||(T=await x(),c))return}})()}),{abortConfirmation:p,confirmationPromise:m}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),b=this.getCancellationPromise(t),A;try{let S=await Promise.race([b,m,u]);if(S.__type===cn.PROCESSED)A=S.response;else{let T;for(;;){let I=await this.getSignatureStatus(o);if(I==null)break;if(I.context.slot<(S.slotInWhichNonceDidAdvance??n)){await Wn(400);continue}T=I;break}if(T?.value){let I=e||"finalized",{confirmationStatus:x}=T.value;switch(I){case"processed":case"recent":if(x!=="processed"&&x!=="confirmed"&&x!=="finalized")throw new qn(o);break;case"confirmed":case"single":case"singleGossip":if(x!=="confirmed"&&x!=="finalized")throw new qn(o);break;case"finalized":case"max":case"root":if(x!=="finalized")throw new qn(o);break;default:}A={context:T.context,value:{err:T.value.err}}}else throw new qn(o)}}finally{c=!0,p()}return A}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,i=new Promise(u=>{let p=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{p=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:cn.TIMED_OUT,timeoutMs:p}),p)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),c;try{let u=await Promise.race([o,i]);if(u.__type===cn.PROCESSED)c=u.response;else throw new jo(t,u.timeoutMs/1e3)}finally{clearTimeout(n),s()}return c}async getClusterNodes(){let e=await this._rpcRequest("getClusterNodes",[]),t=$(e,ge(W(Nv)));if("error"in t)throw new Q(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=await this._rpcRequest("getVoteAccounts",t),i=$(n,Bv);if("error"in i)throw new Q(i.error,"failed to get vote accounts");return i.result}async getSlot(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlot",i),o=$(s,ge(O()));if("error"in o)throw new Q(o.error,"failed to get slot");return o.result}async getSlotLeader(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlotLeader",i),o=$(s,ge(z()));if("error"in o)throw new Q(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){let n=[e,t],i=await this._rpcRequest("getSlotLeaders",n),s=$(i,ge(W(qe)));if("error"in s)throw new Q(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(e,t){let{context:n,value:i}=await this.getSignatureStatuses([e],t);xe(i.length===1);let s=i[0];return{context:n,value:s}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let i=await this._rpcRequest("getSignatureStatuses",n),s=$(i,Pv);if("error"in s)throw new Q(s.error,"failed to get signature status");return s.result}async getTransactionCount(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getTransactionCount",i),o=$(s,ge(O()));if("error"in o)throw new Q(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=await this._rpcRequest("getInflationGovernor",t),i=$(n,iv);if("error"in i)throw new Q(i.error,"failed to get inflation");return i.result}async getInflationReward(e,t,n){let{commitment:i,config:s}=Be(n),o=this._buildArgs([e.map(p=>p.toBase58())],i,void 0,{...s,epoch:t??s?.epoch}),c=await this._rpcRequest("getInflationReward",o),u=$(c,W1);if("error"in u)throw new Q(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){let e=await this._rpcRequest("getInflationRate",[]),t=$(e,sv);if("error"in t)throw new Q(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getEpochInfo",i),o=$(s,av);if("error"in o)throw new Q(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){let e=await this._rpcRequest("getEpochSchedule",[]),t=$(e,cv);if("error"in t)throw new Q(t.error,"failed to get epoch schedule");let n=t.result;return new wu(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){let e=await this._rpcRequest("getLeaderSchedule",[]),t=$(e,uv);if("error"in t)throw new Q(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),i=await this._rpcRequest("getMinimumBalanceForRentExemption",n),s=$(i,Mv);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),n=$(t,Zv);if("error"in n)throw new Q(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),i=await this._rpcRequest("getFeeCalculatorForBlockhash",n),s=$(i,Yv);if("error"in s)throw new Q(s.error,"failed to get fee calculator");let{context:o,value:c}=s.result;return{context:o,value:c!==null?c.feeCalculator:null}}async getFeeForMessage(e,t){let n=_e(e.serialize()).toString("base64"),i=this._buildArgs([n],t),s=await this._rpcRequest("getFeeForMessage",i),o=$(s,Ze(j(O())));if("error"in o)throw new Q(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(o=>o.toBase58()),n=t?.length?[t]:[],i=await this._rpcRequest("getRecentPrioritizationFees",n),s=$(i,ov);if("error"in s)throw new Q(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getLatestBlockhash",i),o=$(s,Kv);if("error"in o)throw new Q(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e],n,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),c=$(o,Hv);if("error"in c)throw new Q(c.error,"failed to determine if the blockhash `"+e+"`is valid");return c.result}async getVersion(){let e=await this._rpcRequest("getVersion",[]),t=$(e,ge(X1));if("error"in t)throw new Q(t.error,"failed to get version");return t.result}async getGenesisHash(){let e=await this._rpcRequest("getGenesisHash",[]),t=$(e,ge(z()));if("error"in t)throw new Q(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i?.transactionDetails){case"accounts":{let c=$(o,Vv);if("error"in c)throw c.error;return c.result}case"none":{let c=$(o,Fv);if("error"in c)throw c.error;return c.result}default:{let c=$(o,zv);if("error"in c)throw c.error;let{result:u}=c;return u?{...u,transactions:u.transactions.map(({transaction:p,meta:m,version:b})=>({meta:m,transaction:{...p,message:lu(b,p.message)},version:b}))}:null}}}catch(c){throw new Q(c,"failed to get confirmed block")}}async getParsedBlock(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i?.transactionDetails){case"accounts":{let c=$(o,Wv);if("error"in c)throw c.error;return c.result}case"none":{let c=$(o,qv);if("error"in c)throw c.error;return c.result}default:{let c=$(o,$v);if("error"in c)throw c.error;return c.result}}}catch(c){throw new Q(c,"failed to get block")}}async getBlockProduction(e){let t,n;if(typeof e=="string")n=e;else if(e){let{commitment:c,...u}=e;n=c,t=u}let i=this._buildArgs([],n,"base64",t),s=await this._rpcRequest("getBlockProduction",i),o=$(s,ev);if("error"in o)throw new Q(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getTransaction",s),c=$(o,du);if("error"in c)throw new Q(c.error,"failed to get transaction");let u=c.result;return u&&{...u,transaction:{...u.transaction,message:lu(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),c=$(o,Fo);if("error"in c)throw new Q(c.error,"failed to get transaction");return c.result}async getParsedTransactions(e,t){let{commitment:n,config:i}=Be(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{let p=$(u,Fo);if("error"in p)throw new Q(p.error,"failed to get transactions");return p.result})}async getTransactions(e,t){let{commitment:n,config:i}=Be(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{let p=$(u,du);if("error"in p)throw new Q(p.error,"failed to get transactions");let m=p.result;return m&&{...m,transaction:{...m.transaction,message:lu(m.version,m.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getBlock",n),s=$(i,jv);if("error"in s)throw new Q(s.error,"failed to get confirmed block");let o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");let c={...o,transactions:o.transactions.map(({transaction:u,meta:p})=>{let m=new ln(u.message);return{meta:p,transaction:{...u,message:m}}})};return{...c,transactions:c.transactions.map(({transaction:u,meta:p})=>({meta:p,transaction:Se.populate(u.message,u.signatures)}))}}async getBlocks(e,t,n){let i=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),s=await this._rpcRequest("getBlocks",i),o=$(s,ge(W(O())));if("error"in o)throw new Q(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=$(i,Jd);if("error"in s)throw new Q(s.error,"failed to get block");let o=s.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=$(i,Jd);if("error"in s)throw new Q(s.error,"failed to get confirmed block");let o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getTransaction",n),s=$(i,du);if("error"in s)throw new Q(s.error,"failed to get transaction");let o=s.result;if(!o)return o;let c=new ln(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Se.populate(c,u)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),i=await this._rpcRequest("getTransaction",n),s=$(i,Fo);if("error"in s)throw new Q(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(e,t){let n=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(o=>{let c=$(o,Fo);if("error"in c)throw new Q(c.error,"failed to get confirmed transactions");return c.result})}async getConfirmedSignaturesForAddress(e,t,n){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(t--,!(t<=0||t<s));)try{let u=await this.getConfirmedBlockSignatures(t,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(n++,!(n>o));)try{let u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(e,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=$(s,wv);if("error"in o)throw new Q(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,n){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getSignaturesForAddress",i),o=$(s,vv);if("error"in o)throw new Q(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){let{context:n,value:i}=await this.getAccountInfoAndContext(e,t),s=null;return i!==null&&(s=new Zo({key:e,state:Zo.deserialize(i.data)})),{context:n,value:s}}async getNonceAndContext(e,t){let{context:n,value:i}=await this.getAccountInfoAndContext(e,t),s=null;return i!==null&&(s=_u.fromAccountData(i.data)),{context:n,value:s}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+n)})}async requestAirdrop(e,t){let n=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),i=$(n,Xv);if("error"in i)throw new Q(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await Wn(100);let n=Date.now()-this._blockhashInfo.lastFetch>=z1;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let i=0;i<50;i++){let s=await this.getLatestBlockhash("finalized");if(n!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await Wn(lh/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,"base64",n),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=$(s,Ze(O()));if("error"in o)throw new Q(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,n){if("message"in e){let I=e.serialize(),x=ae.Buffer.from(I).toString("base64");if(Array.isArray(t)||n!==void 0)throw new Error("Invalid arguments");let B=t||{};B.encoding="base64","commitment"in B||(B.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(B.innerInstructions=t.innerInstructions);let U=[x,B],L=await this._rpcRequest("simulateTransaction",U),F=$(L,Yd);if("error"in F)throw new Error("failed to simulate transaction: "+F.error.message);return F.result}let i;if(e instanceof Se){let T=e;i=new Se,i.feePayer=T.feePayer,i.instructions=e.instructions,i.nonceInfo=T.nonceInfo,i.signatures=T.signatures}else i=Se.populate(e),i._message=i._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");let s=t;if(i.nonceInfo&&s)i.sign(...s);else{let T=this._disableBlockhashCaching;for(;;){let I=await this._blockhashWithExpiryBlockHeight(T);if(i.lastValidBlockHeight=I.lastValidBlockHeight,i.recentBlockhash=I.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");let x=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(x)&&!this._blockhashInfo.transactionSignatures.includes(x)){this._blockhashInfo.simulatedSignatures.push(x);break}else T=!0}}let o=i._compile(),c=o.serialize(),p=i._serialize(c).toString("base64"),m={encoding:"base64",commitment:this.commitment};if(n){let T=(Array.isArray(n)?n:o.nonProgramIds()).map(I=>I.toBase58());m.accounts={encoding:"base64",addresses:T}}s&&(m.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(m.innerInstructions=t.innerInstructions);let b=[p,m],A=await this._rpcRequest("simulateTransaction",b),S=$(A,Yd);if("error"in S){let T;if("data"in S.error&&(T=S.error.data.logs,T&&Array.isArray(T))){let I=`
12
- `,x=I+T.join(I);console.error(S.error.message,x)}throw new cs({action:"simulate",signature:"",transactionMessage:S.error.message,logs:T})}return S.result}async sendTransaction(e,t,n){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");let o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");let i=t;if(e.nonceInfo)e.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){let c=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=c.lastValidBlockHeight,e.recentBlockhash=c.blockhash,e.sign(...i),!e.signature)throw new Error("!signature");let u=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}let s=e.serialize();return await this.sendRawTransaction(s,n)}async sendRawTransaction(e,t){let n=_e(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:"base64"},i=t&&t.skipPreflight,s=i===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),i&&(n.skipPreflight=i),s&&(n.preflightCommitment=s);let o=[e,n],c=await this._rpcRequest("sendTransaction",o),u=$(c,Jv);if("error"in u){let p;throw"data"in u.error&&(p=u.error.data.logs),new cs({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:p})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,n])=>{this._setSubscription(t,{...n,state:"pending"})})}_setSubscription(e,t){let n=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,n!==t.state){let i=this._subscriptionStateChangeCallbacksByHash[e];i&&i.forEach(s=>{try{s(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let i=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return i.add(t),()=>{i.delete(t),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{let i=this._subscriptionsByHash[n];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[n],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:s,method:o}=i;try{this._setSubscription(n,{...i,state:"subscribing"});let c=await this._rpcWebSocket.call(o,s);this._setSubscription(n,{...i,serverSubscriptionId:c,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[c]=i.callbacks,await this._updateSubscriptions()}catch(c){if(console.error(`Received ${c instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:s,error:c}),!t())return;this._setSubscription(n,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:s,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(n,{...i,state:"unsubscribing"}),this._setSubscription(n,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(c){if(c instanceof Error&&console.error(`${o} error:`,c.message),!t())return;this._setSubscription(n,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(i=>{try{i(...t)}catch(s){console.error(s)}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=$(e,Ev);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,i=Hd([e.method,t]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:s.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let o=this._subscriptionsByHash[i];xe(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){let{commitment:i,config:s}=Be(n),o=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){let{result:t,subscription:n}=$(e,Sv);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,i){let{commitment:s,config:o}=Be(n),c=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:Zd(i)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},c)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,n){let i=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){let{result:t,subscription:n}=$(e,eE);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=$(e,xv);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:n}=$(e,Ov);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){let n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,i){let s=t||this._commitment;if(s||n||i){let o={};n&&(o.encoding=n),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,n,i){let s=t||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,i)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=$(e,kv);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,n){let i=this._buildArgs([e],n||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,c)=>{if(o.type==="status"){t(o.result,c);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(e,t,n){let{commitment:i,...s}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([e],i,void 0,s),c=this._makeSubscription({callback:(u,p)=>{t(u,p);try{this.removeSignatureListener(c)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return c}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){let{result:t,subscription:n}=$(e,Tv);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}},Au=class r{constructor(e){this._keypair=void 0,this._keypair=e??Vd()}static generate(){return new r(Vd())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");let n=e.slice(32,64);if(!t||!t.skipValidation){let i=e.slice(0,32),s=gu(i);for(let o=0;o<32;o++)if(n[o]!==s[o])throw new Error("provided secretKey is invalid")}return new r({publicKey:n,secretKey:e})}static fromSeed(e){let t=gu(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new r({publicKey:t,secretKey:n})}get publicKey(){return new ce(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},ss=Object.freeze({CreateLookupTable:{index:0,layout:E.struct([E.u32("instruction"),vi("recentSlot"),E.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:E.struct([E.u32("instruction")])},ExtendLookupTable:{index:2,layout:E.struct([E.u32("instruction"),vi(),E.seq(ye(),E.offset(E.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:E.struct([E.u32("instruction")])},CloseLookupTable:{index:4,layout:E.struct([E.u32("instruction")])}});var xu=class{constructor(){}static createLookupTable(e){let[t,n]=ce.findProgramAddressSync([e.authority.toBuffer(),$c().encode(e.recentSlot)],this.programId),i=ss.CreateLookupTable,s=we(i,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Dt.programId,isSigner:!1,isWritable:!1}];return[new Te({programId:this.programId,keys:o,data:s}),t]}static freezeLookupTable(e){let t=ss.FreezeLookupTable,n=we(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Te({programId:this.programId,keys:i,data:n})}static extendLookupTable(e){let t=ss.ExtendLookupTable,n=we(t,{addresses:e.addresses.map(s=>s.toBytes())}),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&i.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Dt.programId,isSigner:!1,isWritable:!1}),new Te({programId:this.programId,keys:i,data:n})}static deactivateLookupTable(e){let t=ss.DeactivateLookupTable,n=we(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Te({programId:this.programId,keys:i,data:n})}static closeLookupTable(e){let t=ss.CloseLookupTable,n=we(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new Te({programId:this.programId,keys:i,data:n})}};xu.programId=new ce("AddressLookupTab1e1111111111111111111111111");var Vo=Object.freeze({RequestUnits:{index:0,layout:E.struct([E.u8("instruction"),E.u32("units"),E.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:E.struct([E.u8("instruction"),E.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:E.struct([E.u8("instruction"),E.u32("units")])},SetComputeUnitPrice:{index:3,layout:E.struct([E.u8("instruction"),vi("microLamports")])}}),Iu=class{constructor(){}static requestUnits(e){let t=Vo.RequestUnits,n=we(t,e);return new Te({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=Vo.RequestHeapFrame,n=we(t,e);return new Te({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=Vo.SetComputeUnitLimit,n=we(t,e);return new Te({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=Vo.SetComputeUnitPrice,n=we(t,{microLamports:BigInt(e.microLamports)});return new Te({keys:[],programId:this.programId,data:n})}};Iu.programId=new ce("ComputeBudget111111111111111111111111111111");var Qd=64,eh=32,th=64,rh=E.struct([E.u8("numSignatures"),E.u8("padding"),E.u16("signatureOffset"),E.u16("signatureInstructionIndex"),E.u16("publicKeyOffset"),E.u16("publicKeyInstructionIndex"),E.u16("messageDataOffset"),E.u16("messageDataSize"),E.u16("messageInstructionIndex")]),Ou=class r{constructor(){}static createInstructionWithPublicKey(e){let{publicKey:t,message:n,signature:i,instructionIndex:s}=e;xe(t.length===eh,`Public Key must be ${eh} bytes but received ${t.length} bytes`),xe(i.length===th,`Signature must be ${th} bytes but received ${i.length} bytes`);let o=rh.span,c=o+t.length,u=c+i.length,p=1,m=ae.Buffer.alloc(u+n.length),b=s??65535;return rh.encode({numSignatures:p,padding:0,signatureOffset:c,signatureInstructionIndex:b,publicKeyOffset:o,publicKeyInstructionIndex:b,messageDataOffset:u,messageDataSize:n.length,messageInstructionIndex:b},m),m.fill(t,o),m.fill(i,c),m.fill(n,u),new Te({keys:[],programId:r.programId,data:m})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:i}=e;xe(t.length===Qd,`Private key must be ${Qd} bytes but received ${t.length} bytes`);try{let s=Au.fromSecretKey(t),o=s.publicKey.toBytes(),c=Tu(n,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:c,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}};Ou.programId=new ce("Ed25519SigVerify111111111111111111111111111");var rE=(r,e)=>{let t=ns.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};ns.utils.isValidPrivateKey;var nE=ns.getPublicKey,nh=32,hu=20,ih=64,iE=11,pu=E.struct([E.u8("numSignatures"),E.u16("signatureOffset"),E.u8("signatureInstructionIndex"),E.u16("ethAddressOffset"),E.u8("ethAddressInstructionIndex"),E.u16("messageDataOffset"),E.u16("messageDataSize"),E.u8("messageInstructionIndex"),E.blob(20,"ethAddress"),E.blob(64,"signature"),E.u8("recoveryId")]),ku=class r{constructor(){}static publicKeyToEthAddress(e){xe(e.length===ih,`Public key must be ${ih} bytes but received ${e.length} bytes`);try{return ae.Buffer.from(ru(_e(e))).slice(-hu)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){let{publicKey:t,message:n,signature:i,recoveryId:s,instructionIndex:o}=e;return r.createInstructionWithEthAddress({ethAddress:r.publicKeyToEthAddress(t),message:n,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(e){let{ethAddress:t,message:n,signature:i,recoveryId:s,instructionIndex:o=0}=e,c;typeof t=="string"?t.startsWith("0x")?c=ae.Buffer.from(t.substr(2),"hex"):c=ae.Buffer.from(t,"hex"):c=t,xe(c.length===hu,`Address must be ${hu} bytes but received ${c.length} bytes`);let u=1+iE,p=u,m=u+c.length,b=m+i.length+1,A=1,S=ae.Buffer.alloc(pu.span+n.length);return pu.encode({numSignatures:A,signatureOffset:m,signatureInstructionIndex:o,ethAddressOffset:p,ethAddressInstructionIndex:o,messageDataOffset:b,messageDataSize:n.length,messageInstructionIndex:o,signature:_e(i),ethAddress:_e(c),recoveryId:s},S),S.fill(_e(n),pu.span),new Te({keys:[],programId:r.programId,data:S})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:i}=e;xe(t.length===nh,`Private key must be ${nh} bytes but received ${t.length} bytes`);try{let s=_e(t),o=nE(s,!1).slice(1),c=ae.Buffer.from(ru(_e(n))),[u,p]=rE(c,s);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:u,recoveryId:p,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}};ku.programId=new ce("KeccakSecp256k11111111111111111111111111111");var Rh,sE=new ce("StakeConfig11111111111111111111111111111111");var fs=class{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}};Rh=fs;fs.default=new Rh(0,0,ce.default);var un=Object.freeze({Initialize:{index:0,layout:E.struct([E.u32("instruction"),w1(),v1()])},Authorize:{index:1,layout:E.struct([E.u32("instruction"),ye("newAuthorized"),E.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:E.struct([E.u32("instruction")])},Split:{index:3,layout:E.struct([E.u32("instruction"),E.ns64("lamports")])},Withdraw:{index:4,layout:E.struct([E.u32("instruction"),E.ns64("lamports")])},Deactivate:{index:5,layout:E.struct([E.u32("instruction")])},Merge:{index:7,layout:E.struct([E.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:E.struct([E.u32("instruction"),ye("newAuthorized"),E.u32("stakeAuthorizationType"),bi("authoritySeed"),ye("authorityOwner")])}}),$A=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),Jo=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:i}=e,s=i||fs.default,o=un.Initialize,c=we(o,{authorized:{staker:_e(n.staker.toBuffer()),withdrawer:_e(n.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:_e(s.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:as,isSigner:!1,isWritable:!1}],programId:this.programId,data:c};return new Te(u)}static createAccountWithSeed(e){let t=new Se;t.add(Dt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static createAccount(e){let t=new Se;t.add(Dt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:i}=e,s=un.Delegate,o=we(s);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:cu,isSigner:!1,isWritable:!1},{pubkey:sE,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=e,c=un.Authorize,u=we(c,{newAuthorized:_e(i.toBuffer()),stakeAuthorizationType:s.index}),p=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&p.push({pubkey:o,isSigner:!0,isWritable:!1}),new Se().add({keys:p,programId:this.programId,data:u})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:n,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:c,custodianPubkey:u}=e,p=un.AuthorizeWithSeed,m=we(p,{newAuthorized:_e(o.toBuffer()),stakeAuthorizationType:c.index,authoritySeed:i,authorityOwner:_e(s.toBuffer())}),b=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1}];return u&&b.push({pubkey:u,isSigner:!0,isWritable:!1}),new Se().add({keys:b,programId:this.programId,data:m})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:i,lamports:s}=e,o=un.Split,c=we(o,{lamports:s});return new Te({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:c})}static split(e,t){let n=new Se;return n.add(Dt.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:c,lamports:u}=e,p=new Se;return p.add(Dt.allocate({accountPubkey:s,basePubkey:o,seed:c,space:this.space,programId:this.programId})),t&&t>0&&p.add(Dt.transfer({fromPubkey:e.authorizedPubkey,toPubkey:s,lamports:t})),p.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:i}=e,s=un.Merge,o=we(s);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:cu,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:i,lamports:s,custodianPubkey:o}=e,c=un.Withdraw,u=we(c,{lamports:s}),p=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:cu,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&p.push({pubkey:o,isSigner:!0,isWritable:!1}),new Se().add({keys:p,programId:this.programId,data:u})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:n}=e,i=un.Deactivate,s=we(i);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}};Jo.programId=new ce("Stake11111111111111111111111111111111111111");Jo.space=200;var os=Object.freeze({InitializeAccount:{index:0,layout:E.struct([E.u32("instruction"),E1()])},Authorize:{index:1,layout:E.struct([E.u32("instruction"),ye("newAuthorized"),E.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:E.struct([E.u32("instruction"),E.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:E.struct([E.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:E.struct([E.u32("instruction"),R1()])}}),WA=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),Qo=class r{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:i}=e,s=os.InitializeAccount,o=we(s,{voteInit:{nodePubkey:_e(i.nodePubkey.toBuffer()),authorizedVoter:_e(i.authorizedVoter.toBuffer()),authorizedWithdrawer:_e(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),c={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:as,isSigner:!1,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Te(c)}static createAccount(e){let t=new Se;return t.add(Dt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,voteAuthorizationType:s}=e,o=os.Authorize,c=we(o,{newAuthorized:_e(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Se().add({keys:u,programId:this.programId,data:c})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:c}=e,u=os.AuthorizeWithSeed,p=we(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:_e(n.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:_e(s.toBuffer()),voteAuthorizationType:o.index}}),m=[{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Se().add({keys:m,programId:this.programId,data:p})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:i,toPubkey:s}=e,o=os.Withdraw,c=we(o,{lamports:i}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Se().add({keys:u,programId:this.programId,data:c})}static safeWithdraw(e,t,n){if(e.lamports>t-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return r.withdraw(e)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:i}=e,s=os.UpdateValidatorIdentity,o=we(s),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Se().add({keys:c,programId:this.programId,data:o})}};Qo.programId=new ce("Vote111111111111111111111111111111111111111");Qo.space=3762;var qA=new ce("Va1idator1nfo111111111111111111111111111111"),jA=P({name:z(),website:ne(z()),details:ne(z()),iconUrl:ne(z()),keybaseUsername:ne(z())});var KA=new ce("Vote111111111111111111111111111111111111111"),HA=E.struct([ye("nodePubkey"),ye("authorizedWithdrawer"),E.u8("commission"),E.nu64(),E.seq(E.struct([E.nu64("slot"),E.u32("confirmationCount")]),E.offset(E.u32(),-8),"votes"),E.u8("rootSlotValid"),E.nu64("rootSlot"),E.nu64(),E.seq(E.struct([E.nu64("epoch"),ye("authorizedVoter")]),E.offset(E.u32(),-8),"authorizedVoters"),E.struct([E.seq(E.struct([ye("authorizedPubkey"),E.nu64("epochOfLastAuthorizedSwitch"),E.nu64("targetEpoch")]),32,"buf"),E.nu64("idx"),E.u8("isEmpty")],"priorVoters"),E.nu64(),E.seq(E.struct([E.nu64("epoch"),E.nu64("credits"),E.nu64("prevCredits")]),E.offset(E.u32(),-8),"epochCredits"),E.struct([E.nu64("slot"),E.nu64("timestamp")],"lastTimestamp")]);var Pu=r=>({request:r,signMessage:e=>r({method:"signMessage",params:{message:e}}),signTransaction:e=>r({method:"signTransaction",params:{transaction:e}}),signAndSendTransaction:e=>r({method:"signAndSendTransaction",params:e})});function Mu(r){return Buffer.from(r.serialize({verifySignatures:!1})).toString("base64")}function Uu(r){let e=Uint8Array.from(Buffer.from(r,"base64"));return(e[0]&128)!==0?Go.deserialize(e):Se.from(e)}function oE(r){return async t=>{if(t.method==="connect")return await r(t);if(t.method==="signMessage")return await r(t);if(t.method==="signAndSendTransaction"){let{transaction:n,options:i}=t.params,s={transaction:Uu(n),options:i};return await r({method:"signAndSendTransaction",params:s})}if(t.method==="signTransaction"){let{transaction:n}=t.params,i={transaction:Uu(n)},{signedTransaction:s}=await r({method:"signTransaction",params:i});return{signedTransaction:Mu(s)}}}}function Du(r){return async t=>{if(t.method==="connect")return await r(t);if(t.method==="signMessage")return await r(t);if(t.method==="signAndSendTransaction"){let{transaction:n,options:i}=t.params,s={transaction:Mu(n)};return await r({method:"signAndSendTransaction",params:s})}if(t.method==="signTransaction"){let{transaction:n}=t.params,i={transaction:Mu(n)},{signedTransaction:s}=await r({method:"signTransaction",params:i});return{signedTransaction:Uu(s)}}}}var Sh="0.1.1";function Ah(){return Sh}var ra=class r extends Error{constructor(e,t={}){let n=(()=>{if(t.cause instanceof r){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause?.message?t.cause.message:t.details})(),i=t.cause instanceof r&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${i??""}`,c=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||i?["",n?`Details: ${n}`:void 0,i?`See: ${o}`:void 0]:[]].filter(u=>typeof u=="string").join(`
13
- `);super(c,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Ah()}`}),this.cause=t.cause,this.details=n,this.docs=o,this.docsPath=i,this.shortMessage=e}walk(e){return xh(this,e)}};function xh(r,e){return e?.(r)?r:r&&typeof r=="object"&&"cause"in r&&r.cause?xh(r.cause,e):e?null:r}function na(r,e={}){let{raw:t=!1}=e,n=r;if(t)return r;if(n.error){let{code:i}=n.error,s=i===Gn.code?Gn:i===ls.code?ls:i===ws.code?ws:i===_s.code?_s:i===gs.code?gs:i===bs.code?bs:i===ms.code?ms:i===vs.code?vs:i===ds.code?ds:i===hs.code?hs:i===ps.code?ps:i===ys.code?ys:St;throw new s(n.error)}return n.result}var St=class extends Error{constructor(e){let{code:t,message:n,data:i}=e;super(n),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t,this.data=i}},ls=class r extends St{constructor(e={}){super({message:"Missing or invalid parameters.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}};Object.defineProperty(ls,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});var ds=class r extends St{constructor(e={}){super({message:"Requested resource not found.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}};Object.defineProperty(ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});var hs=class r extends St{constructor(e={}){super({message:"Requested resource not available.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}};Object.defineProperty(hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});var ps=class r extends St{constructor(e={}){super({message:"Transaction creation failed.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}};Object.defineProperty(ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});var ms=class r extends St{constructor(e={}){super({message:"Method is not implemented.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}};Object.defineProperty(ms,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});var gs=class r extends St{constructor(e={}){super({message:"Rate limit exceeded.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}};Object.defineProperty(gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});var ys=class r extends St{constructor(e={}){super({message:"JSON-RPC version not supported.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}};Object.defineProperty(ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});var _s=class r extends St{constructor(e={}){super({message:"Input is not a valid JSON-RPC request.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}};Object.defineProperty(_s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});var bs=class r extends St{constructor(e={}){super({message:"Method does not exist.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}};Object.defineProperty(bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});var ws=class r extends St{constructor(e={}){super({message:"Invalid method parameters.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}};Object.defineProperty(ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});var Gn=class r extends St{constructor(e={}){super({message:"Internal JSON-RPC error.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalErrorError"})}};Object.defineProperty(Gn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});var vs=class r extends St{constructor(e={}){super({message:"Failed to parse JSON-RPC response.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}};Object.defineProperty(vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});var _r=class extends Error{constructor(e,t){super(t),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=t}},Es=class extends _r{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}};Object.defineProperty(Es,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});var Rs=class extends _r{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}};Object.defineProperty(Rs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});var Ss=class extends _r{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}};Object.defineProperty(Ss,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});var As=class extends _r{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}};Object.defineProperty(As,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});var xs=class extends _r{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}};Object.defineProperty(xs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function Oh(){let r=new on.default;return{get eventNames(){return r.eventNames.bind(r)},get listenerCount(){return r.listenerCount.bind(r)},get listeners(){return r.listeners.bind(r)},addListener:r.addListener.bind(r),emit:r.emit.bind(r),off:r.off.bind(r),on:r.on.bind(r),once:r.once.bind(r),removeAllListeners:r.removeAllListeners.bind(r),removeListener:r.removeListener.bind(r)}}function kh(r,e={}){let{includeEvents:t=!0}=e;if(!r)throw new zu;return{...t?{on:r.on?.bind(r),removeListener:r.removeListener?.bind(r)}:{},async request(n){let i=await r.request(n);return i&&typeof i=="object"&&"jsonrpc"in i?na(i):i}}}var zu=class extends ra{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}};function Th(r={}){let e=r.id??0;return{prepare(t){return uE({id:e++,...t})},get id(){return e}}}function uE(r){return{...r,jsonrpc:"2.0"}}var Bh=Symbol("Comlink.proxy"),lE=Symbol("Comlink.endpoint"),dE=Symbol("Comlink.releaseProxy"),Fu=Symbol("Comlink.finalizer"),sa=Symbol("Comlink.thrown"),Lh=r=>typeof r=="object"&&r!==null||typeof r=="function",hE={canHandle:r=>Lh(r)&&r[Bh],serialize(r){let{port1:e,port2:t}=new MessageChannel;return Ph(r,e),[t,[t]]},deserialize(r){return r.start(),$u(r)}},pE={canHandle:r=>Lh(r)&&sa in r,serialize({value:r}){let e;return r instanceof Error?e={isError:!0,value:{message:r.message,name:r.name,stack:r.stack}}:e={isError:!1,value:r},[e,[]]},deserialize(r){throw r.isError?Object.assign(new Error(r.value.message),r.value):r.value}},Ch=new Map([["proxy",hE],["throw",pE]]);function mE(r,e){for(let t of r)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Ph(r,e=globalThis,t=["*"]){e.addEventListener("message",function n(i){if(!i||!i.data)return;if(!mE(t,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}let{id:s,type:o,path:c}=Object.assign({path:[]},i.data),u=(i.data.argumentList||[]).map(Zn),p;try{let m=c.slice(0,-1).reduce((A,S)=>A[S],r),b=c.reduce((A,S)=>A[S],r);switch(o){case"GET":p=b;break;case"SET":m[c.slice(-1)[0]]=Zn(i.data.value),p=!0;break;case"APPLY":p=b.apply(m,u);break;case"CONSTRUCT":{let A=new b(...u);p=vE(A)}break;case"ENDPOINT":{let{port1:A,port2:S}=new MessageChannel;Ph(r,S),p=wE(A,[A])}break;case"RELEASE":p=void 0;break;default:return}}catch(m){p={value:m,[sa]:0}}Promise.resolve(p).catch(m=>({value:m,[sa]:0})).then(m=>{let[b,A]=ca(m);e.postMessage(Object.assign(Object.assign({},b),{id:s}),A),o==="RELEASE"&&(e.removeEventListener("message",n),Mh(e),Fu in r&&typeof r[Fu]=="function"&&r[Fu]())}).catch(m=>{let[b,A]=ca({value:new TypeError("Unserializable return value"),[sa]:0});e.postMessage(Object.assign(Object.assign({},b),{id:s}),A)})}),e.start&&e.start()}function gE(r){return r.constructor.name==="MessagePort"}function Mh(r){gE(r)&&r.close()}function $u(r,e){let t=new Map;return r.addEventListener("message",function(i){let{data:s}=i;if(!s||!s.id)return;let o=t.get(s.id);if(o)try{o(s)}finally{t.delete(s.id)}}),Vu(r,t,[],e)}function ia(r){if(r)throw new Error("Proxy has been released and is not useable")}function Uh(r){return Si(r,new Map,{type:"RELEASE"}).then(()=>{Mh(r)})}var oa=new WeakMap,aa="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{let e=(oa.get(r)||0)-1;oa.set(r,e),e===0&&Uh(r)});function yE(r,e){let t=(oa.get(e)||0)+1;oa.set(e,t),aa&&aa.register(r,e,r)}function _E(r){aa&&aa.unregister(r)}function Vu(r,e,t=[],n=function(){}){let i=!1,s=new Proxy(n,{get(o,c){if(ia(i),c===dE)return()=>{_E(s),Uh(r),e.clear(),i=!0};if(c==="then"){if(t.length===0)return{then:()=>s};let u=Si(r,e,{type:"GET",path:t.map(p=>p.toString())}).then(Zn);return u.then.bind(u)}return Vu(r,e,[...t,c])},set(o,c,u){ia(i);let[p,m]=ca(u);return Si(r,e,{type:"SET",path:[...t,c].map(b=>b.toString()),value:p},m).then(Zn)},apply(o,c,u){ia(i);let p=t[t.length-1];if(p===lE)return Si(r,e,{type:"ENDPOINT"}).then(Zn);if(p==="bind")return Vu(r,e,t.slice(0,-1));let[m,b]=Nh(u);return Si(r,e,{type:"APPLY",path:t.map(A=>A.toString()),argumentList:m},b).then(Zn)},construct(o,c){ia(i);let[u,p]=Nh(c);return Si(r,e,{type:"CONSTRUCT",path:t.map(m=>m.toString()),argumentList:u},p).then(Zn)}});return yE(s,r),s}function bE(r){return Array.prototype.concat.apply([],r)}function Nh(r){let e=r.map(ca);return[e.map(t=>t[0]),bE(e.map(t=>t[1]))]}var Dh=new WeakMap;function wE(r,e){return Dh.set(r,e),r}function vE(r){return Object.assign(r,{[Bh]:!0})}function zh(r,e=globalThis,t="*"){return{postMessage:(n,i)=>r.postMessage(n,t,i),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function ca(r){for(let[e,t]of Ch)if(t.canHandle(r)){let[n,i]=t.serialize(r);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:r},Dh.get(r)||[]]}function Zn(r){switch(r.type){case"HANDLER":return Ch.get(r.name).deserialize(r.value);case"RAW":return r.value}}function Si(r,e,t,n){return new Promise(i=>{let s=EE();e.set(s,i),r.start&&r.start(),r.postMessage(Object.assign({id:s},t),n)})}function EE(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var RE={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},SE={postMessage:r=>{console.debug("[webview:req]",r),window.ReactNativeWebView.postMessage(JSON.stringify(r))},addEventListener:(r,e,...t)=>{document.addEventListener("FarcasterFrameCallback",e,...t)},removeEventListener:(r,e)=>{document.removeEventListener("FarcasterFrameCallback",e)}},Fh=typeof window>"u"?RE:window?.ReactNativeWebView?SE:zh(window?.parent??window);var Ee=$u(Fh);var Wu=Oh(),AE=Th();function xE({code:r,details:e}){switch(r){case 4001:return new Es;case 4100:return new Rs;case 4200:return new Ss;case 4900:return new As;case 4901:return new xs;default:return new _r(r,e??"Unknown provider RPC error")}}var Ai=kh({...Wu,async request(r){let e=AE.prepare(r);try{let t=await Ee.ethProviderRequestV2(e).then(n=>na(n,{request:e,raw:!0}));if(t.error)throw xE(t.error);return t.result}catch(t){if(t instanceof Error&&t.message.match(/cannot read property 'apply'/i))return await Ee.ethProviderRequest(e);throw t instanceof _r||t instanceof St?t:new Gn({message:t instanceof Error?t.message:void 0})}}});async function Vh(){try{let r=await Ee.getCapabilities();return!r.includes("wallet.getEthereumProvider")&&!r.includes("wallet.getEvmProvider")?void 0:Ai}catch{return Ai}}function $h(r){let e=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(r)});window.dispatchEvent(e);let t=()=>window.dispatchEvent(e);return window.addEventListener("eip6963:requestProvider",t),()=>window.removeEventListener("eip6963:requestProvider",t)}typeof document<"u"&&(document.addEventListener("eip6963:requestProvider",()=>{Ee.eip6963RequestProvider()}),document.addEventListener("FarcasterFrameEthProviderEvent",r=>{if(r instanceof MessageEvent){let e=r.data;Wu.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",r=>{if(r instanceof MessageEvent){let e=r.data;e.event==="eip6963:announceProvider"&&$h({info:e.info,provider:Ai})}}));typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{Ee.eip6963RequestProvider()}),window.addEventListener("message",r=>{if(r instanceof MessageEvent&&r.data.type==="frameEthProviderEvent"){let e=r.data;Wu.emit(e.event,...e.params)}}),window.addEventListener("message",r=>{if(r instanceof MessageEvent&&r.data.type==="frameEvent"){let e=r.data.event;e.event==="eip6963:announceProvider"&&$h({info:e.info,provider:Ai})}}));var{solanaProviderRequest:Wh}=Ee,qh;Wh&&(qh=Pu(Du(Wh)));async function jh(){let r;try{r=await Ee.getCapabilities()}catch{}if(r?.includes("wallet.getSolanaProvider"))return qh}function Gh(){let r=new on.default;return{get eventNames(){return r.eventNames.bind(r)},get listenerCount(){return r.listenerCount.bind(r)},get listeners(){return r.listeners.bind(r)},addListener:r.addListener.bind(r),emit:r.emit.bind(r),off:r.off.bind(r),on:r.on.bind(r),once:r.once.bind(r),removeAllListeners:r.removeAllListeners.bind(r),removeListener:r.removeListener.bind(r)}}var Jt=Gh(),Kh=null;async function IE(r=50){if(Kh===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;let e=await Promise.race([Ee.context.then(t=>!!t),new Promise(t=>{setTimeout(()=>t(!1),r)})]).catch(()=>!1);return e&&(Kh=!0),e}var Hh=async()=>{let r=await Ee.addFrame();if(r.result)return r.result;throw r.error.type==="invalid_domain_manifest"?new Xn.InvalidDomainManifest:r.error.type==="rejected_by_user"?new Xn.RejectedByUser:new Error("Unreachable")},qu={...Jt,getCapabilities:Ee.getCapabilities,getChains:Ee.getChains,isInMiniApp:IE,context:Ee.context,actions:{setPrimaryButton:Ee.setPrimaryButton.bind(Ee),ready:Ee.ready.bind(Ee),close:Ee.close.bind(Ee),viewProfile:Ee.viewProfile.bind(Ee),signIn:async r=>{let e=await Ee.signIn(r);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new Oi.RejectedByUser:new Error("Unreachable")},openUrl:r=>{let e=typeof r=="string"?r:r.url;return Ee.openUrl(e.trim())},addFrame:Hh,addMiniApp:Hh,composeCast(r={}){return Ee.composeCast(r)},viewToken:Ee.viewToken.bind(Ee),sendToken:Ee.sendToken.bind(Ee),swapToken:Ee.swapToken.bind(Ee)},experimental:{getSolanaProvider:jh},wallet:{ethProvider:Ai,getEthereumProvider:Vh}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",r=>{if(r instanceof MessageEvent){let e=r.data;e.event==="primary_button_clicked"?Jt.emit("primaryButtonClicked"):e.event==="frame_added"?Jt.emit("frameAdded",{notificationDetails:e.notificationDetails}):e.event==="frame_add_rejected"?Jt.emit("frameAddRejected",{reason:e.reason}):e.event==="frame_removed"?Jt.emit("frameRemoved"):e.event==="notifications_enabled"?Jt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"&&Jt.emit("notificationsDisabled")}});typeof window<"u"&&window.addEventListener("message",r=>{if(r instanceof MessageEvent&&r.data.type==="frameEvent"){let e=r.data.event;e.event==="primary_button_clicked"?Jt.emit("primaryButtonClicked"):e.event==="frame_added"?Jt.emit("frameAdded",{notificationDetails:e.notificationDetails}):e.event==="frame_add_rejected"?Jt.emit("frameAddRejected",{reason:e.reason}):e.event==="frame_removed"?Jt.emit("frameRemoved"):e.event==="notifications_enabled"?Jt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"&&Jt.emit("notificationsDisabled")}});var OE=qu;return Oa(kE);})();
11
+ `+s+o;break;default:c=`Unknown action '${(u=>u)(e)}'`}super(c),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){let s=i.meta.logMessages;this.transactionLogs=s,t(s)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}};var Q=class extends Error{constructor({code:e,message:t,data:n},i){super(i!=null?`${i}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}};async function Gd(r,e,t,n){let i=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},s=await r.sendTransaction(e,t,i),o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await r.confirmTransaction({abortSignal:n?.abortSignal,signature:s,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){let{nonceInstruction:c}=e.nonceInfo,u=c.keys[0].pubkey;o=(await r.confirmTransaction({abortSignal:n?.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:e.nonceInfo.nonce,signature:s},n&&n.commitment)).value}else n?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await r.confirmTransaction(s,n&&n.commitment)).value;if(o.err)throw s!=null?new us({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function qn(r){return new Promise(e=>setTimeout(e,r))}function we(r,e){let t=r.layout.span>=0?r.layout.span:dh(r,e),n=ae.Buffer.alloc(t),i=Object.assign({instruction:r.index},e);return r.layout.encode(i,n),n}var M1=E.nu64("lamportsPerSignature"),mh=E.struct([E.u32("version"),E.u32("state"),ye("authorizedPubkey"),ye("nonce"),E.struct([M1],"feeCalculator")]),Zd=mh.span,Eu=class r{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){let t=mh.decode(_e(e),0);return new r({authorizedPubkey:new ce(t.authorizedPubkey),nonce:new ce(t.nonce).toString(),feeCalculator:t.feeCalculator})}};function Ei(r){let e=(0,uh.blob)(8,r),t=e.decode.bind(e),n=e.encode.bind(e),i=e,s=Jl();return i.decode=(o,c)=>{let u=t(o,c);return s.decode(u)},i.encode=(o,c,u)=>{let p=s.encode(o);return n(p,c,u)},i}var nr=Object.freeze({Create:{index:0,layout:E.struct([E.u32("instruction"),E.ns64("lamports"),E.ns64("space"),ye("programId")])},Assign:{index:1,layout:E.struct([E.u32("instruction"),ye("programId")])},Transfer:{index:2,layout:E.struct([E.u32("instruction"),Ei("lamports")])},CreateWithSeed:{index:3,layout:E.struct([E.u32("instruction"),ye("base"),wi("seed"),E.ns64("lamports"),E.ns64("space"),ye("programId")])},AdvanceNonceAccount:{index:4,layout:E.struct([E.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:E.struct([E.u32("instruction"),E.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:E.struct([E.u32("instruction"),ye("authorized")])},AuthorizeNonceAccount:{index:7,layout:E.struct([E.u32("instruction"),ye("authorized")])},Allocate:{index:8,layout:E.struct([E.u32("instruction"),E.ns64("space")])},AllocateWithSeed:{index:9,layout:E.struct([E.u32("instruction"),ye("base"),wi("seed"),E.ns64("space"),ye("programId")])},AssignWithSeed:{index:10,layout:E.struct([E.u32("instruction"),ye("base"),wi("seed"),ye("programId")])},TransferWithSeed:{index:11,layout:E.struct([E.u32("instruction"),Ei("lamports"),wi("seed"),ye("programId")])},UpgradeNonceAccount:{index:12,layout:E.struct([E.u32("instruction")])}}),Dt=class r{constructor(){}static createAccount(e){let t=nr.Create,n=we(t,{lamports:e.lamports,space:e.space,programId:_e(e.programId.toBuffer())});return new Te({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if("basePubkey"in e){let i=nr.TransferWithSeed;t=we(i,{lamports:BigInt(e.lamports),seed:e.seed,programId:_e(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let i=nr.Transfer;t=we(i,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){let i=nr.AssignWithSeed;t=we(i,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,programId:_e(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let i=nr.Assign;t=we(i,{programId:_e(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=nr.CreateWithSeed,n=we(t,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:_e(e.programId.toBuffer())}),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 Te({keys:i,programId:this.programId,data:n})}static createNonceAccount(e){let t=new Se;"basePubkey"in e&&"seed"in e?t.add(r.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Zd,programId:this.programId})):t.add(r.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Zd,programId:this.programId}));let n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){let t=nr.InitializeNonceAccount,n=we(t,{authorized:_e(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1},{pubkey:cs,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Te(i)}static nonceAdvance(e){let t=nr.AdvanceNonceAccount,n=we(t),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Te(i)}static nonceWithdraw(e){let t=nr.WithdrawNonceAccount,n=we(t,{lamports:e.lamports});return new Te({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:lu,isSigner:!1,isWritable:!1},{pubkey:cs,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=nr.AuthorizeNonceAccount,n=we(t,{authorized:_e(e.newAuthorizedPubkey.toBuffer())});return new Te({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if("basePubkey"in e){let i=nr.AllocateWithSeed;t=we(i,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:_e(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let i=nr.Allocate;t=we(i,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:t})}};Dt.programId=new ce("11111111111111111111111111111111");var U1=jn-300,Ru=class r{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/r.chunkSize)+1+1)}static async load(e,t,n,i,s){{let b=await e.getMinimumBalanceForRentExemption(s.length),A=await e.getAccountInfo(n.publicKey,"confirmed"),S=null;if(A!==null){if(A.executable)return console.error("Program load failed, account is already executable"),!1;A.data.length!==s.length&&(S=S||new Se,S.add(Dt.allocate({accountPubkey:n.publicKey,space:s.length}))),A.owner.equals(i)||(S=S||new Se,S.add(Dt.assign({accountPubkey:n.publicKey,programId:i}))),A.lamports<b&&(S=S||new Se,S.add(Dt.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:b-A.lamports})))}else S=new Se().add(Dt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:b>0?b:1,space:s.length,programId:i}));S!==null&&await Gd(e,S,[t,n],{commitment:"confirmed"})}let o=E.struct([E.u32("instruction"),E.u32("offset"),E.u32("bytesLength"),E.u32("bytesLengthPadding"),E.seq(E.u8("byte"),E.offset(E.u32(),-8),"bytes")]),c=r.chunkSize,u=0,p=s,m=[];for(;p.length>0;){let b=p.slice(0,c),A=ae.Buffer.alloc(c+16);o.encode({instruction:0,offset:u,bytes:b,bytesLength:0,bytesLengthPadding:0},A);let S=new Se().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:A});m.push(Gd(e,S,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await qn(1e3/4),u+=c,p=p.slice(c)}await Promise.all(m);{let b=E.struct([E.u32("instruction")]),A=ae.Buffer.alloc(b.span);b.encode({instruction:1},A);let S=new Se().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:cs,isSigner:!1,isWritable:!1}],programId:i,data:A}),T="processed",I=await e.sendTransaction(S,[t,n],{preflightCommitment:T}),{context:x,value:B}=await e.confirmTransaction({signature:I,lastValidBlockHeight:S.lastValidBlockHeight,blockhash:S.recentBlockhash},T);if(B.err)throw new Error(`Transaction ${I} failed (${JSON.stringify(B)})`);for(;;){try{if(await e.getSlot({commitment:T})>x.slot)break}catch{}await new Promise(U=>setTimeout(U,Math.round(ph/2)))}}return!0}};Ru.chunkSize=U1;var JA=new ce("BPFLoader2111111111111111111111111111111111");function D1(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var hu,Yd;function z1(){if(Yd)return hu;Yd=1;var r=Object.prototype.toString,e=Object.keys||function(n){var i=[];for(var s in n)i.push(s);return i};function t(n,i){var s,o,c,u,p,m,b;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return t(n.toJSON(),i);if(b=r.call(n),b==="[object Array]"){for(c="[",o=n.length-1,s=0;s<o;s++)c+=t(n[s],!0)+",";return o>-1&&(c+=t(n[s],!0)),c+"]"}else if(b==="[object Object]"){for(u=e(n).sort(),o=u.length,c="",s=0;s<o;)p=u[s],m=t(n[p],!1),m!==void 0&&(c&&(c+=","),c+=JSON.stringify(p)+":"+m),s++;return"{"+c+"}"}else return JSON.stringify(n);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return hu=function(n){var i=t(n,!1);if(i!==void 0)return""+i},hu}var F1=z1(),Xd=D1(F1),ss=32;function pu(r){let e=0;for(;r>1;)r/=2,e++;return e}function $1(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}var Su=class{constructor(e,t,n,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=pu($1(e+ss+1))-pu(ss)-1,n=this.getSlotsInEpoch(t),i=e-(n-ss);return[t,i]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),i=this.firstNormalEpoch+n,s=t%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*ss:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+pu(ss)):this.slotsPerEpoch}},V1=globalThis.fetch,Au=class extends Nd{constructor(e,t,n){let i=s=>{let o=Td(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}};function q1(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${r.index}`);return t}var Jd=56,Yo=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){let t=q1(W1,e),n=e.length-Jd;xe(n>=0,"lookup table is invalid"),xe(n%32===0,"lookup table is invalid");let i=n/32,{addresses:s}=E.struct([E.seq(ye(),i,"addresses")]).decode(e.slice(Jd));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ce(t.authority[0]):void 0,addresses:s.map(o=>new ce(o))}}},W1={index:1,layout:E.struct([E.u32("typeIndex"),Ei("deactivationSlot"),E.nu64("lastExtendedSlot"),E.u8("lastExtendedStartIndex"),E.u8(),E.seq(ye(),E.offset(E.u8(),-1),"authority")])},j1=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function K1(r){let e=r.match(j1);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);let[t,n,i,s]=e,o=r.startsWith("https:")?"wss:":"ws:",c=i==null?null:parseInt(i.slice(1),10),u=c==null?"":`:${c+1}`;return`${o}//${n}${u}${s}`}var We=bi(No(ce),z(),r=>new ce(r)),gh=Bo([z(),Me("base64")]),Mu=bi(No(ae.Buffer),gh,r=>ae.Buffer.from(r[0],"base64")),H1=30*1e3;function G1(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function Be(r){let e,t;if(typeof r=="string")e=r;else if(r){let{commitment:n,...i}=r;e=n,t=i}return{commitment:e,config:t}}function Qd(r){return r.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function yh(r){return Ot([P({jsonrpc:Me("2.0"),id:z(),result:r}),P({jsonrpc:Me("2.0"),id:z(),error:P({code:Vn(),message:z(),data:ne(rd())})})])}var Z1=yh(Vn());function ge(r){return bi(yh(r),Z1,e=>"error"in e?e:{...e,result:V(e.result,r)})}function Ze(r){return ge(P({context:P({slot:O()}),value:r}))}function ra(r){return P({context:P({slot:O()}),value:r})}function mu(r,e){return r===0?new Go({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new ce(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:vt.default.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new ln(e)}var Y1=P({foundation:O(),foundationTerm:O(),initial:O(),taper:O(),terminal:O()}),X1=ge(q(j(P({epoch:O(),effectiveSlot:O(),amount:O(),postBalance:O(),commission:ne(j(O()))})))),J1=q(P({slot:O(),prioritizationFee:O()})),Q1=P({total:O(),validator:O(),foundation:O(),epoch:O()}),ev=P({epoch:O(),slotIndex:O(),slotsInEpoch:O(),absoluteSlot:O(),blockHeight:ne(O()),transactionCount:ne(O())}),tv=P({slotsPerEpoch:O(),leaderScheduleSlotOffset:O(),warmup:ur(),firstNormalEpoch:O(),firstNormalSlot:O()}),rv=Zc(z(),q(O())),Kn=j(Ot([P({}),z()])),nv=P({err:Kn}),iv=Me("receivedSignature"),sv=P({"solana-core":z(),"feature-set":ne(O())}),ov=P({program:z(),programId:We,parsed:Vn()}),av=P({programId:We,accounts:q(We),data:z()}),eh=Ze(P({err:j(Ot([P({}),z()])),logs:j(q(z())),accounts:ne(j(q(j(P({executable:ur(),owner:z(),lamports:O(),data:q(z()),rentEpoch:ne(O())}))))),unitsConsumed:ne(O()),returnData:ne(j(P({programId:z(),data:Bo([z(),Me("base64")])}))),innerInstructions:ne(j(q(P({index:O(),instructions:q(Ot([ov,av]))}))))})),cv=Ze(P({byIdentity:Zc(z(),q(O())),range:P({firstSlot:O(),lastSlot:O()})}));function uv(r,e,t,n,i,s){let o=t||V1,c;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return n&&(u=async(m,b)=>{let A=await new Promise((S,T)=>{try{n(m,b,(I,x)=>S([I,x]))}catch(I){T(I)}});return await o(...A)}),new fh.default(async(m,b)=>{let A={method:"POST",body:m,agent:c,headers:Object.assign({"Content-Type":"application/json"},e||{},uE)};try{let S=5,T,I=500;for(;u?T=await u(r,A):T=await o(r,A),!(T.status!==429||i===!0||(S-=1,S===0));)console.error(`Server responded with ${T.status} ${T.statusText}. Retrying after ${I}ms delay...`),await qn(I),I*=2;let x=await T.text();T.ok?b(null,x):b(new Error(`${T.status} ${T.statusText}: ${x}`))}catch(S){S instanceof Error&&b(S)}},{})}function fv(r){return(e,t)=>new Promise((n,i)=>{r.request(e,t,(s,o)=>{if(s){i(s);return}n(o)})})}function lv(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);let i=e.map(s=>r.request(s.methodName,s.args));r.request(i,(s,o)=>{if(s){n(s);return}t(o)})})}var dv=ge(Y1),hv=ge(Q1),pv=ge(J1),mv=ge(ev),gv=ge(tv),yv=ge(rv),_v=ge(O()),bv=Ze(P({total:O(),circulating:O(),nonCirculating:O(),nonCirculatingAccounts:q(We)})),xu=P({amount:z(),uiAmount:j(O()),decimals:O(),uiAmountString:ne(z())}),wv=Ze(q(P({address:We,amount:z(),uiAmount:j(O()),decimals:O(),uiAmountString:ne(z())}))),vv=Ze(q(P({pubkey:We,account:P({executable:ur(),owner:We,lamports:O(),data:Mu,rentEpoch:O()})}))),Iu=P({program:z(),parsed:Vn(),space:O()}),Ev=Ze(q(P({pubkey:We,account:P({executable:ur(),owner:We,lamports:O(),data:Iu,rentEpoch:O()})}))),Rv=Ze(q(P({lamports:O(),address:We}))),fs=P({executable:ur(),owner:We,lamports:O(),data:Mu,rentEpoch:O()}),Sv=P({pubkey:We,account:fs}),Av=bi(Ot([No(ae.Buffer),Iu]),Ot([gh,Iu]),r=>Array.isArray(r)?V(r,Mu):r),Ou=P({executable:ur(),owner:We,lamports:O(),data:Av,rentEpoch:O()}),xv=P({pubkey:We,account:Ou}),Iv=P({state:Ot([Me("active"),Me("inactive"),Me("activating"),Me("deactivating")]),active:O(),inactive:O()}),Ov=ge(q(P({signature:z(),slot:O(),err:Kn,memo:j(z()),blockTime:ne(j(O()))}))),kv=ge(q(P({signature:z(),slot:O(),err:Kn,memo:j(z()),blockTime:ne(j(O()))}))),Tv=P({subscription:O(),result:ra(fs)}),Nv=P({pubkey:We,account:fs}),Bv=P({subscription:O(),result:ra(Nv)}),Lv=P({parent:O(),slot:O(),root:O()}),Cv=P({subscription:O(),result:Lv}),Pv=Ot([P({type:Ot([Me("firstShredReceived"),Me("completed"),Me("optimisticConfirmation"),Me("root")]),slot:O(),timestamp:O()}),P({type:Me("createdBank"),parent:O(),slot:O(),timestamp:O()}),P({type:Me("frozen"),slot:O(),timestamp:O(),stats:P({numTransactionEntries:O(),numSuccessfulTransactions:O(),numFailedTransactions:O(),maxTransactionsPerEntry:O()})}),P({type:Me("dead"),slot:O(),timestamp:O(),err:z()})]),Mv=P({subscription:O(),result:Pv}),Uv=P({subscription:O(),result:ra(Ot([nv,iv]))}),Dv=P({subscription:O(),result:O()}),zv=P({pubkey:z(),gossip:j(z()),tpu:j(z()),rpc:j(z()),version:j(z())}),th=P({votePubkey:z(),nodePubkey:z(),activatedStake:O(),epochVoteAccount:ur(),epochCredits:q(Bo([O(),O(),O()])),commission:O(),lastVote:O(),rootSlot:j(O())}),Fv=ge(P({current:q(th),delinquent:q(th)})),$v=Ot([Me("processed"),Me("confirmed"),Me("finalized")]),Vv=P({slot:O(),confirmations:j(O()),err:Kn,confirmationStatus:ne($v)}),qv=Ze(q(j(Vv))),Wv=ge(O()),_h=P({accountKey:We,writableIndexes:q(O()),readonlyIndexes:q(O())}),Uu=P({signatures:q(z()),message:P({accountKeys:q(z()),header:P({numRequiredSignatures:O(),numReadonlySignedAccounts:O(),numReadonlyUnsignedAccounts:O()}),instructions:q(P({accounts:q(O()),data:z(),programIdIndex:O()})),recentBlockhash:z(),addressTableLookups:ne(q(_h))})}),bh=P({pubkey:We,signer:ur(),writable:ur(),source:ne(Ot([Me("transaction"),Me("lookupTable")]))}),wh=P({accountKeys:q(bh),signatures:q(z())}),vh=P({parsed:Vn(),program:z(),programId:We}),Eh=P({accounts:q(We),data:z(),programId:We}),jv=Ot([Eh,vh]),Kv=Ot([P({parsed:Vn(),program:z(),programId:z()}),P({accounts:q(z()),data:z(),programId:z()})]),Rh=bi(jv,Kv,r=>"accounts"in r?V(r,Eh):V(r,vh)),Sh=P({signatures:q(z()),message:P({accountKeys:q(bh),instructions:q(Rh),recentBlockhash:z(),addressTableLookups:ne(j(q(_h)))})}),Xo=P({accountIndex:O(),mint:z(),owner:ne(z()),programId:ne(z()),uiTokenAmount:xu}),Ah=P({writable:q(We),readonly:q(We)}),na=P({err:Kn,fee:O(),innerInstructions:ne(j(q(P({index:O(),instructions:q(P({accounts:q(O()),data:z(),programIdIndex:O()}))})))),preBalances:q(O()),postBalances:q(O()),logMessages:ne(j(q(z()))),preTokenBalances:ne(j(q(Xo))),postTokenBalances:ne(j(q(Xo))),loadedAddresses:ne(Ah),computeUnitsConsumed:ne(O())}),Du=P({err:Kn,fee:O(),innerInstructions:ne(j(q(P({index:O(),instructions:q(Rh)})))),preBalances:q(O()),postBalances:q(O()),logMessages:ne(j(q(z()))),preTokenBalances:ne(j(q(Xo))),postTokenBalances:ne(j(q(Xo))),loadedAddresses:ne(Ah),computeUnitsConsumed:ne(O())}),Si=Ot([Me(0),Me("legacy")]),Hn=P({pubkey:z(),lamports:O(),postBalance:j(O()),rewardType:j(z()),commission:ne(j(O()))}),Hv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:q(P({transaction:Uu,meta:j(na),version:ne(Si)})),rewards:ne(q(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Gv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),rewards:ne(q(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Zv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:q(P({transaction:wh,meta:j(na),version:ne(Si)})),rewards:ne(q(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Yv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:q(P({transaction:Sh,meta:j(Du),version:ne(Si)})),rewards:ne(q(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Xv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:q(P({transaction:wh,meta:j(Du),version:ne(Si)})),rewards:ne(q(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Jv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),rewards:ne(q(Hn)),blockTime:j(O()),blockHeight:j(O())}))),Qv=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),transactions:q(P({transaction:Uu,meta:j(na)})),rewards:ne(q(Hn)),blockTime:j(O())}))),rh=ge(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:O(),signatures:q(z()),blockTime:j(O())}))),gu=ge(j(P({slot:O(),meta:j(na),blockTime:ne(j(O())),transaction:Uu,version:ne(Si)}))),$o=ge(j(P({slot:O(),transaction:Sh,meta:j(Du),blockTime:ne(j(O())),version:ne(Si)}))),eE=Ze(P({blockhash:z(),lastValidBlockHeight:O()})),tE=Ze(ur()),rE=P({slot:O(),numTransactions:O(),numSlots:O(),samplePeriodSecs:O()}),nE=ge(q(rE)),iE=Ze(j(P({feeCalculator:P({lamportsPerSignature:O()})}))),sE=ge(z()),oE=ge(z()),aE=P({err:Kn,logs:q(z()),signature:z()}),cE=P({result:ra(aE),subscription:O()}),uE={"solana-client":"js/1.0.0-maintenance"},Jo=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let p={};return async m=>{let{commitment:b,config:A}=Be(m),S=this._buildArgs([],b,void 0,A),T=Xd(S);return p[T]=p[T]??(async()=>{try{let I=await this._rpcRequest("getBlockHeight",S),x=V(I,ge(O()));if("error"in x)throw new Q(x.error,"failed to get block height information");return x.result}finally{delete p[T]}})(),await p[T]}})();let n,i,s,o,c,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,i=t.httpHeaders,s=t.fetch,o=t.fetchMiddleware,c=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=G1(e),this._rpcWsEndpoint=n||K1(e),this._rpcClient=uv(e,i,s,o,c,u),this._rpcRequest=fv(this._rpcClient),this._rpcBatchRequest=lv(this._rpcClient),this._rpcWebSocket=new Au(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e.toBase58()],n,void 0,i),o=await this._rpcRequest("getBalance",s),c=V(o,Ze(O()));if("error"in c)throw new Q(c.error,`failed to get balance for ${e.toBase58()}`);return c.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+n)})}async getBlockTime(e){let t=await this._rpcRequest("getBlockTime",[e]),n=V(t,ge(j(O())));if("error"in n)throw new Q(n.error,`failed to get block time for slot ${e}`);return n.result}async getMinimumLedgerSlot(){let e=await this._rpcRequest("minimumLedgerSlot",[]),t=V(e,ge(O()));if("error"in t)throw new Q(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){let e=await this._rpcRequest("getFirstAvailableBlock",[]),t=V(e,_v);if("error"in t)throw new Q(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};let n=await this._rpcRequest("getSupply",[t]),i=V(n,bv);if("error"in i)throw new Q(i.error,"failed to get supply");return i.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenSupply",n),s=V(i,Ze(xu));if("error"in s)throw new Q(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenAccountBalance",n),s=V(i,Ze(xu));if("error"in s)throw new Q(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(e,t,n){let{commitment:i,config:s}=Be(n),o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});let c=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",c),p=V(u,vv);if("error"in p)throw new Q(p.error,`failed to get token accounts owned by account ${e.toBase58()}`);return p.result}async getParsedTokenAccountsByOwner(e,t,n){let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});let s=this._buildArgs(i,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),c=V(o,Ev);if("error"in c)throw new Q(c.error,`failed to get token accounts owned by account ${e.toBase58()}`);return c.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],i=await this._rpcRequest("getLargestAccounts",n),s=V(i,Rv);if("error"in s)throw new Q(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenLargestAccounts",n),s=V(i,wv);if("error"in s)throw new Q(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e.toBase58()],n,"base64",i),o=await this._rpcRequest("getAccountInfo",s),c=V(o,Ze(j(fs)));if("error"in c)throw new Q(c.error,`failed to get info about account ${e.toBase58()}`);return c.result}async getParsedAccountInfo(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),c=V(o,Ze(j(Ou)));if("error"in c)throw new Q(c.error,`failed to get info about account ${e.toBase58()}`);return c.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(n){throw new Error("failed to get info about account "+e.toBase58()+": "+n)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:i}=Be(t),s=e.map(p=>p.toBase58()),o=this._buildArgs([s],n,"jsonParsed",i),c=await this._rpcRequest("getMultipleAccounts",o),u=V(c,Ze(q(j(Ou))));if("error"in u)throw new Q(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:i}=Be(t),s=e.map(p=>p.toBase58()),o=this._buildArgs([s],n,"base64",i),c=await this._rpcRequest("getMultipleAccounts",o),u=V(c,Ze(q(j(fs))));if("error"in u)throw new Q(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:i,config:s}=Be(t),o=this._buildArgs([e.toBase58()],i,void 0,{...s,epoch:n??s?.epoch}),c=await this._rpcRequest("getStakeActivation",o),u=V(c,ge(Iv));if("error"in u)throw new Q(u.error,`failed to get Stake Activation ${e.toBase58()}`);return u.result}async getProgramAccounts(e,t){let{commitment:n,config:i}=Be(t),{encoding:s,...o}=i||{},c=this._buildArgs([e.toBase58()],n,s||"base64",{...o,...o.filters?{filters:Qd(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",c),p=q(Sv),m=o.withContext===!0?V(u,Ze(p)):V(u,ge(p));if("error"in m)throw new Q(m.error,`failed to get accounts owned by program ${e.toBase58()}`);return m.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),c=V(o,ge(q(xv)));if("error"in c)throw new Q(c.error,`failed to get accounts owned by program ${e.toBase58()}`);return c.result}async confirmTransaction(e,t){let n;if(typeof e=="string")n=e;else{let s=e;if(s.abortSignal?.aborted)return Promise.reject(s.abortSignal.reason);n=s.signature}let i;try{i=vt.default.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return xe(i.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener("abort",()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,i,s=!1,o=new Promise((u,p)=>{try{n=this.onSignature(t,(b,A)=>{n=void 0;let S={context:A,value:b};u({__type:cn.PROCESSED,response:S})},e);let m=new Promise(b=>{n==null?b():i=this._onSubscriptionStateChange(n,A=>{A==="subscribed"&&b()})});(async()=>{if(await m,s)return;let b=await this.getSignatureStatus(t);if(s||b==null)return;let{context:A,value:S}=b;if(S!=null)if(S?.err)p(S.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(S.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(S.confirmationStatus==="processed"||S.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,u({__type:cn.PROCESSED,response:{context:A,value:S}})}})()}catch(m){p(m)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:i}}){let s=!1,o=new Promise(b=>{let A=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let S=await A();if(!s){for(;S<=n;)if(await qn(1e3),s||(S=await A(),s))return;b({__type:cn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),p=this.getCancellationPromise(t),m;try{let b=await Promise.race([p,u,o]);if(b.__type===cn.PROCESSED)m=b.response;else throw new jo(i)}finally{s=!0,c()}return m}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let c=!1,u=new Promise(S=>{let T=s,I=null,x=async()=>{try{let{context:B,value:U}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:n});return I=B.slot,U?.nonce}catch{return T}};(async()=>{if(T=await x(),!c)for(;;){if(s!==T){S({__type:cn.NONCE_INVALID,slotInWhichNonceDidAdvance:I});return}if(await qn(2e3),c||(T=await x(),c))return}})()}),{abortConfirmation:p,confirmationPromise:m}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),b=this.getCancellationPromise(t),A;try{let S=await Promise.race([b,m,u]);if(S.__type===cn.PROCESSED)A=S.response;else{let T;for(;;){let I=await this.getSignatureStatus(o);if(I==null)break;if(I.context.slot<(S.slotInWhichNonceDidAdvance??n)){await qn(400);continue}T=I;break}if(T?.value){let I=e||"finalized",{confirmationStatus:x}=T.value;switch(I){case"processed":case"recent":if(x!=="processed"&&x!=="confirmed"&&x!=="finalized")throw new Wn(o);break;case"confirmed":case"single":case"singleGossip":if(x!=="confirmed"&&x!=="finalized")throw new Wn(o);break;case"finalized":case"max":case"root":if(x!=="finalized")throw new Wn(o);break;default:}A={context:T.context,value:{err:T.value.err}}}else throw new Wn(o)}}finally{c=!0,p()}return A}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,i=new Promise(u=>{let p=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{p=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:cn.TIMED_OUT,timeoutMs:p}),p)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),c;try{let u=await Promise.race([o,i]);if(u.__type===cn.PROCESSED)c=u.response;else throw new Ko(t,u.timeoutMs/1e3)}finally{clearTimeout(n),s()}return c}async getClusterNodes(){let e=await this._rpcRequest("getClusterNodes",[]),t=V(e,ge(q(zv)));if("error"in t)throw new Q(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=await this._rpcRequest("getVoteAccounts",t),i=V(n,Fv);if("error"in i)throw new Q(i.error,"failed to get vote accounts");return i.result}async getSlot(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlot",i),o=V(s,ge(O()));if("error"in o)throw new Q(o.error,"failed to get slot");return o.result}async getSlotLeader(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlotLeader",i),o=V(s,ge(z()));if("error"in o)throw new Q(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){let n=[e,t],i=await this._rpcRequest("getSlotLeaders",n),s=V(i,ge(q(We)));if("error"in s)throw new Q(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(e,t){let{context:n,value:i}=await this.getSignatureStatuses([e],t);xe(i.length===1);let s=i[0];return{context:n,value:s}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let i=await this._rpcRequest("getSignatureStatuses",n),s=V(i,qv);if("error"in s)throw new Q(s.error,"failed to get signature status");return s.result}async getTransactionCount(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getTransactionCount",i),o=V(s,ge(O()));if("error"in o)throw new Q(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=await this._rpcRequest("getInflationGovernor",t),i=V(n,dv);if("error"in i)throw new Q(i.error,"failed to get inflation");return i.result}async getInflationReward(e,t,n){let{commitment:i,config:s}=Be(n),o=this._buildArgs([e.map(p=>p.toBase58())],i,void 0,{...s,epoch:t??s?.epoch}),c=await this._rpcRequest("getInflationReward",o),u=V(c,X1);if("error"in u)throw new Q(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){let e=await this._rpcRequest("getInflationRate",[]),t=V(e,hv);if("error"in t)throw new Q(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getEpochInfo",i),o=V(s,mv);if("error"in o)throw new Q(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){let e=await this._rpcRequest("getEpochSchedule",[]),t=V(e,gv);if("error"in t)throw new Q(t.error,"failed to get epoch schedule");let n=t.result;return new Su(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){let e=await this._rpcRequest("getLeaderSchedule",[]),t=V(e,yv);if("error"in t)throw new Q(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),i=await this._rpcRequest("getMinimumBalanceForRentExemption",n),s=V(i,Wv);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),n=V(t,nE);if("error"in n)throw new Q(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),i=await this._rpcRequest("getFeeCalculatorForBlockhash",n),s=V(i,iE);if("error"in s)throw new Q(s.error,"failed to get fee calculator");let{context:o,value:c}=s.result;return{context:o,value:c!==null?c.feeCalculator:null}}async getFeeForMessage(e,t){let n=_e(e.serialize()).toString("base64"),i=this._buildArgs([n],t),s=await this._rpcRequest("getFeeForMessage",i),o=V(s,Ze(j(O())));if("error"in o)throw new Q(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(o=>o.toBase58()),n=t?.length?[t]:[],i=await this._rpcRequest("getRecentPrioritizationFees",n),s=V(i,pv);if("error"in s)throw new Q(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getLatestBlockhash",i),o=V(s,eE);if("error"in o)throw new Q(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgs([e],n,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),c=V(o,tE);if("error"in c)throw new Q(c.error,"failed to determine if the blockhash `"+e+"`is valid");return c.result}async getVersion(){let e=await this._rpcRequest("getVersion",[]),t=V(e,ge(sv));if("error"in t)throw new Q(t.error,"failed to get version");return t.result}async getGenesisHash(){let e=await this._rpcRequest("getGenesisHash",[]),t=V(e,ge(z()));if("error"in t)throw new Q(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i?.transactionDetails){case"accounts":{let c=V(o,Zv);if("error"in c)throw c.error;return c.result}case"none":{let c=V(o,Gv);if("error"in c)throw c.error;return c.result}default:{let c=V(o,Hv);if("error"in c)throw c.error;let{result:u}=c;return u?{...u,transactions:u.transactions.map(({transaction:p,meta:m,version:b})=>({meta:m,transaction:{...p,message:mu(b,p.message)},version:b}))}:null}}}catch(c){throw new Q(c,"failed to get confirmed block")}}async getParsedBlock(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i?.transactionDetails){case"accounts":{let c=V(o,Xv);if("error"in c)throw c.error;return c.result}case"none":{let c=V(o,Jv);if("error"in c)throw c.error;return c.result}default:{let c=V(o,Yv);if("error"in c)throw c.error;return c.result}}}catch(c){throw new Q(c,"failed to get block")}}async getBlockProduction(e){let t,n;if(typeof e=="string")n=e;else if(e){let{commitment:c,...u}=e;n=c,t=u}let i=this._buildArgs([],n,"base64",t),s=await this._rpcRequest("getBlockProduction",i),o=V(s,cv);if("error"in o)throw new Q(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getTransaction",s),c=V(o,gu);if("error"in c)throw new Q(c.error,"failed to get transaction");let u=c.result;return u&&{...u,transaction:{...u.transaction,message:mu(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:i}=Be(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),c=V(o,$o);if("error"in c)throw new Q(c.error,"failed to get transaction");return c.result}async getParsedTransactions(e,t){let{commitment:n,config:i}=Be(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{let p=V(u,$o);if("error"in p)throw new Q(p.error,"failed to get transactions");return p.result})}async getTransactions(e,t){let{commitment:n,config:i}=Be(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{let p=V(u,gu);if("error"in p)throw new Q(p.error,"failed to get transactions");let m=p.result;return m&&{...m,transaction:{...m.transaction,message:mu(m.version,m.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getBlock",n),s=V(i,Qv);if("error"in s)throw new Q(s.error,"failed to get confirmed block");let o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");let c={...o,transactions:o.transactions.map(({transaction:u,meta:p})=>{let m=new ln(u.message);return{meta:p,transaction:{...u,message:m}}})};return{...c,transactions:c.transactions.map(({transaction:u,meta:p})=>({meta:p,transaction:Se.populate(u.message,u.signatures)}))}}async getBlocks(e,t,n){let i=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),s=await this._rpcRequest("getBlocks",i),o=V(s,ge(q(O())));if("error"in o)throw new Q(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=V(i,rh);if("error"in s)throw new Q(s.error,"failed to get block");let o=s.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=V(i,rh);if("error"in s)throw new Q(s.error,"failed to get confirmed block");let o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getTransaction",n),s=V(i,gu);if("error"in s)throw new Q(s.error,"failed to get transaction");let o=s.result;if(!o)return o;let c=new ln(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Se.populate(c,u)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),i=await this._rpcRequest("getTransaction",n),s=V(i,$o);if("error"in s)throw new Q(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(e,t){let n=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(o=>{let c=V(o,$o);if("error"in c)throw new Q(c.error,"failed to get confirmed transactions");return c.result})}async getConfirmedSignaturesForAddress(e,t,n){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(t--,!(t<=0||t<s));)try{let u=await this.getConfirmedBlockSignatures(t,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(n++,!(n>o));)try{let u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(e,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=V(s,Ov);if("error"in o)throw new Q(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,n){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getSignaturesForAddress",i),o=V(s,kv);if("error"in o)throw new Q(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){let{context:n,value:i}=await this.getAccountInfoAndContext(e,t),s=null;return i!==null&&(s=new Yo({key:e,state:Yo.deserialize(i.data)})),{context:n,value:s}}async getNonceAndContext(e,t){let{context:n,value:i}=await this.getAccountInfoAndContext(e,t),s=null;return i!==null&&(s=Eu.fromAccountData(i.data)),{context:n,value:s}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+n)})}async requestAirdrop(e,t){let n=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),i=V(n,sE);if("error"in i)throw new Q(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await qn(100);let n=Date.now()-this._blockhashInfo.lastFetch>=H1;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let i=0;i<50;i++){let s=await this.getLatestBlockhash("finalized");if(n!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await qn(ph/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Be(e),i=this._buildArgs([],t,"base64",n),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=V(s,Ze(O()));if("error"in o)throw new Q(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,n){if("message"in e){let I=e.serialize(),x=ae.Buffer.from(I).toString("base64");if(Array.isArray(t)||n!==void 0)throw new Error("Invalid arguments");let B=t||{};B.encoding="base64","commitment"in B||(B.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(B.innerInstructions=t.innerInstructions);let U=[x,B],L=await this._rpcRequest("simulateTransaction",U),F=V(L,eh);if("error"in F)throw new Error("failed to simulate transaction: "+F.error.message);return F.result}let i;if(e instanceof Se){let T=e;i=new Se,i.feePayer=T.feePayer,i.instructions=e.instructions,i.nonceInfo=T.nonceInfo,i.signatures=T.signatures}else i=Se.populate(e),i._message=i._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");let s=t;if(i.nonceInfo&&s)i.sign(...s);else{let T=this._disableBlockhashCaching;for(;;){let I=await this._blockhashWithExpiryBlockHeight(T);if(i.lastValidBlockHeight=I.lastValidBlockHeight,i.recentBlockhash=I.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");let x=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(x)&&!this._blockhashInfo.transactionSignatures.includes(x)){this._blockhashInfo.simulatedSignatures.push(x);break}else T=!0}}let o=i._compile(),c=o.serialize(),p=i._serialize(c).toString("base64"),m={encoding:"base64",commitment:this.commitment};if(n){let T=(Array.isArray(n)?n:o.nonProgramIds()).map(I=>I.toBase58());m.accounts={encoding:"base64",addresses:T}}s&&(m.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(m.innerInstructions=t.innerInstructions);let b=[p,m],A=await this._rpcRequest("simulateTransaction",b),S=V(A,eh);if("error"in S){let T;if("data"in S.error&&(T=S.error.data.logs,T&&Array.isArray(T))){let I=`
12
+ `,x=I+T.join(I);console.error(S.error.message,x)}throw new us({action:"simulate",signature:"",transactionMessage:S.error.message,logs:T})}return S.result}async sendTransaction(e,t,n){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");let o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");let i=t;if(e.nonceInfo)e.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){let c=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=c.lastValidBlockHeight,e.recentBlockhash=c.blockhash,e.sign(...i),!e.signature)throw new Error("!signature");let u=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}let s=e.serialize();return await this.sendRawTransaction(s,n)}async sendRawTransaction(e,t){let n=_e(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:"base64"},i=t&&t.skipPreflight,s=i===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),i&&(n.skipPreflight=i),s&&(n.preflightCommitment=s);let o=[e,n],c=await this._rpcRequest("sendTransaction",o),u=V(c,oE);if("error"in u){let p;throw"data"in u.error&&(p=u.error.data.logs),new us({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:p})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,n])=>{this._setSubscription(t,{...n,state:"pending"})})}_setSubscription(e,t){let n=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,n!==t.state){let i=this._subscriptionStateChangeCallbacksByHash[e];i&&i.forEach(s=>{try{s(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let i=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return i.add(t),()=>{i.delete(t),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{let i=this._subscriptionsByHash[n];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[n],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:s,method:o}=i;try{this._setSubscription(n,{...i,state:"subscribing"});let c=await this._rpcWebSocket.call(o,s);this._setSubscription(n,{...i,serverSubscriptionId:c,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[c]=i.callbacks,await this._updateSubscriptions()}catch(c){if(console.error(`Received ${c instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:s,error:c}),!t())return;this._setSubscription(n,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:s,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(n,{...i,state:"unsubscribing"}),this._setSubscription(n,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(c){if(c instanceof Error&&console.error(`${o} error:`,c.message),!t())return;this._setSubscription(n,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(i=>{try{i(...t)}catch(s){console.error(s)}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=V(e,Tv);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,i=Xd([e.method,t]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:s.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let o=this._subscriptionsByHash[i];xe(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){let{commitment:i,config:s}=Be(n),o=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){let{result:t,subscription:n}=V(e,Bv);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,i){let{commitment:s,config:o}=Be(n),c=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:Qd(i)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},c)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,n){let i=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){let{result:t,subscription:n}=V(e,cE);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=V(e,Cv);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:n}=V(e,Mv);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){let n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,i){let s=t||this._commitment;if(s||n||i){let o={};n&&(o.encoding=n),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,n,i){let s=t||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,i)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=V(e,Uv);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,n){let i=this._buildArgs([e],n||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,c)=>{if(o.type==="status"){t(o.result,c);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(e,t,n){let{commitment:i,...s}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([e],i,void 0,s),c=this._makeSubscription({callback:(u,p)=>{t(u,p);try{this.removeSignatureListener(c)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return c}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){let{result:t,subscription:n}=V(e,Dv);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}},ku=class r{constructor(e){this._keypair=void 0,this._keypair=e??jd()}static generate(){return new r(jd())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");let n=e.slice(32,64);if(!t||!t.skipValidation){let i=e.slice(0,32),s=wu(i);for(let o=0;o<32;o++)if(n[o]!==s[o])throw new Error("provided secretKey is invalid")}return new r({publicKey:n,secretKey:e})}static fromSeed(e){let t=wu(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new r({publicKey:t,secretKey:n})}get publicKey(){return new ce(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},os=Object.freeze({CreateLookupTable:{index:0,layout:E.struct([E.u32("instruction"),Ei("recentSlot"),E.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:E.struct([E.u32("instruction")])},ExtendLookupTable:{index:2,layout:E.struct([E.u32("instruction"),Ei(),E.seq(ye(),E.offset(E.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:E.struct([E.u32("instruction")])},CloseLookupTable:{index:4,layout:E.struct([E.u32("instruction")])}});var Tu=class{constructor(){}static createLookupTable(e){let[t,n]=ce.findProgramAddressSync([e.authority.toBuffer(),Kc().encode(e.recentSlot)],this.programId),i=os.CreateLookupTable,s=we(i,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Dt.programId,isSigner:!1,isWritable:!1}];return[new Te({programId:this.programId,keys:o,data:s}),t]}static freezeLookupTable(e){let t=os.FreezeLookupTable,n=we(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Te({programId:this.programId,keys:i,data:n})}static extendLookupTable(e){let t=os.ExtendLookupTable,n=we(t,{addresses:e.addresses.map(s=>s.toBytes())}),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&i.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Dt.programId,isSigner:!1,isWritable:!1}),new Te({programId:this.programId,keys:i,data:n})}static deactivateLookupTable(e){let t=os.DeactivateLookupTable,n=we(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Te({programId:this.programId,keys:i,data:n})}static closeLookupTable(e){let t=os.CloseLookupTable,n=we(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new Te({programId:this.programId,keys:i,data:n})}};Tu.programId=new ce("AddressLookupTab1e1111111111111111111111111");var Vo=Object.freeze({RequestUnits:{index:0,layout:E.struct([E.u8("instruction"),E.u32("units"),E.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:E.struct([E.u8("instruction"),E.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:E.struct([E.u8("instruction"),E.u32("units")])},SetComputeUnitPrice:{index:3,layout:E.struct([E.u8("instruction"),Ei("microLamports")])}}),Nu=class{constructor(){}static requestUnits(e){let t=Vo.RequestUnits,n=we(t,e);return new Te({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=Vo.RequestHeapFrame,n=we(t,e);return new Te({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=Vo.SetComputeUnitLimit,n=we(t,e);return new Te({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=Vo.SetComputeUnitPrice,n=we(t,{microLamports:BigInt(e.microLamports)});return new Te({keys:[],programId:this.programId,data:n})}};Nu.programId=new ce("ComputeBudget111111111111111111111111111111");var nh=64,ih=32,sh=64,oh=E.struct([E.u8("numSignatures"),E.u8("padding"),E.u16("signatureOffset"),E.u16("signatureInstructionIndex"),E.u16("publicKeyOffset"),E.u16("publicKeyInstructionIndex"),E.u16("messageDataOffset"),E.u16("messageDataSize"),E.u16("messageInstructionIndex")]),Bu=class r{constructor(){}static createInstructionWithPublicKey(e){let{publicKey:t,message:n,signature:i,instructionIndex:s}=e;xe(t.length===ih,`Public Key must be ${ih} bytes but received ${t.length} bytes`),xe(i.length===sh,`Signature must be ${sh} bytes but received ${i.length} bytes`);let o=oh.span,c=o+t.length,u=c+i.length,p=1,m=ae.Buffer.alloc(u+n.length),b=s??65535;return oh.encode({numSignatures:p,padding:0,signatureOffset:c,signatureInstructionIndex:b,publicKeyOffset:o,publicKeyInstructionIndex:b,messageDataOffset:u,messageDataSize:n.length,messageInstructionIndex:b},m),m.fill(t,o),m.fill(i,c),m.fill(n,u),new Te({keys:[],programId:r.programId,data:m})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:i}=e;xe(t.length===nh,`Private key must be ${nh} bytes but received ${t.length} bytes`);try{let s=ku.fromSecretKey(t),o=s.publicKey.toBytes(),c=Cu(n,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:c,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}};Bu.programId=new ce("Ed25519SigVerify111111111111111111111111111");var fE=(r,e)=>{let t=is.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};is.utils.isValidPrivateKey;var lE=is.getPublicKey,ah=32,yu=20,ch=64,dE=11,_u=E.struct([E.u8("numSignatures"),E.u16("signatureOffset"),E.u8("signatureInstructionIndex"),E.u16("ethAddressOffset"),E.u8("ethAddressInstructionIndex"),E.u16("messageDataOffset"),E.u16("messageDataSize"),E.u8("messageInstructionIndex"),E.blob(20,"ethAddress"),E.blob(64,"signature"),E.u8("recoveryId")]),Lu=class r{constructor(){}static publicKeyToEthAddress(e){xe(e.length===ch,`Public key must be ${ch} bytes but received ${e.length} bytes`);try{return ae.Buffer.from(ou(_e(e))).slice(-yu)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){let{publicKey:t,message:n,signature:i,recoveryId:s,instructionIndex:o}=e;return r.createInstructionWithEthAddress({ethAddress:r.publicKeyToEthAddress(t),message:n,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(e){let{ethAddress:t,message:n,signature:i,recoveryId:s,instructionIndex:o=0}=e,c;typeof t=="string"?t.startsWith("0x")?c=ae.Buffer.from(t.substr(2),"hex"):c=ae.Buffer.from(t,"hex"):c=t,xe(c.length===yu,`Address must be ${yu} bytes but received ${c.length} bytes`);let u=1+dE,p=u,m=u+c.length,b=m+i.length+1,A=1,S=ae.Buffer.alloc(_u.span+n.length);return _u.encode({numSignatures:A,signatureOffset:m,signatureInstructionIndex:o,ethAddressOffset:p,ethAddressInstructionIndex:o,messageDataOffset:b,messageDataSize:n.length,messageInstructionIndex:o,signature:_e(i),ethAddress:_e(c),recoveryId:s},S),S.fill(_e(n),_u.span),new Te({keys:[],programId:r.programId,data:S})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:i}=e;xe(t.length===ah,`Private key must be ${ah} bytes but received ${t.length} bytes`);try{let s=_e(t),o=lE(s,!1).slice(1),c=ae.Buffer.from(ou(_e(n))),[u,p]=fE(c,s);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:u,recoveryId:p,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}};Lu.programId=new ce("KeccakSecp256k11111111111111111111111111111");var xh,hE=new ce("StakeConfig11111111111111111111111111111111");var ls=class{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}};xh=ls;ls.default=new xh(0,0,ce.default);var un=Object.freeze({Initialize:{index:0,layout:E.struct([E.u32("instruction"),O1(),k1()])},Authorize:{index:1,layout:E.struct([E.u32("instruction"),ye("newAuthorized"),E.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:E.struct([E.u32("instruction")])},Split:{index:3,layout:E.struct([E.u32("instruction"),E.ns64("lamports")])},Withdraw:{index:4,layout:E.struct([E.u32("instruction"),E.ns64("lamports")])},Deactivate:{index:5,layout:E.struct([E.u32("instruction")])},Merge:{index:7,layout:E.struct([E.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:E.struct([E.u32("instruction"),ye("newAuthorized"),E.u32("stakeAuthorizationType"),wi("authoritySeed"),ye("authorityOwner")])}}),QA=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),Qo=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:i}=e,s=i||ls.default,o=un.Initialize,c=we(o,{authorized:{staker:_e(n.staker.toBuffer()),withdrawer:_e(n.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:_e(s.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:cs,isSigner:!1,isWritable:!1}],programId:this.programId,data:c};return new Te(u)}static createAccountWithSeed(e){let t=new Se;t.add(Dt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static createAccount(e){let t=new Se;t.add(Dt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:i}=e,s=un.Delegate,o=we(s);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:du,isSigner:!1,isWritable:!1},{pubkey:hE,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=e,c=un.Authorize,u=we(c,{newAuthorized:_e(i.toBuffer()),stakeAuthorizationType:s.index}),p=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&p.push({pubkey:o,isSigner:!0,isWritable:!1}),new Se().add({keys:p,programId:this.programId,data:u})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:n,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:c,custodianPubkey:u}=e,p=un.AuthorizeWithSeed,m=we(p,{newAuthorized:_e(o.toBuffer()),stakeAuthorizationType:c.index,authoritySeed:i,authorityOwner:_e(s.toBuffer())}),b=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1}];return u&&b.push({pubkey:u,isSigner:!0,isWritable:!1}),new Se().add({keys:b,programId:this.programId,data:m})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:i,lamports:s}=e,o=un.Split,c=we(o,{lamports:s});return new Te({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:c})}static split(e,t){let n=new Se;return n.add(Dt.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:c,lamports:u}=e,p=new Se;return p.add(Dt.allocate({accountPubkey:s,basePubkey:o,seed:c,space:this.space,programId:this.programId})),t&&t>0&&p.add(Dt.transfer({fromPubkey:e.authorizedPubkey,toPubkey:s,lamports:t})),p.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:i}=e,s=un.Merge,o=we(s);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:du,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:i,lamports:s,custodianPubkey:o}=e,c=un.Withdraw,u=we(c,{lamports:s}),p=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:du,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&p.push({pubkey:o,isSigner:!0,isWritable:!1}),new Se().add({keys:p,programId:this.programId,data:u})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:n}=e,i=un.Deactivate,s=we(i);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}};Qo.programId=new ce("Stake11111111111111111111111111111111111111");Qo.space=200;var as=Object.freeze({InitializeAccount:{index:0,layout:E.struct([E.u32("instruction"),T1()])},Authorize:{index:1,layout:E.struct([E.u32("instruction"),ye("newAuthorized"),E.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:E.struct([E.u32("instruction"),E.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:E.struct([E.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:E.struct([E.u32("instruction"),N1()])}}),ex=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),ea=class r{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:i}=e,s=as.InitializeAccount,o=we(s,{voteInit:{nodePubkey:_e(i.nodePubkey.toBuffer()),authorizedVoter:_e(i.authorizedVoter.toBuffer()),authorizedWithdrawer:_e(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),c={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:cs,isSigner:!1,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Te(c)}static createAccount(e){let t=new Se;return t.add(Dt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,voteAuthorizationType:s}=e,o=as.Authorize,c=we(o,{newAuthorized:_e(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Se().add({keys:u,programId:this.programId,data:c})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:c}=e,u=as.AuthorizeWithSeed,p=we(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:_e(n.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:_e(s.toBuffer()),voteAuthorizationType:o.index}}),m=[{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Se().add({keys:m,programId:this.programId,data:p})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:i,toPubkey:s}=e,o=as.Withdraw,c=we(o,{lamports:i}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Se().add({keys:u,programId:this.programId,data:c})}static safeWithdraw(e,t,n){if(e.lamports>t-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return r.withdraw(e)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:i}=e,s=as.UpdateValidatorIdentity,o=we(s),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Se().add({keys:c,programId:this.programId,data:o})}};ea.programId=new ce("Vote111111111111111111111111111111111111111");ea.space=3762;var tx=new ce("Va1idator1nfo111111111111111111111111111111"),rx=P({name:z(),website:ne(z()),details:ne(z()),iconUrl:ne(z()),keybaseUsername:ne(z())});var nx=new ce("Vote111111111111111111111111111111111111111"),ix=E.struct([ye("nodePubkey"),ye("authorizedWithdrawer"),E.u8("commission"),E.nu64(),E.seq(E.struct([E.nu64("slot"),E.u32("confirmationCount")]),E.offset(E.u32(),-8),"votes"),E.u8("rootSlotValid"),E.nu64("rootSlot"),E.nu64(),E.seq(E.struct([E.nu64("epoch"),ye("authorizedVoter")]),E.offset(E.u32(),-8),"authorizedVoters"),E.struct([E.seq(E.struct([ye("authorizedPubkey"),E.nu64("epochOfLastAuthorizedSwitch"),E.nu64("targetEpoch")]),32,"buf"),E.nu64("idx"),E.u8("isEmpty")],"priorVoters"),E.nu64(),E.seq(E.struct([E.nu64("epoch"),E.nu64("credits"),E.nu64("prevCredits")]),E.offset(E.u32(),-8),"epochCredits"),E.struct([E.nu64("slot"),E.nu64("timestamp")],"lastTimestamp")]);var zu=r=>({request:r,signMessage:e=>r({method:"signMessage",params:{message:e}}),signTransaction:e=>r({method:"signTransaction",params:{transaction:e}}),signAndSendTransaction:e=>r({method:"signAndSendTransaction",params:e})});function Fu(r){return Buffer.from(r.serialize({verifySignatures:!1})).toString("base64")}function $u(r){let e=Buffer.from(r,"base64");return ta.deserializeMessageVersion(e)==="legacy"?Zo.deserialize(e):Se.from(e)}function pE(r){return async t=>{if(t.method==="connect")return await r(t);if(t.method==="signMessage")return await r(t);if(t.method==="signAndSendTransaction"){let{transaction:n,options:i}=t.params,s={transaction:$u(n),options:i};return await r({method:"signAndSendTransaction",params:s})}if(t.method==="signTransaction"){let{transaction:n}=t.params,i={transaction:$u(n)},{signedTransaction:s}=await r({method:"signTransaction",params:i});return{signedTransaction:Fu(s)}}}}function Vu(r){return async t=>{if(t.method==="connect")return await r(t);if(t.method==="signMessage")return await r(t);if(t.method==="signAndSendTransaction"){let{transaction:n,options:i}=t.params,s={transaction:Fu(n)};return await r({method:"signAndSendTransaction",params:s})}if(t.method==="signTransaction"){let{transaction:n}=t.params,i={transaction:Fu(n)},{signedTransaction:s}=await r({method:"signTransaction",params:i});return{signedTransaction:$u(s)}}}}var ia=class r extends Error{constructor(e,t={}){let n=(()=>{if(t.cause instanceof r){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&typeof t.cause.details=="string"?t.cause.details:t.cause?.message?t.cause.message:t.details})(),i=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n?["",n?`Details: ${n}`:void 0]:[]].filter(s=>typeof s=="string").join(`
13
+ `);super(i,t.cause?{cause:t.cause}:void 0),this.name="BaseError",this.cause=t.cause,this.details=n,this.shortMessage=e}},Ai=class extends ia{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}},sa=class extends ia{constructor(e){super(e),this.name="InvalidToken"}};async function Ih({origin:r}){let e=await fetch(`${r}/nonce`,{method:"POST"});if(!e.ok)throw new Ai({status:e.status});return await e.json()}async function Oh({origin:r},e){let t=await fetch(`${r}/verify-siwf`,{method:"POST",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(e)});if(!t.ok)throw new Ai({status:t.status});let n=await t.json();if(n.valid===!1)throw new sa(n.message??"unknown");return{token:n.token}}function kh(r={}){return{origin:r.origin??"https://auth.farcaster.xyz"}}function Th(r={}){let e=kh(r);return{generateNonce:()=>Ih(e),verifySiwf:t=>Oh(e,t)}}var Nh="0.1.1";function Bh(){return Nh}var oa=class r extends Error{constructor(e,t={}){let n=(()=>{if(t.cause instanceof r){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause?.message?t.cause.message:t.details})(),i=t.cause instanceof r&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${i??""}`,c=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||i?["",n?`Details: ${n}`:void 0,i?`See: ${o}`:void 0]:[]].filter(u=>typeof u=="string").join(`
14
+ `);super(c,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Bh()}`}),this.cause=t.cause,this.details=n,this.docs=o,this.docsPath=i,this.shortMessage=e}walk(e){return Lh(this,e)}};function Lh(r,e){return e?.(r)?r:r&&typeof r=="object"&&"cause"in r&&r.cause?Lh(r.cause,e):e?null:r}var gE=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,yE=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function Ch(r){let{scheme:e,statement:t,...n}=r.match(gE)?.groups??{},{chainId:i,expirationTime:s,issuedAt:o,notBefore:c,requestId:u,...p}=r.match(yE)?.groups??{},m=r.split("Resources:")[1]?.split(`
15
+ - `).slice(1);return{...n,...p,...i?{chainId:Number(i)}:{},...s?{expirationTime:new Date(s)}:{},...o?{issuedAt:new Date(o)}:{},...c?{notBefore:new Date(c)}:{},...u?{requestId:u}:{},...m?{resources:m}:{},...e?{scheme:e}:{},...t?{statement:t}:{}}}function aa(r,e={}){let{raw:t=!1}=e,n=r;if(t)return r;if(n.error){let{code:i}=n.error,s=i===Gn.code?Gn:i===ds.code?ds:i===vs.code?vs:i===bs.code?bs:i===ys.code?ys:i===ws.code?ws:i===gs.code?gs:i===Es.code?Es:i===hs.code?hs:i===ps.code?ps:i===ms.code?ms:i===_s.code?_s:St;throw new s(n.error)}return n.result}var St=class extends Error{constructor(e){let{code:t,message:n,data:i}=e;super(n),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t,this.data=i}},ds=class r extends St{constructor(e={}){super({message:"Missing or invalid parameters.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}};Object.defineProperty(ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});var hs=class r extends St{constructor(e={}){super({message:"Requested resource not found.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}};Object.defineProperty(hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});var ps=class r extends St{constructor(e={}){super({message:"Requested resource not available.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}};Object.defineProperty(ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});var ms=class r extends St{constructor(e={}){super({message:"Transaction creation failed.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}};Object.defineProperty(ms,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});var gs=class r extends St{constructor(e={}){super({message:"Method is not implemented.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}};Object.defineProperty(gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});var ys=class r extends St{constructor(e={}){super({message:"Rate limit exceeded.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}};Object.defineProperty(ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});var _s=class r extends St{constructor(e={}){super({message:"JSON-RPC version not supported.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}};Object.defineProperty(_s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});var bs=class r extends St{constructor(e={}){super({message:"Input is not a valid JSON-RPC request.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}};Object.defineProperty(bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});var ws=class r extends St{constructor(e={}){super({message:"Method does not exist.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}};Object.defineProperty(ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});var vs=class r extends St{constructor(e={}){super({message:"Invalid method parameters.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}};Object.defineProperty(vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});var Gn=class r extends St{constructor(e={}){super({message:"Internal JSON-RPC error.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalErrorError"})}};Object.defineProperty(Gn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});var Es=class r extends St{constructor(e={}){super({message:"Failed to parse JSON-RPC response.",...e,code:r.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}};Object.defineProperty(Es,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});var _r=class extends Error{constructor(e,t){super(t),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=t}},Rs=class extends _r{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}};Object.defineProperty(Rs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});var Ss=class extends _r{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}};Object.defineProperty(Ss,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});var As=class extends _r{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}};Object.defineProperty(As,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});var xs=class extends _r{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}};Object.defineProperty(xs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});var Is=class extends _r{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}};Object.defineProperty(Is,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function Mh(){let r=new on.default;return{get eventNames(){return r.eventNames.bind(r)},get listenerCount(){return r.listenerCount.bind(r)},get listeners(){return r.listeners.bind(r)},addListener:r.addListener.bind(r),emit:r.emit.bind(r),off:r.off.bind(r),on:r.on.bind(r),once:r.once.bind(r),removeAllListeners:r.removeAllListeners.bind(r),removeListener:r.removeListener.bind(r)}}function Uh(r,e={}){let{includeEvents:t=!0}=e;if(!r)throw new qu;return{...t?{on:r.on?.bind(r),removeListener:r.removeListener?.bind(r)}:{},async request(n){let i=await r.request(n);return i&&typeof i=="object"&&"jsonrpc"in i?aa(i):i}}}var qu=class extends oa{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}};function Dh(r={}){let e=r.id??0;return{prepare(t){return wE({id:e++,...t})},get id(){return e}}}function wE(r){return{...r,jsonrpc:"2.0"}}var Fh=Symbol("Comlink.proxy"),EE=Symbol("Comlink.endpoint"),RE=Symbol("Comlink.releaseProxy"),Wu=Symbol("Comlink.finalizer"),ua=Symbol("Comlink.thrown"),$h=r=>typeof r=="object"&&r!==null||typeof r=="function",SE={canHandle:r=>$h(r)&&r[Fh],serialize(r){let{port1:e,port2:t}=new MessageChannel;return qh(r,e),[t,[t]]},deserialize(r){return r.start(),Ku(r)}},AE={canHandle:r=>$h(r)&&ua in r,serialize({value:r}){let e;return r instanceof Error?e={isError:!0,value:{message:r.message,name:r.name,stack:r.stack}}:e={isError:!1,value:r},[e,[]]},deserialize(r){throw r.isError?Object.assign(new Error(r.value.message),r.value):r.value}},Vh=new Map([["proxy",SE],["throw",AE]]);function xE(r,e){for(let t of r)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function qh(r,e=globalThis,t=["*"]){e.addEventListener("message",function n(i){if(!i||!i.data)return;if(!xE(t,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}let{id:s,type:o,path:c}=Object.assign({path:[]},i.data),u=(i.data.argumentList||[]).map(Zn),p;try{let m=c.slice(0,-1).reduce((A,S)=>A[S],r),b=c.reduce((A,S)=>A[S],r);switch(o){case"GET":p=b;break;case"SET":m[c.slice(-1)[0]]=Zn(i.data.value),p=!0;break;case"APPLY":p=b.apply(m,u);break;case"CONSTRUCT":{let A=new b(...u);p=BE(A)}break;case"ENDPOINT":{let{port1:A,port2:S}=new MessageChannel;qh(r,S),p=NE(A,[A])}break;case"RELEASE":p=void 0;break;default:return}}catch(m){p={value:m,[ua]:0}}Promise.resolve(p).catch(m=>({value:m,[ua]:0})).then(m=>{let[b,A]=da(m);e.postMessage(Object.assign(Object.assign({},b),{id:s}),A),o==="RELEASE"&&(e.removeEventListener("message",n),Wh(e),Wu in r&&typeof r[Wu]=="function"&&r[Wu]())}).catch(m=>{let[b,A]=da({value:new TypeError("Unserializable return value"),[ua]:0});e.postMessage(Object.assign(Object.assign({},b),{id:s}),A)})}),e.start&&e.start()}function IE(r){return r.constructor.name==="MessagePort"}function Wh(r){IE(r)&&r.close()}function Ku(r,e){let t=new Map;return r.addEventListener("message",function(i){let{data:s}=i;if(!s||!s.id)return;let o=t.get(s.id);if(o)try{o(s)}finally{t.delete(s.id)}}),ju(r,t,[],e)}function ca(r){if(r)throw new Error("Proxy has been released and is not useable")}function jh(r){return xi(r,new Map,{type:"RELEASE"}).then(()=>{Wh(r)})}var fa=new WeakMap,la="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{let e=(fa.get(r)||0)-1;fa.set(r,e),e===0&&jh(r)});function OE(r,e){let t=(fa.get(e)||0)+1;fa.set(e,t),la&&la.register(r,e,r)}function kE(r){la&&la.unregister(r)}function ju(r,e,t=[],n=function(){}){let i=!1,s=new Proxy(n,{get(o,c){if(ca(i),c===RE)return()=>{kE(s),jh(r),e.clear(),i=!0};if(c==="then"){if(t.length===0)return{then:()=>s};let u=xi(r,e,{type:"GET",path:t.map(p=>p.toString())}).then(Zn);return u.then.bind(u)}return ju(r,e,[...t,c])},set(o,c,u){ca(i);let[p,m]=da(u);return xi(r,e,{type:"SET",path:[...t,c].map(b=>b.toString()),value:p},m).then(Zn)},apply(o,c,u){ca(i);let p=t[t.length-1];if(p===EE)return xi(r,e,{type:"ENDPOINT"}).then(Zn);if(p==="bind")return ju(r,e,t.slice(0,-1));let[m,b]=zh(u);return xi(r,e,{type:"APPLY",path:t.map(A=>A.toString()),argumentList:m},b).then(Zn)},construct(o,c){ca(i);let[u,p]=zh(c);return xi(r,e,{type:"CONSTRUCT",path:t.map(m=>m.toString()),argumentList:u},p).then(Zn)}});return OE(s,r),s}function TE(r){return Array.prototype.concat.apply([],r)}function zh(r){let e=r.map(da);return[e.map(t=>t[0]),TE(e.map(t=>t[1]))]}var Kh=new WeakMap;function NE(r,e){return Kh.set(r,e),r}function BE(r){return Object.assign(r,{[Fh]:!0})}function Hh(r,e=globalThis,t="*"){return{postMessage:(n,i)=>r.postMessage(n,t,i),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function da(r){for(let[e,t]of Vh)if(t.canHandle(r)){let[n,i]=t.serialize(r);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:r},Kh.get(r)||[]]}function Zn(r){switch(r.type){case"HANDLER":return Vh.get(r.name).deserialize(r.value);case"RAW":return r.value}}function xi(r,e,t,n){return new Promise(i=>{let s=LE();e.set(s,i),r.start&&r.start(),r.postMessage(Object.assign({id:s},t),n)})}function LE(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var CE={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},PE={postMessage:r=>{console.debug("[webview:req]",r),window.ReactNativeWebView.postMessage(JSON.stringify(r))},addEventListener:(r,e,...t)=>{document.addEventListener("FarcasterFrameCallback",e,...t)},removeEventListener:(r,e)=>{document.removeEventListener("FarcasterFrameCallback",e)}},Gh=typeof window>"u"?CE:window?.ReactNativeWebView?PE:Hh(window?.parent??window);var ve=Ku(Gh);var Hu=Mh(),ME=Dh();function UE({code:r,details:e}){switch(r){case 4001:return new Rs;case 4100:return new Ss;case 4200:return new As;case 4900:return new xs;case 4901:return new Is;default:return new _r(r,e??"Unknown provider RPC error")}}var Ii=Uh({...Hu,async request(r){let e=ME.prepare(r);try{let t=await ve.ethProviderRequestV2(e).then(n=>aa(n,{request:e,raw:!0}));if(t.error)throw UE(t.error);return t.result}catch(t){if(t instanceof Error&&t.message.match(/cannot read property 'apply'/i))return await ve.ethProviderRequest(e);throw t instanceof _r||t instanceof St?t:new Gn({message:t instanceof Error?t.message:void 0})}}});async function Zh(){try{let r=await ve.getCapabilities();return!r.includes("wallet.getEthereumProvider")&&!r.includes("wallet.getEvmProvider")?void 0:Ii}catch{return Ii}}function Yh(r){let e=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(r)});window.dispatchEvent(e);let t=()=>window.dispatchEvent(e);return window.addEventListener("eip6963:requestProvider",t),()=>window.removeEventListener("eip6963:requestProvider",t)}typeof document<"u"&&(document.addEventListener("eip6963:requestProvider",()=>{ve.eip6963RequestProvider()}),document.addEventListener("FarcasterFrameEthProviderEvent",r=>{if(r instanceof MessageEvent){let e=r.data;Hu.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",r=>{if(r instanceof MessageEvent){let e=r.data;e.event==="eip6963:announceProvider"&&Yh({info:e.info,provider:Ii})}}));typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{ve.eip6963RequestProvider()}),window.addEventListener("message",r=>{if(r instanceof MessageEvent&&r.data.type==="frameEthProviderEvent"){let e=r.data;Hu.emit(e.event,...e.params)}}),window.addEventListener("message",r=>{if(r instanceof MessageEvent&&r.data.type==="frameEvent"){let e=r.data.event;e.event==="eip6963:announceProvider"&&Yh({info:e.info,provider:Ii})}}));var{solanaProviderRequest:Xh}=ve,Jh;Xh&&(Jh=zu(Vu(Xh)));async function Qh(){let r;try{r=await ve.getCapabilities()}catch{}if(r?.includes("wallet.getSolanaProvider"))return Jh}function r0(){let r=new on.default;return{get eventNames(){return r.eventNames.bind(r)},get listenerCount(){return r.listenerCount.bind(r)},get listeners(){return r.listeners.bind(r)},addListener:r.addListener.bind(r),emit:r.emit.bind(r),off:r.off.bind(r),on:r.on.bind(r),once:r.once.bind(r),removeAllListeners:r.removeAllListeners.bind(r),removeListener:r.removeListener.bind(r)}}var Jt=r0(),e0=null;async function DE(r=50){if(e0===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;let e=await Promise.race([ve.context.then(t=>!!t),new Promise(t=>{setTimeout(()=>t(!1),r)})]).catch(()=>!1);return e&&(e0=!0),e}var t0=async()=>{let r=await ve.addFrame();if(r.result)return r.result;throw r.error.type==="invalid_domain_manifest"?new Xn.InvalidDomainManifest:r.error.type==="rejected_by_user"?new Xn.RejectedByUser:new Error("Unreachable")},Gu={...Jt,getCapabilities:ve.getCapabilities,getChains:ve.getChains,isInMiniApp:DE,context:ve.context,actions:{setPrimaryButton:ve.setPrimaryButton.bind(ve),ready:ve.ready.bind(ve),close:ve.close.bind(ve),viewProfile:ve.viewProfile.bind(ve),signIn:async r=>{let e=await ve.signIn(r);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new Jn.RejectedByUser:new Error("Unreachable")},openUrl:r=>{let e=typeof r=="string"?r:r.url;return ve.openUrl(e.trim())},addFrame:t0,addMiniApp:t0,composeCast(r={}){return ve.composeCast(r)},viewToken:ve.viewToken.bind(ve),sendToken:ve.sendToken.bind(ve),swapToken:ve.swapToken.bind(ve)},experimental:{getSolanaProvider:Qh,quickAuth:async(r={})=>{let e=Th({origin:r.quickAuthServerOrigin}),{nonce:t}=await e.generateNonce(),n=await ve.signIn({nonce:t});if(n.result){let i=Ch(n.result.message);if(!i.domain)throw new Error("Missing domain on SIWE message");return await e.verifySiwf({domain:i.domain,message:n.result.message,signature:n.result.signature})}throw n.error.type==="rejected_by_user"?new Jn.RejectedByUser:new Error("Unreachable")}},wallet:{ethProvider:Ii,getEthereumProvider:Zh}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",r=>{if(r instanceof MessageEvent){let e=r.data;e.event==="primary_button_clicked"?Jt.emit("primaryButtonClicked"):e.event==="frame_added"?Jt.emit("frameAdded",{notificationDetails:e.notificationDetails}):e.event==="frame_add_rejected"?Jt.emit("frameAddRejected",{reason:e.reason}):e.event==="frame_removed"?Jt.emit("frameRemoved"):e.event==="notifications_enabled"?Jt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"&&Jt.emit("notificationsDisabled")}});typeof window<"u"&&window.addEventListener("message",r=>{if(r instanceof MessageEvent&&r.data.type==="frameEvent"){let e=r.data.event;e.event==="primary_button_clicked"?Jt.emit("primaryButtonClicked"):e.event==="frame_added"?Jt.emit("frameAdded",{notificationDetails:e.notificationDetails}):e.event==="frame_add_rejected"?Jt.emit("frameAddRejected",{reason:e.reason}):e.event==="frame_removed"?Jt.emit("frameRemoved"):e.event==="notifications_enabled"?Jt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"&&Jt.emit("notificationsDisabled")}});var zE=Gu;return Ba(FE);})();
14
16
  /*! Bundled license information:
15
17
 
16
18
  ieee754/index.js: