@farcaster/frame-sdk 0.0.60 → 0.0.61

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,18 +1,18 @@
1
- "use strict";var frame=(()=>{var c0=Object.create;var Ci=Object.defineProperty;var u0=Object.getOwnPropertyDescriptor;var f0=Object.getOwnPropertyNames;var l0=Object.getPrototypeOf,d0=Object.prototype.hasOwnProperty;var Mt=(r,e)=>()=>(r&&(e=r(r=0)),e);var Ft=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),wr=(r,e)=>{for(var t in e)Ci(r,t,{get:e[t],enumerable:!0})},cf=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of f0(e))!d0.call(r,s)&&s!==t&&Ci(r,s,{get:()=>e[s],enumerable:!(n=u0(e,s))||n.enumerable});return r};var vr=(r,e,t)=>(t=r!=null?c0(l0(r)):{},cf(e||!r||!r.__esModule?Ci(t,"default",{value:r,enumerable:!0}):t,r)),Ca=r=>cf(Ci({},"__esModule",{value:!0}),r);var qf=Ft(Wi=>{"use strict";Wi.byteLength=Mp;Wi.toByteArray=Dp;Wi.fromByteArray=$p;var hr=[],tr=[],Pp=typeof Uint8Array<"u"?Uint8Array:Array,Ha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Tn=0,Vf=Ha.length;Tn<Vf;++Tn)hr[Tn]=Ha[Tn],tr[Ha.charCodeAt(Tn)]=Tn;var Tn,Vf;tr[45]=62;tr[95]=63;function Wf(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 Mp(r){var e=Wf(r),t=e[0],n=e[1];return(t+n)*3/4-n}function Up(r,e,t){return(e+t)*3/4-t}function Dp(r){var e,t=Wf(r),n=t[0],s=t[1],i=new Pp(Up(r,n,s)),o=0,c=s>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)],i[o++]=e>>16&255,i[o++]=e>>8&255,i[o++]=e&255;return s===2&&(e=tr[r.charCodeAt(u)]<<2|tr[r.charCodeAt(u+1)]>>4,i[o++]=e&255),s===1&&(e=tr[r.charCodeAt(u)]<<10|tr[r.charCodeAt(u+1)]<<4|tr[r.charCodeAt(u+2)]>>2,i[o++]=e>>8&255,i[o++]=e&255),i}function zp(r){return hr[r>>18&63]+hr[r>>12&63]+hr[r>>6&63]+hr[r&63]}function Fp(r,e,t){for(var n,s=[],i=e;i<t;i+=3)n=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(r[i+2]&255),s.push(zp(n));return s.join("")}function $p(r){for(var e,t=r.length,n=t%3,s=[],i=16383,o=0,c=t-n;o<c;o+=i)s.push(Fp(r,o,o+i>c?c:o+i));return n===1?(e=r[t-1],s.push(hr[e>>2]+hr[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],s.push(hr[e>>10]+hr[e>>4&63]+hr[e<<2&63]+"=")),s.join("")}});var jf=Ft(Ga=>{Ga.read=function(r,e,t,n,s){var i,o,c=s*8-n-1,u=(1<<c)-1,p=u>>1,m=-7,b=t?s-1:0,x=t?-1:1,S=r[e+b];for(b+=x,i=S&(1<<-m)-1,S>>=-m,m+=c;m>0;i=i*256+r[e+b],b+=x,m-=8);for(o=i&(1<<-m)-1,i>>=-m,m+=n;m>0;o=o*256+r[e+b],b+=x,m-=8);if(i===0)i=1-p;else{if(i===u)return o?NaN:(S?-1:1)*(1/0);o=o+Math.pow(2,n),i=i-p}return(S?-1:1)*o*Math.pow(2,i-n)};Ga.write=function(r,e,t,n,s,i){var o,c,u,p=i*8-s-1,m=(1<<p)-1,b=m>>1,x=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:i-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+=x/u:e+=x*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,s),o=o+b):(c=e*Math.pow(2,b-1)*Math.pow(2,s),o=0));s>=8;r[t+S]=c&255,S+=T,c/=256,s-=8);for(o=o<<s|c,p+=s;p>0;r[t+S]=o&255,S+=T,o/=256,p-=8);r[t+S-T]|=I*128}});var $s=Ft(ds=>{"use strict";var Za=qf(),fs=jf(),Kf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ds.Buffer=N;ds.SlowBuffer=Hp;ds.INSPECT_MAX_BYTES=50;var qi=2147483647;ds.kMaxLength=qi;N.TYPED_ARRAY_SUPPORT=Vp();!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 Vp(){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 Ar(r){if(r>qi)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 Qa(r)}return Yf(r,e,t)}N.poolSize=8192;function Yf(r,e,t){if(typeof r=="string")return qp(r,e);if(ArrayBuffer.isView(r))return jp(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(pr(r,ArrayBuffer)||r&&pr(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(pr(r,SharedArrayBuffer)||r&&pr(r.buffer,SharedArrayBuffer)))return Xa(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 s=Kp(r);if(s)return s;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 Yf(r,e,t)};Object.setPrototypeOf(N.prototype,Uint8Array.prototype);Object.setPrototypeOf(N,Uint8Array);function Xf(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 Wp(r,e,t){return Xf(r),r<=0?Ar(r):e!==void 0?typeof t=="string"?Ar(r).fill(e,t):Ar(r).fill(e):Ar(r)}N.alloc=function(r,e,t){return Wp(r,e,t)};function Qa(r){return Xf(r),Ar(r<0?0:ec(r)|0)}N.allocUnsafe=function(r){return Qa(r)};N.allocUnsafeSlow=function(r){return Qa(r)};function qp(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!N.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=Jf(r,e)|0,n=Ar(t),s=n.write(r,e);return s!==t&&(n=n.slice(0,s)),n}function Ya(r){let e=r.length<0?0:ec(r.length)|0,t=Ar(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function jp(r){if(pr(r,Uint8Array)){let e=new Uint8Array(r);return Xa(e.buffer,e.byteOffset,e.byteLength)}return Ya(r)}function Xa(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 Kp(r){if(N.isBuffer(r)){let e=ec(r.length)|0,t=Ar(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||rc(r.length)?Ar(0):Ya(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Ya(r.data)}function ec(r){if(r>=qi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+qi.toString(16)+" bytes");return r|0}function Hp(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(pr(e,Uint8Array)&&(e=N.from(e,e.offset,e.byteLength)),pr(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,s=t.length;for(let i=0,o=Math.min(n,s);i<o;++i)if(e[i]!==t[i]){n=e[i],s=t[i];break}return n<s?-1:s<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 s=N.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let o=e[n];if(pr(o,Uint8Array))i+o.length>s.length?(N.isBuffer(o)||(o=N.from(o)),o.copy(s,i)):Uint8Array.prototype.set.call(s,o,i);else if(N.isBuffer(o))o.copy(s,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=o.length}return s};function Jf(r,e){if(N.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||pr(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 s=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Ja(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return al(r).length;default:if(s)return n?-1:Ja(r).length;e=(""+e).toLowerCase(),s=!0}}N.byteLength=Jf;function Gp(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 sm(this,e,t);case"utf8":case"utf-8":return el(this,e,t);case"ascii":return rm(this,e,t);case"latin1":case"binary":return nm(this,e,t);case"base64":return em(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return im(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}N.prototype._isBuffer=!0;function Nn(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)Nn(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)Nn(this,t,t+3),Nn(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)Nn(this,t,t+7),Nn(this,t+1,t+6),Nn(this,t+2,t+5),Nn(this,t+3,t+4);return this};N.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?el(this,0,e):Gp.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=ds.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Kf&&(N.prototype[Kf]=N.prototype.inspect);N.prototype.compare=function(e,t,n,s,i){if(pr(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),s===void 0&&(s=0),i===void 0&&(i=this.length),t<0||n>e.length||s<0||i>this.length)throw new RangeError("out of range index");if(s>=i&&t>=n)return 0;if(s>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,s>>>=0,i>>>=0,this===e)return 0;let o=i-s,c=n-t,u=Math.min(o,c),p=this.slice(s,i),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 Qf(r,e,t,n,s){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,rc(t)&&(t=s?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(s)return-1;t=r.length-1}else if(t<0)if(s)t=0;else return-1;if(typeof e=="string"&&(e=N.from(e,n)),N.isBuffer(e))return e.length===0?-1:Hf(r,e,t,n,s);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Hf(r,[e],t,n,s);throw new TypeError("val must be string, number or Buffer")}function Hf(r,e,t,n,s){let i=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;i=2,o/=2,c/=2,t/=2}function u(m,b){return i===1?m[b]:m.readUInt16BE(b*i)}let p;if(s){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*i}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 Qf(this,e,t,n,!0)};N.prototype.lastIndexOf=function(e,t,n){return Qf(this,e,t,n,!1)};function Zp(r,e,t,n){t=Number(t)||0;let s=r.length-t;n?(n=Number(n),n>s&&(n=s)):n=s;let i=e.length;n>i/2&&(n=i/2);let o;for(o=0;o<n;++o){let c=parseInt(e.substr(o*2,2),16);if(rc(c))return o;r[t+o]=c}return o}function Yp(r,e,t,n){return ji(Ja(e,r.length-t),r,t,n)}function Xp(r,e,t,n){return ji(um(e),r,t,n)}function Jp(r,e,t,n){return ji(al(e),r,t,n)}function Qp(r,e,t,n){return ji(fm(e,r.length-t),r,t,n)}N.prototype.write=function(e,t,n,s){if(t===void 0)s="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")s=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,s===void 0&&(s="utf8")):(s=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let o=!1;for(;;)switch(s){case"hex":return Zp(this,e,t,n);case"utf8":case"utf-8":return Yp(this,e,t,n);case"ascii":case"latin1":case"binary":return Xp(this,e,t,n);case"base64":return Jp(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qp(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),o=!0}};N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function em(r,e,t){return e===0&&t===r.length?Za.fromByteArray(r):Za.fromByteArray(r.slice(e,t))}function el(r,e,t){t=Math.min(r.length,t);let n=[],s=e;for(;s<t;){let i=r[s],o=null,c=i>239?4:i>223?3:i>191?2:1;if(s+c<=t){let u,p,m,b;switch(c){case 1:i<128&&(o=i);break;case 2:u=r[s+1],(u&192)===128&&(b=(i&31)<<6|u&63,b>127&&(o=b));break;case 3:u=r[s+1],p=r[s+2],(u&192)===128&&(p&192)===128&&(b=(i&15)<<12|(u&63)<<6|p&63,b>2047&&(b<55296||b>57343)&&(o=b));break;case 4:u=r[s+1],p=r[s+2],m=r[s+3],(u&192)===128&&(p&192)===128&&(m&192)===128&&(b=(i&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),s+=c}return tm(n)}var Gf=4096;function tm(r){let e=r.length;if(e<=Gf)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Gf));return t}function rm(r,e,t){let n="";t=Math.min(r.length,t);for(let s=e;s<t;++s)n+=String.fromCharCode(r[s]&127);return n}function nm(r,e,t){let n="";t=Math.min(r.length,t);for(let s=e;s<t;++s)n+=String.fromCharCode(r[s]);return n}function sm(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let s="";for(let i=e;i<t;++i)s+=lm[r[i]];return s}function im(r,e,t){let n=r.slice(e,t),s="";for(let i=0;i<n.length-1;i+=2)s+=String.fromCharCode(n[i]+n[i+1]*256);return s}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 s=this.subarray(e,t);return Object.setPrototypeOf(s,N.prototype),s};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 s=this[e],i=1,o=0;for(;++o<t&&(i*=256);)s+=this[e+o]*i;return s};N.prototype.readUintBE=N.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let s=this[e+--t],i=1;for(;t>0&&(i*=256);)s+=this[e+--t]*i;return s};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=qr(function(e){e=e>>>0,ls(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Fs(e,this.length-8);let s=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(s)+(BigInt(i)<<BigInt(32))});N.prototype.readBigUInt64BE=qr(function(e){e=e>>>0,ls(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Fs(e,this.length-8);let s=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(s)<<BigInt(32))+BigInt(i)});N.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let s=this[e],i=1,o=0;for(;++o<t&&(i*=256);)s+=this[e+o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*t)),s};N.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let s=t,i=1,o=this[e+--s];for(;s>0&&(i*=256);)o+=this[e+--s]*i;return i*=128,o>=i&&(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=qr(function(e){e=e>>>0,ls(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Fs(e,this.length-8);let s=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(s)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});N.prototype.readBigInt64BE=qr(function(e){e=e>>>0,ls(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Fs(e,this.length-8);let s=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(s)<<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),fs.read(this,e,!0,23,4)};N.prototype.readFloatBE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),fs.read(this,e,!1,23,4)};N.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||bt(e,8,this.length),fs.read(this,e,!0,52,8)};N.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||bt(e,8,this.length),fs.read(this,e,!1,52,8)};function Wt(r,e,t,n,s,i){if(!N.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||e<i)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,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let c=Math.pow(2,8*n)-1;Wt(this,e,t,n,c,0)}let i=1,o=0;for(this[t]=e&255;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n};N.prototype.writeUintBE=N.prototype.writeUIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let c=Math.pow(2,8*n)-1;Wt(this,e,t,n,c,0)}let i=n-1,o=1;for(this[t+i]=e&255;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n};N.prototype.writeUint8=N.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||Wt(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||Wt(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||Wt(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||Wt(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||Wt(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 tl(r,e,t,n,s){ol(e,n,s,r,t,7);let i=Number(e&BigInt(4294967295));r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i;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 rl(r,e,t,n,s){ol(e,n,s,r,t,7);let i=Number(e&BigInt(4294967295));r[t+7]=i,i=i>>8,r[t+6]=i,i=i>>8,r[t+5]=i,i=i>>8,r[t+4]=i;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=qr(function(e,t=0){return tl(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});N.prototype.writeBigUInt64BE=qr(function(e,t=0){return rl(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});N.prototype.writeIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let u=Math.pow(2,8*n-1);Wt(this,e,t,n,u-1,-u)}let i=0,o=1,c=0;for(this[t]=e&255;++i<n&&(o*=256);)e<0&&c===0&&this[t+i-1]!==0&&(c=1),this[t+i]=(e/o>>0)-c&255;return t+n};N.prototype.writeIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let u=Math.pow(2,8*n-1);Wt(this,e,t,n,u-1,-u)}let i=n-1,o=1,c=0;for(this[t+i]=e&255;--i>=0&&(o*=256);)e<0&&c===0&&this[t+i+1]!==0&&(c=1),this[t+i]=(e/o>>0)-c&255;return t+n};N.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||Wt(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||Wt(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||Wt(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||Wt(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||Wt(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=qr(function(e,t=0){return tl(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});N.prototype.writeBigInt64BE=qr(function(e,t=0){return rl(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function nl(r,e,t,n,s,i){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function sl(r,e,t,n,s){return e=+e,t=t>>>0,s||nl(r,e,t,4,34028234663852886e22,-34028234663852886e22),fs.write(r,e,t,n,23,4),t+4}N.prototype.writeFloatLE=function(e,t,n){return sl(this,e,t,!0,n)};N.prototype.writeFloatBE=function(e,t,n){return sl(this,e,t,!1,n)};function il(r,e,t,n,s){return e=+e,t=t>>>0,s||nl(r,e,t,8,17976931348623157e292,-17976931348623157e292),fs.write(r,e,t,n,52,8),t+8}N.prototype.writeDoubleLE=function(e,t,n){return il(this,e,t,!0,n)};N.prototype.writeDoubleBE=function(e,t,n){return il(this,e,t,!1,n)};N.prototype.copy=function(e,t,n,s){if(!N.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!s&&s!==0&&(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<n&&(s=n),s===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(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-n&&(s=e.length-t+n);let i=s-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,s):Uint8Array.prototype.set.call(e,this.subarray(n,s),t),i};N.prototype.fill=function(e,t,n,s){if(typeof e=="string"){if(typeof t=="string"?(s=t,t=0,n=this.length):typeof n=="string"&&(s=n,n=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!N.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(e.length===1){let o=e.charCodeAt(0);(s==="utf8"&&o<128||s==="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 i;if(typeof e=="number")for(i=t;i<n;++i)this[i]=e;else{let o=N.isBuffer(e)?e:N.from(e,s),c=o.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=o[i%c]}return this};var us={};function tc(r,e,t){us[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(s){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:s,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}tc("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);tc("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);tc("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,s=t;return Number.isInteger(t)&&Math.abs(t)>2**32?s=Zf(String(t)):typeof t=="bigint"&&(s=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(s=Zf(s)),s+="n"),n+=` It must be ${e}. Received ${s}`,n},RangeError);function Zf(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 om(r,e,t){ls(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Fs(e,r.length-(t+1))}function ol(r,e,t,n,s,i){if(r>t||r<e){let o=typeof e=="bigint"?"n":"",c;throw i>3?e===0||e===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(i+1)*8}${o}`:c=`>= -(2${o} ** ${(i+1)*8-1}${o}) and < 2 ** ${(i+1)*8-1}${o}`:c=`>= ${e}${o} and <= ${t}${o}`,new us.ERR_OUT_OF_RANGE("value",c,r)}om(n,s,i)}function ls(r,e){if(typeof r!="number")throw new us.ERR_INVALID_ARG_TYPE(e,"number",r)}function Fs(r,e,t){throw Math.floor(r)!==r?(ls(r,t),new us.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new us.ERR_BUFFER_OUT_OF_BOUNDS:new us.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var am=/[^+/0-9A-Za-z-_]/g;function cm(r){if(r=r.split("=")[0],r=r.trim().replace(am,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Ja(r,e){e=e||1/0;let t,n=r.length,s=null,i=[];for(let o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!s){if(t>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&i.push(239,191,189);continue}s=t;continue}if(t<56320){(e-=3)>-1&&i.push(239,191,189),s=t;continue}t=(s-55296<<10|t-56320)+65536}else s&&(e-=3)>-1&&i.push(239,191,189);if(s=null,t<128){if((e-=1)<0)break;i.push(t)}else if(t<2048){if((e-=2)<0)break;i.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;i.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;i.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return i}function um(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function fm(r,e){let t,n,s,i=[];for(let o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),n=t>>8,s=t%256,i.push(s),i.push(n);return i}function al(r){return Za.toByteArray(cm(r))}function ji(r,e,t,n){let s;for(s=0;s<n&&!(s+t>=e.length||s>=r.length);++s)e[s+t]=r[s];return s}function pr(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function rc(r){return r!==r}var lm=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let s=0;s<16;++s)e[n+s]=r[t]+r[s]}return e}();function qr(r){return typeof BigInt>"u"?dm:r}function dm(){throw new Error("BigInt not supported")}});var Ol=Ft(()=>{});var kc=Ft((Tl,Ic)=>{(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 s(v,a,l){if(s.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=s:e.BN=s,s.BN=s,s.wordSize=26;var i;try{typeof window<"u"&&typeof window.Buffer<"u"?i=window.Buffer:i=Ol().Buffer}catch{}s.isBN=function(a){return a instanceof s?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===s.wordSize&&Array.isArray(a.words)},s.max=function(a,l){return a.cmp(l)>0?a:l},s.min=function(a,l){return a.cmp(l)<0?a:l},s.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)))},s.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)},s.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}s.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}s.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()},s.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(s.prototype._move=function(a){p(a,this)},s.prototype.clone=function(){var a=new s(null);return this.copy(a),a},s.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch{s.prototype.inspect=m}else s.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"],x=[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];s.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=x[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")},s.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},s.prototype.toJSON=function(){return this.toString(16,2)},i&&(s.prototype.toBuffer=function(a,l){return this.toArrayLike(i,a,l)}),s.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)};s.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},s.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},s.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?s.prototype._countBits=function(a){return 32-Math.clz32(a)}:s.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},s.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},s.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}s.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},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},s.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.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()},s.prototype.ior=function(a){return t((this.negative|a.negative)===0),this.iuor(a)},s.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},s.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},s.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()},s.prototype.iand=function(a){return t((this.negative|a.negative)===0),this.iuand(a)},s.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},s.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},s.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()},s.prototype.ixor=function(a){return t((this.negative|a.negative)===0),this.iuxor(a)},s.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},s.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},s.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()},s.prototype.notn=function(a){return this.clone().inotn(a)},s.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()},s.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},s.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)},s.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()},s.prototype.sub=function(a){return this.clone().isub(a)};function A(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 J=f-$|0;h=v.words[J]|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,J=h[1]|0,se=J&8191,ue=J>>>13,Le=h[2]|0,he=Le&8191,me=Le>>>13,Ht=h[3]|0,xe=Ht&8191,Ne=Ht>>>13,Ti=h[4]|0,je=Ti&8191,Ke=Ti>>>13,Ni=h[5]|0,Ue=Ni&8191,De=Ni>>>13,Jn=h[6]|0,ze=Jn&8191,Fe=Jn>>>13,Ts=h[7]|0,$e=Ts&8191,Ve=Ts>>>13,Bi=h[8]|0,He=Bi&8191,Ge=Bi>>>13,Li=h[9]|0,Ye=Li&8191,Xe=Li>>>13,Xu=g[0]|0,Je=Xu&8191,Qe=Xu>>>13,Ju=g[1]|0,et=Ju&8191,tt=Ju>>>13,Qu=g[2]|0,rt=Qu&8191,nt=Qu>>>13,ef=g[3]|0,st=ef&8191,it=ef>>>13,tf=g[4]|0,ot=tf&8191,at=tf>>>13,rf=g[5]|0,ct=rf&8191,ut=rf>>>13,nf=g[6]|0,ft=nf&8191,lt=nf>>>13,sf=g[7]|0,dt=sf&8191,ht=sf>>>13,of=g[8]|0,pt=of&8191,mt=of>>>13,af=g[9]|0,gt=af&8191,yt=af>>>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 ma=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ma>>>26)|0,ma&=67108863,y=Math.imul(se,Je),f=Math.imul(se,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 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(me,Je)|0,_=Math.imul(me,Qe),y=y+Math.imul(se,et)|0,f=f+Math.imul(se,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 ya=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ya>>>26)|0,ya&=67108863,y=Math.imul(xe,Je),f=Math.imul(xe,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(se,rt)|0,f=f+Math.imul(se,nt)|0,f=f+Math.imul(ue,rt)|0,_=_+Math.imul(ue,nt)|0,y=y+Math.imul(D,st)|0,f=f+Math.imul(D,it)|0,f=f+Math.imul($,st)|0,_=_+Math.imul($,it)|0;var _a=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(_a>>>26)|0,_a&=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(xe,et)|0,f=f+Math.imul(xe,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(se,st)|0,f=f+Math.imul(se,it)|0,f=f+Math.imul(ue,st)|0,_=_+Math.imul(ue,it)|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 ba=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ba>>>26)|0,ba&=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(xe,rt)|0,f=f+Math.imul(xe,nt)|0,f=f+Math.imul(Ne,rt)|0,_=_+Math.imul(Ne,nt)|0,y=y+Math.imul(he,st)|0,f=f+Math.imul(he,it)|0,f=f+Math.imul(me,st)|0,_=_+Math.imul(me,it)|0,y=y+Math.imul(se,ot)|0,f=f+Math.imul(se,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 wa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(wa>>>26)|0,wa&=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(xe,st)|0,f=f+Math.imul(xe,it)|0,f=f+Math.imul(Ne,st)|0,_=_+Math.imul(Ne,it)|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(se,ct)|0,f=f+Math.imul(se,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 va=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(va>>>26)|0,va&=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,st)|0,f=f+Math.imul(je,it)|0,f=f+Math.imul(Ke,st)|0,_=_+Math.imul(Ke,it)|0,y=y+Math.imul(xe,ot)|0,f=f+Math.imul(xe,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(se,ft)|0,f=f+Math.imul(se,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 Ea=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ea>>>26)|0,Ea&=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,st)|0,f=f+Math.imul(Ue,it)|0,f=f+Math.imul(De,st)|0,_=_+Math.imul(De,it)|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(xe,ct)|0,f=f+Math.imul(xe,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(se,dt)|0,f=f+Math.imul(se,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 Ra=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ra>>>26)|0,Ra&=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,st)|0,f=f+Math.imul(ze,it)|0,f=f+Math.imul(Fe,st)|0,_=_+Math.imul(Fe,it)|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(xe,ft)|0,f=f+Math.imul(xe,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(se,pt)|0,f=f+Math.imul(se,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 Sa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Sa>>>26)|0,Sa&=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,st)|0,f=f+Math.imul($e,it)|0,f=f+Math.imul(Ve,st)|0,_=_+Math.imul(Ve,it)|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(xe,dt)|0,f=f+Math.imul(xe,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(se,gt)|0,f=f+Math.imul(se,yt)|0,f=f+Math.imul(ue,gt)|0,_=_+Math.imul(ue,yt)|0;var xa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(xa>>>26)|0,xa&=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,st)|0,f=f+Math.imul(He,it)|0,f=f+Math.imul(Ge,st)|0,_=_+Math.imul(Ge,it)|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(xe,pt)|0,f=f+Math.imul(xe,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 Aa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Aa>>>26)|0,Aa&=67108863,y=Math.imul(Ye,st),f=Math.imul(Ye,it),f=f+Math.imul(Xe,st)|0,_=Math.imul(Xe,it),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(xe,gt)|0,f=f+Math.imul(xe,yt)|0,f=f+Math.imul(Ne,gt)|0,_=_+Math.imul(Ne,yt)|0;var Ia=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ia>>>26)|0,Ia&=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 ka=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(ka>>>26)|0,ka&=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 Oa=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Oa>>>26)|0,Oa&=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 Ta=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ta>>>26)|0,Ta&=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 Na=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Na>>>26)|0,Na&=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 Ba=(R+y|0)+((f&8191)<<13)|0;R=(_+(f>>>13)|0)+(Ba>>>26)|0,Ba&=67108863,y=Math.imul(Ye,gt),f=Math.imul(Ye,yt),f=f+Math.imul(Xe,gt)|0,_=Math.imul(Xe,yt);var La=(R+y|0)+((f&8191)<<13)|0;return R=(_+(f>>>13)|0)+(La>>>26)|0,La&=67108863,w[0]=ma,w[1]=ga,w[2]=ya,w[3]=_a,w[4]=ba,w[5]=wa,w[6]=va,w[7]=Ea,w[8]=Ra,w[9]=Sa,w[10]=xa,w[11]=Aa,w[12]=Ia,w[13]=ka,w[14]=Oa,w[15]=Ta,w[16]=Na,w[17]=Ba,w[18]=La,R!==0&&(w[19]=R,d.length++),d};Math.imul||(B=A);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,J=$&67108863;w=w+($/67108864|0)|0,J=J+R|0,R=J&67108863,w=w+(J>>>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)}s.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=A(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=s.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,$=_,J=0;J<R;J++){var se=d[C+J],ue=h[C+J],Le=d[C+J+R],he=h[C+J+R],me=D*Le-$*he;he=D*he+$*Le,Le=me,d[C+J]=se+Le,h[C+J]=ue+he,d[C+J+R]=se-Le,h[C+J+R]=ue-he,J!==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 J=0;J<h;J++){var se=y[J]*C[J]-f[J]*D[J];f[J]=y[J]*D[J]+f[J]*C[J],y[J]=se}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()},s.prototype.mul=function(a){var l=new s(null);return l.words=new Array(this.length+a.length),this.mulTo(a,l)},s.prototype.mulf=function(a){var l=new s(null);return l.words=new Array(this.length+a.length),L(this,a,l)},s.prototype.imul=function(a){return this.clone().mulTo(a,this)},s.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},s.prototype.muln=function(a){return this.clone().imuln(a)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(a){var l=I(a);if(l.length===0)return new s(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},s.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()},s.prototype.ishln=function(a){return t(this.negative===0),this.iushln(a)},s.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()},s.prototype.ishrn=function(a,l,d){return t(this.negative===0),this.iushrn(a,l,d)},s.prototype.shln=function(a){return this.clone().ishln(a)},s.prototype.ushln=function(a){return this.clone().iushln(a)},s.prototype.shrn=function(a){return this.clone().ishrn(a)},s.prototype.ushrn=function(a){return this.clone().iushrn(a)},s.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)},s.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()},s.prototype.maskn=function(a){return this.clone().imaskn(a)},s.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)},s.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},s.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()},s.prototype.addn=function(a){return this.clone().iaddn(a)},s.prototype.subn=function(a){return this.clone().isubn(a)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.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()},s.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 s(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}},s.prototype.divmod=function(a,l,d){if(t(!a.isZero()),this.isZero())return{div:new s(0),mod:new s(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 s(0),mod:this}:a.length===1?l==="div"?{div:this.divn(a.words[0]),mod:null}:l==="mod"?{div:null,mod:new s(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new s(this.modrn(a.words[0]))}:this._wordDiv(a,l)},s.prototype.div=function(a){return this.divmod(a,"div",!1).div},s.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},s.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},s.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)},s.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},s.prototype.modn=function(a){return this.modrn(a)},s.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},s.prototype.divn=function(a){return this.clone().idivn(a)},s.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 s(1),g=new s(0),w=new s(0),R=new s(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,J=1;(d.words[0]&J)===0&&$<26;++$,J<<=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)}},s.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 s(1),g=new s(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},s.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)},s.prototype.invm=function(a){return this.egcd(a).a.umod(a)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(a){return this.words[0]&a},s.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},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.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},s.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},s.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},s.prototype.gtn=function(a){return this.cmpn(a)===1},s.prototype.gt=function(a){return this.cmp(a)===1},s.prototype.gten=function(a){return this.cmpn(a)>=0},s.prototype.gte=function(a){return this.cmp(a)>=0},s.prototype.ltn=function(a){return this.cmpn(a)===-1},s.prototype.lt=function(a){return this.cmp(a)===-1},s.prototype.lten=function(a){return this.cmpn(a)<=0},s.prototype.lte=function(a){return this.cmp(a)<=0},s.prototype.eqn=function(a){return this.cmpn(a)===0},s.prototype.eq=function(a){return this.cmp(a)===0},s.red=function(a){return new re(a)},s.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)},s.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(a){return this.red=a,this},s.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},s.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},s.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},s.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},s.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},s.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},s.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},s.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},s.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.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 G(v,a){this.name=v,this.p=new s(a,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}G.prototype._tmp=function(){var a=new s(null);return a.words=new Array(Math.ceil(this.n/13)),a},G.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},G.prototype.split=function(a,l){a.iushrn(this.n,0,l)},G.prototype.imulK=function(a){return a.imul(this.k)};function Z(){G.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(Z,G),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(){G.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ee,G);function Y(){G.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(Y,G);function Ie(){G.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Ie,G),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},s._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=s._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 s(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 s(1).toRed(this),R=w.redNeg(),y=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(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 J=D,se=0;J.cmp(w)!==0;se++)J=J.redSqr();t(se<$);var ue=this.pow(_,new s(1).iushln($-se-1));C=C.redMul(ue),_=ue.redSqr(),D=D.redMul(_),$=se}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 s(1).toRed(this);if(l.cmpn(1)===0)return a.clone();var d=4,h=new Array(1<<d);h[0]=new s(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},s.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 s(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 s(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 Ic>"u"||Ic,Tl)});var Ll=Ft((Oc,Bl)=>{var so=$s(),gr=so.Buffer;function Nl(r,e){for(var t in r)e[t]=r[t]}gr.from&&gr.alloc&&gr.allocUnsafe&&gr.allocUnsafeSlow?Bl.exports=so:(Nl(so,Oc),Oc.Buffer=zn);function zn(r,e,t){return gr(r,e,t)}zn.prototype=Object.create(gr.prototype);Nl(gr,zn);zn.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return gr(r,e,t)};zn.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=gr(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};zn.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return gr(r)};zn.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return so.SlowBuffer(r)}});var Pl=Ft((zS,Cl)=>{"use strict";var io=Ll().Buffer;function dg(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 s=r.charAt(n),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=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=io.from(S)),!io.isBuffer(S))throw new TypeError("Expected Buffer");if(S.length===0)return"";for(var T=0,I=0,A=0,B=S.length;A!==B&&S[A]===0;)A++,T++;for(var U=(B-A)*p+1>>>0,L=new Uint8Array(U);A!==B;){for(var F=S[A],te=0,G=U-1;(F!==0||te<I)&&G!==-1;G--,te++)F+=256*L[G]>>>0,L[G]=F%o>>>0,F=F/o>>>0;if(F!==0)throw new Error("Non-zero carry");I=te,A++}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 io.alloc(0);for(var T=0,I=0,A=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,G=B-1;(F!==0||te<A)&&G!==-1;G--,te++)F+=o*U[G]>>>0,U[G]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");A=te,T++}for(var Z=B-A;Z!==B&&U[Z]===0;)Z++;var ee=io.allocUnsafe(I+(B-Z));ee.fill(0,0,I);for(var Y=I;Z!==B;)ee[Y++]=U[Z++];return ee}function x(S){var T=b(S);if(T)return T;throw new Error("Non-base"+o+" character")}return{encode:m,decodeUnsafe:b,decode:x}}Cl.exports=dg});var Tc=Ft((FS,Ml)=>{var hg=Pl(),pg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Ml.exports=hg(pg)});var Ul=Ft(Cc=>{"use strict";function Br(r,e,t){return e<=r&&r<=t}function fo(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function gg(r){for(var e=String(r),t=e.length,n=0,s=[];n<t;){var i=e.charCodeAt(n);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(n===t-1)s.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var c=i&1023,u=o&1023;s.push(65536+(c<<10)+u),n+=1}else s.push(65533)}n+=1}return s}function yg(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 oo=-1;function Lc(r){this.tokens=[].slice.call(r)}Lc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():oo},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 gs=-1;function Bc(r,e){if(r)throw TypeError("Decoder error");return e||65533}var ao="utf-8";function co(r,e){if(!(this instanceof co))return new co(r,e);if(r=r!==void 0?String(r).toLowerCase():ao,r!==ao)throw new Error("Encoding not supported. Only utf-8 is supported");e=fo(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})}co.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=fo(t),this._streaming||(this._decoder=new _g({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var s=new Lc(n),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==gs);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===gs)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),yg(i)}};function uo(r,e){if(!(this instanceof uo))return new uo(r,e);if(r=r!==void 0?String(r).toLowerCase():ao,r!==ao)throw new Error("Encoding not supported. Only utf-8 is supported");e=fo(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}uo.prototype={encode:function(e,t){e=e?String(e):"",t=fo(t),this._streaming||(this._encoder=new bg(this._options)),this._streaming=!!t.stream;for(var n=[],s=new Lc(gg(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==gs);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==gs;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}};function _g(r){var e=r.fatal,t=0,n=0,s=0,i=128,o=191;this.handler=function(c,u){if(u===oo&&s!==0)return s=0,Bc(e);if(u===oo)return gs;if(s===0){if(Br(u,0,127))return u;if(Br(u,194,223))s=1,t=u-192;else if(Br(u,224,239))u===224&&(i=160),u===237&&(o=159),s=2,t=u-224;else if(Br(u,240,244))u===240&&(i=144),u===244&&(o=143),s=3,t=u-240;else return Bc(e);return t=t<<6*s,null}if(!Br(u,i,o))return t=s=n=0,i=128,o=191,c.prepend(u),Bc(e);if(i=128,o=191,n+=1,t+=u-128<<6*(s-n),n!==s)return null;var p=t;return t=s=n=0,p}}function bg(r){var e=r.fatal;this.handler=function(t,n){if(n===oo)return gs;if(Br(n,0,127))return n;var s,i;Br(n,128,2047)?(s=1,i=192):Br(n,2048,65535)?(s=2,i=224):Br(n,65536,1114111)&&(s=3,i=240);for(var o=[(n>>6*s)+i];s>0;){var c=n>>6*(s-1);o.push(128|c&63),s-=1}return o}}Cc.TextEncoder=uo;Cc.TextDecoder=co});var Vl=Ft(Oe=>{"use strict";var wg=Oe&&Oe.__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]}),vg=Oe&&Oe.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),yr=Oe&&Oe.__decorate||function(r,e,t,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(i=(s<3?o(i):s>3?o(e,t,i):o(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i},Eg=Oe&&Oe.__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)&&wg(e,r,t);return vg(e,r),e},Dl=Oe&&Oe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.deserializeUnchecked=Oe.deserialize=Oe.serialize=Oe.BinaryReader=Oe.BinaryWriter=Oe.BorshError=Oe.baseDecode=Oe.baseEncode=void 0;var rn=Dl(kc()),zl=Dl(Tc()),Rg=Eg(Ul()),Sg=typeof TextDecoder!="function"?Rg.TextDecoder:TextDecoder,xg=new Sg("utf-8",{fatal:!0});function Ag(r){return typeof r=="string"&&(r=Buffer.from(r,"utf8")),zl.default.encode(Buffer.from(r))}Oe.baseEncode=Ag;function Ig(r){return Buffer.from(zl.default.decode(r))}Oe.baseDecode=Ig;var Pc=1024,St=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(".")}};Oe.BorshError=St;var lo=class{constructor(){this.buf=Buffer.alloc(Pc),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Pc)]))}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 rn.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new rn.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new rn.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new rn.default(e).toArray("le",64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(Pc)]),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)}};Oe.BinaryWriter=lo;function _r(r,e,t){let n=t.value;t.value=function(...s){try{return n.apply(this,s)}catch(i){if(i instanceof RangeError){let o=i.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new St("Reached the end of buffer when deserializing")}throw i}}}var Ut=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 rn.default(e,"le")}readU128(){let e=this.readBuffer(16);return new rn.default(e,"le")}readU256(){let e=this.readBuffer(32);return new rn.default(e,"le")}readU512(){let e=this.readBuffer(64);return new rn.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new St(`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 xg.decode(t)}catch(n){throw new St(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=Array();for(let s=0;s<t;++s)n.push(e());return n}};yr([_r],Ut.prototype,"readU8",null);yr([_r],Ut.prototype,"readU16",null);yr([_r],Ut.prototype,"readU32",null);yr([_r],Ut.prototype,"readU64",null);yr([_r],Ut.prototype,"readU128",null);yr([_r],Ut.prototype,"readU256",null);yr([_r],Ut.prototype,"readU512",null);yr([_r],Ut.prototype,"readString",null);yr([_r],Ut.prototype,"readFixedArray",null);yr([_r],Ut.prototype,"readArray",null);Oe.BinaryReader=Ut;function Fl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Fn(r,e,t,n,s){try{if(typeof n=="string")s[`write${Fl(n)}`](t);else if(n instanceof Array)if(typeof n[0]=="number"){if(t.length!==n[0])throw new St(`Expecting byte array of length ${n[0]}, but got ${t.length} bytes`);s.writeFixedArray(t)}else if(n.length===2&&typeof n[1]=="number"){if(t.length!==n[1])throw new St(`Expecting byte array of length ${n[1]}, but got ${t.length} bytes`);for(let i=0;i<n[1];i++)Fn(r,null,t[i],n[0],s)}else s.writeArray(t,i=>{Fn(r,e,i,n[0],s)});else if(n.kind!==void 0)switch(n.kind){case"option":{t==null?s.writeU8(0):(s.writeU8(1),Fn(r,e,t,n.type,s));break}case"map":{s.writeU32(t.size),t.forEach((i,o)=>{Fn(r,e,o,n.key,s),Fn(r,e,i,n.value,s)});break}default:throw new St(`FieldType ${n} unrecognized`)}else $l(r,t,s)}catch(i){throw i instanceof St&&i.addToFieldPath(e),i}}function $l(r,e,t){if(typeof e.borshSerialize=="function"){e.borshSerialize(t);return}let n=r.get(e.constructor);if(!n)throw new St(`Class ${e.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([s,i])=>{Fn(r,s,e[s],i,t)});else if(n.kind==="enum"){let s=e[n.field];for(let i=0;i<n.values.length;++i){let[o,c]=n.values[i];if(o===s){t.writeU8(i),Fn(r,o,e[o],c,t);break}}}else throw new St(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function kg(r,e,t=lo){let n=new t;return $l(r,e,n),n.toArray()}Oe.serialize=kg;function $n(r,e,t,n){try{if(typeof t=="string")return n[`read${Fl(t)}`]();if(t instanceof Array){if(typeof t[0]=="number")return n.readFixedArray(t[0]);if(typeof t[1]=="number"){let s=[];for(let i=0;i<t[1];i++)s.push($n(r,null,t[0],n));return s}else return n.readArray(()=>$n(r,e,t[0],n))}if(t.kind==="option")return n.readU8()?$n(r,e,t.type,n):void 0;if(t.kind==="map"){let s=new Map,i=n.readU32();for(let o=0;o<i;o++){let c=$n(r,e,t.key,n),u=$n(r,e,t.value,n);s.set(c,u)}return s}return Mc(r,t,n)}catch(s){throw s instanceof St&&s.addToFieldPath(e),s}}function Mc(r,e,t){if(typeof e.borshDeserialize=="function")return e.borshDeserialize(t);let n=r.get(e);if(!n)throw new St(`Class ${e.name} is missing in schema`);if(n.kind==="struct"){let s={};for(let[i,o]of r.get(e).fields)s[i]=$n(r,i,o,t);return new e(s)}if(n.kind==="enum"){let s=t.readU8();if(s>=n.values.length)throw new St(`Enum index: ${s} is out of range`);let[i,o]=n.values[s],c=$n(r,i,o,t);return new e({[i]:c})}throw new St(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function Og(r,e,t,n=Ut){let s=new n(t),i=Mc(r,e,s);if(s.offset<t.length)throw new St(`Unexpected ${t.length-s.offset} bytes after deserialized data`);return i}Oe.deserialize=Og;function Tg(r,e,t,n=Ut){let s=new n(t);return Mc(r,e,s)}Oe.deserializeUnchecked=Tg});var Fc=Ft(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.s16=O.s8=O.nu64be=O.u48be=O.u40be=O.u32be=O.u24be=O.u16be=O.nu64=O.u48=O.u40=O.u32=O.u24=O.u16=O.u8=O.offset=O.greedy=O.Constant=O.UTF8=O.CString=O.Blob=O.Boolean=O.BitField=O.BitStructure=O.VariantLayout=O.Union=O.UnionLayoutDiscriminator=O.UnionDiscriminator=O.Structure=O.Sequence=O.DoubleBE=O.Double=O.FloatBE=O.Float=O.NearInt64BE=O.NearInt64=O.NearUInt64BE=O.NearUInt64=O.IntBE=O.Int=O.UIntBE=O.UInt=O.OffsetLayout=O.GreedyCount=O.ExternalLayout=O.bindConstructorLayout=O.nameWithProperty=O.Layout=O.uint8ArrayToBuffer=O.checkUint8Array=void 0;O.constant=O.utf8=O.cstr=O.blob=O.unionLayoutDiscriminator=O.union=O.seq=O.bits=O.struct=O.f64be=O.f64=O.f32be=O.f32=O.ns64be=O.s48be=O.s40be=O.s32be=O.s24be=O.s16be=O.ns64=O.s48=O.s40=O.s32=O.s24=void 0;var Dc=$s();function bs(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}O.checkUint8Array=bs;function Ee(r){return bs(r),Dc.Buffer.from(r.buffer,r.byteOffset,r.length)}O.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){}};O.Layout=Re;function zc(r,e){return e.property?r+"["+e.property+"]":r}O.nameWithProperty=zc;function Ng(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})}O.bindConstructorLayout=Ng;var Ot=class extends Re{isCount(){throw new Error("ExternalLayout is abstract")}};O.ExternalLayout=Ot;var ho=class extends Ot{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){bs(e);let n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}};O.GreedyCount=ho;var Hs=class extends Ot{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 Kt||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)}};O.OffsetLayout=Hs;var Kt=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}};O.UInt=Kt;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}};O.UIntBE=Gt;var Lr=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}};O.Int=Lr;var nn=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}};O.IntBE=nn;var Uc=Math.pow(2,32);function To(r){let e=Math.floor(r/Uc),t=r-e*Uc;return{hi32:e,lo32:t}}function No(r,e){return r*Uc+e}var po=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=Ee(e),s=n.readUInt32LE(t),i=n.readUInt32LE(t+4);return No(i,s)}encode(e,t,n=0){let s=To(e),i=Ee(t);return i.writeUInt32LE(s.lo32,n),i.writeUInt32LE(s.hi32,n+4),8}};O.NearUInt64=po;var mo=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=Ee(e),s=n.readUInt32BE(t),i=n.readUInt32BE(t+4);return No(s,i)}encode(e,t,n=0){let s=To(e),i=Ee(t);return i.writeUInt32BE(s.hi32,n),i.writeUInt32BE(s.lo32,n+4),8}};O.NearUInt64BE=mo;var go=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=Ee(e),s=n.readUInt32LE(t),i=n.readInt32LE(t+4);return No(i,s)}encode(e,t,n=0){let s=To(e),i=Ee(t);return i.writeUInt32LE(s.lo32,n),i.writeInt32LE(s.hi32,n+4),8}};O.NearInt64=go;var yo=class extends Re{constructor(e){super(8,e)}decode(e,t=0){let n=Ee(e),s=n.readInt32BE(t),i=n.readUInt32BE(t+4);return No(s,i)}encode(e,t,n=0){let s=To(e),i=Ee(t);return i.writeInt32BE(s.hi32,n),i.writeUInt32BE(s.lo32,n+4),8}};O.NearInt64BE=yo;var _o=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}};O.Float=_o;var bo=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}};O.FloatBE=bo;var wo=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}};O.Double=wo;var vo=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}};O.DoubleBE=vo;var Eo=class extends Re{constructor(e,t,n){if(!(e instanceof Re))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof Ot&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let s=-1;!(t instanceof Ot)&&0<e.span&&(s=t*e.span),super(s,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,s=this.count;if(s instanceof Ot&&(s=s.decode(e,t)),0<this.elementLayout.span)n=s*this.elementLayout.span;else{let i=0;for(;i<s;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],s=0,i=this.count;for(i instanceof Ot&&(i=i.decode(e,t));s<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),s+=1;return n}encode(e,t,n=0){let s=this.elementLayout,i=e.reduce((o,c)=>o+s.encode(c,t,n+o),0);return this.count instanceof Ot&&this.count.encode(e.length,t,n),i}};O.Sequence=Eo;var Ro=class extends Re{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((i,o)=>i&&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 i of e)if(0>i.span&&i.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let s=-1;try{s=e.reduce((i,o)=>i+o.getSpan(),0)}catch{}super(s,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((s,i)=>{let o=i.getSpan(e,t);return t+=o,s+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t=0){bs(e);let n=this.makeDestinationObject();for(let s of this.fields)if(s.property!==void 0&&(n[s.property]=s.decode(e,t)),t+=s.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){let s=n,i=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)))}i=n,n+=u}return i+o-s}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)}}};O.Structure=Ro;var Gs=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")}};O.UnionDiscriminator=Gs;var _s=class extends Gs{constructor(e,t){if(!(e instanceof Ot&&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)}};O.UnionLayoutDiscriminator=_s;var Zs=class extends Re{constructor(e,t,n){let s;if(e instanceof Kt||e instanceof Gt)s=new _s(new Hs(e));else if(e instanceof Ot&&e.isCount())s=new _s(e);else if(e instanceof Gs)s=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 i=-1;t&&(i=t.span,0<=i&&(e instanceof Kt||e instanceof Gt)&&(i+=s.layout.span)),super(i,n),this.discriminator=s,this.usesPrefixDiscriminator=e instanceof Kt||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,s=this.discriminator,i=s.decode(e,t),o=this.registry[i];if(o===void 0){let c=this.defaultLayout,u=0;this.usesPrefixDiscriminator&&(u=s.layout.span),n=this.makeDestinationObject(),n[s.property]=i,n[c.property]=c.decode(e,t+u)}else n=o.decode(e,t);return n}encode(e,t,n=0){let s=this.getSourceVariant(e);if(s===void 0){let i=this.discriminator,o=this.defaultLayout,c=0;return this.usesPrefixDiscriminator&&(c=i.layout.span),i.encode(e[i.property],t,n),c+o.encode(e[o.property],t,n+c)}return s.encode(e,t,n)}addVariant(e,t,n){let s=new So(this,e,t,n);return this.registry[e]=s,s}getVariant(e,t=0){let n;return e instanceof Uint8Array?n=this.discriminator.decode(e,t):n=e,this.registry[n]}};O.Union=Zs;var So=class extends Re{constructor(e,t,n,s){if(!(e instanceof Zs))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"&&s===void 0&&(s=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 s!="string")throw new TypeError("variant must have a String property")}let i=e.span;0>e.span&&(i=n?n.span:0,0<=i&&e.usesPrefixDiscriminator&&(i+=e.discriminator.layout.span)),super(i,s),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 s=0;return this.layout&&(s=this.layout.getSpan(e,t+n)),n+s}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let s=0;return this.union.usesPrefixDiscriminator&&(s=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+s):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let s=0;if(this.union.usesPrefixDiscriminator&&(s=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 i=s;if(this.layout&&(this.layout.encode(e[this.property],t,n+s),i+=this.layout.getSpan(t,n+s),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};O.VariantLayout=So;function ys(r){return 0>r&&(r+=4294967296),r}var Ys=class extends Re{constructor(e,t,n){if(!(e instanceof Kt||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 s=0;this._packedSetValue=function(i){return s=ys(i),this},this._packedGetValue=function(){return s}}decode(e,t=0){let n=this.makeDestinationObject(),s=this.word.decode(e,t);this._packedSetValue(s);for(let i of this.fields)i.property!==void 0&&(n[i.property]=i.decode(e));return n}encode(e,t,n=0){let s=this.word.decode(t,n);this._packedSetValue(s);for(let i of this.fields)if(i.property!==void 0){let o=e[i.property];o!==void 0&&i.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new Xs(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new xo(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}};O.BitStructure=Ys;var Xs=class{constructor(e,t,n){if(!(e instanceof Ys))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");let s=8*e.span,i=e.fields.reduce((o,c)=>o+c.bits,0);if(t+i>s)throw new Error("bits too long for span remainder ("+(s-i)+" of "+s+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=s-i-t),this.wordMask=ys(this.valueMask<<this.start),this.property=n}decode(e,t){let n=this.container._packedGetValue();return ys(n&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==ys(e&this.valueMask))throw new TypeError(zc("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let t=this.container._packedGetValue(),n=ys(e<<this.start);this.container._packedSetValue(ys(t&~this.wordMask)|n)}};O.BitField=Xs;var xo=class extends Xs{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)}};O.Boolean=xo;var Ao=class extends Re{constructor(e,t){if(!(e instanceof Ot&&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 Ot||(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 s=this.length;if(this.length instanceof Ot&&(s=e.length),!(e instanceof Uint8Array&&s===e.length))throw new TypeError(zc("Blob.encode",this)+" requires (length "+s+") Uint8Array as src");if(n+s>t.length)throw new RangeError("encoding overruns Uint8Array");let i=Ee(e);return Ee(t).write(i.toString("hex"),n,s,"hex"),this.length instanceof Ot&&this.length.encode(s,t,n),s}};O.Blob=Ao;var Io=class extends Re{constructor(e){super(-1,e)}getSpan(e,t=0){bs(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 s=Dc.Buffer.from(e,"utf8"),i=s.length;if(n+i>t.length)throw new RangeError("encoding overruns Buffer");let o=Ee(t);return s.copy(o,n),o[n+i]=0,i+1}};O.CString=Io;var ko=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 bs(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 s=Dc.Buffer.from(e,"utf8"),i=s.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(n+i>t.length)throw new RangeError("encoding overruns Buffer");return s.copy(Ee(t),n),i}};O.UTF8=ko;var Oo=class extends Re{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};O.Constant=Oo;O.greedy=(r,e)=>new ho(r,e);O.offset=(r,e,t)=>new Hs(r,e,t);O.u8=r=>new Kt(1,r);O.u16=r=>new Kt(2,r);O.u24=r=>new Kt(3,r);O.u32=r=>new Kt(4,r);O.u40=r=>new Kt(5,r);O.u48=r=>new Kt(6,r);O.nu64=r=>new po(r);O.u16be=r=>new Gt(2,r);O.u24be=r=>new Gt(3,r);O.u32be=r=>new Gt(4,r);O.u40be=r=>new Gt(5,r);O.u48be=r=>new Gt(6,r);O.nu64be=r=>new mo(r);O.s8=r=>new Lr(1,r);O.s16=r=>new Lr(2,r);O.s24=r=>new Lr(3,r);O.s32=r=>new Lr(4,r);O.s40=r=>new Lr(5,r);O.s48=r=>new Lr(6,r);O.ns64=r=>new go(r);O.s16be=r=>new nn(2,r);O.s24be=r=>new nn(3,r);O.s32be=r=>new nn(4,r);O.s40be=r=>new nn(5,r);O.s48be=r=>new nn(6,r);O.ns64be=r=>new yo(r);O.f32=r=>new _o(r);O.f32be=r=>new bo(r);O.f64=r=>new wo(r);O.f64be=r=>new vo(r);O.struct=(r,e,t)=>new Ro(r,e,t);O.bits=(r,e,t)=>new Ys(r,e,t);O.seq=(r,e,t)=>new Eo(r,e,t);O.union=(r,e,t)=>new Zs(r,e,t);O.unionLayoutDiscriminator=(r,e)=>new _s(r,e);O.blob=(r,e)=>new Ao(r,e);O.cstr=r=>new Io(r);O.utf8=(r,e)=>new ko(r,e);O.constant=(r,e)=>new Oo(r,e)});function ei(){if(!Po&&(Po=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Po))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Po(Ww)}var Po,Ww,Xc=Mt(()=>{Ww=new Uint8Array(16)});var ad,cd=Mt(()=>{ad=/^(?:[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 qw(r){return typeof r=="string"&&ad.test(r)}var on,ti=Mt(()=>{cd();on=qw});function jw(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(xt[r[e+0]]+xt[r[e+1]]+xt[r[e+2]]+xt[r[e+3]]+"-"+xt[r[e+4]]+xt[r[e+5]]+"-"+xt[r[e+6]]+xt[r[e+7]]+"-"+xt[r[e+8]]+xt[r[e+9]]+"-"+xt[r[e+10]]+xt[r[e+11]]+xt[r[e+12]]+xt[r[e+13]]+xt[r[e+14]]+xt[r[e+15]]).toLowerCase();if(!on(t))throw TypeError("Stringified UUID is invalid");return t}var xt,Mo,an,ri=Mt(()=>{ti();xt=[];for(Mo=0;Mo<256;++Mo)xt.push((Mo+256).toString(16).substr(1));an=jw});function Kw(r,e,t){var n=e&&t||0,s=e||new Array(16);r=r||{};var i=r.node||ud,o=r.clockseq!==void 0?r.clockseq:Jc;if(i==null||o==null){var c=r.random||(r.rng||ei)();i==null&&(i=ud=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),o==null&&(o=Jc=(c[6]<<8|c[7])&16383)}var u=r.msecs!==void 0?r.msecs:Date.now(),p=r.nsecs!==void 0?r.nsecs:eu+1,m=u-Qc+(p-eu)/1e4;if(m<0&&r.clockseq===void 0&&(o=o+1&16383),(m<0||u>Qc)&&r.nsecs===void 0&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Qc=u,eu=p,Jc=o,u+=122192928e5;var b=((u&268435455)*1e4+p)%4294967296;s[n++]=b>>>24&255,s[n++]=b>>>16&255,s[n++]=b>>>8&255,s[n++]=b&255;var x=u/4294967296*1e4&268435455;s[n++]=x>>>8&255,s[n++]=x&255,s[n++]=x>>>24&15|16,s[n++]=x>>>16&255,s[n++]=o>>>8|128,s[n++]=o&255;for(var S=0;S<6;++S)s[n+S]=i[S];return e||an(s)}var ud,Jc,Qc,eu,fd,ld=Mt(()=>{Xc();ri();Qc=0,eu=0;fd=Kw});function Hw(r){if(!on(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 Uo,tu=Mt(()=>{ti();Uo=Hw});function Gw(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}function Do(r,e,t){function n(s,i,o,c){if(typeof s=="string"&&(s=Gw(s)),typeof i=="string"&&(i=Uo(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+s.length);if(u.set(i),u.set(s,i.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 an(u)}try{n.name=r}catch{}return n.DNS=Zw,n.URL=Yw,n}var Zw,Yw,ru=Mt(()=>{ri();tu();Zw="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Yw="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function Xw(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 Jw(Qw(e1(r),r.length*8))}function Jw(r){for(var e=[],t=r.length*32,n="0123456789abcdef",s=0;s<t;s+=8){var i=r[s>>5]>>>s%32&255,o=parseInt(n.charAt(i>>>4&15)+n.charAt(i&15),16);e.push(o)}return e}function dd(r){return(r+64>>>9<<4)+14+1}function Qw(r,e){r[e>>5]|=128<<e%32,r[dd(e)-1]=e;for(var t=1732584193,n=-271733879,s=-1732584194,i=271733878,o=0;o<r.length;o+=16){var c=t,u=n,p=s,m=i;t=Nt(t,n,s,i,r[o],7,-680876936),i=Nt(i,t,n,s,r[o+1],12,-389564586),s=Nt(s,i,t,n,r[o+2],17,606105819),n=Nt(n,s,i,t,r[o+3],22,-1044525330),t=Nt(t,n,s,i,r[o+4],7,-176418897),i=Nt(i,t,n,s,r[o+5],12,1200080426),s=Nt(s,i,t,n,r[o+6],17,-1473231341),n=Nt(n,s,i,t,r[o+7],22,-45705983),t=Nt(t,n,s,i,r[o+8],7,1770035416),i=Nt(i,t,n,s,r[o+9],12,-1958414417),s=Nt(s,i,t,n,r[o+10],17,-42063),n=Nt(n,s,i,t,r[o+11],22,-1990404162),t=Nt(t,n,s,i,r[o+12],7,1804603682),i=Nt(i,t,n,s,r[o+13],12,-40341101),s=Nt(s,i,t,n,r[o+14],17,-1502002290),n=Nt(n,s,i,t,r[o+15],22,1236535329),t=Bt(t,n,s,i,r[o+1],5,-165796510),i=Bt(i,t,n,s,r[o+6],9,-1069501632),s=Bt(s,i,t,n,r[o+11],14,643717713),n=Bt(n,s,i,t,r[o],20,-373897302),t=Bt(t,n,s,i,r[o+5],5,-701558691),i=Bt(i,t,n,s,r[o+10],9,38016083),s=Bt(s,i,t,n,r[o+15],14,-660478335),n=Bt(n,s,i,t,r[o+4],20,-405537848),t=Bt(t,n,s,i,r[o+9],5,568446438),i=Bt(i,t,n,s,r[o+14],9,-1019803690),s=Bt(s,i,t,n,r[o+3],14,-187363961),n=Bt(n,s,i,t,r[o+8],20,1163531501),t=Bt(t,n,s,i,r[o+13],5,-1444681467),i=Bt(i,t,n,s,r[o+2],9,-51403784),s=Bt(s,i,t,n,r[o+7],14,1735328473),n=Bt(n,s,i,t,r[o+12],20,-1926607734),t=Lt(t,n,s,i,r[o+5],4,-378558),i=Lt(i,t,n,s,r[o+8],11,-2022574463),s=Lt(s,i,t,n,r[o+11],16,1839030562),n=Lt(n,s,i,t,r[o+14],23,-35309556),t=Lt(t,n,s,i,r[o+1],4,-1530992060),i=Lt(i,t,n,s,r[o+4],11,1272893353),s=Lt(s,i,t,n,r[o+7],16,-155497632),n=Lt(n,s,i,t,r[o+10],23,-1094730640),t=Lt(t,n,s,i,r[o+13],4,681279174),i=Lt(i,t,n,s,r[o],11,-358537222),s=Lt(s,i,t,n,r[o+3],16,-722521979),n=Lt(n,s,i,t,r[o+6],23,76029189),t=Lt(t,n,s,i,r[o+9],4,-640364487),i=Lt(i,t,n,s,r[o+12],11,-421815835),s=Lt(s,i,t,n,r[o+15],16,530742520),n=Lt(n,s,i,t,r[o+2],23,-995338651),t=Ct(t,n,s,i,r[o],6,-198630844),i=Ct(i,t,n,s,r[o+7],10,1126891415),s=Ct(s,i,t,n,r[o+14],15,-1416354905),n=Ct(n,s,i,t,r[o+5],21,-57434055),t=Ct(t,n,s,i,r[o+12],6,1700485571),i=Ct(i,t,n,s,r[o+3],10,-1894986606),s=Ct(s,i,t,n,r[o+10],15,-1051523),n=Ct(n,s,i,t,r[o+1],21,-2054922799),t=Ct(t,n,s,i,r[o+8],6,1873313359),i=Ct(i,t,n,s,r[o+15],10,-30611744),s=Ct(s,i,t,n,r[o+6],15,-1560198380),n=Ct(n,s,i,t,r[o+13],21,1309151649),t=Ct(t,n,s,i,r[o+4],6,-145523070),i=Ct(i,t,n,s,r[o+11],10,-1120210379),s=Ct(s,i,t,n,r[o+2],15,718787259),n=Ct(n,s,i,t,r[o+9],21,-343485551),t=cn(t,c),n=cn(n,u),s=cn(s,p),i=cn(i,m)}return[t,n,s,i]}function e1(r){if(r.length===0)return[];for(var e=r.length*8,t=new Uint32Array(dd(e)),n=0;n<e;n+=8)t[n>>5]|=(r[n/8]&255)<<n%32;return t}function cn(r,e){var t=(r&65535)+(e&65535),n=(r>>16)+(e>>16)+(t>>16);return n<<16|t&65535}function t1(r,e){return r<<e|r>>>32-e}function zo(r,e,t,n,s,i){return cn(t1(cn(cn(e,r),cn(n,i)),s),t)}function Nt(r,e,t,n,s,i,o){return zo(e&t|~e&n,r,e,s,i,o)}function Bt(r,e,t,n,s,i,o){return zo(e&n|t&~n,r,e,s,i,o)}function Lt(r,e,t,n,s,i,o){return zo(e^t^n,r,e,s,i,o)}function Ct(r,e,t,n,s,i,o){return zo(t^(e|~n),r,e,s,i,o)}var hd,pd=Mt(()=>{hd=Xw});var r1,md,gd=Mt(()=>{ru();pd();r1=Do("v3",48,hd),md=r1});function n1(r,e,t){r=r||{};var n=r.random||(r.rng||ei)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=n[s];return e}return an(n)}var yd,_d=Mt(()=>{Xc();ri();yd=n1});function s1(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 nu(r,e){return r<<e|r>>>32-e}function i1(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 s=0;s<n.length;++s)r.push(n.charCodeAt(s))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var i=r.length/4+2,o=Math.ceil(i/16),c=new Array(o),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 x=new Uint32Array(80),S=0;S<16;++S)x[S]=c[b][S];for(var T=16;T<80;++T)x[T]=nu(x[T-3]^x[T-8]^x[T-14]^x[T-16],1);for(var I=t[0],A=t[1],B=t[2],U=t[3],L=t[4],F=0;F<80;++F){var te=Math.floor(F/20),G=nu(I,5)+s1(te,A,B,U)+L+e[te]+x[F]>>>0;L=U,U=B,B=nu(A,30)>>>0,A=I,I=G}t[0]=t[0]+I>>>0,t[1]=t[1]+A>>>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 bd,wd=Mt(()=>{bd=i1});var o1,vd,Ed=Mt(()=>{ru();wd();o1=Do("v5",80,bd),vd=o1});var Rd,Sd=Mt(()=>{Rd="00000000-0000-0000-0000-000000000000"});function a1(r){if(!on(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}var xd,Ad=Mt(()=>{ti();xd=a1});var su={};wr(su,{NIL:()=>Rd,parse:()=>Uo,stringify:()=>an,v1:()=>fd,v3:()=>md,v4:()=>yd,v5:()=>vd,validate:()=>on,version:()=>xd});var iu=Mt(()=>{ld();gd();_d();Ed();Sd();Ad();ti();ri();tu()});var kd=Ft((zx,Id)=>{"use strict";var c1=(iu(),Ca(su)).v4,u1=function(r,e,t,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};let s=typeof n.version=="number"?n.version:2;if(s!==1&&s!==2)throw new TypeError(s+" must be 1 or 2");let i={method:r};if(s===2&&(i.jsonrpc="2.0"),e){if(typeof e!="object"&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");i.params=e}if(typeof t>"u"){let o=typeof n.generator=="function"?n.generator:function(){return c1()};i.id=o(i,n)}else s===2&&t===null?n.notificationIdNull&&(i.id=null):i.id=t;return i};Id.exports=u1});var Td=Ft((Fx,Od)=>{"use strict";var f1=(iu(),Ca(su)).v4,l1=kd(),ni=function(r,e){if(!(this instanceof ni))return new ni(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 f1()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=r};Od.exports=ni;ni.prototype.request=function(r,e,t,n){let s=this,i=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,i=r;else{typeof t=="function"&&(n=t,t=void 0);let p=typeof n=="function";try{i=l1(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 i}let u;try{u=JSON.stringify(i,this.options.replacer)}catch(p){return n(p)}return this.callServer(u,function(p,m){s._parseResponse(p,m,n)}),i};ni.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(s){return t(s)}if(t.length===3)if(Array.isArray(n)){let s=function(o){return typeof o.error<"u"},i=function(o){return!s(o)};return t(null,n.filter(s),n.filter(i))}else return t(null,n.error,n.result);t(null,n)}});var Bd=Ft(($x,ou)=>{"use strict";var d1=Object.prototype.hasOwnProperty,Dt="~";function si(){}Object.create&&(si.prototype=Object.create(null),new si().__proto__||(Dt=!1));function h1(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Nd(r,e,t,n,s){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new h1(t,n||r,s),o=Dt?Dt+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],i]:r._events[o].push(i):(r._events[o]=i,r._eventsCount++),r}function Fo(r,e){--r._eventsCount===0?r._events=new si:delete r._events[e]}function Pt(){this._events=new si,this._eventsCount=0}Pt.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)d1.call(t,n)&&e.push(Dt?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Pt.prototype.listeners=function(e){var t=Dt?Dt+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var s=0,i=n.length,o=new Array(i);s<i;s++)o[s]=n[s].fn;return o};Pt.prototype.listenerCount=function(e){var t=Dt?Dt+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Pt.prototype.emit=function(e,t,n,s,i,o){var c=Dt?Dt+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,s),!0;case 5:return u.fn.call(u.context,t,n,s,i),!0;case 6:return u.fn.call(u.context,t,n,s,i,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 x=u.length,S;for(b=0;b<x;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,s);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};Pt.prototype.on=function(e,t,n){return Nd(this,e,t,n,!1)};Pt.prototype.once=function(e,t,n){return Nd(this,e,t,n,!0)};Pt.prototype.removeListener=function(e,t,n,s){var i=Dt?Dt+e:e;if(!this._events[i])return this;if(!t)return Fo(this,i),this;var o=this._events[i];if(o.fn)o.fn===t&&(!s||o.once)&&(!n||o.context===n)&&Fo(this,i);else{for(var c=0,u=[],p=o.length;c<p;c++)(o[c].fn!==t||s&&!o[c].once||n&&o[c].context!==n)&&u.push(o[c]);u.length?this._events[i]=u.length===1?u[0]:u:Fo(this,i)}return this};Pt.prototype.removeAllListeners=function(e){var t;return e?(t=Dt?Dt+e:e,this._events[t]&&Fo(this,t)):(this._events=new si,this._eventsCount=0),this};Pt.prototype.off=Pt.prototype.removeListener;Pt.prototype.addListener=Pt.prototype.on;Pt.prefixed=Dt;Pt.EventEmitter=Pt;typeof ou<"u"&&(ou.exports=Pt)});var QE={};wr(QE,{AddMiniApp:()=>Qn,Back:()=>Fa,ComposeCast:()=>uf,Context:()=>yf,DEFAULT_READY_OPTIONS:()=>Ua,Errors:()=>Ns,Ethereum:()=>gf,Haptics:()=>ff,Manifest:()=>_f,Ready:()=>Da,SendToken:()=>lf,SignIn:()=>es,SolanaConnection:()=>ea,SwapToken:()=>df,ViewCast:()=>hf,ViewProfile:()=>pf,ViewToken:()=>mf,actionLaunchFrameSchema:()=>Nf,actionSchema:()=>Lf,actionViewTokenSchema:()=>Bf,aspectRatioSchema:()=>ja,buttonSchema:()=>Cf,buttonTitleSchema:()=>Ds,caip19TokenSchema:()=>qa,createSimpleStringSchema:()=>Wr,createSolanaWalletProvider:()=>Fu,default:()=>JE,domainFrameConfigSchema:()=>$f,domainManifestSchema:()=>Cp,encodedJsonFarcasterSignatureSchema:()=>Ka,eventFrameAddedSchema:()=>Mf,eventFrameRemovedSchema:()=>Uf,eventNotificationsEnabledSchema:()=>Df,frameEmbedNextSchema:()=>Pf,frameHost:()=>de,frameNameSchema:()=>Us,hexColorSchema:()=>zs,jsonFarcasterSignatureHeaderSchema:()=>kp,miniAppHostCapabilityList:()=>Pi,notificationDetailsSchema:()=>Vi,notificationsDisabledSchema:()=>zf,safeParseFrameEmbed:()=>Op,sdk:()=>Yu,secureUrlSchema:()=>Rt,sendNotificationRequestSchema:()=>Tp,sendNotificationResponseSchema:()=>Np,serverEventSchema:()=>Bp,unwrapSolanaProviderRequest:()=>Wu,wrapSolanaProviderRequest:()=>EE});var Qn={};wr(Qn,{InvalidDomainManifest:()=>Pa,RejectedByUser:()=>Ma});var Ns={};wr(Ns,{BaseError:()=>Dr});var Dr=class extends Error{name="BaseError";cause;constructor(e,t={}){super(e,t.cause?{cause:t.cause}:void 0),this.cause=t.cause}};var Pa=class extends Dr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}},Ma=class extends Dr{name="AddMiniApp.RejectedByUser";constructor(){super("Add frame rejected by user")}};var uf={};var ff={};var Da={};wr(Da,{DEFAULT_READY_OPTIONS:()=>Ua});var Ua={disableNativeGestures:!1};var es={};wr(es,{RejectedByUser:()=>za});var za=class extends Dr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};var lf={};var df={};var hf={};var pf={};var mf={};var gf={};var Fa={};wr(Fa,{DEFAULT_BACK_STATE:()=>h0});var h0={visible:!1};var yf={};var _f={};var Pi=["wallet.getEthereumProvider","wallet.getSolanaProvider","actions.ready","actions.openUrl","actions.close","actions.setPrimaryButton","actions.addMiniApp","actions.signIn","actions.viewCast","actions.viewProfile","actions.composeCast","actions.viewToken","actions.sendToken","actions.swapToken","haptics.impactOccurred","haptics.notificationOccurred","haptics.selectionChanged","back"];var K={};wr(K,{BRAND:()=>z0,DIRTY:()=>pn,EMPTY_PATH:()=>y0,INVALID:()=>ie,NEVER:()=>Rp,OK:()=>kt,ParseStatus:()=>Et,Schema:()=>ge,ZodAny:()=>$r,ZodArray:()=>xr,ZodBigInt:()=>gn,ZodBoolean:()=>yn,ZodBranded:()=>Ps,ZodCatch:()=>kn,ZodDate:()=>_n,ZodDefault:()=>In,ZodDiscriminatedUnion:()=>zi,ZodEffects:()=>er,ZodEnum:()=>xn,ZodError:()=>$t,ZodFirstPartyTypeKind:()=>oe,ZodFunction:()=>$i,ZodIntersection:()=>En,ZodIssueCode:()=>M,ZodLazy:()=>Rn,ZodLiteral:()=>Sn,ZodMap:()=>os,ZodNaN:()=>cs,ZodNativeEnum:()=>An,ZodNever:()=>sr,ZodNull:()=>wn,ZodNullable:()=>dr,ZodNumber:()=>mn,ZodObject:()=>Vt,ZodOptional:()=>Jt,ZodParsedType:()=>H,ZodPipeline:()=>Ms,ZodPromise:()=>Vr,ZodReadonly:()=>On,ZodRecord:()=>Fi,ZodSchema:()=>ge,ZodSet:()=>as,ZodString:()=>Fr,ZodSymbol:()=>ss,ZodTransformer:()=>er,ZodTuple:()=>lr,ZodType:()=>ge,ZodUndefined:()=>bn,ZodUnion:()=>vn,ZodUnknown:()=>Sr,ZodVoid:()=>is,addIssueToContext:()=>W,any:()=>G0,array:()=>J0,bigint:()=>W0,boolean:()=>Tf,coerce:()=>Ep,custom:()=>If,date:()=>q0,datetimeRegex:()=>xf,defaultErrorMap:()=>Er,discriminatedUnion:()=>rp,effect:()=>pp,enum:()=>lp,function:()=>cp,getErrorMap:()=>ts,getParsedType:()=>fr,instanceof:()=>$0,intersection:()=>np,isAborted:()=>Mi,isAsync:()=>rs,isDirty:()=>Ui,isValid:()=>zr,late:()=>F0,lazy:()=>up,literal:()=>fp,makeIssue:()=>Bs,map:()=>op,nan:()=>V0,nativeEnum:()=>dp,never:()=>Y0,null:()=>H0,nullable:()=>gp,number:()=>Of,object:()=>Q0,objectUtil:()=>$a,oboolean:()=>vp,onumber:()=>wp,optional:()=>mp,ostring:()=>bp,pipeline:()=>_p,preprocess:()=>yp,promise:()=>hp,quotelessJson:()=>p0,record:()=>ip,set:()=>ap,setErrorMap:()=>g0,strictObject:()=>ep,string:()=>kf,symbol:()=>j0,transformer:()=>pp,tuple:()=>sp,undefined:()=>K0,union:()=>tp,unknown:()=>Z0,util:()=>_e,void:()=>X0});var _e;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},r.getValidEnumValues=s=>{let i=r.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(let c of i)o[c]=s[c];return r.objectValues(o)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},r.find=(s,i)=>{for(let o of s)if(i(o))return o},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(_e||(_e={}));var $a;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})($a||($a={}));var H=_e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),fr=r=>{switch(typeof r){case"undefined":return H.undefined;case"string":return H.string;case"number":return Number.isNaN(r)?H.nan:H.number;case"boolean":return H.boolean;case"function":return H.function;case"bigint":return H.bigint;case"symbol":return H.symbol;case"object":return Array.isArray(r)?H.array:r===null?H.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?H.promise:typeof Map<"u"&&r instanceof Map?H.map:typeof Set<"u"&&r instanceof Set?H.set:typeof Date<"u"&&r instanceof Date?H.date:H.object;default:return H.unknown}};var M=_e.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"]),p0=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),$t=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(i){return i.message},n={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(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 s(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,_e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};$t.create=r=>new $t(r);var m0=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===H.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,_e.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${_e.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_e.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${_e.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}"`:_e.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,_e.assertNever(r)}return{message:t}},Er=m0;var bf=Er;function g0(r){bf=r}function ts(){return bf}var Bs=r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="",u=n.filter(p=>!!p).slice().reverse();for(let p of u)c=p(o,{data:e,defaultError:c}).message;return{...s,path:i,message:c}},y0=[];function W(r,e){let t=ts(),n=Bs({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Er?void 0:Er].filter(s=>!!s)});r.common.issues.push(n)}var Et=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 s of t){if(s.status==="aborted")return ie;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return ie;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}},ie=Object.freeze({status:"aborted"}),pn=r=>({status:"dirty",value:r}),kt=r=>({status:"valid",value:r}),Mi=r=>r.status==="aborted",Ui=r=>r.status==="dirty",zr=r=>r.status==="valid",rs=r=>typeof Promise<"u"&&r instanceof Promise;var X;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(X||(X={}));var Di=function(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)},Ef=function(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t},Ls,Cs,Qt=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},wf=(r,e)=>{if(zr(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 $t(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:s}=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:s}:{errorMap:(o,c)=>{let{message:u}=r;return o.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:u??n??c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:u??t??c.defaultError}},description:s}}var ge=class{get description(){return this._def.description}_getType(e){return fr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:fr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Et,ctx:{common:e.parent.common,data:e.data,parsedType:fr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(rs(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){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fr(e)},s=this._parseSync({data:e,path:n.path,parent:n});return wf(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fr(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return zr(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>zr(n)?{value:n.value}:{issues:t.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:fr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(rs(s)?s:Promise.resolve(s));return wf(n,i)}refine(e,t){let n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{let o=e(s),c=()=>i.addIssue({code:M.custom,...n(s)});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,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new er({schema:this,typeName:oe.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 Jt.create(this,this._def)}nullable(){return dr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xr.create(this)}promise(){return Vr.create(this,this._def)}or(e){return vn.create([this,e],this._def)}and(e){return En.create(this,e,this._def)}transform(e){return new er({...le(this._def),schema:this,typeName:oe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new In({...le(this._def),innerType:this,defaultValue:t,typeName:oe.ZodDefault})}brand(){return new Ps({typeName:oe.ZodBranded,type:this,...le(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new kn({...le(this._def),innerType:this,catchValue:t,typeName:oe.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ms.create(this,e)}readonly(){return On.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},_0=/^c[^\s-]{8,}$/i,b0=/^[0-9a-z]+$/,w0=/^[0-9A-HJKMNP-TV-Z]{26}$/i,v0=/^[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,E0=/^[a-z0-9_-]{21}$/i,R0=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,S0=/^[-+]?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)?)??$/,x0=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,A0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Va,I0=/^(?:(?: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])$/,k0=/^(?:(?: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])$/,O0=/^(([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]))$/,T0=/^(([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])$/,N0=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,B0=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Rf="((\\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])))",L0=new RegExp(`^${Rf}$`);function Sf(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function C0(r){return new RegExp(`^${Sf(r)}$`)}function xf(r){let e=`${Rf}T${Sf(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 P0(r,e){return!!((e==="v4"||!e)&&I0.test(r)||(e==="v6"||!e)&&O0.test(r))}function M0(r,e){if(!R0.test(r))return!1;try{let[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function U0(r,e){return!!((e==="v4"||!e)&&k0.test(r)||(e==="v6"||!e)&&T0.test(r))}var Fr=class r extends ge{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==H.string){let i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:H.string,received:i.parsedType}),ie}let n=new Et,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,c=e.data.length<i.value;(o||c)&&(s=this._getOrReturnCtx(e,s),o?W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")x0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Va||(Va=new RegExp(A0,"u")),Va.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")v0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")E0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")_0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")b0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")w0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:M.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"regex",code:M.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?xf(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?L0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?C0(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?S0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?P0(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?M0(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"jwt",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?U0(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cidr",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?N0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?B0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64url",code:M.invalid_string,message:i.message}),n.dirty()):_e.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:M.invalid_string,...X.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...X.errToObj(e)})}url(e){return this._addCheck({kind:"url",...X.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...X.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...X.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...X.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...X.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...X.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...X.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...X.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...X.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...X.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...X.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...X.errToObj(e)})}datetime(e){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:e?.offset??!1,local:e?.local??!1,...X.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,...X.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...X.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...X.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...X.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...X.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...X.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...X.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...X.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...X.errToObj(t)})}nonempty(e){return this.min(1,X.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}};Fr.create=r=>new Fr({checks:[],typeName:oe.ZodString,coerce:r?.coerce??!1,...le(r)});function D0(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=Number.parseInt(r.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var mn=class r extends ge{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)!==H.number){let i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:H.number,received:i.parsedType}),ie}let n,s=new Et;for(let i of this._def.checks)i.kind==="int"?_e.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?D0(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_finite,message:i.message}),s.dirty()):_e.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,X.toString(t))}gt(e,t){return this.setLimit("min",e,!1,X.toString(t))}lte(e,t){return this.setLimit("max",e,!0,X.toString(t))}lt(e,t){return this.setLimit("max",e,!1,X.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:X.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:X.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:X.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:X.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:X.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:X.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:X.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:X.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:X.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"&&_e.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)}};mn.create=r=>new mn({checks:[],typeName:oe.ZodNumber,coerce:r?.coerce||!1,...le(r)});var gn=class r extends ge{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)!==H.bigint)return this._getInvalidInput(e);let n,s=new Et;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):_e.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:H.bigint,received:t.parsedType}),ie}gte(e,t){return this.setLimit("min",e,!0,X.toString(t))}gt(e,t){return this.setLimit("min",e,!1,X.toString(t))}lte(e,t){return this.setLimit("max",e,!0,X.toString(t))}lt(e,t){return this.setLimit("max",e,!1,X.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:X.toString(s)}]})}_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:X.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:X.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:X.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:X.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:X.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}};gn.create=r=>new gn({checks:[],typeName:oe.ZodBigInt,coerce:r?.coerce??!1,...le(r)});var yn=class extends ge{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==H.boolean){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.boolean,received:n.parsedType}),ie}return kt(e.data)}};yn.create=r=>new yn({typeName:oe.ZodBoolean,coerce:r?.coerce||!1,...le(r)});var _n=class r extends ge{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==H.date){let i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:H.date,received:i.parsedType}),ie}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_date}),ie}let n=new Et,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):_e.assertNever(i);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:X.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:X.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}};_n.create=r=>new _n({checks:[],coerce:r?.coerce||!1,typeName:oe.ZodDate,...le(r)});var ss=class extends ge{_parse(e){if(this._getType(e)!==H.symbol){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.symbol,received:n.parsedType}),ie}return kt(e.data)}};ss.create=r=>new ss({typeName:oe.ZodSymbol,...le(r)});var bn=class extends ge{_parse(e){if(this._getType(e)!==H.undefined){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.undefined,received:n.parsedType}),ie}return kt(e.data)}};bn.create=r=>new bn({typeName:oe.ZodUndefined,...le(r)});var wn=class extends ge{_parse(e){if(this._getType(e)!==H.null){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.null,received:n.parsedType}),ie}return kt(e.data)}};wn.create=r=>new wn({typeName:oe.ZodNull,...le(r)});var $r=class extends ge{constructor(){super(...arguments),this._any=!0}_parse(e){return kt(e.data)}};$r.create=r=>new $r({typeName:oe.ZodAny,...le(r)});var Sr=class extends ge{constructor(){super(...arguments),this._unknown=!0}_parse(e){return kt(e.data)}};Sr.create=r=>new Sr({typeName:oe.ZodUnknown,...le(r)});var sr=class extends ge{_parse(e){let t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:H.never,received:t.parsedType}),ie}};sr.create=r=>new sr({typeName:oe.ZodNever,...le(r)});var is=class extends ge{_parse(e){if(this._getType(e)!==H.undefined){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.void,received:n.parsedType}),ie}return kt(e.data)}};is.create=r=>new is({typeName:oe.ZodVoid,...le(r)});var xr=class r extends ge{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==H.array)return W(t,{code:M.invalid_type,expected:H.array,received:t.parsedType}),ie;if(s.exactLength!==null){let o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(W(t,{code:o?M.too_big:M.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(W(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(W(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new Qt(t,o,t.path,c)))).then(o=>Et.mergeArray(n,o));let i=[...t.data].map((o,c)=>s.type._parseSync(new Qt(t,o,t.path,c)));return Et.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:X.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:X.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:X.toString(t)}})}nonempty(e){return this.min(1,e)}};xr.create=(r,e)=>new xr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:oe.ZodArray,...le(e)});function ns(r){if(r instanceof Vt){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=Jt.create(ns(n))}return new Vt({...r._def,shape:()=>e})}else return r instanceof xr?new xr({...r._def,type:ns(r.element)}):r instanceof Jt?Jt.create(ns(r.unwrap())):r instanceof dr?dr.create(ns(r.unwrap())):r instanceof lr?lr.create(r.items.map(e=>ns(e))):r}var Vt=class r extends ge{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=_e.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==H.object){let p=this._getOrReturnCtx(e);return W(p,{code:M.invalid_type,expected:H.object,received:p.parsedType}),ie}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof sr&&this._def.unknownKeys==="strip"))for(let p in s.data)o.includes(p)||c.push(p);let u=[];for(let p of o){let m=i[p],b=s.data[p];u.push({key:{status:"valid",value:p},value:m._parse(new Qt(s,b,s.path,p)),alwaysSet:p in s.data})}if(this._def.catchall instanceof sr){let p=this._def.unknownKeys;if(p==="passthrough")for(let m of c)u.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(p==="strict")c.length>0&&(W(s,{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=s.data[m];u.push({key:{status:"valid",value:m},value:p._parse(new Qt(s,b,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let p=[];for(let m of u){let b=await m.key,x=await m.value;p.push({key:b,value:x,alwaysSet:m.alwaysSet})}return p}).then(p=>Et.mergeObjectSync(n,p)):Et.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return X.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:X.errToObj(e).message??s}:{message:s}}}:{}})}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:oe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let n of _e.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let n of _e.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}deepPartial(){return ns(this)}partial(e){let t={};for(let n of _e.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let n of _e.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof Jt;)i=i._def.innerType;t[n]=i}return new r({...this._def,shape:()=>t})}keyof(){return Af(_e.objectKeys(this.shape))}};Vt.create=(r,e)=>new Vt({shape:()=>r,unknownKeys:"strip",catchall:sr.create(),typeName:oe.ZodObject,...le(e)});Vt.strictCreate=(r,e)=>new Vt({shape:()=>r,unknownKeys:"strict",catchall:sr.create(),typeName:oe.ZodObject,...le(e)});Vt.lazycreate=(r,e)=>new Vt({shape:r,unknownKeys:"strip",catchall:sr.create(),typeName:oe.ZodObject,...le(e)});var vn=class extends ge{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(let c of i)if(c.result.status==="valid")return c.result;for(let c of i)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;let o=i.map(c=>new $t(c.ctx.common.issues));return W(t,{code:M.invalid_union,unionErrors:o}),ie}if(t.common.async)return Promise.all(n.map(async i=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let i,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"&&!i&&(i={result:m,ctx:p}),p.common.issues.length&&o.push(p.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let c=o.map(u=>new $t(u));return W(t,{code:M.invalid_union,unionErrors:c}),ie}}get options(){return this._def.options}};vn.create=(r,e)=>new vn({options:r,typeName:oe.ZodUnion,...le(e)});var Rr=r=>r instanceof Rn?Rr(r.schema):r instanceof er?Rr(r.innerType()):r instanceof Sn?[r.value]:r instanceof xn?r.options:r instanceof An?_e.objectValues(r.enum):r instanceof In?Rr(r._def.innerType):r instanceof bn?[void 0]:r instanceof wn?[null]:r instanceof Jt?[void 0,...Rr(r.unwrap())]:r instanceof dr?[null,...Rr(r.unwrap())]:r instanceof Ps||r instanceof On?Rr(r.unwrap()):r instanceof kn?Rr(r._def.innerType):[],zi=class r extends ge{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.object)return W(t,{code:M.invalid_type,expected:H.object,received:t.parsedType}),ie;let n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let i of t){let o=Rr(i.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(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,i)}}return new r({typeName:oe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...le(n)})}};function Wa(r,e){let t=fr(r),n=fr(e);if(r===e)return{valid:!0,data:r};if(t===H.object&&n===H.object){let s=_e.objectKeys(e),i=_e.objectKeys(r).filter(c=>s.indexOf(c)!==-1),o={...r,...e};for(let c of i){let u=Wa(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===H.array&&n===H.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<r.length;i++){let o=r[i],c=e[i],u=Wa(o,c);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===H.date&&n===H.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var En=class extends ge{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(i,o)=>{if(Mi(i)||Mi(o))return ie;let c=Wa(i.value,o.value);return c.valid?((Ui(i)||Ui(o))&&t.dirty(),{status:t.value,value:c.data}):(W(n,{code:M.invalid_intersection_types}),ie)};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(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};En.create=(r,e,t)=>new En({left:r,right:e,typeName:oe.ZodIntersection,...le(t)});var lr=class r extends ge{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.array)return W(n,{code:M.invalid_type,expected:H.array,received:n.parsedType}),ie;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"}),ie;!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 i=[...n.data].map((o,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new Qt(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>Et.mergeArray(t,o)):Et.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};lr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new lr({items:r,typeName:oe.ZodTuple,rest:null,...le(e)})};var Fi=class r extends ge{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!==H.object)return W(n,{code:M.invalid_type,expected:H.object,received:n.parsedType}),ie;let s=[],i=this._def.keyType,o=this._def.valueType;for(let c in n.data)s.push({key:i._parse(new Qt(n,c,n.path,c)),value:o._parse(new Qt(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?Et.mergeObjectAsync(t,s):Et.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof ge?new r({keyType:e,valueType:t,typeName:oe.ZodRecord,...le(n)}):new r({keyType:Fr.create(),valueType:e,typeName:oe.ZodRecord,...le(t)})}},os=class extends ge{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!==H.map)return W(n,{code:M.invalid_type,expected:H.map,received:n.parsedType}),ie;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([c,u],p)=>({key:s._parse(new Qt(n,c,n.path,[p,"key"])),value:i._parse(new Qt(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 ie;(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 ie;(p.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(p.value,m.value)}return{status:t.value,value:c}}}};os.create=(r,e,t)=>new os({valueType:e,keyType:r,typeName:oe.ZodMap,...le(t)});var as=class r extends ge{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.set)return W(n,{code:M.invalid_type,expected:H.set,received:n.parsedType}),ie;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let i=this._def.valueType;function o(u){let p=new Set;for(let m of u){if(m.status==="aborted")return ie;m.status==="dirty"&&t.dirty(),p.add(m.value)}return{status:t.value,value:p}}let c=[...n.data.values()].map((u,p)=>i._parse(new Qt(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:X.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:X.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};as.create=(r,e)=>new as({valueType:r,minSize:null,maxSize:null,typeName:oe.ZodSet,...le(e)});var $i=class r extends ge{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.function)return W(t,{code:M.invalid_type,expected:H.function,received:t.parsedType}),ie;function n(c,u){return Bs({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ts(),Er].filter(p=>!!p),issueData:{code:M.invalid_arguments,argumentsError:u}})}function s(c,u){return Bs({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ts(),Er].filter(p=>!!p),issueData:{code:M.invalid_return_type,returnTypeError:u}})}let i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Vr){let c=this;return kt(async function(...u){let p=new $t([]),m=await c._def.args.parseAsync(u,i).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,i).catch(S=>{throw p.addIssue(s(b,S)),p})})}else{let c=this;return kt(function(...u){let p=c._def.args.safeParse(u,i);if(!p.success)throw new $t([n(u,p.error)]);let m=Reflect.apply(o,this,p.data),b=c._def.returns.safeParse(m,i);if(!b.success)throw new $t([s(m,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:lr.create(e).rest(Sr.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||lr.create([]).rest(Sr.create()),returns:t||Sr.create(),typeName:oe.ZodFunction,...le(n)})}},Rn=class extends ge{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})}};Rn.create=(r,e)=>new Rn({getter:r,typeName:oe.ZodLazy,...le(e)});var Sn=class extends ge{_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}),ie}return{status:"valid",value:e.data}}get value(){return this._def.value}};Sn.create=(r,e)=>new Sn({value:r,typeName:oe.ZodLiteral,...le(e)});function Af(r,e){return new xn({values:r,typeName:oe.ZodEnum,...le(e)})}var xn=class r extends ge{constructor(){super(...arguments),Ls.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:_e.joinValues(n),received:t.parsedType,code:M.invalid_type}),ie}if(Di(this,Ls,"f")||Ef(this,Ls,new Set(this._def.values),"f"),!Di(this,Ls,"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}),ie}return kt(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})}};Ls=new WeakMap;xn.create=Af;var An=class extends ge{constructor(){super(...arguments),Cs.set(this,void 0)}_parse(e){let t=_e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==H.string&&n.parsedType!==H.number){let s=_e.objectValues(t);return W(n,{expected:_e.joinValues(s),received:n.parsedType,code:M.invalid_type}),ie}if(Di(this,Cs,"f")||Ef(this,Cs,new Set(_e.getValidEnumValues(this._def.values)),"f"),!Di(this,Cs,"f").has(e.data)){let s=_e.objectValues(t);return W(n,{received:n.data,code:M.invalid_enum_value,options:s}),ie}return kt(e.data)}get enum(){return this._def.values}};Cs=new WeakMap;An.create=(r,e)=>new An({values:r,typeName:oe.ZodNativeEnum,...le(e)});var Vr=class extends ge{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.promise&&t.common.async===!1)return W(t,{code:M.invalid_type,expected:H.promise,received:t.parsedType}),ie;let n=t.parsedType===H.promise?t.data:Promise.resolve(t.data);return kt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Vr.create=(r,e)=>new Vr({type:r,typeName:oe.ZodPromise,...le(e)});var er=class extends ge{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===oe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{W(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return ie;let u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?ie:u.status==="dirty"?pn(u.value):t.value==="dirty"?pn(u.value):u});{if(t.value==="aborted")return ie;let c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?ie:c.status==="dirty"?pn(c.value):t.value==="dirty"?pn(c.value):c}}if(s.type==="refinement"){let o=c=>{let u=s.refinement(c,i);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"?ie:(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"?ie:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!zr(o))return o;let c=s.transform(o.value,i);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=>zr(o)?Promise.resolve(s.transform(o.value,i)).then(c=>({status:t.value,value:c})):o);_e.assertNever(s)}};er.create=(r,e,t)=>new er({schema:r,typeName:oe.ZodEffects,effect:e,...le(t)});er.createWithPreprocess=(r,e,t)=>new er({schema:e,effect:{type:"preprocess",transform:r},typeName:oe.ZodEffects,...le(t)});var Jt=class extends ge{_parse(e){return this._getType(e)===H.undefined?kt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Jt.create=(r,e)=>new Jt({innerType:r,typeName:oe.ZodOptional,...le(e)});var dr=class extends ge{_parse(e){return this._getType(e)===H.null?kt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};dr.create=(r,e)=>new dr({innerType:r,typeName:oe.ZodNullable,...le(e)});var In=class extends ge{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===H.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};In.create=(r,e)=>new In({innerType:r,typeName:oe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...le(e)});var kn=class extends ge{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return rs(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $t(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new $t(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};kn.create=(r,e)=>new kn({innerType:r,typeName:oe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...le(e)});var cs=class extends ge{_parse(e){if(this._getType(e)!==H.nan){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.nan,received:n.parsedType}),ie}return{status:"valid",value:e.data}}};cs.create=r=>new cs({typeName:oe.ZodNaN,...le(r)});var z0=Symbol("zod_brand"),Ps=class extends ge{_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}},Ms=class r extends ge{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ie:i.status==="dirty"?(t.dirty(),pn(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ie:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:oe.ZodPipeline})}},On=class extends ge{_parse(e){let t=this._def.innerType._parse(e),n=s=>(zr(s)&&(s.value=Object.freeze(s.value)),s);return rs(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};On.create=(r,e)=>new On({innerType:r,typeName:oe.ZodReadonly,...le(e)});function vf(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function If(r,e={},t){return r?$r.create().superRefine((n,s)=>{let i=r(n);if(i instanceof Promise)return i.then(o=>{if(!o){let c=vf(e,n),u=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:u})}});if(!i){let o=vf(e,n),c=o.fatal??t??!0;s.addIssue({code:"custom",...o,fatal:c})}}):$r.create()}var F0={object:Vt.lazycreate},oe;(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"})(oe||(oe={}));var $0=(r,e={message:`Input not instance of ${r.name}`})=>If(t=>t instanceof r,e),kf=Fr.create,Of=mn.create,V0=cs.create,W0=gn.create,Tf=yn.create,q0=_n.create,j0=ss.create,K0=bn.create,H0=wn.create,G0=$r.create,Z0=Sr.create,Y0=sr.create,X0=is.create,J0=xr.create,Q0=Vt.create,ep=Vt.strictCreate,tp=vn.create,rp=zi.create,np=En.create,sp=lr.create,ip=Fi.create,op=os.create,ap=as.create,cp=$i.create,up=Rn.create,fp=Sn.create,lp=xn.create,dp=An.create,hp=Vr.create,pp=er.create,mp=Jt.create,gp=dr.create,yp=er.createWithPreprocess,_p=Ms.create,bp=()=>kf().optional(),wp=()=>Of().optional(),vp=()=>Tf().optional(),Ep={string:r=>Fr.create({...r,coerce:!0}),number:r=>mn.create({...r,coerce:!0}),boolean:r=>yn.create({...r,coerce:!0}),bigint:r=>gn.create({...r,coerce:!0}),date:r=>_n.create({...r,coerce:!0})};var Rp=ie;var Sp=/[@#$%^&*+=\/\\|~«»]/,xp=/(!{2,}|\?{2,}|-{2,})/,Ap=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,Wr=({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=>!Ap.test(n),{message:"Emojis and symbols are not allowed"}).refine(n=>!Sp.test(n),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, \xAB, \xBB) are not allowed"}).refine(n=>!xp.test(n),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),Rt=K.string().url().startsWith("https://",{message:"Must be an https url"}).max(1024),Us=K.string().max(32),Ds=K.string().max(32),Ip=/^[-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(Ip,{message:"Invalid CAIP-19 asset ID"}),zs=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."}),ja=K.union([K.literal("1:1"),K.literal("3:2")]),Ka=K.object({header:K.string(),payload:K.string(),signature:K.string()}),kp=K.object({fid:K.number(),type:K.literal("app_key"),key:K.string().startsWith("0x")});var Nf=K.object({type:K.literal("launch_frame"),name:Us,url:Rt.optional(),splashImageUrl:Rt.optional(),splashBackgroundColor:zs.optional()}),Bf=K.object({type:K.literal("view_token"),token:qa}),Lf=K.discriminatedUnion("type",[Nf,Bf]),Cf=K.object({title:Ds,action:Lf}),Pf=K.object({version:K.literal("next"),imageUrl:Rt,aspectRatio:ja.optional(),button:Cf}),Op=r=>Pf.safeParse(r);var Vi=K.object({url:K.string(),token:K.string()}),Tp=K.object({notificationId:K.string().max(128),title:K.string().max(32),body:K.string().max(128),targetUrl:Rt,tokens:K.string().array().max(100)}),Np=K.object({result:K.object({successfulTokens:K.array(K.string()),invalidTokens:K.array(K.string()),rateLimitedTokens:K.array(K.string())})});var Mf=K.object({event:K.literal("frame_added"),notificationDetails:Vi.optional()}),Uf=K.object({event:K.literal("frame_removed")}),Df=K.object({event:K.literal("notifications_enabled"),notificationDetails:Vi.required()}),zf=K.object({event:K.literal("notifications_disabled")}),Bp=K.discriminatedUnion("event",[Mf,Uf,Df,zf]);var Lp=K.enum(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),Ff=["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"],$f=K.object({version:K.union([K.literal("0.0.0"),K.literal("0.0.1"),K.literal("1"),K.literal("next")]),name:Us,iconUrl:Rt,homeUrl:Rt,imageUrl:Rt.optional(),buttonTitle:Ds.optional(),splashImageUrl:Rt.optional(),splashBackgroundColor:zs.optional(),webhookUrl:Rt.optional(),subtitle:Wr({max:30}).optional(),description:Wr({max:170}).optional(),screenshotUrls:K.array(Rt).max(3).optional(),primaryCategory:Lp.optional(),tags:K.array(Wr({max:20,noSpaces:!0})).max(5).optional(),heroImageUrl:Rt.optional(),tagline:Wr({max:30}).optional(),ogTitle:Wr({max:30}).optional(),ogDescription:Wr({max:100}).optional(),ogImageUrl:Rt.optional(),noindex:K.boolean().optional(),requiredChains:K.array(K.enum(Ff)).max(Ff.length).optional(),requiredCapabilities:K.array(K.enum(Pi)).max(Pi.length).optional(),castShareUrl:Rt.optional()}).refine(r=>{if(r.castShareUrl===void 0)return!0;try{let e=new URL(r.homeUrl).hostname,t=new URL(r.castShareUrl).hostname;return e===t}catch{return!1}},{message:"castShareUrl must have the same domain as homeUrl",path:["castShareUrl"]}),Cp=K.object({accountAssociation:Ka,frame:$f.optional()});var ae=vr($s());function Vs(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function hm(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function jr(r,...e){if(!hm(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 cl(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Vs(r.outputLen),Vs(r.blockLen)}function Ir(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 Ki(r,e){jr(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Bn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ul(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function Hi(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function ir(r,e){return r<<32-e|r>>>e}var nc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function pm(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function sc(r){for(let e=0;e<r.length;e++)r[e]=pm(r[e])}function fl(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Hr(r){return typeof r=="string"&&(r=fl(r)),jr(r),r}function ic(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];jr(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let i=r[n];t.set(i,s),s+=i.length}return t}var Kr=class{clone(){return this._cloneInto()}};function hs(r){let e=n=>r().update(Hr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function ll(r){let e=(n,s)=>r(s).update(Hr(n)).digest(),t=r({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}function Gi(r=32){if(Bn&&typeof Bn.getRandomValues=="function")return Bn.getRandomValues(new Uint8Array(r));if(Bn&&typeof Bn.randomBytes=="function")return Bn.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function mm(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),c=Number(t&i),u=n?4:0,p=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+p,c,n)}function dl(r,e,t){return r&e^~r&t}function hl(r,e,t){return r&e^r&t^e&t}var ps=class extends Kr{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Hi(this.buffer)}update(e){Ir(this);let{view:t,buffer:n,blockLen:s}=this;e=Hr(e);let i=e.length;for(let o=0;o<i;){let c=Math.min(s-this.pos,i-o);if(c===s){let u=Hi(e);for(;s<=i-o;o+=s)this.process(u,o);continue}n.set(e.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ir(this),Ki(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:s,isLE:i}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(n,0),o=0);for(let b=o;b<s;b++)t[b]=0;mm(n,s-8,BigInt(this.length*8),i),this.process(n,0);let c=Hi(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],i)}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:s,finished:i,destroyed:o,pos:c}=this;return e.length=s,e.pos=c,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(n),e}};var Zi=BigInt(4294967295),oc=BigInt(32);function pl(r,e=!1){return e?{h:Number(r&Zi),l:Number(r>>oc&Zi)}:{h:Number(r>>oc&Zi)|0,l:Number(r&Zi)|0}}function ac(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:i,l:o}=pl(r[s],e);[t[s],n[s]]=[i,o]}return[t,n]}var gm=(r,e)=>BigInt(r>>>0)<<oc|BigInt(e>>>0),ym=(r,e,t)=>r>>>t,_m=(r,e,t)=>r<<32-t|e>>>t,bm=(r,e,t)=>r>>>t|e<<32-t,wm=(r,e,t)=>r<<32-t|e>>>t,vm=(r,e,t)=>r<<64-t|e>>>t-32,Em=(r,e,t)=>r>>>t-32|e<<64-t,Rm=(r,e)=>e,Sm=(r,e)=>r,cc=(r,e,t)=>r<<t|e>>>32-t,uc=(r,e,t)=>e<<t|r>>>32-t,fc=(r,e,t)=>e<<t-32|r>>>64-t,lc=(r,e,t)=>r<<t-32|e>>>64-t;function xm(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var Am=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Im=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,km=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Om=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,Tm=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),Nm=(r,e,t,n,s,i)=>e+t+n+s+i+(r/2**32|0)|0;var Bm={fromBig:pl,split:ac,toBig:gm,shrSH:ym,shrSL:_m,rotrSH:bm,rotrSL:wm,rotrBH:vm,rotrBL:Em,rotr32H:Rm,rotr32L:Sm,rotlSH:cc,rotlSL:uc,rotlBH:fc,rotlBL:lc,add:xm,add3L:Am,add3H:Im,add4L:km,add4H:Om,add5H:Nm,add5L:Tm},pe=Bm;var[Lm,Cm]=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))),Gr=new Uint32Array(80),Zr=new Uint32Array(80),dc=class extends ps{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:s,Ch:i,Cl:o,Dh:c,Dl:u,Eh:p,El:m,Fh:b,Fl:x,Gh:S,Gl:T,Hh:I,Hl:A}=this;return[e,t,n,s,i,o,c,u,p,m,b,x,S,T,I,A]}set(e,t,n,s,i,o,c,u,p,m,b,x,S,T,I,A){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|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=x|0,this.Gh=S|0,this.Gl=T|0,this.Hh=I|0,this.Hl=A|0}process(e,t){for(let L=0;L<16;L++,t+=4)Gr[L]=e.getUint32(t),Zr[L]=e.getUint32(t+=4);for(let L=16;L<80;L++){let F=Gr[L-15]|0,te=Zr[L-15]|0,G=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=Gr[L-2]|0,Y=Zr[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,Zr[L-7],Zr[L-16]),v=pe.add4H(fe,G,Ie,Gr[L-7],Gr[L-16]);Gr[L]=v|0,Zr[L]=fe|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:c,Cl:u,Dh:p,Dl:m,Eh:b,El:x,Fh:S,Fl:T,Gh:I,Gl:A,Hh:B,Hl:U}=this;for(let L=0;L<80;L++){let F=pe.rotrSH(b,x,14)^pe.rotrSH(b,x,18)^pe.rotrBH(b,x,41),te=pe.rotrSL(b,x,14)^pe.rotrSL(b,x,18)^pe.rotrBL(b,x,41),G=b&S^~b&I,Z=x&T^~x&A,ee=pe.add5L(U,te,Z,Cm[L],Zr[L]),Y=pe.add5H(ee,B,F,G,Lm[L],Gr[L]),Ie=ee|0,re=pe.rotrSH(n,s,28)^pe.rotrBH(n,s,34)^pe.rotrBH(n,s,39),fe=pe.rotrSL(n,s,28)^pe.rotrBL(n,s,34)^pe.rotrBL(n,s,39),v=n&i^n&c^i&c,a=s&o^s&u^o&u;B=I|0,U=A|0,I=S|0,A=T|0,S=b|0,T=x|0,{h:b,l:x}=pe.add(p|0,m|0,Y|0,Ie|0),p=c|0,m=u|0,c=i|0,u=o|0,i=n|0,o=s|0;let l=pe.add3L(Ie,fe,a);n=pe.add3H(l,Y,re,v),s=l|0}({h:n,l:s}=pe.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=pe.add(this.Bh|0,this.Bl|0,i|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:x}=pe.add(this.Eh|0,this.El|0,b|0,x|0),{h:S,l:T}=pe.add(this.Fh|0,this.Fl|0,S|0,T|0),{h:I,l:A}=pe.add(this.Gh|0,this.Gl|0,I|0,A|0),{h:B,l:U}=pe.add(this.Hh|0,this.Hl|0,B|0,U|0),this.set(n,s,i,o,c,u,p,m,b,x,S,T,I,A,B,U)}roundClean(){Gr.fill(0),Zr.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 ml=hs(()=>new dc);var Ji={};wr(Ji,{aInRange:()=>qt,abool:()=>or,abytes:()=>ms,bitGet:()=>Fm,bitLen:()=>gc,bitMask:()=>qs,bitSet:()=>$m,bytesToHex:()=>Or,bytesToNumberBE:()=>Tr,bytesToNumberLE:()=>Xr,concatBytes:()=>Nr,createHmacDrbg:()=>yc,ensureBytes:()=>We,equalBytes:()=>Dm,hexToBytes:()=>Cn,hexToNumber:()=>mc,inRange:()=>Ws,isBytes:()=>Yr,memoized:()=>Mn,notImplemented:()=>Wm,numberToBytesBE:()=>Jr,numberToBytesLE:()=>Pn,numberToHexUnpadded:()=>Ln,numberToVarBytesBE:()=>Um,utf8ToBytes:()=>zm,validateObject:()=>mr});var Yi=BigInt(0),Xi=BigInt(1),Pm=BigInt(2);function Yr(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ms(r){if(!Yr(r))throw new Error("Uint8Array expected")}function or(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}var Mm=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Or(r){ms(r);let e="";for(let t=0;t<r.length;t++)e+=Mm[r[t]];return e}function Ln(r){let e=r.toString(16);return e.length&1?"0"+e:e}function mc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Yi:BigInt("0x"+r)}var kr={_0:48,_9:57,A:65,F:70,a:97,f:102};function gl(r){if(r>=kr._0&&r<=kr._9)return r-kr._0;if(r>=kr.A&&r<=kr.F)return r-(kr.A-10);if(r>=kr.a&&r<=kr.f)return r-(kr.a-10)}function Cn(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 s=0,i=0;s<t;s++,i+=2){let o=gl(r.charCodeAt(i)),c=gl(r.charCodeAt(i+1));if(o===void 0||c===void 0){let u=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+i)}n[s]=o*16+c}return n}function Tr(r){return mc(Or(r))}function Xr(r){return ms(r),mc(Or(Uint8Array.from(r).reverse()))}function Jr(r,e){return Cn(r.toString(16).padStart(e*2,"0"))}function Pn(r,e){return Jr(r,e).reverse()}function Um(r){return Cn(Ln(r))}function We(r,e,t){let n;if(typeof e=="string")try{n=Cn(e)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(Yr(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let s=n.length;if(typeof t=="number"&&s!==t)throw new Error(r+" of length "+t+" expected, got "+s);return n}function Nr(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];ms(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let i=r[n];t.set(i,s),s+=i.length}return t}function Dm(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 zm(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var hc=r=>typeof r=="bigint"&&Yi<=r;function Ws(r,e,t){return hc(r)&&hc(e)&&hc(t)&&e<=r&&r<t}function qt(r,e,t,n){if(!Ws(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function gc(r){let e;for(e=0;r>Yi;r>>=Xi,e+=1);return e}function Fm(r,e){return r>>BigInt(e)&Xi}function $m(r,e,t){return r|(t?Xi:Yi)<<BigInt(e)}var qs=r=>(Pm<<BigInt(r-1))-Xi,pc=r=>new Uint8Array(r),yl=r=>Uint8Array.from(r);function yc(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=pc(r),s=pc(r),i=0,o=()=>{n.fill(1),s.fill(0),i=0},c=(...b)=>t(s,n,...b),u=(b=pc())=>{s=c(yl([0]),b),n=c(),b.length!==0&&(s=c(yl([1]),b),n=c())},p=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let b=0,x=[];for(;b<e;){n=c();let S=n.slice();x.push(S),b+=n.length}return Nr(...x)};return(b,x)=>{o(),u(b);let S;for(;!(S=x(p()));)u();return o(),S}}var Vm={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"||Yr(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 mr(r,e,t={}){let n=(s,i,o)=>{let c=Vm[i];if(typeof c!="function")throw new Error("invalid validator function");let u=r[s];if(!(o&&u===void 0)&&!c(u,r))throw new Error("param "+String(s)+" is invalid. Expected "+i+", got "+u)};for(let[s,i]of Object.entries(e))n(s,i,!1);for(let[s,i]of Object.entries(t))n(s,i,!0);return r}var Wm=()=>{throw new Error("not implemented")};function Mn(r){let e=new WeakMap;return(t,...n)=>{let s=e.get(t);if(s!==void 0)return s;let i=r(t,...n);return e.set(t,i),i}}var _t=BigInt(0),Ce=BigInt(1),Un=BigInt(2),qm=BigInt(3),_c=BigInt(4),_l=BigInt(5),bl=BigInt(8),jm=BigInt(9),Km=BigInt(16);function ke(r,e){let t=r%e;return t>=_t?t:e+t}function Hm(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 Qi(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=ke(r,e),n=e,s=_t,i=Ce,o=Ce,c=_t;for(;t!==_t;){let p=n/t,m=n%t,b=s-o*p,x=i-c*p;n=t,t=m,s=o,i=c,o=b,c=x}if(n!==Ce)throw new Error("invert: does not exist");return ke(s,e)}function Gm(r){let e=(r-Ce)/Un,t,n,s;for(t=r-Ce,n=0;t%Un===_t;t/=Un,n++);for(s=Un;s<r&&Hm(s,e,r)!==r-Ce;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let o=(r+Ce)/_c;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 i=(t+Ce)/Un;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,s),t),b=c.pow(u,i),x=c.pow(u,t);for(;!c.eql(x,c.ONE);){if(c.eql(x,c.ZERO))return c.ZERO;let S=1;for(let I=c.sqr(x);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),x=c.mul(x,m),p=S}return b}}function Zm(r){if(r%_c===qm){let e=(r+Ce)/_c;return function(n,s){let i=n.pow(s,e);if(!n.eql(n.sqr(i),s))throw new Error("Cannot find square root");return i}}if(r%bl===_l){let e=(r-_l)/bl;return function(n,s){let i=n.mul(s,Un),o=n.pow(i,e),c=n.mul(s,o),u=n.mul(n.mul(c,Un),o),p=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(p),s))throw new Error("Cannot find square root");return p}}return r%Km,Gm(r)}var wl=(r,e)=>(ke(r,e)&Ce)===Ce,Ym=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bc(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Ym.reduce((n,s)=>(n[s]="function",n),e);return mr(r,t)}function Xm(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,s=e;for(;t>_t;)t&Ce&&(n=r.mul(n,s)),s=r.sqr(s),t>>=Ce;return n}function Jm(r,e){let t=new Array(e.length),n=e.reduce((i,o,c)=>r.is0(o)?i:(t[c]=i,r.mul(i,o)),r.ONE),s=r.inv(n);return e.reduceRight((i,o,c)=>r.is0(o)?i:(t[c]=r.mul(i,t[c]),r.mul(i,o)),s),t}function wc(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Qr(r,e,t=!1,n={}){if(r<=_t)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:s,nByteLength:i}=wc(r,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o,c=Object.freeze({ORDER:r,isLE:t,BITS:s,BYTES:i,MASK:qs(s),ZERO:_t,ONE:Ce,create:u=>ke(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=>ke(-u,r),eql:(u,p)=>u===p,sqr:u=>ke(u*u,r),add:(u,p)=>ke(u+p,r),sub:(u,p)=>ke(u-p,r),mul:(u,p)=>ke(u*p,r),pow:(u,p)=>Xm(c,u,p),div:(u,p)=>ke(u*Qi(p,r),r),sqrN:u=>u*u,addN:(u,p)=>u+p,subN:(u,p)=>u-p,mulN:(u,p)=>u*p,inv:u=>Qi(u,r),sqrt:n.sqrt||(u=>(o||(o=Zm(r)),o(c,u))),invertBatch:u=>Jm(c,u),cmov:(u,p,m)=>m?p:u,toBytes:u=>t?Pn(u,i):Jr(u,i),fromBytes:u=>{if(u.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+u.length);return t?Xr(u):Tr(u)}});return Object.freeze(c)}function vl(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 vc(r){let e=vl(r);return e+Math.ceil(e/2)}function El(r,e,t=!1){let n=r.length,s=vl(e),i=vc(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let o=t?Xr(r):Tr(r),c=ke(o,e-Ce)+Ce;return t?Pn(c,s):Jr(c,s)}var Rl=BigInt(0),eo=BigInt(1);function Ec(r,e){let t=e.negate();return r?t:e}function Sl(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Rc(r,e){Sl(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function Qm(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 eg(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 Sc=new WeakMap,xl=new WeakMap;function xc(r){return xl.get(r)||1}function to(r,e){return{constTimeNegate:Ec,hasPrecomputes(t){return xc(t)!==1},unsafeLadder(t,n,s=r.ZERO){let i=t;for(;n>Rl;)n&eo&&(s=s.add(i)),i=i.double(),n>>=eo;return s},precomputeWindow(t,n){let{windows:s,windowSize:i}=Rc(n,e),o=[],c=t,u=c;for(let p=0;p<s;p++){u=c,o.push(u);for(let m=1;m<i;m++)u=u.add(c),o.push(u);c=u.double()}return o},wNAF(t,n,s){let{windows:i,windowSize:o}=Rc(t,e),c=r.ZERO,u=r.BASE,p=BigInt(2**t-1),m=2**t,b=BigInt(t);for(let x=0;x<i;x++){let S=x*o,T=Number(s&p);s>>=b,T>o&&(T-=m,s+=eo);let I=S,A=S+Math.abs(T)-1,B=x%2!==0,U=T<0;T===0?u=u.add(Ec(B,n[I])):c=c.add(Ec(U,n[A]))}return{p:c,f:u}},wNAFUnsafe(t,n,s,i=r.ZERO){let{windows:o,windowSize:c}=Rc(t,e),u=BigInt(2**t-1),p=2**t,m=BigInt(t);for(let b=0;b<o;b++){let x=b*c;if(s===Rl)break;let S=Number(s&u);if(s>>=m,S>c&&(S-=p,s+=eo),S===0)continue;let T=n[x+Math.abs(S)-1];S<0&&(T=T.negate()),i=i.add(T)}return i},getPrecomputes(t,n,s){let i=Sc.get(n);return i||(i=this.precomputeWindow(n,t),t!==1&&Sc.set(n,s(i))),i},wNAFCached(t,n,s){let i=xc(t);return this.wNAF(i,this.getPrecomputes(i,t,s),n)},wNAFCachedUnsafe(t,n,s,i){let o=xc(t);return o===1?this.unsafeLadder(t,n,i):this.wNAFUnsafe(o,this.getPrecomputes(o,t,s),n,i)},setWindowSize(t,n){Sl(n,e),xl.set(t,n),Sc.delete(t)}}}function ro(r,e,t,n){if(Qm(t,r),eg(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,i=gc(BigInt(t.length)),o=i>12?i-3:i>4?i-2:i?2:1,c=(1<<o)-1,u=new Array(c+1).fill(s),p=Math.floor((e.BITS-1)/o)*o,m=s;for(let b=p;b>=0;b-=o){u.fill(s);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 x=s;for(let S=u.length-1,T=s;S>0;S--)T=T.add(u[S]),x=x.add(T);if(m=m.add(x),b!==0)for(let S=0;S<o;S++)m=m.double()}return m}function js(r){return bc(r.Fp),mr(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...wc(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var ar=BigInt(0),jt=BigInt(1),no=BigInt(2),tg=BigInt(8),rg={zip215:!0};function ng(r){let e=js(r);return mr(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Al(r){let e=ng(r),{Fp:t,n,prehash:s,hash:i,randomBytes:o,nByteLength:c,h:u}=e,p=no<<BigInt(c*8)-jt,m=t.create,b=Qr(e.n,e.nBitLength),x=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){qt("coordinate "+d,h,ar,p)}function A(d){if(!(d instanceof L))throw new Error("ExtendedPoint expected")}let B=Mn((d,h)=>{let{ex:g,ey:w,ez:R}=d,y=d.is0();h==null&&(h=y?tg:t.inv(R));let f=m(g*h),_=m(w*h),C=m(R*h);if(y)return{x:ar,y:jt};if(C!==jt)throw new Error("invZ was invalid");return{x:f,y:_}}),U=Mn(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),J=m(_*h),se=m(D*m(J+C)),ue=m($+m(g*m(_*C)));if(se!==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,jt,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 ro(L,b,h,g)}_setWindowSize(h){G.setWindowSize(this,h)}assertValidity(){U(this)}equals(h){A(h);let{ex:g,ey:w,ez:R}=this,{ex:y,ey:f,ez:_}=h,C=m(g*_),D=m(y*R),$=m(w*_),J=m(f*R);return C===D&&$===J}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(no*m(R*R)),C=m(h*y),D=g+w,$=m(m(D*D)-y-f),J=C+f,se=J-_,ue=C-f,Le=m($*se),he=m(J*ue),me=m($*ue),Ht=m(se*J);return new L(Le,he,Ht,me)}add(h){A(h);let{a:g,d:w}=e,{ex:R,ey:y,ez:f,et:_}=this,{ex:C,ey:D,ez:$,et:J}=h;if(g===BigInt(-1)){let Ue=m((y-R)*(D+C)),De=m((y+R)*(D-C)),Jn=m(De-Ue);if(Jn===ar)return this.double();let ze=m(f*no*J),Fe=m(_*no*$),Ts=Fe+ze,$e=De+Ue,Ve=Fe-ze,Bi=m(Ts*Jn),He=m($e*Ve),Ge=m(Ts*Ve),Li=m(Jn*$e);return new L(Bi,He,Li,Ge)}let se=m(R*C),ue=m(y*D),Le=m(_*w*J),he=m(f*$),me=m((R+y)*(C+D)-se-ue),Ht=he-Le,xe=he+Le,Ne=m(ue-g*se),Ti=m(me*Ht),je=m(xe*Ne),Ke=m(me*Ne),Ni=m(Ht*xe);return new L(Ti,je,Ni,Ke)}subtract(h){return this.add(h.negate())}wNAF(h){return G.wNAFCached(this,h,L.normalizeZ)}multiply(h){let g=h;qt("scalar",g,jt,n);let{p:w,f:R}=this.wNAF(g);return L.normalizeZ([w,R])[0]}multiplyUnsafe(h,g=L.ZERO){let w=h;return qt("scalar",w,ar,n),w===ar?te:this.is0()||w===jt?this:G.wNAFCachedUnsafe(this,w,L.normalizeZ,g)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return G.unsafeLadder(this,n).is0()}toAffine(h){return B(this,h)}clearCofactor(){let{h}=e;return h===jt?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=Xr(f),D=g?p:t.ORDER;qt("pointHex.y",C,ar,D);let $=m(C*C),J=m($-jt),se=m(w*$-R),{isValid:ue,value:Le}=x(J,se);if(!ue)throw new Error("Point.fromHex: invalid y coordinate");let he=(Le&jt)===jt,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=Pn(g,t.BYTES);return w[w.length-1]|=h&jt?128:0,w}toHex(){return Or(this.toRawBytes())}}L.BASE=new L(e.Gx,e.Gy,jt,m(e.Gx*e.Gy)),L.ZERO=new L(ar,jt,jt,ar);let{BASE:F,ZERO:te}=L,G=to(L,c*8);function Z(d){return ke(d,n)}function ee(d){return Z(Xr(d))}function Y(d){let h=t.BYTES;d=We("private key",d,h);let g=We("hashed private key",i(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=Nr(...h);return ee(i(T(g,We("context",d),!!s)))}function fe(d,h,g={}){d=We("message",d),s&&(d=s(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);qt("signature.s",D,ar,n);let $=Nr(_,Pn(D,t.BYTES));return We("result",$,t.BYTES*2)}let v=rg;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),s&&(h=s(h));let _=Xr(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 J=re(R,D.toRawBytes(),C.toRawBytes(),h);return D.add(C.multiplyUnsafe(J)).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"),Il=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),CS=BigInt(0),sg=BigInt(1),kl=BigInt(2),PS=BigInt(3),ig=BigInt(5),og=BigInt(8);function ag(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),s=BigInt(80),i=Ac,c=r*r%i*r%i,u=Pe(c,kl,i)*c%i,p=Pe(u,sg,i)*r%i,m=Pe(p,ig,i)*p%i,b=Pe(m,e,i)*m%i,x=Pe(b,t,i)*b%i,S=Pe(x,n,i)*x%i,T=Pe(S,s,i)*S%i,I=Pe(T,s,i)*S%i,A=Pe(I,e,i)*m%i;return{pow_p_5_8:Pe(A,kl,i)*r%i,b2:c}}function cg(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function ug(r,e){let t=Ac,n=ke(e*e*e,t),s=ke(n*n*e,t),i=ag(r*s).pow_p_5_8,o=ke(r*n*i,t),c=ke(e*o*o,t),u=o,p=ke(o*Il,t),m=c===r,b=c===ke(-r,t),x=c===ke(-r*Il,t);return m&&(o=u),(b||x)&&(o=p),wl(o,t)&&(o=ke(-o,t)),{isValid:m||b,value:o}}var fg=Qr(Ac,void 0,!0),lg={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:fg,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:og,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ml,randomBytes:Gi,adjustScalarBytes:cg,uvRatio:ug},Dn=Al(lg);var wu=vr(kc()),vt=vr(Tc());var mg=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]),en=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),tn=new Uint32Array(64),Nc=class extends ps{constructor(){super(64,32,8,!1),this.A=en[0]|0,this.B=en[1]|0,this.C=en[2]|0,this.D=en[3]|0,this.E=en[4]|0,this.F=en[5]|0,this.G=en[6]|0,this.H=en[7]|0}get(){let{A:e,B:t,C:n,D:s,E:i,F:o,G:c,H:u}=this;return[e,t,n,s,i,o,c,u]}set(e,t,n,s,i,o,c,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=i|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)tn[b]=e.getUint32(t,!1);for(let b=16;b<64;b++){let x=tn[b-15],S=tn[b-2],T=ir(x,7)^ir(x,18)^x>>>3,I=ir(S,17)^ir(S,19)^S>>>10;tn[b]=I+tn[b-7]+T+tn[b-16]|0}let{A:n,B:s,C:i,D:o,E:c,F:u,G:p,H:m}=this;for(let b=0;b<64;b++){let x=ir(c,6)^ir(c,11)^ir(c,25),S=m+x+dl(c,u,p)+mg[b]+tn[b]|0,I=(ir(n,2)^ir(n,13)^ir(n,22))+hl(n,s,i)|0;m=p,p=u,u=c,c=o+S|0,o=i,i=s,s=n,n=S+I|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,p=p+this.G|0,m=m+this.H|0,this.set(n,s,i,o,c,u,p,m)}roundClean(){tn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ks=hs(()=>new Nc);var xs=vr(Vl()),E=vr(Fc()),ph=vr(Fc());var Bg=1,Lg=2,Cg=3,Pg=4,Mg=5,Ug=6,Dg=7,zg=8,Fg=9,$g=10,Vg=-32700,Wg=-32603,qg=-32602,jg=-32601,Kg=-32600,Hg=-32016,Gg=-32015,Zg=-32014,Yg=-32013,Xg=-32012,Jg=-32011,Qg=-32010,ey=-32009,ty=-32008,ry=-32007,ny=-32006,sy=-32005,iy=-32004,oy=-32003,ay=-32002,cy=-32001,uy=28e5,fy=2800001,ly=2800002,dy=2800003,hy=2800004,py=2800005,my=2800006,gy=2800007,yy=2800008,_y=2800009,by=2800010,wy=323e4,vy=32300001,Ey=3230002,Ry=3230003,Sy=3230004,xy=361e4,Ay=3610001,Iy=3610002,ky=3610003,Oy=3610004,Ty=3610005,Ny=3610006,By=3610007,Ly=3611e3,Cy=3704e3,Py=3704001,My=3704002,Uy=3704003,Dy=3704004,zy=4128e3,Fy=4128001,$y=4128002,Vy=4615e3,Wy=4615001,qy=4615002,jy=4615003,Ky=4615004,Hy=4615005,Gy=4615006,Zy=4615007,Yy=4615008,Xy=4615009,Jy=4615010,Qy=4615011,e_=4615012,t_=4615013,r_=4615014,n_=4615015,s_=4615016,i_=4615017,o_=4615018,a_=4615019,c_=4615020,u_=4615021,f_=4615022,l_=4615023,d_=4615024,h_=4615025,p_=4615026,m_=4615027,g_=4615028,y_=4615029,__=4615030,b_=4615031,w_=4615032,v_=4615033,E_=4615034,R_=4615035,S_=4615036,x_=4615037,A_=4615038,I_=4615039,k_=4615040,O_=4615041,T_=4615042,N_=4615043,B_=4615044,L_=4615045,C_=4615046,P_=4615047,M_=4615048,U_=4615049,D_=4615050,z_=4615051,F_=4615052,$_=4615053,V_=4615054,W_=5508e3,q_=5508001,j_=5508002,K_=5508003,H_=5508004,G_=5508005,Z_=5508006,Y_=5508007,X_=5508008,J_=5508009,Q_=5508010,eb=5508011,tb=5663e3,rb=5663001,nb=5663002,sb=5663003,ib=5663004,ob=5663005,ab=5663006,cb=5663007,ub=5663008,fb=5663009,lb=5663010,db=5663011,hb=5663012,pb=5663013,mb=5663014,gb=5663015,yb=5663016,_b=5663017,bb=5663018,wb=5663019,vb=705e4,Eb=7050001,Rb=7050002,Sb=7050003,xb=7050004,Ab=7050005,Ib=7050006,kb=7050007,Ob=7050008,Tb=7050009,Nb=7050010,Bb=7050011,Lb=7050012,Cb=7050013,Pb=7050014,Mb=7050015,Ub=7050016,Db=7050017,zb=7050018,Fb=7050019,$b=7050020,Vb=7050021,Wb=7050022,qb=7050023,jb=7050024,Kb=7050025,Hb=7050026,Gb=7050027,Zb=7050028,Yb=7050029,Xb=7050030,Jb=7050031,Qb=7050032,ew=7050033,tw=7050034,rw=7050035,nw=7050036,$c=8078e3,Vc=8078001,Wl=8078002,ql=8078003,Wc=8078004,qc=8078005,jc=8078006,sw=8078007,iw=8078008,ow=8078009,aw=8078010,Kc=8078011,cw=8078012,jl=8078013,Kl=8078014,uw=8078015,fw=8078016,lw=8078017,dw=8078018,hw=8078019,Hl=8078020,Gl=8078021,pw=8078022,mw=81e5,gw=8100001,yw=8100002,_w=8100003,bw=819e4,ww=8190001,vw=8190002,Ew=8190003,Rw=8190004,Sw=99e5,xw=9900001,Aw=9900002,Iw=9900003,kw=9900004;function Zl(r){return Array.isArray(r)?"%5B"+r.map(Zl).join("%2C%20")+"%5D":typeof r=="bigint"?`${r}n`:encodeURIComponent(String(r!=null&&Object.getPrototypeOf(r)===null?{...r}:r))}function Ow([r,e]){return`${r}=${Zl(e)}`}function Tw(r){let e=Object.entries(r).map(Ow).join("&");return btoa(e)}var HS={[wy]:"Account not found at address: $address",[Sy]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[Ry]:"Expected decoded account at address: $address",[Ey]:"Failed to decode account data at address: $address",[vy]:"Accounts not found at addresses: $addresses",[_y]:"Unable to find a viable program address bump seed.",[ly]:"$putativeAddress is not a base58-encoded address.",[uy]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[dy]:"The `CryptoKey` must be an `Ed25519` public key.",[yy]:"Invalid seeds; point must fall off the Ed25519 curve.",[hy]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[my]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[gy]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[py]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[by]:"Program address cannot end with PDA marker.",[fy]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Pg]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Bg]:"The network has progressed past the last block for which this transaction could have been committed.",[$c]:"Codec [$codecDescription] cannot decode empty byte arrays.",[pw]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Hl]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[qc]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[jc]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Wc]:"Encoder and decoder must either both be fixed-size or variable-size.",[iw]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Wl]:"Expected a fixed-size codec, got a variable-size one.",[jl]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[ql]:"Expected a variable-size codec, got a fixed-size one.",[hw]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Vc]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[dw]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[ow]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[aw]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[uw]:"Invalid literal union variant. Expected one of [$variants], got $value.",[sw]:"Expected [$codecDescription] to have $expected items, got $actual.",[cw]:"Invalid value $value for base $base with alphabet $alphabet.",[fw]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Kc]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Kl]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Gl]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[lw]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Ly]:"No random values implementation could be found.",[Xy]:"instruction requires an uninitialized account",[l_]:"instruction tries to borrow reference for an account which is already borrowed",[d_]:"instruction left account with an outstanding borrowed reference",[u_]:"program other than the account's owner changed the size of the account data",[Hy]:"account data too small for instruction",[f_]:"instruction expected an executable account",[C_]:"An account does not have enough lamports to be rent-exempt",[M_]:"Program arithmetic overflowed",[L_]:"Failed to serialize or deserialize account data: $encodedData",[V_]:"Builtin programs must consume compute units",[w_]:"Cross-program invocation call depth too deep",[A_]:"Computational budget exceeded",[p_]:"custom program error: #$code",[i_]:"instruction contains duplicate accounts",[h_]:"instruction modifications of multiply-passed account differ",[__]:"executable accounts must be rent exempt",[g_]:"instruction changed executable accounts data",[y_]:"instruction changed the balance of an executable account",[o_]:"instruction changed executable bit of an account",[r_]:"instruction modified data of an account it does not own",[t_]:"instruction spent from the balance of an account it does not own",[Wy]:"generic instruction error",[D_]:"Provided owner is not allowed",[N_]:"Account is immutable",[B_]:"Incorrect authority provided",[Zy]:"incorrect program id for instruction",[Gy]:"insufficient funds for instruction",[Ky]:"invalid account data for instruction",[P_]:"Invalid account owner",[qy]:"invalid program argument",[m_]:"program returned invalid error code",[jy]:"invalid instruction data",[x_]:"Failed to reallocate account data",[S_]:"Provided seeds do not result in a valid address",[z_]:"Accounts data allocations exceeded the maximum allowed per transaction",[F_]:"Max accounts exceeded",[$_]:"Max instruction trace length exceeded",[R_]:"Length of the seed is too long for address generation",[v_]:"An account required by the instruction is missing",[Yy]:"missing required signature for instruction",[e_]:"instruction illegally modified the program id of an account",[c_]:"insufficient account keys for instruction",[I_]:"Cross-program invocation with unauthorized signer or writable account",[k_]:"Failed to create program execution environment",[T_]:"Program failed to compile",[O_]:"Program failed to complete",[s_]:"instruction modified data of a read-only account",[n_]:"instruction changed the balance of a read-only account",[E_]:"Cross-program invocation reentrancy not allowed for this instruction",[a_]:"instruction modified rent epoch of an account",[Qy]:"sum of account balances before and after instruction do not match",[Jy]:"instruction requires an initialized account",[Vy]:"",[b_]:"Unsupported program id",[U_]:"Unsupported sysvar",[zy]:"The instruction does not have any accounts.",[Fy]:"The instruction does not have any data.",[$y]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[Mg]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Lg]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Aw]:"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",[kw]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[xw]:"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",[Sw]:"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",[Iw]:"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",[Wg]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[qg]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Kg]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[jg]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Vg]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Xg]:"$__serverMessage",[cy]:"$__serverMessage",[iy]:"$__serverMessage",[Zg]:"$__serverMessage",[Qg]:"$__serverMessage",[ey]:"$__serverMessage",[Hg]:"Minimum context slot has not been reached",[sy]:"Node is unhealthy; behind by $numSlotsBehind slots",[ty]:"No snapshot",[ay]:"Transaction simulation failed",[ry]:"$__serverMessage",[Jg]:"Transaction history is not available from this node",[ny]:"$__serverMessage",[Yg]:"Transaction signature length mismatch",[oy]:"Transaction signature verification failure",[Gg]:"$__serverMessage",[Cy]:"Key pair bytes must be of length 64, got $byteLength.",[Py]:"Expected private key bytes with length 32. Actual length: $actualLength.",[My]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Dy]:"The provided private key does not match the provided public key.",[Uy]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[Ug]:"Lamports value must be in the range [0, 2e64-1]",[Dg]:"`$value` cannot be parsed as a `BigInt`",[$g]:"$message",[zg]:"`$value` cannot be parsed as a `Number`",[Cg]:"No nonce account could be found at address `$nonceAccountAddress`",[bw]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[vw]:"WebSocket was closed before payload could be added to the send buffer",[Ew]:"WebSocket connection closed",[Rw]:"WebSocket failed to connect",[ww]:"Failed to obtain a subscription id from the server",[_w]:"Could not find an API plan for RPC method: `$method`",[mw]:"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`.",[yw]:"HTTP error ($statusCode): $message",[gw]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[W_]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[q_]:"The provided value does not implement the `KeyPairSigner` interface",[K_]:"The provided value does not implement the `MessageModifyingSigner` interface",[H_]:"The provided value does not implement the `MessagePartialSigner` interface",[j_]:"The provided value does not implement any of the `MessageSigner` interfaces",[Z_]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Y_]:"The provided value does not implement the `TransactionPartialSigner` interface",[X_]:"The provided value does not implement the `TransactionSendingSigner` interface",[G_]:"The provided value does not implement any of the `TransactionSigner` interfaces",[J_]:"More than one `TransactionSendingSigner` was identified.",[Q_]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[eb]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[By]:"Cannot export a non-extractable key.",[Ay]:"No digest implementation could be found.",[xy]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Iy]:`This runtime does not support the generation of Ed25519 key pairs.
1
+ "use strict";var frame=(()=>{var T0=Object.create;var Ui=Object.defineProperty;var N0=Object.getOwnPropertyDescriptor;var L0=Object.getOwnPropertyNames;var B0=Object.getPrototypeOf,C0=Object.prototype.hasOwnProperty;var Ut=(r,e)=>()=>(r&&(e=r(r=0)),e);var $t=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),dr=(r,e)=>{for(var t in e)Ui(r,t,{get:e[t],enumerable:!0})},If=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of L0(e))!C0.call(r,s)&&s!==t&&Ui(r,s,{get:()=>e[s],enumerable:!(n=N0(e,s))||n.enumerable});return r};var vr=(r,e,t)=>(t=r!=null?T0(B0(r)):{},If(e||!r||!r.__esModule?Ui(t,"default",{value:r,enumerable:!0}):t,r)),Da=r=>If(Ui({},"__esModule",{value:!0}),r);var ul=$t(Ki=>{"use strict";Ki.byteLength=sm;Ki.toByteArray=om;Ki.fromByteArray=um;var gr=[],rr=[],nm=typeof Uint8Array<"u"?Uint8Array:Array,Ja="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Bn=0,al=Ja.length;Bn<al;++Bn)gr[Bn]=Ja[Bn],rr[Ja.charCodeAt(Bn)]=Bn;var Bn,al;rr[45]=62;rr[95]=63;function cl(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 sm(r){var e=cl(r),t=e[0],n=e[1];return(t+n)*3/4-n}function im(r,e,t){return(e+t)*3/4-t}function om(r){var e,t=cl(r),n=t[0],s=t[1],i=new nm(im(r,n,s)),o=0,c=s>0?n-4:n,u;for(u=0;u<c;u+=4)e=rr[r.charCodeAt(u)]<<18|rr[r.charCodeAt(u+1)]<<12|rr[r.charCodeAt(u+2)]<<6|rr[r.charCodeAt(u+3)],i[o++]=e>>16&255,i[o++]=e>>8&255,i[o++]=e&255;return s===2&&(e=rr[r.charCodeAt(u)]<<2|rr[r.charCodeAt(u+1)]>>4,i[o++]=e&255),s===1&&(e=rr[r.charCodeAt(u)]<<10|rr[r.charCodeAt(u+1)]<<4|rr[r.charCodeAt(u+2)]>>2,i[o++]=e>>8&255,i[o++]=e&255),i}function am(r){return gr[r>>18&63]+gr[r>>12&63]+gr[r>>6&63]+gr[r&63]}function cm(r,e,t){for(var n,s=[],i=e;i<t;i+=3)n=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(r[i+2]&255),s.push(am(n));return s.join("")}function um(r){for(var e,t=r.length,n=t%3,s=[],i=16383,o=0,c=t-n;o<c;o+=i)s.push(cm(r,o,o+i>c?c:o+i));return n===1?(e=r[t-1],s.push(gr[e>>2]+gr[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],s.push(gr[e>>10]+gr[e>>4&63]+gr[e<<2&63]+"=")),s.join("")}});var fl=$t(Xa=>{Xa.read=function(r,e,t,n,s){var i,o,c=s*8-n-1,u=(1<<c)-1,p=u>>1,m=-7,b=t?s-1:0,x=t?-1:1,S=r[e+b];for(b+=x,i=S&(1<<-m)-1,S>>=-m,m+=c;m>0;i=i*256+r[e+b],b+=x,m-=8);for(o=i&(1<<-m)-1,i>>=-m,m+=n;m>0;o=o*256+r[e+b],b+=x,m-=8);if(i===0)i=1-p;else{if(i===u)return o?NaN:(S?-1:1)*(1/0);o=o+Math.pow(2,n),i=i-p}return(S?-1:1)*o*Math.pow(2,i-n)};Xa.write=function(r,e,t,n,s,i){var o,c,u,p=i*8-s-1,m=(1<<p)-1,b=m>>1,x=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:i-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+=x/u:e+=x*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,s),o=o+b):(c=e*Math.pow(2,b-1)*Math.pow(2,s),o=0));s>=8;r[t+S]=c&255,S+=T,c/=256,s-=8);for(o=o<<s|c,p+=s;p>0;r[t+S]=o&255,S+=T,o/=256,p-=8);r[t+S-T]|=I*128}});var qs=$t(ps=>{"use strict";var Qa=ul(),ds=fl(),ll=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ps.Buffer=N;ps.SlowBuffer=mm;ps.INSPECT_MAX_BYTES=50;var Hi=2147483647;ps.kMaxLength=Hi;N.TYPED_ARRAY_SUPPORT=fm();!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 fm(){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 kr(r){if(r>Hi)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 nc(r)}return ml(r,e,t)}N.poolSize=8192;function ml(r,e,t){if(typeof r=="string")return dm(r,e);if(ArrayBuffer.isView(r))return hm(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(yr(r,ArrayBuffer)||r&&yr(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(yr(r,SharedArrayBuffer)||r&&yr(r.buffer,SharedArrayBuffer)))return tc(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 s=pm(r);if(s)return s;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 ml(r,e,t)};Object.setPrototypeOf(N.prototype,Uint8Array.prototype);Object.setPrototypeOf(N,Uint8Array);function gl(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 lm(r,e,t){return gl(r),r<=0?kr(r):e!==void 0?typeof t=="string"?kr(r).fill(e,t):kr(r).fill(e):kr(r)}N.alloc=function(r,e,t){return lm(r,e,t)};function nc(r){return gl(r),kr(r<0?0:sc(r)|0)}N.allocUnsafe=function(r){return nc(r)};N.allocUnsafeSlow=function(r){return nc(r)};function dm(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!N.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=yl(r,e)|0,n=kr(t),s=n.write(r,e);return s!==t&&(n=n.slice(0,s)),n}function ec(r){let e=r.length<0?0:sc(r.length)|0,t=kr(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function hm(r){if(yr(r,Uint8Array)){let e=new Uint8Array(r);return tc(e.buffer,e.byteOffset,e.byteLength)}return ec(r)}function tc(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 pm(r){if(N.isBuffer(r)){let e=sc(r.length)|0,t=kr(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||oc(r.length)?kr(0):ec(r);if(r.type==="Buffer"&&Array.isArray(r.data))return ec(r.data)}function sc(r){if(r>=Hi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Hi.toString(16)+" bytes");return r|0}function mm(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(yr(e,Uint8Array)&&(e=N.from(e,e.offset,e.byteLength)),yr(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,s=t.length;for(let i=0,o=Math.min(n,s);i<o;++i)if(e[i]!==t[i]){n=e[i],s=t[i];break}return n<s?-1:s<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 s=N.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let o=e[n];if(yr(o,Uint8Array))i+o.length>s.length?(N.isBuffer(o)||(o=N.from(o)),o.copy(s,i)):Uint8Array.prototype.set.call(s,o,i);else if(N.isBuffer(o))o.copy(s,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=o.length}return s};function yl(r,e){if(N.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||yr(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 s=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return rc(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Al(r).length;default:if(s)return n?-1:rc(r).length;e=(""+e).toLowerCase(),s=!0}}N.byteLength=yl;function gm(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 Am(this,e,t);case"utf8":case"utf-8":return bl(this,e,t);case"ascii":return Sm(this,e,t);case"latin1":case"binary":return xm(this,e,t);case"base64":return Rm(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Im(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}N.prototype._isBuffer=!0;function Cn(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)Cn(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)Cn(this,t,t+3),Cn(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)Cn(this,t,t+7),Cn(this,t+1,t+6),Cn(this,t+2,t+5),Cn(this,t+3,t+4);return this};N.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?bl(this,0,e):gm.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=ps.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};ll&&(N.prototype[ll]=N.prototype.inspect);N.prototype.compare=function(e,t,n,s,i){if(yr(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),s===void 0&&(s=0),i===void 0&&(i=this.length),t<0||n>e.length||s<0||i>this.length)throw new RangeError("out of range index");if(s>=i&&t>=n)return 0;if(s>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,s>>>=0,i>>>=0,this===e)return 0;let o=i-s,c=n-t,u=Math.min(o,c),p=this.slice(s,i),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 _l(r,e,t,n,s){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,oc(t)&&(t=s?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(s)return-1;t=r.length-1}else if(t<0)if(s)t=0;else return-1;if(typeof e=="string"&&(e=N.from(e,n)),N.isBuffer(e))return e.length===0?-1:dl(r,e,t,n,s);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):dl(r,[e],t,n,s);throw new TypeError("val must be string, number or Buffer")}function dl(r,e,t,n,s){let i=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;i=2,o/=2,c/=2,t/=2}function u(m,b){return i===1?m[b]:m.readUInt16BE(b*i)}let p;if(s){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*i}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 _l(this,e,t,n,!0)};N.prototype.lastIndexOf=function(e,t,n){return _l(this,e,t,n,!1)};function ym(r,e,t,n){t=Number(t)||0;let s=r.length-t;n?(n=Number(n),n>s&&(n=s)):n=s;let i=e.length;n>i/2&&(n=i/2);let o;for(o=0;o<n;++o){let c=parseInt(e.substr(o*2,2),16);if(oc(c))return o;r[t+o]=c}return o}function _m(r,e,t,n){return Gi(rc(e,r.length-t),r,t,n)}function bm(r,e,t,n){return Gi(Nm(e),r,t,n)}function wm(r,e,t,n){return Gi(Al(e),r,t,n)}function Em(r,e,t,n){return Gi(Lm(e,r.length-t),r,t,n)}N.prototype.write=function(e,t,n,s){if(t===void 0)s="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")s=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,s===void 0&&(s="utf8")):(s=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let o=!1;for(;;)switch(s){case"hex":return ym(this,e,t,n);case"utf8":case"utf-8":return _m(this,e,t,n);case"ascii":case"latin1":case"binary":return bm(this,e,t,n);case"base64":return wm(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Em(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),o=!0}};N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Rm(r,e,t){return e===0&&t===r.length?Qa.fromByteArray(r):Qa.fromByteArray(r.slice(e,t))}function bl(r,e,t){t=Math.min(r.length,t);let n=[],s=e;for(;s<t;){let i=r[s],o=null,c=i>239?4:i>223?3:i>191?2:1;if(s+c<=t){let u,p,m,b;switch(c){case 1:i<128&&(o=i);break;case 2:u=r[s+1],(u&192)===128&&(b=(i&31)<<6|u&63,b>127&&(o=b));break;case 3:u=r[s+1],p=r[s+2],(u&192)===128&&(p&192)===128&&(b=(i&15)<<12|(u&63)<<6|p&63,b>2047&&(b<55296||b>57343)&&(o=b));break;case 4:u=r[s+1],p=r[s+2],m=r[s+3],(u&192)===128&&(p&192)===128&&(m&192)===128&&(b=(i&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),s+=c}return vm(n)}var hl=4096;function vm(r){let e=r.length;if(e<=hl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=hl));return t}function Sm(r,e,t){let n="";t=Math.min(r.length,t);for(let s=e;s<t;++s)n+=String.fromCharCode(r[s]&127);return n}function xm(r,e,t){let n="";t=Math.min(r.length,t);for(let s=e;s<t;++s)n+=String.fromCharCode(r[s]);return n}function Am(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let s="";for(let i=e;i<t;++i)s+=Bm[r[i]];return s}function Im(r,e,t){let n=r.slice(e,t),s="";for(let i=0;i<n.length-1;i+=2)s+=String.fromCharCode(n[i]+n[i+1]*256);return s}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 s=this.subarray(e,t);return Object.setPrototypeOf(s,N.prototype),s};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 s=this[e],i=1,o=0;for(;++o<t&&(i*=256);)s+=this[e+o]*i;return s};N.prototype.readUintBE=N.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let s=this[e+--t],i=1;for(;t>0&&(i*=256);)s+=this[e+--t]*i;return s};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=Kr(function(e){e=e>>>0,hs(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ws(e,this.length-8);let s=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(s)+(BigInt(i)<<BigInt(32))});N.prototype.readBigUInt64BE=Kr(function(e){e=e>>>0,hs(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ws(e,this.length-8);let s=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(s)<<BigInt(32))+BigInt(i)});N.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let s=this[e],i=1,o=0;for(;++o<t&&(i*=256);)s+=this[e+o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*t)),s};N.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bt(e,t,this.length);let s=t,i=1,o=this[e+--s];for(;s>0&&(i*=256);)o+=this[e+--s]*i;return i*=128,o>=i&&(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=Kr(function(e){e=e>>>0,hs(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ws(e,this.length-8);let s=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(s)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});N.prototype.readBigInt64BE=Kr(function(e){e=e>>>0,hs(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ws(e,this.length-8);let s=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(s)<<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),ds.read(this,e,!0,23,4)};N.prototype.readFloatBE=function(e,t){return e=e>>>0,t||bt(e,4,this.length),ds.read(this,e,!1,23,4)};N.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||bt(e,8,this.length),ds.read(this,e,!0,52,8)};N.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||bt(e,8,this.length),ds.read(this,e,!1,52,8)};function qt(r,e,t,n,s,i){if(!N.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||e<i)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,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let c=Math.pow(2,8*n)-1;qt(this,e,t,n,c,0)}let i=1,o=0;for(this[t]=e&255;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n};N.prototype.writeUintBE=N.prototype.writeUIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let c=Math.pow(2,8*n)-1;qt(this,e,t,n,c,0)}let i=n-1,o=1;for(this[t+i]=e&255;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n};N.prototype.writeUint8=N.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||qt(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||qt(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||qt(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||qt(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||qt(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 wl(r,e,t,n,s){xl(e,n,s,r,t,7);let i=Number(e&BigInt(4294967295));r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i;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 El(r,e,t,n,s){xl(e,n,s,r,t,7);let i=Number(e&BigInt(4294967295));r[t+7]=i,i=i>>8,r[t+6]=i,i=i>>8,r[t+5]=i,i=i>>8,r[t+4]=i;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=Kr(function(e,t=0){return wl(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});N.prototype.writeBigUInt64BE=Kr(function(e,t=0){return El(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});N.prototype.writeIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let u=Math.pow(2,8*n-1);qt(this,e,t,n,u-1,-u)}let i=0,o=1,c=0;for(this[t]=e&255;++i<n&&(o*=256);)e<0&&c===0&&this[t+i-1]!==0&&(c=1),this[t+i]=(e/o>>0)-c&255;return t+n};N.prototype.writeIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let u=Math.pow(2,8*n-1);qt(this,e,t,n,u-1,-u)}let i=n-1,o=1,c=0;for(this[t+i]=e&255;--i>=0&&(o*=256);)e<0&&c===0&&this[t+i+1]!==0&&(c=1),this[t+i]=(e/o>>0)-c&255;return t+n};N.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||qt(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||qt(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||qt(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||qt(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||qt(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=Kr(function(e,t=0){return wl(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});N.prototype.writeBigInt64BE=Kr(function(e,t=0){return El(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Rl(r,e,t,n,s,i){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function vl(r,e,t,n,s){return e=+e,t=t>>>0,s||Rl(r,e,t,4,34028234663852886e22,-34028234663852886e22),ds.write(r,e,t,n,23,4),t+4}N.prototype.writeFloatLE=function(e,t,n){return vl(this,e,t,!0,n)};N.prototype.writeFloatBE=function(e,t,n){return vl(this,e,t,!1,n)};function Sl(r,e,t,n,s){return e=+e,t=t>>>0,s||Rl(r,e,t,8,17976931348623157e292,-17976931348623157e292),ds.write(r,e,t,n,52,8),t+8}N.prototype.writeDoubleLE=function(e,t,n){return Sl(this,e,t,!0,n)};N.prototype.writeDoubleBE=function(e,t,n){return Sl(this,e,t,!1,n)};N.prototype.copy=function(e,t,n,s){if(!N.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!s&&s!==0&&(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<n&&(s=n),s===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(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-n&&(s=e.length-t+n);let i=s-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,s):Uint8Array.prototype.set.call(e,this.subarray(n,s),t),i};N.prototype.fill=function(e,t,n,s){if(typeof e=="string"){if(typeof t=="string"?(s=t,t=0,n=this.length):typeof n=="string"&&(s=n,n=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!N.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(e.length===1){let o=e.charCodeAt(0);(s==="utf8"&&o<128||s==="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 i;if(typeof e=="number")for(i=t;i<n;++i)this[i]=e;else{let o=N.isBuffer(e)?e:N.from(e,s),c=o.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=o[i%c]}return this};var ls={};function ic(r,e,t){ls[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(s){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:s,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ic("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ic("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);ic("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,s=t;return Number.isInteger(t)&&Math.abs(t)>2**32?s=pl(String(t)):typeof t=="bigint"&&(s=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(s=pl(s)),s+="n"),n+=` It must be ${e}. Received ${s}`,n},RangeError);function pl(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 km(r,e,t){hs(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Ws(e,r.length-(t+1))}function xl(r,e,t,n,s,i){if(r>t||r<e){let o=typeof e=="bigint"?"n":"",c;throw i>3?e===0||e===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(i+1)*8}${o}`:c=`>= -(2${o} ** ${(i+1)*8-1}${o}) and < 2 ** ${(i+1)*8-1}${o}`:c=`>= ${e}${o} and <= ${t}${o}`,new ls.ERR_OUT_OF_RANGE("value",c,r)}km(n,s,i)}function hs(r,e){if(typeof r!="number")throw new ls.ERR_INVALID_ARG_TYPE(e,"number",r)}function Ws(r,e,t){throw Math.floor(r)!==r?(hs(r,t),new ls.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new ls.ERR_BUFFER_OUT_OF_BOUNDS:new ls.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Om=/[^+/0-9A-Za-z-_]/g;function Tm(r){if(r=r.split("=")[0],r=r.trim().replace(Om,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function rc(r,e){e=e||1/0;let t,n=r.length,s=null,i=[];for(let o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!s){if(t>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&i.push(239,191,189);continue}s=t;continue}if(t<56320){(e-=3)>-1&&i.push(239,191,189),s=t;continue}t=(s-55296<<10|t-56320)+65536}else s&&(e-=3)>-1&&i.push(239,191,189);if(s=null,t<128){if((e-=1)<0)break;i.push(t)}else if(t<2048){if((e-=2)<0)break;i.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;i.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;i.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return i}function Nm(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Lm(r,e){let t,n,s,i=[];for(let o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),n=t>>8,s=t%256,i.push(s),i.push(n);return i}function Al(r){return Qa.toByteArray(Tm(r))}function Gi(r,e,t,n){let s;for(s=0;s<n&&!(s+t>=e.length||s>=r.length);++s)e[s+t]=r[s];return s}function yr(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function oc(r){return r!==r}var Bm=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let s=0;s<16;++s)e[n+s]=r[t]+r[s]}return e}();function Kr(r){return typeof BigInt>"u"?Cm:r}function Cm(){throw new Error("BigInt not supported")}});var Gl=$t(()=>{});var Lc=$t((Zl,Nc)=>{(function(r,e){"use strict";function t(E,a){if(!E)throw new Error(a||"Assertion failed")}function n(E,a){E.super_=a;var l=function(){};l.prototype=a.prototype,E.prototype=new l,E.prototype.constructor=E}function s(E,a,l){if(s.isBN(E))return E;this.negative=0,this.words=null,this.length=0,this.red=null,E!==null&&((a==="le"||a==="be")&&(l=a,a=10),this._init(E||0,a||10,l||"be"))}typeof r=="object"?r.exports=s:e.BN=s,s.BN=s,s.wordSize=26;var i;try{typeof window<"u"&&typeof window.Buffer<"u"?i=window.Buffer:i=Gl().Buffer}catch{}s.isBN=function(a){return a instanceof s?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===s.wordSize&&Array.isArray(a.words)},s.max=function(a,l){return a.cmp(l)>0?a:l},s.min=function(a,l){return a.cmp(l)<0?a:l},s.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)))},s.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)},s.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,v=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<<v&67108863,this.words[g+1]=w>>>26-v&67108863,v+=24,v>=26&&(v-=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<<v&67108863,this.words[g+1]=w>>>26-v&67108863,v+=24,v>=26&&(v-=26,g++);return this._strip()};function o(E,a){var l=E.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 "+E)}function c(E,a,l){var d=o(E,l);return l-1>=a&&(d|=o(E,l-1)<<4),d}s.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,v;if(d==="be")for(h=a.length-1;h>=l;h-=2)v=c(a,l,h)<<g,this.words[w]|=v&67108863,g>=18?(g-=18,w+=1,this.words[w]|=v>>>26):g+=8;else{var y=a.length-l;for(h=y%2===0?l+1:l;h<a.length;h+=2)v=c(a,l,h)<<g,this.words[w]|=v&67108863,g>=18?(g-=18,w+=1,this.words[w]|=v>>>26):g+=8}this._strip()};function u(E,a,l,d){for(var h=0,g=0,w=Math.min(E.length,l),v=a;v<w;v++){var y=E.charCodeAt(v)-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}s.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,v=w%h,y=Math.min(w,w-v)+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(v!==0){var C=1;for(f=u(a,_,a.length,l),_=0;_<v;_++)C*=l;this.imuln(C),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},s.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(E,a){E.words=a.words,E.length=a.length,E.negative=a.negative,E.red=a.red}if(s.prototype._move=function(a){p(a,this)},s.prototype.clone=function(){var a=new s(null);return this.copy(a),a},s.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch{s.prototype.inspect=m}else s.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"],x=[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];s.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 v=this.words[w],y=((v<<h|g)&16777215).toString(16);g=v>>>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=x[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")},s.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},s.prototype.toJSON=function(){return this.toString(16,2)},i&&(s.prototype.toBuffer=function(a,l){return this.toArrayLike(i,a,l)}),s.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)};s.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),v=l==="le"?"LE":"BE";return this["_toArrayLike"+v](w,h),w},s.prototype._toArrayLikeLE=function(a,l){for(var d=0,h=0,g=0,w=0;g<this.length;g++){var v=this.words[g]<<w|h;a[d++]=v&255,d<a.length&&(a[d++]=v>>8&255),d<a.length&&(a[d++]=v>>16&255),w===6?(d<a.length&&(a[d++]=v>>24&255),h=0,w=0):(h=v>>>24,w+=2)}if(d<a.length)for(a[d++]=h;d<a.length;)a[d++]=0},s.prototype._toArrayLikeBE=function(a,l){for(var d=a.length-1,h=0,g=0,w=0;g<this.length;g++){var v=this.words[g]<<w|h;a[d--]=v&255,d>=0&&(a[d--]=v>>8&255),d>=0&&(a[d--]=v>>16&255),w===6?(d>=0&&(a[d--]=v>>24&255),h=0,w=0):(h=v>>>24,w+=2)}if(d>=0)for(a[d--]=h;d>=0;)a[d--]=0},Math.clz32?s.prototype._countBits=function(a){return 32-Math.clz32(a)}:s.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},s.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},s.prototype.bitLength=function(){var a=this.words[this.length-1],l=this._countBits(a);return(this.length-1)*26+l};function I(E){for(var a=new Array(E.bitLength()),l=0;l<a.length;l++){var d=l/26|0,h=l%26;a[l]=E.words[d]>>>h&1}return a}s.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},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},s.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.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()},s.prototype.ior=function(a){return t((this.negative|a.negative)===0),this.iuor(a)},s.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},s.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},s.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()},s.prototype.iand=function(a){return t((this.negative|a.negative)===0),this.iuand(a)},s.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},s.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},s.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()},s.prototype.ixor=function(a){return t((this.negative|a.negative)===0),this.iuxor(a)},s.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},s.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},s.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()},s.prototype.notn=function(a){return this.clone().inotn(a)},s.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()},s.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},s.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)},s.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,v=0;v<g.length;v++)l=(h.words[v]|0)-(g.words[v]|0)+w,w=l>>26,this.words[v]=l&67108863;for(;w!==0&&v<h.length;v++)l=(h.words[v]|0)+w,w=l>>26,this.words[v]=l&67108863;if(w===0&&v<h.length&&h!==this)for(;v<h.length;v++)this.words[v]=h.words[v];return this.length=Math.max(this.length,v),h!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(a){return this.clone().isub(a)};function A(E,a,l){l.negative=a.negative^E.negative;var d=E.length+a.length|0;l.length=d,d=d-1|0;var h=E.words[0]|0,g=a.words[0]|0,w=h*g,v=w&67108863,y=w/67108864|0;l.words[0]=v;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-E.length+1);$<=D;$++){var X=f-$|0;h=E.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 L=function(a,l,d){var h=a.words,g=l.words,w=d.words,v=0,y,f,_,C=h[0]|0,D=C&8191,$=C>>>13,X=h[1]|0,se=X&8191,ue=X>>>13,Be=h[2]|0,he=Be&8191,me=Be>>>13,Gt=h[3]|0,xe=Gt&8191,Ne=Gt>>>13,Bi=h[4]|0,je=Bi&8191,Ke=Bi>>>13,Ci=h[5]|0,Ue=Ci&8191,De=Ci>>>13,ts=h[6]|0,ze=ts&8191,Fe=ts>>>13,Bs=h[7]|0,$e=Bs&8191,Ve=Bs>>>13,Pi=h[8]|0,He=Pi&8191,Ge=Pi>>>13,Mi=h[9]|0,Ye=Mi&8191,Je=Mi>>>13,yf=g[0]|0,Xe=yf&8191,Qe=yf>>>13,_f=g[1]|0,et=_f&8191,tt=_f>>>13,bf=g[2]|0,rt=bf&8191,nt=bf>>>13,wf=g[3]|0,st=wf&8191,it=wf>>>13,Ef=g[4]|0,ot=Ef&8191,at=Ef>>>13,Rf=g[5]|0,ct=Rf&8191,ut=Rf>>>13,vf=g[6]|0,ft=vf&8191,lt=vf>>>13,Sf=g[7]|0,dt=Sf&8191,ht=Sf>>>13,xf=g[8]|0,pt=xf&8191,mt=xf>>>13,Af=g[9]|0,gt=Af&8191,yt=Af>>>13;d.negative=a.negative^l.negative,d.length=19,y=Math.imul(D,Xe),f=Math.imul(D,Qe),f=f+Math.imul($,Xe)|0,_=Math.imul($,Qe);var ba=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(ba>>>26)|0,ba&=67108863,y=Math.imul(se,Xe),f=Math.imul(se,Qe),f=f+Math.imul(ue,Xe)|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 wa=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(wa>>>26)|0,wa&=67108863,y=Math.imul(he,Xe),f=Math.imul(he,Qe),f=f+Math.imul(me,Xe)|0,_=Math.imul(me,Qe),y=y+Math.imul(se,et)|0,f=f+Math.imul(se,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 Ea=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Ea>>>26)|0,Ea&=67108863,y=Math.imul(xe,Xe),f=Math.imul(xe,Qe),f=f+Math.imul(Ne,Xe)|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(se,rt)|0,f=f+Math.imul(se,nt)|0,f=f+Math.imul(ue,rt)|0,_=_+Math.imul(ue,nt)|0,y=y+Math.imul(D,st)|0,f=f+Math.imul(D,it)|0,f=f+Math.imul($,st)|0,_=_+Math.imul($,it)|0;var Ra=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Ra>>>26)|0,Ra&=67108863,y=Math.imul(je,Xe),f=Math.imul(je,Qe),f=f+Math.imul(Ke,Xe)|0,_=Math.imul(Ke,Qe),y=y+Math.imul(xe,et)|0,f=f+Math.imul(xe,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(se,st)|0,f=f+Math.imul(se,it)|0,f=f+Math.imul(ue,st)|0,_=_+Math.imul(ue,it)|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 va=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(va>>>26)|0,va&=67108863,y=Math.imul(Ue,Xe),f=Math.imul(Ue,Qe),f=f+Math.imul(De,Xe)|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(xe,rt)|0,f=f+Math.imul(xe,nt)|0,f=f+Math.imul(Ne,rt)|0,_=_+Math.imul(Ne,nt)|0,y=y+Math.imul(he,st)|0,f=f+Math.imul(he,it)|0,f=f+Math.imul(me,st)|0,_=_+Math.imul(me,it)|0,y=y+Math.imul(se,ot)|0,f=f+Math.imul(se,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 Sa=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Sa>>>26)|0,Sa&=67108863,y=Math.imul(ze,Xe),f=Math.imul(ze,Qe),f=f+Math.imul(Fe,Xe)|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(xe,st)|0,f=f+Math.imul(xe,it)|0,f=f+Math.imul(Ne,st)|0,_=_+Math.imul(Ne,it)|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(se,ct)|0,f=f+Math.imul(se,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 xa=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(xa>>>26)|0,xa&=67108863,y=Math.imul($e,Xe),f=Math.imul($e,Qe),f=f+Math.imul(Ve,Xe)|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,st)|0,f=f+Math.imul(je,it)|0,f=f+Math.imul(Ke,st)|0,_=_+Math.imul(Ke,it)|0,y=y+Math.imul(xe,ot)|0,f=f+Math.imul(xe,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(se,ft)|0,f=f+Math.imul(se,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 Aa=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Aa>>>26)|0,Aa&=67108863,y=Math.imul(He,Xe),f=Math.imul(He,Qe),f=f+Math.imul(Ge,Xe)|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,st)|0,f=f+Math.imul(Ue,it)|0,f=f+Math.imul(De,st)|0,_=_+Math.imul(De,it)|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(xe,ct)|0,f=f+Math.imul(xe,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(se,dt)|0,f=f+Math.imul(se,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 Ia=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Ia>>>26)|0,Ia&=67108863,y=Math.imul(Ye,Xe),f=Math.imul(Ye,Qe),f=f+Math.imul(Je,Xe)|0,_=Math.imul(Je,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,st)|0,f=f+Math.imul(ze,it)|0,f=f+Math.imul(Fe,st)|0,_=_+Math.imul(Fe,it)|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(xe,ft)|0,f=f+Math.imul(xe,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(se,pt)|0,f=f+Math.imul(se,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 ka=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(ka>>>26)|0,ka&=67108863,y=Math.imul(Ye,et),f=Math.imul(Ye,tt),f=f+Math.imul(Je,et)|0,_=Math.imul(Je,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,st)|0,f=f+Math.imul($e,it)|0,f=f+Math.imul(Ve,st)|0,_=_+Math.imul(Ve,it)|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(xe,dt)|0,f=f+Math.imul(xe,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(se,gt)|0,f=f+Math.imul(se,yt)|0,f=f+Math.imul(ue,gt)|0,_=_+Math.imul(ue,yt)|0;var Oa=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Oa>>>26)|0,Oa&=67108863,y=Math.imul(Ye,rt),f=Math.imul(Ye,nt),f=f+Math.imul(Je,rt)|0,_=Math.imul(Je,nt),y=y+Math.imul(He,st)|0,f=f+Math.imul(He,it)|0,f=f+Math.imul(Ge,st)|0,_=_+Math.imul(Ge,it)|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(xe,pt)|0,f=f+Math.imul(xe,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 Ta=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Ta>>>26)|0,Ta&=67108863,y=Math.imul(Ye,st),f=Math.imul(Ye,it),f=f+Math.imul(Je,st)|0,_=Math.imul(Je,it),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(xe,gt)|0,f=f+Math.imul(xe,yt)|0,f=f+Math.imul(Ne,gt)|0,_=_+Math.imul(Ne,yt)|0;var Na=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Na>>>26)|0,Na&=67108863,y=Math.imul(Ye,ot),f=Math.imul(Ye,at),f=f+Math.imul(Je,ot)|0,_=Math.imul(Je,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 La=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(La>>>26)|0,La&=67108863,y=Math.imul(Ye,ct),f=Math.imul(Ye,ut),f=f+Math.imul(Je,ct)|0,_=Math.imul(Je,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 Ba=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Ba>>>26)|0,Ba&=67108863,y=Math.imul(Ye,ft),f=Math.imul(Ye,lt),f=f+Math.imul(Je,ft)|0,_=Math.imul(Je,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 Ca=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Ca>>>26)|0,Ca&=67108863,y=Math.imul(Ye,dt),f=Math.imul(Ye,ht),f=f+Math.imul(Je,dt)|0,_=Math.imul(Je,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 Pa=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Pa>>>26)|0,Pa&=67108863,y=Math.imul(Ye,pt),f=Math.imul(Ye,mt),f=f+Math.imul(Je,pt)|0,_=Math.imul(Je,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 Ma=(v+y|0)+((f&8191)<<13)|0;v=(_+(f>>>13)|0)+(Ma>>>26)|0,Ma&=67108863,y=Math.imul(Ye,gt),f=Math.imul(Ye,yt),f=f+Math.imul(Je,gt)|0,_=Math.imul(Je,yt);var Ua=(v+y|0)+((f&8191)<<13)|0;return v=(_+(f>>>13)|0)+(Ua>>>26)|0,Ua&=67108863,w[0]=ba,w[1]=wa,w[2]=Ea,w[3]=Ra,w[4]=va,w[5]=Sa,w[6]=xa,w[7]=Aa,w[8]=Ia,w[9]=ka,w[10]=Oa,w[11]=Ta,w[12]=Na,w[13]=La,w[14]=Ba,w[15]=Ca,w[16]=Pa,w[17]=Ma,w[18]=Ua,v!==0&&(w[19]=v,d.length++),d};Math.imul||(L=A);function U(E,a,l){l.negative=a.negative^E.negative,l.length=E.length+a.length;for(var d=0,h=0,g=0;g<l.length-1;g++){var w=h;h=0;for(var v=d&67108863,y=Math.min(g,a.length-1),f=Math.max(0,g-E.length+1);f<=y;f++){var _=g-f,C=E.words[_]|0,D=a.words[f]|0,$=C*D,X=$&67108863;w=w+($/67108864|0)|0,X=X+v|0,v=X&67108863,w=w+(X>>>26)|0,h+=w>>>26,w&=67108863}l.words[g]=v,d=w,w=h}return d!==0?l.words[g]=d:l.length--,l._strip()}function B(E,a,l){return U(E,a,l)}s.prototype.mulTo=function(a,l){var d,h=this.length+a.length;return this.length===10&&a.length===10?d=L(this,a,l):h<63?d=A(this,a,l):h<1024?d=U(this,a,l):d=B(this,a,l),d};function F(E,a){this.x=E,this.y=a}F.prototype.makeRBT=function(a){for(var l=new Array(a),d=s.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 v=0;v<w;v++)h[v]=l[a[v]],g[v]=d[a[v]]},F.prototype.transform=function(a,l,d,h,g,w){this.permute(w,a,l,d,h,g);for(var v=1;v<g;v<<=1)for(var y=v<<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<v;X++){var se=d[C+X],ue=h[C+X],Be=d[C+X+v],he=h[C+X+v],me=D*Be-$*he;he=D*he+$*Be,Be=me,d[C+X]=se+Be,h[C+X]=ue+he,d[C+X+v]=se-Be,h[C+X+v]=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),v=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,v,h),this.convert13b(l.words,l.length,_,h),this.transform(v,w,y,f,h,g),this.transform(_,w,C,D,h,g);for(var X=0;X<h;X++){var se=y[X]*C[X]-f[X]*D[X];f[X]=y[X]*D[X]+f[X]*C[X],y[X]=se}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()},s.prototype.mul=function(a){var l=new s(null);return l.words=new Array(this.length+a.length),this.mulTo(a,l)},s.prototype.mulf=function(a){var l=new s(null);return l.words=new Array(this.length+a.length),B(this,a,l)},s.prototype.imul=function(a){return this.clone().mulTo(a,this)},s.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},s.prototype.muln=function(a){return this.clone().imuln(a)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(a){var l=I(a);if(l.length===0)return new s(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},s.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 v=this.words[g]&h,y=(this.words[g]|0)-v<<l;this.words[g]=y|w,w=v>>>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()},s.prototype.ishln=function(a){return t(this.negative===0),this.iushln(a)},s.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),v=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&v}return y&&_!==0&&(y.words[y.length++]=_),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(a,l,d){return t(this.negative===0),this.iushrn(a,l,d)},s.prototype.shln=function(a){return this.clone().ishln(a)},s.prototype.ushln=function(a){return this.clone().iushln(a)},s.prototype.shrn=function(a){return this.clone().ishrn(a)},s.prototype.ushrn=function(a){return this.clone().iushrn(a)},s.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)},s.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()},s.prototype.maskn=function(a){return this.clone().imaskn(a)},s.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)},s.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},s.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()},s.prototype.addn=function(a){return this.clone().iaddn(a)},s.prototype.subn=function(a){return this.clone().isubn(a)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(a,l,d){var h=a.length+d,g;this._expand(h);var w,v=0;for(g=0;g<a.length;g++){w=(this.words[g+d]|0)+v;var y=(a.words[g]|0)*l;w-=y&67108863,v=(w>>26)-(y/67108864|0),this.words[g+d]=w&67108863}for(;g<this.length-d;g++)w=(this.words[g+d]|0)+v,v=w>>26,this.words[g+d]=w&67108863;if(v===0)return this._strip();for(t(v===-1),v=0,g=0;g<this.length;g++)w=-(this.words[g]|0)+v,v=w>>26,this.words[g]=w&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(a,l){var d=this.length-a.length,h=this.clone(),g=a,w=g.words[g.length-1]|0,v=this._countBits(w);d=26-v,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 s(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}},s.prototype.divmod=function(a,l,d){if(t(!a.isZero()),this.isZero())return{div:new s(0),mod:new s(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 s(0),mod:this}:a.length===1?l==="div"?{div:this.divn(a.words[0]),mod:null}:l==="mod"?{div:null,mod:new s(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new s(this.modrn(a.words[0]))}:this._wordDiv(a,l)},s.prototype.div=function(a){return this.divmod(a,"div",!1).div},s.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},s.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},s.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)},s.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},s.prototype.modn=function(a){return this.modrn(a)},s.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},s.prototype.divn=function(a){return this.clone().idivn(a)},s.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 s(1),g=new s(0),w=new s(0),v=new s(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()||v.isOdd())&&(w.iadd(f),v.isub(_)),w.iushrn(1),v.iushrn(1);l.cmp(d)>=0?(l.isub(d),h.isub(w),g.isub(v)):(d.isub(l),w.isub(h),v.isub(g))}return{a:w,b:v,gcd:d.iushln(y)}},s.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 s(1),g=new s(0),w=d.clone();l.cmpn(1)>0&&d.cmpn(1)>0;){for(var v=0,y=1;(l.words[0]&y)===0&&v<26;++v,y<<=1);if(v>0)for(l.iushrn(v);v-- >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},s.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)},s.prototype.invm=function(a){return this.egcd(a).a.umod(a)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(a){return this.words[0]&a},s.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 v=this.words[w]|0;v+=g,g=v>>>26,v&=67108863,this.words[w]=v}return g!==0&&(this.words[w]=g,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.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},s.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},s.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},s.prototype.gtn=function(a){return this.cmpn(a)===1},s.prototype.gt=function(a){return this.cmp(a)===1},s.prototype.gten=function(a){return this.cmpn(a)>=0},s.prototype.gte=function(a){return this.cmp(a)>=0},s.prototype.ltn=function(a){return this.cmpn(a)===-1},s.prototype.lt=function(a){return this.cmp(a)===-1},s.prototype.lten=function(a){return this.cmpn(a)<=0},s.prototype.lte=function(a){return this.cmp(a)<=0},s.prototype.eqn=function(a){return this.cmpn(a)===0},s.prototype.eq=function(a){return this.cmp(a)===0},s.red=function(a){return new re(a)},s.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)},s.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(a){return this.red=a,this},s.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},s.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},s.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},s.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},s.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},s.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},s.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},s.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},s.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.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 G(E,a){this.name=E,this.p=new s(a,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}G.prototype._tmp=function(){var a=new s(null);return a.words=new Array(Math.ceil(this.n/13)),a},G.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},G.prototype.split=function(a,l){a.iushrn(this.n,0,l)},G.prototype.imulK=function(a){return a.imul(this.k)};function Z(){G.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(Z,G),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 v=a.words[g]|0;a.words[g-10]=(v&d)<<4|w>>>22,w=v}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(){G.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ee,G);function Y(){G.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(Y,G);function Ie(){G.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Ie,G),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},s._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(E){if(typeof E=="string"){var a=s._prime(E);this.m=a.p,this.prime=a}else t(E.gtn(1),"modulus must be greater than 1"),this.m=E,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 s(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 s(1).toRed(this),v=w.redNeg(),y=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);this.pow(f,y).cmp(v)!==0;)f.redIAdd(v);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,se=0;X.cmp(w)!==0;se++)X=X.redSqr();t(se<$);var ue=this.pow(_,new s(1).iushln($-se-1));C=C.redMul(ue),_=ue.redSqr(),D=D.redMul(_),$=se}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 s(1).toRed(this);if(l.cmpn(1)===0)return a.clone();var d=4,h=new Array(1<<d);h[0]=new s(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],v=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&&v===0){y=0;continue}v<<=1,v|=D,y++,!(y!==d&&(g!==0||C!==0))&&(w=this.mul(w,h[v]),y=0,v=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},s.mont=function(a){return new fe(a)};function fe(E){re.call(this,E),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(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 s(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 Nc>"u"||Nc,Zl)});var Xl=$t((Bc,Jl)=>{var ao=qs(),br=ao.Buffer;function Yl(r,e){for(var t in r)e[t]=r[t]}br.from&&br.alloc&&br.allocUnsafe&&br.allocUnsafeSlow?Jl.exports=ao:(Yl(ao,Bc),Bc.Buffer=Vn);function Vn(r,e,t){return br(r,e,t)}Vn.prototype=Object.create(br.prototype);Yl(br,Vn);Vn.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return br(r,e,t)};Vn.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=br(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};Vn.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return br(r)};Vn.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return ao.SlowBuffer(r)}});var ed=$t((lx,Ql)=>{"use strict";var co=Xl().Buffer;function Cg(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 s=r.charAt(n),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=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=co.from(S)),!co.isBuffer(S))throw new TypeError("Expected Buffer");if(S.length===0)return"";for(var T=0,I=0,A=0,L=S.length;A!==L&&S[A]===0;)A++,T++;for(var U=(L-A)*p+1>>>0,B=new Uint8Array(U);A!==L;){for(var F=S[A],te=0,G=U-1;(F!==0||te<I)&&G!==-1;G--,te++)F+=256*B[G]>>>0,B[G]=F%o>>>0,F=F/o>>>0;if(F!==0)throw new Error("Non-zero carry");I=te,A++}for(var Z=U-I;Z!==U&&B[Z]===0;)Z++;for(var ee=c.repeat(T);Z<U;++Z)ee+=r.charAt(B[Z]);return ee}function b(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return co.alloc(0);for(var T=0,I=0,A=0;S[T]===c;)I++,T++;for(var L=(S.length-T)*u+1>>>0,U=new Uint8Array(L);T<S.length;){var B=S.charCodeAt(T);if(B>255)return;var F=e[B];if(F===255)return;for(var te=0,G=L-1;(F!==0||te<A)&&G!==-1;G--,te++)F+=o*U[G]>>>0,U[G]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");A=te,T++}for(var Z=L-A;Z!==L&&U[Z]===0;)Z++;var ee=co.allocUnsafe(I+(L-Z));ee.fill(0,0,I);for(var Y=I;Z!==L;)ee[Y++]=U[Z++];return ee}function x(S){var T=b(S);if(T)return T;throw new Error("Non-base"+o+" character")}return{encode:m,decodeUnsafe:b,decode:x}}Ql.exports=Cg});var Cc=$t((dx,td)=>{var Pg=ed(),Mg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";td.exports=Pg(Mg)});var rd=$t(Dc=>{"use strict";function Cr(r,e,t){return e<=r&&r<=t}function po(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function Dg(r){for(var e=String(r),t=e.length,n=0,s=[];n<t;){var i=e.charCodeAt(n);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(n===t-1)s.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var c=i&1023,u=o&1023;s.push(65536+(c<<10)+u),n+=1}else s.push(65533)}n+=1}return s}function zg(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 uo=-1;function Uc(r){this.tokens=[].slice.call(r)}Uc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():uo},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 _s=-1;function Mc(r,e){if(r)throw TypeError("Decoder error");return e||65533}var fo="utf-8";function lo(r,e){if(!(this instanceof lo))return new lo(r,e);if(r=r!==void 0?String(r).toLowerCase():fo,r!==fo)throw new Error("Encoding not supported. Only utf-8 is supported");e=po(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})}lo.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=po(t),this._streaming||(this._decoder=new Fg({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var s=new Uc(n),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==_s);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===_s)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),zg(i)}};function ho(r,e){if(!(this instanceof ho))return new ho(r,e);if(r=r!==void 0?String(r).toLowerCase():fo,r!==fo)throw new Error("Encoding not supported. Only utf-8 is supported");e=po(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}ho.prototype={encode:function(e,t){e=e?String(e):"",t=po(t),this._streaming||(this._encoder=new $g(this._options)),this._streaming=!!t.stream;for(var n=[],s=new Uc(Dg(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==_s);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==_s;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}};function Fg(r){var e=r.fatal,t=0,n=0,s=0,i=128,o=191;this.handler=function(c,u){if(u===uo&&s!==0)return s=0,Mc(e);if(u===uo)return _s;if(s===0){if(Cr(u,0,127))return u;if(Cr(u,194,223))s=1,t=u-192;else if(Cr(u,224,239))u===224&&(i=160),u===237&&(o=159),s=2,t=u-224;else if(Cr(u,240,244))u===240&&(i=144),u===244&&(o=143),s=3,t=u-240;else return Mc(e);return t=t<<6*s,null}if(!Cr(u,i,o))return t=s=n=0,i=128,o=191,c.prepend(u),Mc(e);if(i=128,o=191,n+=1,t+=u-128<<6*(s-n),n!==s)return null;var p=t;return t=s=n=0,p}}function $g(r){var e=r.fatal;this.handler=function(t,n){if(n===uo)return _s;if(Cr(n,0,127))return n;var s,i;Cr(n,128,2047)?(s=1,i=192):Cr(n,2048,65535)?(s=2,i=224):Cr(n,65536,1114111)&&(s=3,i=240);for(var o=[(n>>6*s)+i];s>0;){var c=n>>6*(s-1);o.push(128|c&63),s-=1}return o}}Dc.TextEncoder=ho;Dc.TextDecoder=lo});var ad=$t(Oe=>{"use strict";var Vg=Oe&&Oe.__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]}),Wg=Oe&&Oe.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),wr=Oe&&Oe.__decorate||function(r,e,t,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(i=(s<3?o(i):s>3?o(e,t,i):o(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i},qg=Oe&&Oe.__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)&&Vg(e,r,t);return Wg(e,r),e},nd=Oe&&Oe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.deserializeUnchecked=Oe.deserialize=Oe.serialize=Oe.BinaryReader=Oe.BinaryWriter=Oe.BorshError=Oe.baseDecode=Oe.baseEncode=void 0;var sn=nd(Lc()),sd=nd(Cc()),jg=qg(rd()),Kg=typeof TextDecoder!="function"?jg.TextDecoder:TextDecoder,Hg=new Kg("utf-8",{fatal:!0});function Gg(r){return typeof r=="string"&&(r=Buffer.from(r,"utf8")),sd.default.encode(Buffer.from(r))}Oe.baseEncode=Gg;function Zg(r){return Buffer.from(sd.default.decode(r))}Oe.baseDecode=Zg;var zc=1024,St=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(".")}};Oe.BorshError=St;var mo=class{constructor(){this.buf=Buffer.alloc(zc),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(zc)]))}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 sn.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new sn.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new sn.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new sn.default(e).toArray("le",64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(zc)]),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)}};Oe.BinaryWriter=mo;function Er(r,e,t){let n=t.value;t.value=function(...s){try{return n.apply(this,s)}catch(i){if(i instanceof RangeError){let o=i.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new St("Reached the end of buffer when deserializing")}throw i}}}var Dt=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 sn.default(e,"le")}readU128(){let e=this.readBuffer(16);return new sn.default(e,"le")}readU256(){let e=this.readBuffer(32);return new sn.default(e,"le")}readU512(){let e=this.readBuffer(64);return new sn.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new St(`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 Hg.decode(t)}catch(n){throw new St(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=Array();for(let s=0;s<t;++s)n.push(e());return n}};wr([Er],Dt.prototype,"readU8",null);wr([Er],Dt.prototype,"readU16",null);wr([Er],Dt.prototype,"readU32",null);wr([Er],Dt.prototype,"readU64",null);wr([Er],Dt.prototype,"readU128",null);wr([Er],Dt.prototype,"readU256",null);wr([Er],Dt.prototype,"readU512",null);wr([Er],Dt.prototype,"readString",null);wr([Er],Dt.prototype,"readFixedArray",null);wr([Er],Dt.prototype,"readArray",null);Oe.BinaryReader=Dt;function id(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Wn(r,e,t,n,s){try{if(typeof n=="string")s[`write${id(n)}`](t);else if(n instanceof Array)if(typeof n[0]=="number"){if(t.length!==n[0])throw new St(`Expecting byte array of length ${n[0]}, but got ${t.length} bytes`);s.writeFixedArray(t)}else if(n.length===2&&typeof n[1]=="number"){if(t.length!==n[1])throw new St(`Expecting byte array of length ${n[1]}, but got ${t.length} bytes`);for(let i=0;i<n[1];i++)Wn(r,null,t[i],n[0],s)}else s.writeArray(t,i=>{Wn(r,e,i,n[0],s)});else if(n.kind!==void 0)switch(n.kind){case"option":{t==null?s.writeU8(0):(s.writeU8(1),Wn(r,e,t,n.type,s));break}case"map":{s.writeU32(t.size),t.forEach((i,o)=>{Wn(r,e,o,n.key,s),Wn(r,e,i,n.value,s)});break}default:throw new St(`FieldType ${n} unrecognized`)}else od(r,t,s)}catch(i){throw i instanceof St&&i.addToFieldPath(e),i}}function od(r,e,t){if(typeof e.borshSerialize=="function"){e.borshSerialize(t);return}let n=r.get(e.constructor);if(!n)throw new St(`Class ${e.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([s,i])=>{Wn(r,s,e[s],i,t)});else if(n.kind==="enum"){let s=e[n.field];for(let i=0;i<n.values.length;++i){let[o,c]=n.values[i];if(o===s){t.writeU8(i),Wn(r,o,e[o],c,t);break}}}else throw new St(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function Yg(r,e,t=mo){let n=new t;return od(r,e,n),n.toArray()}Oe.serialize=Yg;function qn(r,e,t,n){try{if(typeof t=="string")return n[`read${id(t)}`]();if(t instanceof Array){if(typeof t[0]=="number")return n.readFixedArray(t[0]);if(typeof t[1]=="number"){let s=[];for(let i=0;i<t[1];i++)s.push(qn(r,null,t[0],n));return s}else return n.readArray(()=>qn(r,e,t[0],n))}if(t.kind==="option")return n.readU8()?qn(r,e,t.type,n):void 0;if(t.kind==="map"){let s=new Map,i=n.readU32();for(let o=0;o<i;o++){let c=qn(r,e,t.key,n),u=qn(r,e,t.value,n);s.set(c,u)}return s}return Fc(r,t,n)}catch(s){throw s instanceof St&&s.addToFieldPath(e),s}}function Fc(r,e,t){if(typeof e.borshDeserialize=="function")return e.borshDeserialize(t);let n=r.get(e);if(!n)throw new St(`Class ${e.name} is missing in schema`);if(n.kind==="struct"){let s={};for(let[i,o]of r.get(e).fields)s[i]=qn(r,i,o,t);return new e(s)}if(n.kind==="enum"){let s=t.readU8();if(s>=n.values.length)throw new St(`Enum index: ${s} is out of range`);let[i,o]=n.values[s],c=qn(r,i,o,t);return new e({[i]:c})}throw new St(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function Jg(r,e,t,n=Dt){let s=new n(t),i=Fc(r,e,s);if(s.offset<t.length)throw new St(`Unexpected ${t.length-s.offset} bytes after deserialized data`);return i}Oe.deserialize=Jg;function Xg(r,e,t,n=Dt){let s=new n(t);return Fc(r,e,s)}Oe.deserializeUnchecked=Xg});var qc=$t(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.s16=O.s8=O.nu64be=O.u48be=O.u40be=O.u32be=O.u24be=O.u16be=O.nu64=O.u48=O.u40=O.u32=O.u24=O.u16=O.u8=O.offset=O.greedy=O.Constant=O.UTF8=O.CString=O.Blob=O.Boolean=O.BitField=O.BitStructure=O.VariantLayout=O.Union=O.UnionLayoutDiscriminator=O.UnionDiscriminator=O.Structure=O.Sequence=O.DoubleBE=O.Double=O.FloatBE=O.Float=O.NearInt64BE=O.NearInt64=O.NearUInt64BE=O.NearUInt64=O.IntBE=O.Int=O.UIntBE=O.UInt=O.OffsetLayout=O.GreedyCount=O.ExternalLayout=O.bindConstructorLayout=O.nameWithProperty=O.Layout=O.uint8ArrayToBuffer=O.checkUint8Array=void 0;O.constant=O.utf8=O.cstr=O.blob=O.unionLayoutDiscriminator=O.union=O.seq=O.bits=O.struct=O.f64be=O.f64=O.f32be=O.f32=O.ns64be=O.s48be=O.s40be=O.s32be=O.s24be=O.s16be=O.ns64=O.s48=O.s40=O.s32=O.s24=void 0;var Vc=qs();function Es(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}O.checkUint8Array=Es;function Re(r){return Es(r),Vc.Buffer.from(r.buffer,r.byteOffset,r.length)}O.uint8ArrayToBuffer=Re;var ve=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){}};O.Layout=ve;function Wc(r,e){return e.property?r+"["+e.property+"]":r}O.nameWithProperty=Wc;function Qg(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 ve))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})}O.bindConstructorLayout=Qg;var Tt=class extends ve{isCount(){throw new Error("ExternalLayout is abstract")}};O.ExternalLayout=Tt;var go=class extends Tt{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){Es(e);let n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}};O.GreedyCount=go;var Ys=class extends Tt{constructor(e,t=0,n){if(!(e instanceof ve))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 Ht||this.layout instanceof Zt}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)}};O.OffsetLayout=Ys;var Ht=class extends ve{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return Re(e).readUIntLE(t,this.span)}encode(e,t,n=0){return Re(t).writeUIntLE(e,n,this.span),this.span}};O.UInt=Ht;var Zt=class extends ve{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return Re(e).readUIntBE(t,this.span)}encode(e,t,n=0){return Re(t).writeUIntBE(e,n,this.span),this.span}};O.UIntBE=Zt;var Pr=class extends ve{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return Re(e).readIntLE(t,this.span)}encode(e,t,n=0){return Re(t).writeIntLE(e,n,this.span),this.span}};O.Int=Pr;var on=class extends ve{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return Re(e).readIntBE(t,this.span)}encode(e,t,n=0){return Re(t).writeIntBE(e,n,this.span),this.span}};O.IntBE=on;var $c=Math.pow(2,32);function Bo(r){let e=Math.floor(r/$c),t=r-e*$c;return{hi32:e,lo32:t}}function Co(r,e){return r*$c+e}var yo=class extends ve{constructor(e){super(8,e)}decode(e,t=0){let n=Re(e),s=n.readUInt32LE(t),i=n.readUInt32LE(t+4);return Co(i,s)}encode(e,t,n=0){let s=Bo(e),i=Re(t);return i.writeUInt32LE(s.lo32,n),i.writeUInt32LE(s.hi32,n+4),8}};O.NearUInt64=yo;var _o=class extends ve{constructor(e){super(8,e)}decode(e,t=0){let n=Re(e),s=n.readUInt32BE(t),i=n.readUInt32BE(t+4);return Co(s,i)}encode(e,t,n=0){let s=Bo(e),i=Re(t);return i.writeUInt32BE(s.hi32,n),i.writeUInt32BE(s.lo32,n+4),8}};O.NearUInt64BE=_o;var bo=class extends ve{constructor(e){super(8,e)}decode(e,t=0){let n=Re(e),s=n.readUInt32LE(t),i=n.readInt32LE(t+4);return Co(i,s)}encode(e,t,n=0){let s=Bo(e),i=Re(t);return i.writeUInt32LE(s.lo32,n),i.writeInt32LE(s.hi32,n+4),8}};O.NearInt64=bo;var wo=class extends ve{constructor(e){super(8,e)}decode(e,t=0){let n=Re(e),s=n.readInt32BE(t),i=n.readUInt32BE(t+4);return Co(s,i)}encode(e,t,n=0){let s=Bo(e),i=Re(t);return i.writeInt32BE(s.hi32,n),i.writeUInt32BE(s.lo32,n+4),8}};O.NearInt64BE=wo;var Eo=class extends ve{constructor(e){super(4,e)}decode(e,t=0){return Re(e).readFloatLE(t)}encode(e,t,n=0){return Re(t).writeFloatLE(e,n),4}};O.Float=Eo;var Ro=class extends ve{constructor(e){super(4,e)}decode(e,t=0){return Re(e).readFloatBE(t)}encode(e,t,n=0){return Re(t).writeFloatBE(e,n),4}};O.FloatBE=Ro;var vo=class extends ve{constructor(e){super(8,e)}decode(e,t=0){return Re(e).readDoubleLE(t)}encode(e,t,n=0){return Re(t).writeDoubleLE(e,n),8}};O.Double=vo;var So=class extends ve{constructor(e){super(8,e)}decode(e,t=0){return Re(e).readDoubleBE(t)}encode(e,t,n=0){return Re(t).writeDoubleBE(e,n),8}};O.DoubleBE=So;var xo=class extends ve{constructor(e,t,n){if(!(e instanceof ve))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof Tt&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let s=-1;!(t instanceof Tt)&&0<e.span&&(s=t*e.span),super(s,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,s=this.count;if(s instanceof Tt&&(s=s.decode(e,t)),0<this.elementLayout.span)n=s*this.elementLayout.span;else{let i=0;for(;i<s;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],s=0,i=this.count;for(i instanceof Tt&&(i=i.decode(e,t));s<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),s+=1;return n}encode(e,t,n=0){let s=this.elementLayout,i=e.reduce((o,c)=>o+s.encode(c,t,n+o),0);return this.count instanceof Tt&&this.count.encode(e.length,t,n),i}};O.Sequence=xo;var Ao=class extends ve{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((i,o)=>i&&o instanceof ve,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(let i of e)if(0>i.span&&i.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let s=-1;try{s=e.reduce((i,o)=>i+o.getSpan(),0)}catch{}super(s,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((s,i)=>{let o=i.getSpan(e,t);return t+=o,s+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t=0){Es(e);let n=this.makeDestinationObject();for(let s of this.fields)if(s.property!==void 0&&(n[s.property]=s.decode(e,t)),t+=s.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){let s=n,i=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)))}i=n,n+=u}return i+o-s}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)}}};O.Structure=Ao;var Js=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")}};O.UnionDiscriminator=Js;var ws=class extends Js{constructor(e,t){if(!(e instanceof Tt&&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)}};O.UnionLayoutDiscriminator=ws;var Xs=class extends ve{constructor(e,t,n){let s;if(e instanceof Ht||e instanceof Zt)s=new ws(new Ys(e));else if(e instanceof Tt&&e.isCount())s=new ws(e);else if(e instanceof Js)s=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 ve))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 i=-1;t&&(i=t.span,0<=i&&(e instanceof Ht||e instanceof Zt)&&(i+=s.layout.span)),super(i,n),this.discriminator=s,this.usesPrefixDiscriminator=e instanceof Ht||e instanceof Zt,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,s=this.discriminator,i=s.decode(e,t),o=this.registry[i];if(o===void 0){let c=this.defaultLayout,u=0;this.usesPrefixDiscriminator&&(u=s.layout.span),n=this.makeDestinationObject(),n[s.property]=i,n[c.property]=c.decode(e,t+u)}else n=o.decode(e,t);return n}encode(e,t,n=0){let s=this.getSourceVariant(e);if(s===void 0){let i=this.discriminator,o=this.defaultLayout,c=0;return this.usesPrefixDiscriminator&&(c=i.layout.span),i.encode(e[i.property],t,n),c+o.encode(e[o.property],t,n+c)}return s.encode(e,t,n)}addVariant(e,t,n){let s=new Io(this,e,t,n);return this.registry[e]=s,s}getVariant(e,t=0){let n;return e instanceof Uint8Array?n=this.discriminator.decode(e,t):n=e,this.registry[n]}};O.Union=Xs;var Io=class extends ve{constructor(e,t,n,s){if(!(e instanceof Xs))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"&&s===void 0&&(s=n,n=null),n){if(!(n instanceof ve))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 s!="string")throw new TypeError("variant must have a String property")}let i=e.span;0>e.span&&(i=n?n.span:0,0<=i&&e.usesPrefixDiscriminator&&(i+=e.discriminator.layout.span)),super(i,s),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 s=0;return this.layout&&(s=this.layout.getSpan(e,t+n)),n+s}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let s=0;return this.union.usesPrefixDiscriminator&&(s=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+s):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let s=0;if(this.union.usesPrefixDiscriminator&&(s=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 i=s;if(this.layout&&(this.layout.encode(e[this.property],t,n+s),i+=this.layout.getSpan(t,n+s),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};O.VariantLayout=Io;function bs(r){return 0>r&&(r+=4294967296),r}var Qs=class extends ve{constructor(e,t,n){if(!(e instanceof Ht||e instanceof Zt))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 s=0;this._packedSetValue=function(i){return s=bs(i),this},this._packedGetValue=function(){return s}}decode(e,t=0){let n=this.makeDestinationObject(),s=this.word.decode(e,t);this._packedSetValue(s);for(let i of this.fields)i.property!==void 0&&(n[i.property]=i.decode(e));return n}encode(e,t,n=0){let s=this.word.decode(t,n);this._packedSetValue(s);for(let i of this.fields)if(i.property!==void 0){let o=e[i.property];o!==void 0&&i.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new ei(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new ko(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}};O.BitStructure=Qs;var ei=class{constructor(e,t,n){if(!(e instanceof Qs))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");let s=8*e.span,i=e.fields.reduce((o,c)=>o+c.bits,0);if(t+i>s)throw new Error("bits too long for span remainder ("+(s-i)+" of "+s+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=s-i-t),this.wordMask=bs(this.valueMask<<this.start),this.property=n}decode(e,t){let n=this.container._packedGetValue();return bs(n&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==bs(e&this.valueMask))throw new TypeError(Wc("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let t=this.container._packedGetValue(),n=bs(e<<this.start);this.container._packedSetValue(bs(t&~this.wordMask)|n)}};O.BitField=ei;var ko=class extends ei{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)}};O.Boolean=ko;var Oo=class extends ve{constructor(e,t){if(!(e instanceof Tt&&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 Tt||(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)),Re(e).slice(t,t+n)}encode(e,t,n){let s=this.length;if(this.length instanceof Tt&&(s=e.length),!(e instanceof Uint8Array&&s===e.length))throw new TypeError(Wc("Blob.encode",this)+" requires (length "+s+") Uint8Array as src");if(n+s>t.length)throw new RangeError("encoding overruns Uint8Array");let i=Re(e);return Re(t).write(i.toString("hex"),n,s,"hex"),this.length instanceof Tt&&this.length.encode(s,t,n),s}};O.Blob=Oo;var To=class extends ve{constructor(e){super(-1,e)}getSpan(e,t=0){Es(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 Re(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));let s=Vc.Buffer.from(e,"utf8"),i=s.length;if(n+i>t.length)throw new RangeError("encoding overruns Buffer");let o=Re(t);return s.copy(o,n),o[n+i]=0,i+1}};O.CString=To;var No=class extends ve{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 Es(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 Re(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));let s=Vc.Buffer.from(e,"utf8"),i=s.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(n+i>t.length)throw new RangeError("encoding overruns Buffer");return s.copy(Re(t),n),i}};O.UTF8=No;var Lo=class extends ve{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};O.Constant=Lo;O.greedy=(r,e)=>new go(r,e);O.offset=(r,e,t)=>new Ys(r,e,t);O.u8=r=>new Ht(1,r);O.u16=r=>new Ht(2,r);O.u24=r=>new Ht(3,r);O.u32=r=>new Ht(4,r);O.u40=r=>new Ht(5,r);O.u48=r=>new Ht(6,r);O.nu64=r=>new yo(r);O.u16be=r=>new Zt(2,r);O.u24be=r=>new Zt(3,r);O.u32be=r=>new Zt(4,r);O.u40be=r=>new Zt(5,r);O.u48be=r=>new Zt(6,r);O.nu64be=r=>new _o(r);O.s8=r=>new Pr(1,r);O.s16=r=>new Pr(2,r);O.s24=r=>new Pr(3,r);O.s32=r=>new Pr(4,r);O.s40=r=>new Pr(5,r);O.s48=r=>new Pr(6,r);O.ns64=r=>new bo(r);O.s16be=r=>new on(2,r);O.s24be=r=>new on(3,r);O.s32be=r=>new on(4,r);O.s40be=r=>new on(5,r);O.s48be=r=>new on(6,r);O.ns64be=r=>new wo(r);O.f32=r=>new Eo(r);O.f32be=r=>new Ro(r);O.f64=r=>new vo(r);O.f64be=r=>new So(r);O.struct=(r,e,t)=>new Ao(r,e,t);O.bits=(r,e,t)=>new Qs(r,e,t);O.seq=(r,e,t)=>new xo(r,e,t);O.union=(r,e,t)=>new Xs(r,e,t);O.unionLayoutDiscriminator=(r,e)=>new ws(r,e);O.blob=(r,e)=>new Oo(r,e);O.cstr=r=>new To(r);O.utf8=(r,e)=>new No(r,e);O.constant=(r,e)=>new Lo(r,e)});function ni(){if(!Do&&(Do=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Do))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Do(l1)}var Do,l1,tu=Ut(()=>{l1=new Uint8Array(16)});var Ad,Id=Ut(()=>{Ad=/^(?:[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 d1(r){return typeof r=="string"&&Ad.test(r)}var cn,si=Ut(()=>{Id();cn=d1});function h1(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(xt[r[e+0]]+xt[r[e+1]]+xt[r[e+2]]+xt[r[e+3]]+"-"+xt[r[e+4]]+xt[r[e+5]]+"-"+xt[r[e+6]]+xt[r[e+7]]+"-"+xt[r[e+8]]+xt[r[e+9]]+"-"+xt[r[e+10]]+xt[r[e+11]]+xt[r[e+12]]+xt[r[e+13]]+xt[r[e+14]]+xt[r[e+15]]).toLowerCase();if(!cn(t))throw TypeError("Stringified UUID is invalid");return t}var xt,zo,un,ii=Ut(()=>{si();xt=[];for(zo=0;zo<256;++zo)xt.push((zo+256).toString(16).substr(1));un=h1});function p1(r,e,t){var n=e&&t||0,s=e||new Array(16);r=r||{};var i=r.node||kd,o=r.clockseq!==void 0?r.clockseq:ru;if(i==null||o==null){var c=r.random||(r.rng||ni)();i==null&&(i=kd=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),o==null&&(o=ru=(c[6]<<8|c[7])&16383)}var u=r.msecs!==void 0?r.msecs:Date.now(),p=r.nsecs!==void 0?r.nsecs:su+1,m=u-nu+(p-su)/1e4;if(m<0&&r.clockseq===void 0&&(o=o+1&16383),(m<0||u>nu)&&r.nsecs===void 0&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");nu=u,su=p,ru=o,u+=122192928e5;var b=((u&268435455)*1e4+p)%4294967296;s[n++]=b>>>24&255,s[n++]=b>>>16&255,s[n++]=b>>>8&255,s[n++]=b&255;var x=u/4294967296*1e4&268435455;s[n++]=x>>>8&255,s[n++]=x&255,s[n++]=x>>>24&15|16,s[n++]=x>>>16&255,s[n++]=o>>>8|128,s[n++]=o&255;for(var S=0;S<6;++S)s[n+S]=i[S];return e||un(s)}var kd,ru,nu,su,Od,Td=Ut(()=>{tu();ii();nu=0,su=0;Od=p1});function m1(r){if(!cn(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 Fo,iu=Ut(()=>{si();Fo=m1});function g1(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}function $o(r,e,t){function n(s,i,o,c){if(typeof s=="string"&&(s=g1(s)),typeof i=="string"&&(i=Fo(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+s.length);if(u.set(i),u.set(s,i.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 un(u)}try{n.name=r}catch{}return n.DNS=y1,n.URL=_1,n}var y1,_1,ou=Ut(()=>{ii();iu();y1="6ba7b810-9dad-11d1-80b4-00c04fd430c8",_1="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function b1(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 w1(E1(R1(r),r.length*8))}function w1(r){for(var e=[],t=r.length*32,n="0123456789abcdef",s=0;s<t;s+=8){var i=r[s>>5]>>>s%32&255,o=parseInt(n.charAt(i>>>4&15)+n.charAt(i&15),16);e.push(o)}return e}function Nd(r){return(r+64>>>9<<4)+14+1}function E1(r,e){r[e>>5]|=128<<e%32,r[Nd(e)-1]=e;for(var t=1732584193,n=-271733879,s=-1732584194,i=271733878,o=0;o<r.length;o+=16){var c=t,u=n,p=s,m=i;t=Lt(t,n,s,i,r[o],7,-680876936),i=Lt(i,t,n,s,r[o+1],12,-389564586),s=Lt(s,i,t,n,r[o+2],17,606105819),n=Lt(n,s,i,t,r[o+3],22,-1044525330),t=Lt(t,n,s,i,r[o+4],7,-176418897),i=Lt(i,t,n,s,r[o+5],12,1200080426),s=Lt(s,i,t,n,r[o+6],17,-1473231341),n=Lt(n,s,i,t,r[o+7],22,-45705983),t=Lt(t,n,s,i,r[o+8],7,1770035416),i=Lt(i,t,n,s,r[o+9],12,-1958414417),s=Lt(s,i,t,n,r[o+10],17,-42063),n=Lt(n,s,i,t,r[o+11],22,-1990404162),t=Lt(t,n,s,i,r[o+12],7,1804603682),i=Lt(i,t,n,s,r[o+13],12,-40341101),s=Lt(s,i,t,n,r[o+14],17,-1502002290),n=Lt(n,s,i,t,r[o+15],22,1236535329),t=Bt(t,n,s,i,r[o+1],5,-165796510),i=Bt(i,t,n,s,r[o+6],9,-1069501632),s=Bt(s,i,t,n,r[o+11],14,643717713),n=Bt(n,s,i,t,r[o],20,-373897302),t=Bt(t,n,s,i,r[o+5],5,-701558691),i=Bt(i,t,n,s,r[o+10],9,38016083),s=Bt(s,i,t,n,r[o+15],14,-660478335),n=Bt(n,s,i,t,r[o+4],20,-405537848),t=Bt(t,n,s,i,r[o+9],5,568446438),i=Bt(i,t,n,s,r[o+14],9,-1019803690),s=Bt(s,i,t,n,r[o+3],14,-187363961),n=Bt(n,s,i,t,r[o+8],20,1163531501),t=Bt(t,n,s,i,r[o+13],5,-1444681467),i=Bt(i,t,n,s,r[o+2],9,-51403784),s=Bt(s,i,t,n,r[o+7],14,1735328473),n=Bt(n,s,i,t,r[o+12],20,-1926607734),t=Ct(t,n,s,i,r[o+5],4,-378558),i=Ct(i,t,n,s,r[o+8],11,-2022574463),s=Ct(s,i,t,n,r[o+11],16,1839030562),n=Ct(n,s,i,t,r[o+14],23,-35309556),t=Ct(t,n,s,i,r[o+1],4,-1530992060),i=Ct(i,t,n,s,r[o+4],11,1272893353),s=Ct(s,i,t,n,r[o+7],16,-155497632),n=Ct(n,s,i,t,r[o+10],23,-1094730640),t=Ct(t,n,s,i,r[o+13],4,681279174),i=Ct(i,t,n,s,r[o],11,-358537222),s=Ct(s,i,t,n,r[o+3],16,-722521979),n=Ct(n,s,i,t,r[o+6],23,76029189),t=Ct(t,n,s,i,r[o+9],4,-640364487),i=Ct(i,t,n,s,r[o+12],11,-421815835),s=Ct(s,i,t,n,r[o+15],16,530742520),n=Ct(n,s,i,t,r[o+2],23,-995338651),t=Pt(t,n,s,i,r[o],6,-198630844),i=Pt(i,t,n,s,r[o+7],10,1126891415),s=Pt(s,i,t,n,r[o+14],15,-1416354905),n=Pt(n,s,i,t,r[o+5],21,-57434055),t=Pt(t,n,s,i,r[o+12],6,1700485571),i=Pt(i,t,n,s,r[o+3],10,-1894986606),s=Pt(s,i,t,n,r[o+10],15,-1051523),n=Pt(n,s,i,t,r[o+1],21,-2054922799),t=Pt(t,n,s,i,r[o+8],6,1873313359),i=Pt(i,t,n,s,r[o+15],10,-30611744),s=Pt(s,i,t,n,r[o+6],15,-1560198380),n=Pt(n,s,i,t,r[o+13],21,1309151649),t=Pt(t,n,s,i,r[o+4],6,-145523070),i=Pt(i,t,n,s,r[o+11],10,-1120210379),s=Pt(s,i,t,n,r[o+2],15,718787259),n=Pt(n,s,i,t,r[o+9],21,-343485551),t=fn(t,c),n=fn(n,u),s=fn(s,p),i=fn(i,m)}return[t,n,s,i]}function R1(r){if(r.length===0)return[];for(var e=r.length*8,t=new Uint32Array(Nd(e)),n=0;n<e;n+=8)t[n>>5]|=(r[n/8]&255)<<n%32;return t}function fn(r,e){var t=(r&65535)+(e&65535),n=(r>>16)+(e>>16)+(t>>16);return n<<16|t&65535}function v1(r,e){return r<<e|r>>>32-e}function Vo(r,e,t,n,s,i){return fn(v1(fn(fn(e,r),fn(n,i)),s),t)}function Lt(r,e,t,n,s,i,o){return Vo(e&t|~e&n,r,e,s,i,o)}function Bt(r,e,t,n,s,i,o){return Vo(e&n|t&~n,r,e,s,i,o)}function Ct(r,e,t,n,s,i,o){return Vo(e^t^n,r,e,s,i,o)}function Pt(r,e,t,n,s,i,o){return Vo(t^(e|~n),r,e,s,i,o)}var Ld,Bd=Ut(()=>{Ld=b1});var S1,Cd,Pd=Ut(()=>{ou();Bd();S1=$o("v3",48,Ld),Cd=S1});function x1(r,e,t){r=r||{};var n=r.random||(r.rng||ni)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=n[s];return e}return un(n)}var Md,Ud=Ut(()=>{tu();ii();Md=x1});function A1(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 au(r,e){return r<<e|r>>>32-e}function I1(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 s=0;s<n.length;++s)r.push(n.charCodeAt(s))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var i=r.length/4+2,o=Math.ceil(i/16),c=new Array(o),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 x=new Uint32Array(80),S=0;S<16;++S)x[S]=c[b][S];for(var T=16;T<80;++T)x[T]=au(x[T-3]^x[T-8]^x[T-14]^x[T-16],1);for(var I=t[0],A=t[1],L=t[2],U=t[3],B=t[4],F=0;F<80;++F){var te=Math.floor(F/20),G=au(I,5)+A1(te,A,L,U)+B+e[te]+x[F]>>>0;B=U,U=L,L=au(A,30)>>>0,A=I,I=G}t[0]=t[0]+I>>>0,t[1]=t[1]+A>>>0,t[2]=t[2]+L>>>0,t[3]=t[3]+U>>>0,t[4]=t[4]+B>>>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 Dd,zd=Ut(()=>{Dd=I1});var k1,Fd,$d=Ut(()=>{ou();zd();k1=$o("v5",80,Dd),Fd=k1});var Vd,Wd=Ut(()=>{Vd="00000000-0000-0000-0000-000000000000"});function O1(r){if(!cn(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}var qd,jd=Ut(()=>{si();qd=O1});var cu={};dr(cu,{NIL:()=>Vd,parse:()=>Fo,stringify:()=>un,v1:()=>Od,v3:()=>Cd,v4:()=>Md,v5:()=>Fd,validate:()=>cn,version:()=>qd});var uu=Ut(()=>{Td();Pd();Ud();$d();Wd();jd();si();ii();iu()});var Hd=$t((lA,Kd)=>{"use strict";var T1=(uu(),Da(cu)).v4,N1=function(r,e,t,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};let s=typeof n.version=="number"?n.version:2;if(s!==1&&s!==2)throw new TypeError(s+" must be 1 or 2");let i={method:r};if(s===2&&(i.jsonrpc="2.0"),e){if(typeof e!="object"&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");i.params=e}if(typeof t>"u"){let o=typeof n.generator=="function"?n.generator:function(){return T1()};i.id=o(i,n)}else s===2&&t===null?n.notificationIdNull&&(i.id=null):i.id=t;return i};Kd.exports=N1});var Zd=$t((dA,Gd)=>{"use strict";var L1=(uu(),Da(cu)).v4,B1=Hd(),oi=function(r,e){if(!(this instanceof oi))return new oi(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 L1()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=r};Gd.exports=oi;oi.prototype.request=function(r,e,t,n){let s=this,i=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,i=r;else{typeof t=="function"&&(n=t,t=void 0);let p=typeof n=="function";try{i=B1(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 i}let u;try{u=JSON.stringify(i,this.options.replacer)}catch(p){return n(p)}return this.callServer(u,function(p,m){s._parseResponse(p,m,n)}),i};oi.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(s){return t(s)}if(t.length===3)if(Array.isArray(n)){let s=function(o){return typeof o.error<"u"},i=function(o){return!s(o)};return t(null,n.filter(s),n.filter(i))}else return t(null,n.error,n.result);t(null,n)}});var Jd=$t((hA,fu)=>{"use strict";var C1=Object.prototype.hasOwnProperty,zt="~";function ai(){}Object.create&&(ai.prototype=Object.create(null),new ai().__proto__||(zt=!1));function P1(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Yd(r,e,t,n,s){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new P1(t,n||r,s),o=zt?zt+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],i]:r._events[o].push(i):(r._events[o]=i,r._eventsCount++),r}function Wo(r,e){--r._eventsCount===0?r._events=new ai:delete r._events[e]}function Mt(){this._events=new ai,this._eventsCount=0}Mt.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)C1.call(t,n)&&e.push(zt?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Mt.prototype.listeners=function(e){var t=zt?zt+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var s=0,i=n.length,o=new Array(i);s<i;s++)o[s]=n[s].fn;return o};Mt.prototype.listenerCount=function(e){var t=zt?zt+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Mt.prototype.emit=function(e,t,n,s,i,o){var c=zt?zt+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,s),!0;case 5:return u.fn.call(u.context,t,n,s,i),!0;case 6:return u.fn.call(u.context,t,n,s,i,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 x=u.length,S;for(b=0;b<x;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,s);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};Mt.prototype.on=function(e,t,n){return Yd(this,e,t,n,!1)};Mt.prototype.once=function(e,t,n){return Yd(this,e,t,n,!0)};Mt.prototype.removeListener=function(e,t,n,s){var i=zt?zt+e:e;if(!this._events[i])return this;if(!t)return Wo(this,i),this;var o=this._events[i];if(o.fn)o.fn===t&&(!s||o.once)&&(!n||o.context===n)&&Wo(this,i);else{for(var c=0,u=[],p=o.length;c<p;c++)(o[c].fn!==t||s&&!o[c].once||n&&o[c].context!==n)&&u.push(o[c]);u.length?this._events[i]=u.length===1?u[0]:u:Wo(this,i)}return this};Mt.prototype.removeAllListeners=function(e){var t;return e?(t=zt?zt+e:e,this._events[t]&&Wo(this,t)):(this._events=new ai,this._eventsCount=0),this};Mt.prototype.off=Mt.prototype.removeListener;Mt.prototype.addListener=Mt.prototype.on;Mt.prefixed=zt;Mt.EventEmitter=Mt;typeof fu<"u"&&(fu.exports=Mt)});var xv={};dr(xv,{AddMiniApp:()=>rs,Back:()=>qa,ComposeCast:()=>kf,Context:()=>Mf,DEFAULT_READY_OPTIONS:()=>$a,Errors:()=>Cs,Ethereum:()=>Pf,Haptics:()=>Of,Manifest:()=>Uf,QuickAuth:()=>pf,Ready:()=>Va,SendToken:()=>Tf,SignIn:()=>gn,SolanaConnection:()=>na,SwapToken:()=>Nf,ViewCast:()=>Lf,ViewProfile:()=>Bf,ViewToken:()=>Cf,actionLaunchFrameSchema:()=>Yf,actionSchema:()=>Xf,actionViewTokenSchema:()=>Jf,aspectRatioSchema:()=>Za,buttonSchema:()=>Qf,buttonTitleSchema:()=>$s,caip19TokenSchema:()=>Ga,createSimpleStringSchema:()=>jr,createSolanaWalletProvider:()=>qu,default:()=>Sv,domainFrameConfigSchema:()=>ol,domainManifestSchema:()=>rm,encodedJsonFarcasterSignatureSchema:()=>Ya,eventFrameAddedSchema:()=>tl,eventFrameRemovedSchema:()=>rl,eventNotificationsEnabledSchema:()=>nl,frameEmbedNextSchema:()=>el,frameHost:()=>le,frameNameSchema:()=>Fs,hexColorSchema:()=>Vs,jsonFarcasterSignatureHeaderSchema:()=>Yp,miniAppHostCapabilityList:()=>Di,notificationDetailsSchema:()=>ji,notificationsDisabledSchema:()=>sl,quickAuth:()=>Ls,safeParseFrameEmbed:()=>Jp,sdk:()=>gf,secureUrlSchema:()=>vt,sendNotificationRequestSchema:()=>Xp,sendNotificationResponseSchema:()=>Qp,serverEventSchema:()=>em,unwrapSolanaProviderRequest:()=>Hu,wrapSolanaProviderRequest:()=>qR});var rs={};dr(rs,{InvalidDomainManifest:()=>za,RejectedByUser:()=>Fa});var Cs={};dr(Cs,{BaseError:()=>Fr});var Fr=class extends Error{name="BaseError";cause;constructor(e,t={}){super(e,t.cause?{cause:t.cause}:void 0),this.cause=t.cause}};var za=class extends Fr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}},Fa=class extends Fr{name="AddMiniApp.RejectedByUser";constructor(){super("Add frame rejected by user")}};var kf={};var Of={};var Va={};dr(Va,{DEFAULT_READY_OPTIONS:()=>$a});var $a={disableNativeGestures:!1};var gn={};dr(gn,{RejectedByUser:()=>Wa});var Wa=class extends Fr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};var Tf={};var Nf={};var Lf={};var Bf={};var Cf={};var Pf={};var qa={};dr(qa,{DEFAULT_BACK_STATE:()=>P0});var P0={visible:!1};var Mf={};var Uf={};var Di=["wallet.getEthereumProvider","wallet.getSolanaProvider","actions.ready","actions.openUrl","actions.close","actions.setPrimaryButton","actions.addMiniApp","actions.signIn","actions.viewCast","actions.viewProfile","actions.composeCast","actions.viewToken","actions.sendToken","actions.swapToken","haptics.impactOccurred","haptics.notificationOccurred","haptics.selectionChanged","back"];var K={};dr(K,{BRAND:()=>ap,DIRTY:()=>yn,EMPTY_PATH:()=>z0,INVALID:()=>ie,NEVER:()=>jp,OK:()=>Ot,ParseStatus:()=>Rt,Schema:()=>ge,ZodAny:()=>Wr,ZodArray:()=>Ir,ZodBigInt:()=>bn,ZodBoolean:()=>wn,ZodBranded:()=>Ds,ZodCatch:()=>Nn,ZodDate:()=>En,ZodDefault:()=>Tn,ZodDiscriminatedUnion:()=>Vi,ZodEffects:()=>tr,ZodEnum:()=>kn,ZodError:()=>Vt,ZodFirstPartyTypeKind:()=>oe,ZodFunction:()=>qi,ZodIntersection:()=>xn,ZodIssueCode:()=>M,ZodLazy:()=>An,ZodLiteral:()=>In,ZodMap:()=>cs,ZodNaN:()=>fs,ZodNativeEnum:()=>On,ZodNever:()=>ir,ZodNull:()=>vn,ZodNullable:()=>mr,ZodNumber:()=>_n,ZodObject:()=>Wt,ZodOptional:()=>Qt,ZodParsedType:()=>H,ZodPipeline:()=>zs,ZodPromise:()=>qr,ZodReadonly:()=>Ln,ZodRecord:()=>Wi,ZodSchema:()=>ge,ZodSet:()=>us,ZodString:()=>Vr,ZodSymbol:()=>os,ZodTransformer:()=>tr,ZodTuple:()=>pr,ZodType:()=>ge,ZodUndefined:()=>Rn,ZodUnion:()=>Sn,ZodUnknown:()=>Ar,ZodVoid:()=>as,addIssueToContext:()=>W,any:()=>gp,array:()=>wp,bigint:()=>lp,boolean:()=>Zf,coerce:()=>qp,custom:()=>Kf,date:()=>dp,datetimeRegex:()=>qf,defaultErrorMap:()=>Sr,discriminatedUnion:()=>Sp,effect:()=>Mp,enum:()=>Bp,function:()=>Tp,getErrorMap:()=>ns,getParsedType:()=>hr,instanceof:()=>up,intersection:()=>xp,isAborted:()=>zi,isAsync:()=>ss,isDirty:()=>Fi,isValid:()=>$r,late:()=>cp,lazy:()=>Np,literal:()=>Lp,makeIssue:()=>Ps,map:()=>kp,nan:()=>fp,nativeEnum:()=>Cp,never:()=>_p,null:()=>mp,nullable:()=>Dp,number:()=>Gf,object:()=>Ep,objectUtil:()=>ja,oboolean:()=>Wp,onumber:()=>Vp,optional:()=>Up,ostring:()=>$p,pipeline:()=>Fp,preprocess:()=>zp,promise:()=>Pp,quotelessJson:()=>M0,record:()=>Ip,set:()=>Op,setErrorMap:()=>D0,strictObject:()=>Rp,string:()=>Hf,symbol:()=>hp,transformer:()=>Mp,tuple:()=>Ap,undefined:()=>pp,union:()=>vp,unknown:()=>yp,util:()=>_e,void:()=>bp});var _e;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},r.getValidEnumValues=s=>{let i=r.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(let c of i)o[c]=s[c];return r.objectValues(o)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},r.find=(s,i)=>{for(let o of s)if(i(o))return o},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(_e||(_e={}));var ja;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(ja||(ja={}));var H=_e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),hr=r=>{switch(typeof r){case"undefined":return H.undefined;case"string":return H.string;case"number":return Number.isNaN(r)?H.nan:H.number;case"boolean":return H.boolean;case"function":return H.function;case"bigint":return H.bigint;case"symbol":return H.symbol;case"object":return Array.isArray(r)?H.array:r===null?H.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?H.promise:typeof Map<"u"&&r instanceof Map?H.map:typeof Set<"u"&&r instanceof Set?H.set:typeof Date<"u"&&r instanceof Date?H.date:H.object;default:return H.unknown}};var M=_e.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"]),M0=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),Vt=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(i){return i.message},n={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(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 s(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,_e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Vt.create=r=>new Vt(r);var U0=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===H.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,_e.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${_e.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_e.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${_e.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}"`:_e.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,_e.assertNever(r)}return{message:t}},Sr=U0;var Df=Sr;function D0(r){Df=r}function ns(){return Df}var Ps=r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="",u=n.filter(p=>!!p).slice().reverse();for(let p of u)c=p(o,{data:e,defaultError:c}).message;return{...s,path:i,message:c}},z0=[];function W(r,e){let t=ns(),n=Ps({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Sr?void 0:Sr].filter(s=>!!s)});r.common.issues.push(n)}var Rt=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 s of t){if(s.status==="aborted")return ie;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return ie;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}},ie=Object.freeze({status:"aborted"}),yn=r=>({status:"dirty",value:r}),Ot=r=>({status:"valid",value:r}),zi=r=>r.status==="aborted",Fi=r=>r.status==="dirty",$r=r=>r.status==="valid",ss=r=>typeof Promise<"u"&&r instanceof Promise;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 $i=function(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)},$f=function(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t},Ms,Us,er=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},zf=(r,e)=>{if($r(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 Vt(r.common.issues);return this._error=t,this._error}}};function de(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=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:s}:{errorMap:(o,c)=>{let{message:u}=r;return o.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:u??n??c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:u??t??c.defaultError}},description:s}}var ge=class{get description(){return this._def.description}_getType(e){return hr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:hr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Rt,ctx:{common:e.parent.common,data:e.data,parsedType:hr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ss(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){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:hr(e)},s=this._parseSync({data:e,path:n.path,parent:n});return zf(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:hr(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return $r(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>$r(n)?{value:n.value}:{issues:t.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:hr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(ss(s)?s:Promise.resolve(s));return zf(n,i)}refine(e,t){let n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{let o=e(s),c=()=>i.addIssue({code:M.custom,...n(s)});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,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new tr({schema:this,typeName:oe.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 mr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ir.create(this)}promise(){return qr.create(this,this._def)}or(e){return Sn.create([this,e],this._def)}and(e){return xn.create(this,e,this._def)}transform(e){return new tr({...de(this._def),schema:this,typeName:oe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Tn({...de(this._def),innerType:this,defaultValue:t,typeName:oe.ZodDefault})}brand(){return new Ds({typeName:oe.ZodBranded,type:this,...de(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Nn({...de(this._def),innerType:this,catchValue:t,typeName:oe.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return zs.create(this,e)}readonly(){return Ln.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},F0=/^c[^\s-]{8,}$/i,$0=/^[0-9a-z]+$/,V0=/^[0-9A-HJKMNP-TV-Z]{26}$/i,W0=/^[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,q0=/^[a-z0-9_-]{21}$/i,j0=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,K0=/^[-+]?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)?)??$/,H0=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,G0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ka,Z0=/^(?:(?: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])$/,Y0=/^(?:(?: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])$/,J0=/^(([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]))$/,X0=/^(([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])$/,Q0=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ep=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Vf="((\\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])))",tp=new RegExp(`^${Vf}$`);function Wf(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function rp(r){return new RegExp(`^${Wf(r)}$`)}function qf(r){let e=`${Vf}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 np(r,e){return!!((e==="v4"||!e)&&Z0.test(r)||(e==="v6"||!e)&&J0.test(r))}function sp(r,e){if(!j0.test(r))return!1;try{let[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function ip(r,e){return!!((e==="v4"||!e)&&Y0.test(r)||(e==="v6"||!e)&&X0.test(r))}var Vr=class r extends ge{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==H.string){let i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:H.string,received:i.parsedType}),ie}let n=new Rt,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,c=e.data.length<i.value;(o||c)&&(s=this._getOrReturnCtx(e,s),o?W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")H0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Ka||(Ka=new RegExp(G0,"u")),Ka.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")W0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")q0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")F0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")$0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")V0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:M.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"regex",code:M.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?qf(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?tp.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?rp(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?K0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?np(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?sp(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"jwt",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?ip(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cidr",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Q0.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?ep.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64url",code:M.invalid_string,message:i.message}),n.dirty()):_e.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{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){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:e?.offset??!1,local:e?.local??!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}};Vr.create=r=>new Vr({checks:[],typeName:oe.ZodString,coerce:r?.coerce??!1,...de(r)});function op(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=Number.parseInt(r.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var _n=class r extends ge{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)!==H.number){let i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:H.number,received:i.parsedType}),ie}let n,s=new Rt;for(let i of this._def.checks)i.kind==="int"?_e.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?op(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_finite,message:i.message}),s.dirty()):_e.assertNever(i);return{status:s.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,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:J.toString(s)}]})}_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"&&_e.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)}};_n.create=r=>new _n({checks:[],typeName:oe.ZodNumber,coerce:r?.coerce||!1,...de(r)});var bn=class r extends ge{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)!==H.bigint)return this._getInvalidInput(e);let n,s=new Rt;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):_e.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:H.bigint,received:t.parsedType}),ie}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,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:J.toString(s)}]})}_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}};bn.create=r=>new bn({checks:[],typeName:oe.ZodBigInt,coerce:r?.coerce??!1,...de(r)});var wn=class extends ge{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==H.boolean){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.boolean,received:n.parsedType}),ie}return Ot(e.data)}};wn.create=r=>new wn({typeName:oe.ZodBoolean,coerce:r?.coerce||!1,...de(r)});var En=class r extends ge{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==H.date){let i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:H.date,received:i.parsedType}),ie}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_date}),ie}let n=new Rt,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):_e.assertNever(i);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}};En.create=r=>new En({checks:[],coerce:r?.coerce||!1,typeName:oe.ZodDate,...de(r)});var os=class extends ge{_parse(e){if(this._getType(e)!==H.symbol){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.symbol,received:n.parsedType}),ie}return Ot(e.data)}};os.create=r=>new os({typeName:oe.ZodSymbol,...de(r)});var Rn=class extends ge{_parse(e){if(this._getType(e)!==H.undefined){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.undefined,received:n.parsedType}),ie}return Ot(e.data)}};Rn.create=r=>new Rn({typeName:oe.ZodUndefined,...de(r)});var vn=class extends ge{_parse(e){if(this._getType(e)!==H.null){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.null,received:n.parsedType}),ie}return Ot(e.data)}};vn.create=r=>new vn({typeName:oe.ZodNull,...de(r)});var Wr=class extends ge{constructor(){super(...arguments),this._any=!0}_parse(e){return Ot(e.data)}};Wr.create=r=>new Wr({typeName:oe.ZodAny,...de(r)});var Ar=class extends ge{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ot(e.data)}};Ar.create=r=>new Ar({typeName:oe.ZodUnknown,...de(r)});var ir=class extends ge{_parse(e){let t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:H.never,received:t.parsedType}),ie}};ir.create=r=>new ir({typeName:oe.ZodNever,...de(r)});var as=class extends ge{_parse(e){if(this._getType(e)!==H.undefined){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.void,received:n.parsedType}),ie}return Ot(e.data)}};as.create=r=>new as({typeName:oe.ZodVoid,...de(r)});var Ir=class r extends ge{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==H.array)return W(t,{code:M.invalid_type,expected:H.array,received:t.parsedType}),ie;if(s.exactLength!==null){let o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(W(t,{code:o?M.too_big:M.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(W(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(W(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new er(t,o,t.path,c)))).then(o=>Rt.mergeArray(n,o));let i=[...t.data].map((o,c)=>s.type._parseSync(new er(t,o,t.path,c)));return Rt.mergeArray(n,i)}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)}};Ir.create=(r,e)=>new Ir({type:r,minLength:null,maxLength:null,exactLength:null,typeName:oe.ZodArray,...de(e)});function is(r){if(r instanceof Wt){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=Qt.create(is(n))}return new Wt({...r._def,shape:()=>e})}else return r instanceof Ir?new Ir({...r._def,type:is(r.element)}):r instanceof Qt?Qt.create(is(r.unwrap())):r instanceof mr?mr.create(is(r.unwrap())):r instanceof pr?pr.create(r.items.map(e=>is(e))):r}var Wt=class r extends ge{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=_e.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==H.object){let p=this._getOrReturnCtx(e);return W(p,{code:M.invalid_type,expected:H.object,received:p.parsedType}),ie}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof ir&&this._def.unknownKeys==="strip"))for(let p in s.data)o.includes(p)||c.push(p);let u=[];for(let p of o){let m=i[p],b=s.data[p];u.push({key:{status:"valid",value:p},value:m._parse(new er(s,b,s.path,p)),alwaysSet:p in s.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:s.data[m]}});else if(p==="strict")c.length>0&&(W(s,{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=s.data[m];u.push({key:{status:"valid",value:m},value:p._parse(new er(s,b,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let p=[];for(let m of u){let b=await m.key,x=await m.value;p.push({key:b,value:x,alwaysSet:m.alwaysSet})}return p}).then(p=>Rt.mergeObjectSync(n,p)):Rt.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)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:J.errToObj(e).message??s}:{message:s}}}:{}})}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:oe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let n of _e.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let n of _e.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}deepPartial(){return is(this)}partial(e){let t={};for(let n of _e.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let n of _e.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof Qt;)i=i._def.innerType;t[n]=i}return new r({...this._def,shape:()=>t})}keyof(){return jf(_e.objectKeys(this.shape))}};Wt.create=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strip",catchall:ir.create(),typeName:oe.ZodObject,...de(e)});Wt.strictCreate=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strict",catchall:ir.create(),typeName:oe.ZodObject,...de(e)});Wt.lazycreate=(r,e)=>new Wt({shape:r,unknownKeys:"strip",catchall:ir.create(),typeName:oe.ZodObject,...de(e)});var Sn=class extends ge{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(let c of i)if(c.result.status==="valid")return c.result;for(let c of i)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;let o=i.map(c=>new Vt(c.ctx.common.issues));return W(t,{code:M.invalid_union,unionErrors:o}),ie}if(t.common.async)return Promise.all(n.map(async i=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let i,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"&&!i&&(i={result:m,ctx:p}),p.common.issues.length&&o.push(p.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let c=o.map(u=>new Vt(u));return W(t,{code:M.invalid_union,unionErrors:c}),ie}}get options(){return this._def.options}};Sn.create=(r,e)=>new Sn({options:r,typeName:oe.ZodUnion,...de(e)});var xr=r=>r instanceof An?xr(r.schema):r instanceof tr?xr(r.innerType()):r instanceof In?[r.value]:r instanceof kn?r.options:r instanceof On?_e.objectValues(r.enum):r instanceof Tn?xr(r._def.innerType):r instanceof Rn?[void 0]:r instanceof vn?[null]:r instanceof Qt?[void 0,...xr(r.unwrap())]:r instanceof mr?[null,...xr(r.unwrap())]:r instanceof Ds||r instanceof Ln?xr(r.unwrap()):r instanceof Nn?xr(r._def.innerType):[],Vi=class r extends ge{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.object)return W(t,{code:M.invalid_type,expected:H.object,received:t.parsedType}),ie;let n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let i of t){let o=xr(i.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(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,i)}}return new r({typeName:oe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...de(n)})}};function Ha(r,e){let t=hr(r),n=hr(e);if(r===e)return{valid:!0,data:r};if(t===H.object&&n===H.object){let s=_e.objectKeys(e),i=_e.objectKeys(r).filter(c=>s.indexOf(c)!==-1),o={...r,...e};for(let c of i){let u=Ha(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===H.array&&n===H.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<r.length;i++){let o=r[i],c=e[i],u=Ha(o,c);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===H.date&&n===H.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var xn=class extends ge{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(i,o)=>{if(zi(i)||zi(o))return ie;let c=Ha(i.value,o.value);return c.valid?((Fi(i)||Fi(o))&&t.dirty(),{status:t.value,value:c.data}):(W(n,{code:M.invalid_intersection_types}),ie)};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(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};xn.create=(r,e,t)=>new xn({left:r,right:e,typeName:oe.ZodIntersection,...de(t)});var pr=class r extends ge{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.array)return W(n,{code:M.invalid_type,expected:H.array,received:n.parsedType}),ie;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"}),ie;!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 i=[...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(i).then(o=>Rt.mergeArray(t,o)):Rt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};pr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pr({items:r,typeName:oe.ZodTuple,rest:null,...de(e)})};var Wi=class r extends ge{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!==H.object)return W(n,{code:M.invalid_type,expected:H.object,received:n.parsedType}),ie;let s=[],i=this._def.keyType,o=this._def.valueType;for(let c in n.data)s.push({key:i._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?Rt.mergeObjectAsync(t,s):Rt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof ge?new r({keyType:e,valueType:t,typeName:oe.ZodRecord,...de(n)}):new r({keyType:Vr.create(),valueType:e,typeName:oe.ZodRecord,...de(t)})}},cs=class extends ge{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!==H.map)return W(n,{code:M.invalid_type,expected:H.map,received:n.parsedType}),ie;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([c,u],p)=>({key:s._parse(new er(n,c,n.path,[p,"key"])),value:i._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 ie;(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 ie;(p.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(p.value,m.value)}return{status:t.value,value:c}}}};cs.create=(r,e,t)=>new cs({valueType:e,keyType:r,typeName:oe.ZodMap,...de(t)});var us=class r extends ge{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.set)return W(n,{code:M.invalid_type,expected:H.set,received:n.parsedType}),ie;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let i=this._def.valueType;function o(u){let p=new Set;for(let m of u){if(m.status==="aborted")return ie;m.status==="dirty"&&t.dirty(),p.add(m.value)}return{status:t.value,value:p}}let c=[...n.data.values()].map((u,p)=>i._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)}};us.create=(r,e)=>new us({valueType:r,minSize:null,maxSize:null,typeName:oe.ZodSet,...de(e)});var qi=class r extends ge{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.function)return W(t,{code:M.invalid_type,expected:H.function,received:t.parsedType}),ie;function n(c,u){return Ps({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ns(),Sr].filter(p=>!!p),issueData:{code:M.invalid_arguments,argumentsError:u}})}function s(c,u){return Ps({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ns(),Sr].filter(p=>!!p),issueData:{code:M.invalid_return_type,returnTypeError:u}})}let i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof qr){let c=this;return Ot(async function(...u){let p=new Vt([]),m=await c._def.args.parseAsync(u,i).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,i).catch(S=>{throw p.addIssue(s(b,S)),p})})}else{let c=this;return Ot(function(...u){let p=c._def.args.safeParse(u,i);if(!p.success)throw new Vt([n(u,p.error)]);let m=Reflect.apply(o,this,p.data),b=c._def.returns.safeParse(m,i);if(!b.success)throw new Vt([s(m,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:pr.create(e).rest(Ar.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||pr.create([]).rest(Ar.create()),returns:t||Ar.create(),typeName:oe.ZodFunction,...de(n)})}},An=class extends ge{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})}};An.create=(r,e)=>new An({getter:r,typeName:oe.ZodLazy,...de(e)});var In=class extends ge{_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}),ie}return{status:"valid",value:e.data}}get value(){return this._def.value}};In.create=(r,e)=>new In({value:r,typeName:oe.ZodLiteral,...de(e)});function jf(r,e){return new kn({values:r,typeName:oe.ZodEnum,...de(e)})}var kn=class r extends ge{constructor(){super(...arguments),Ms.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:_e.joinValues(n),received:t.parsedType,code:M.invalid_type}),ie}if($i(this,Ms,"f")||$f(this,Ms,new Set(this._def.values),"f"),!$i(this,Ms,"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}),ie}return Ot(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})}};Ms=new WeakMap;kn.create=jf;var On=class extends ge{constructor(){super(...arguments),Us.set(this,void 0)}_parse(e){let t=_e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==H.string&&n.parsedType!==H.number){let s=_e.objectValues(t);return W(n,{expected:_e.joinValues(s),received:n.parsedType,code:M.invalid_type}),ie}if($i(this,Us,"f")||$f(this,Us,new Set(_e.getValidEnumValues(this._def.values)),"f"),!$i(this,Us,"f").has(e.data)){let s=_e.objectValues(t);return W(n,{received:n.data,code:M.invalid_enum_value,options:s}),ie}return Ot(e.data)}get enum(){return this._def.values}};Us=new WeakMap;On.create=(r,e)=>new On({values:r,typeName:oe.ZodNativeEnum,...de(e)});var qr=class extends ge{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.promise&&t.common.async===!1)return W(t,{code:M.invalid_type,expected:H.promise,received:t.parsedType}),ie;let n=t.parsedType===H.promise?t.data:Promise.resolve(t.data);return Ot(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qr.create=(r,e)=>new qr({type:r,typeName:oe.ZodPromise,...de(e)});var tr=class extends ge{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===oe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{W(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return ie;let u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?ie:u.status==="dirty"?yn(u.value):t.value==="dirty"?yn(u.value):u});{if(t.value==="aborted")return ie;let c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?ie:c.status==="dirty"?yn(c.value):t.value==="dirty"?yn(c.value):c}}if(s.type==="refinement"){let o=c=>{let u=s.refinement(c,i);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"?ie:(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"?ie:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!$r(o))return o;let c=s.transform(o.value,i);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=>$r(o)?Promise.resolve(s.transform(o.value,i)).then(c=>({status:t.value,value:c})):o);_e.assertNever(s)}};tr.create=(r,e,t)=>new tr({schema:r,typeName:oe.ZodEffects,effect:e,...de(t)});tr.createWithPreprocess=(r,e,t)=>new tr({schema:e,effect:{type:"preprocess",transform:r},typeName:oe.ZodEffects,...de(t)});var Qt=class extends ge{_parse(e){return this._getType(e)===H.undefined?Ot(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Qt.create=(r,e)=>new Qt({innerType:r,typeName:oe.ZodOptional,...de(e)});var mr=class extends ge{_parse(e){return this._getType(e)===H.null?Ot(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};mr.create=(r,e)=>new mr({innerType:r,typeName:oe.ZodNullable,...de(e)});var Tn=class extends ge{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===H.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Tn.create=(r,e)=>new Tn({innerType:r,typeName:oe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...de(e)});var Nn=class extends ge{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ss(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Vt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Vt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Nn.create=(r,e)=>new Nn({innerType:r,typeName:oe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...de(e)});var fs=class extends ge{_parse(e){if(this._getType(e)!==H.nan){let n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:H.nan,received:n.parsedType}),ie}return{status:"valid",value:e.data}}};fs.create=r=>new fs({typeName:oe.ZodNaN,...de(r)});var ap=Symbol("zod_brand"),Ds=class extends ge{_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}},zs=class r extends ge{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ie:i.status==="dirty"?(t.dirty(),yn(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ie:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:oe.ZodPipeline})}},Ln=class extends ge{_parse(e){let t=this._def.innerType._parse(e),n=s=>($r(s)&&(s.value=Object.freeze(s.value)),s);return ss(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};Ln.create=(r,e)=>new Ln({innerType:r,typeName:oe.ZodReadonly,...de(e)});function Ff(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Kf(r,e={},t){return r?Wr.create().superRefine((n,s)=>{let i=r(n);if(i instanceof Promise)return i.then(o=>{if(!o){let c=Ff(e,n),u=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:u})}});if(!i){let o=Ff(e,n),c=o.fatal??t??!0;s.addIssue({code:"custom",...o,fatal:c})}}):Wr.create()}var cp={object:Wt.lazycreate},oe;(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"})(oe||(oe={}));var up=(r,e={message:`Input not instance of ${r.name}`})=>Kf(t=>t instanceof r,e),Hf=Vr.create,Gf=_n.create,fp=fs.create,lp=bn.create,Zf=wn.create,dp=En.create,hp=os.create,pp=Rn.create,mp=vn.create,gp=Wr.create,yp=Ar.create,_p=ir.create,bp=as.create,wp=Ir.create,Ep=Wt.create,Rp=Wt.strictCreate,vp=Sn.create,Sp=Vi.create,xp=xn.create,Ap=pr.create,Ip=Wi.create,kp=cs.create,Op=us.create,Tp=qi.create,Np=An.create,Lp=In.create,Bp=kn.create,Cp=On.create,Pp=qr.create,Mp=tr.create,Up=Qt.create,Dp=mr.create,zp=tr.createWithPreprocess,Fp=zs.create,$p=()=>Hf().optional(),Vp=()=>Gf().optional(),Wp=()=>Zf().optional(),qp={string:r=>Vr.create({...r,coerce:!0}),number:r=>_n.create({...r,coerce:!0}),boolean:r=>wn.create({...r,coerce:!0}),bigint:r=>bn.create({...r,coerce:!0}),date:r=>En.create({...r,coerce:!0})};var jp=ie;var Kp=/[@#$%^&*+=\/\\|~«»]/,Hp=/(!{2,}|\?{2,}|-{2,})/,Gp=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,jr=({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=>!Gp.test(n),{message:"Emojis and symbols are not allowed"}).refine(n=>!Kp.test(n),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, \xAB, \xBB) are not allowed"}).refine(n=>!Hp.test(n),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),vt=K.string().url().startsWith("https://",{message:"Must be an https url"}).max(1024),Fs=K.string().max(32),$s=K.string().max(32),Zp=/^[-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)$/,Ga=K.string().regex(Zp,{message:"Invalid CAIP-19 asset ID"}),Vs=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."}),Za=K.union([K.literal("1:1"),K.literal("3:2")]),Ya=K.object({header:K.string(),payload:K.string(),signature:K.string()}),Yp=K.object({fid:K.number(),type:K.literal("app_key"),key:K.string().startsWith("0x")});var Yf=K.object({type:K.literal("launch_frame"),name:Fs,url:vt.optional(),splashImageUrl:vt.optional(),splashBackgroundColor:Vs.optional()}),Jf=K.object({type:K.literal("view_token"),token:Ga}),Xf=K.discriminatedUnion("type",[Yf,Jf]),Qf=K.object({title:$s,action:Xf}),el=K.object({version:K.literal("next"),imageUrl:vt,aspectRatio:Za.optional(),button:Qf}),Jp=r=>el.safeParse(r);var ji=K.object({url:K.string(),token:K.string()}),Xp=K.object({notificationId:K.string().max(128),title:K.string().max(32),body:K.string().max(128),targetUrl:vt,tokens:K.string().array().max(100)}),Qp=K.object({result:K.object({successfulTokens:K.array(K.string()),invalidTokens:K.array(K.string()),rateLimitedTokens:K.array(K.string())})});var tl=K.object({event:K.literal("frame_added"),notificationDetails:ji.optional()}),rl=K.object({event:K.literal("frame_removed")}),nl=K.object({event:K.literal("notifications_enabled"),notificationDetails:ji.required()}),sl=K.object({event:K.literal("notifications_disabled")}),em=K.discriminatedUnion("event",[tl,rl,nl,sl]);var tm=K.enum(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),il=["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"],ol=K.object({version:K.union([K.literal("0.0.0"),K.literal("0.0.1"),K.literal("1"),K.literal("next")]),name:Fs,iconUrl:vt,homeUrl:vt,imageUrl:vt.optional(),buttonTitle:$s.optional(),splashImageUrl:vt.optional(),splashBackgroundColor:Vs.optional(),webhookUrl:vt.optional(),subtitle:jr({max:30}).optional(),description:jr({max:170}).optional(),screenshotUrls:K.array(vt).max(3).optional(),primaryCategory:tm.optional(),tags:K.array(jr({max:20,noSpaces:!0})).max(5).optional(),heroImageUrl:vt.optional(),tagline:jr({max:30}).optional(),ogTitle:jr({max:30}).optional(),ogDescription:jr({max:100}).optional(),ogImageUrl:vt.optional(),noindex:K.boolean().optional(),requiredChains:K.array(K.enum(il)).max(il.length).optional(),requiredCapabilities:K.array(K.enum(Di)).max(Di.length).optional(),castShareUrl:vt.optional()}).refine(r=>{if(r.castShareUrl===void 0)return!0;try{let e=new URL(r.homeUrl).hostname,t=new URL(r.castShareUrl).hostname;return e===t}catch{return!1}},{message:"castShareUrl must have the same domain as homeUrl",path:["castShareUrl"]}),rm=K.object({accountAssociation:Ya,frame:ol.optional()});var ae=vr(qs());function js(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Pm(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Hr(r,...e){if(!Pm(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");js(r.outputLen),js(r.blockLen)}function Or(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 Zi(r,e){Hr(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Pn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function kl(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function Yi(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function or(r,e){return r<<32-e|r>>>e}var ac=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Mm(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function cc(r){for(let e=0;e<r.length;e++)r[e]=Mm(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 Zr(r){return typeof r=="string"&&(r=Ol(r)),Hr(r),r}function uc(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];Hr(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let i=r[n];t.set(i,s),s+=i.length}return t}var Gr=class{clone(){return this._cloneInto()}};function ms(r){let e=n=>r().update(Zr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Tl(r){let e=(n,s)=>r(s).update(Zr(n)).digest(),t=r({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}function Ji(r=32){if(Pn&&typeof Pn.getRandomValues=="function")return Pn.getRandomValues(new Uint8Array(r));if(Pn&&typeof Pn.randomBytes=="function")return Pn.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Um(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),c=Number(t&i),u=n?4:0,p=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+p,c,n)}function Nl(r,e,t){return r&e^~r&t}function Ll(r,e,t){return r&e^r&t^e&t}var gs=class extends Gr{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Yi(this.buffer)}update(e){Or(this);let{view:t,buffer:n,blockLen:s}=this;e=Zr(e);let i=e.length;for(let o=0;o<i;){let c=Math.min(s-this.pos,i-o);if(c===s){let u=Yi(e);for(;s<=i-o;o+=s)this.process(u,o);continue}n.set(e.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Or(this),Zi(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:s,isLE:i}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(n,0),o=0);for(let b=o;b<s;b++)t[b]=0;Um(n,s-8,BigInt(this.length*8),i),this.process(n,0);let c=Yi(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],i)}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:s,finished:i,destroyed:o,pos:c}=this;return e.length=s,e.pos=c,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(n),e}};var Xi=BigInt(4294967295),fc=BigInt(32);function Bl(r,e=!1){return e?{h:Number(r&Xi),l:Number(r>>fc&Xi)}:{h:Number(r>>fc&Xi)|0,l:Number(r&Xi)|0}}function lc(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:i,l:o}=Bl(r[s],e);[t[s],n[s]]=[i,o]}return[t,n]}var Dm=(r,e)=>BigInt(r>>>0)<<fc|BigInt(e>>>0),zm=(r,e,t)=>r>>>t,Fm=(r,e,t)=>r<<32-t|e>>>t,$m=(r,e,t)=>r>>>t|e<<32-t,Vm=(r,e,t)=>r<<32-t|e>>>t,Wm=(r,e,t)=>r<<64-t|e>>>t-32,qm=(r,e,t)=>r>>>t-32|e<<64-t,jm=(r,e)=>e,Km=(r,e)=>r,dc=(r,e,t)=>r<<t|e>>>32-t,hc=(r,e,t)=>e<<t|r>>>32-t,pc=(r,e,t)=>e<<t-32|r>>>64-t,mc=(r,e,t)=>r<<t-32|e>>>64-t;function Hm(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var Gm=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Zm=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Ym=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Jm=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,Xm=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),Qm=(r,e,t,n,s,i)=>e+t+n+s+i+(r/2**32|0)|0;var eg={fromBig:Bl,split:lc,toBig:Dm,shrSH:zm,shrSL:Fm,rotrSH:$m,rotrSL:Vm,rotrBH:Wm,rotrBL:qm,rotr32H:jm,rotr32L:Km,rotlSH:dc,rotlSL:hc,rotlBH:pc,rotlBL:mc,add:Hm,add3L:Gm,add3H:Zm,add4L:Ym,add4H:Jm,add5H:Qm,add5L:Xm},pe=eg;var[tg,rg]=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))),Yr=new Uint32Array(80),Jr=new Uint32Array(80),gc=class extends gs{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:s,Ch:i,Cl:o,Dh:c,Dl:u,Eh:p,El:m,Fh:b,Fl:x,Gh:S,Gl:T,Hh:I,Hl:A}=this;return[e,t,n,s,i,o,c,u,p,m,b,x,S,T,I,A]}set(e,t,n,s,i,o,c,u,p,m,b,x,S,T,I,A){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|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=x|0,this.Gh=S|0,this.Gl=T|0,this.Hh=I|0,this.Hl=A|0}process(e,t){for(let B=0;B<16;B++,t+=4)Yr[B]=e.getUint32(t),Jr[B]=e.getUint32(t+=4);for(let B=16;B<80;B++){let F=Yr[B-15]|0,te=Jr[B-15]|0,G=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=Yr[B-2]|0,Y=Jr[B-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,Jr[B-7],Jr[B-16]),E=pe.add4H(fe,G,Ie,Yr[B-7],Yr[B-16]);Yr[B]=E|0,Jr[B]=fe|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:c,Cl:u,Dh:p,Dl:m,Eh:b,El:x,Fh:S,Fl:T,Gh:I,Gl:A,Hh:L,Hl:U}=this;for(let B=0;B<80;B++){let F=pe.rotrSH(b,x,14)^pe.rotrSH(b,x,18)^pe.rotrBH(b,x,41),te=pe.rotrSL(b,x,14)^pe.rotrSL(b,x,18)^pe.rotrBL(b,x,41),G=b&S^~b&I,Z=x&T^~x&A,ee=pe.add5L(U,te,Z,rg[B],Jr[B]),Y=pe.add5H(ee,L,F,G,tg[B],Yr[B]),Ie=ee|0,re=pe.rotrSH(n,s,28)^pe.rotrBH(n,s,34)^pe.rotrBH(n,s,39),fe=pe.rotrSL(n,s,28)^pe.rotrBL(n,s,34)^pe.rotrBL(n,s,39),E=n&i^n&c^i&c,a=s&o^s&u^o&u;L=I|0,U=A|0,I=S|0,A=T|0,S=b|0,T=x|0,{h:b,l:x}=pe.add(p|0,m|0,Y|0,Ie|0),p=c|0,m=u|0,c=i|0,u=o|0,i=n|0,o=s|0;let l=pe.add3L(Ie,fe,a);n=pe.add3H(l,Y,re,E),s=l|0}({h:n,l:s}=pe.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=pe.add(this.Bh|0,this.Bl|0,i|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:x}=pe.add(this.Eh|0,this.El|0,b|0,x|0),{h:S,l:T}=pe.add(this.Fh|0,this.Fl|0,S|0,T|0),{h:I,l:A}=pe.add(this.Gh|0,this.Gl|0,I|0,A|0),{h:L,l:U}=pe.add(this.Hh|0,this.Hl|0,L|0,U|0),this.set(n,s,i,o,c,u,p,m,b,x,S,T,I,A,L,U)}roundClean(){Yr.fill(0),Jr.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 Cl=ms(()=>new gc);var to={};dr(to,{aInRange:()=>jt,abool:()=>ar,abytes:()=>ys,bitGet:()=>cg,bitLen:()=>wc,bitMask:()=>Hs,bitSet:()=>ug,bytesToHex:()=>Nr,bytesToNumberBE:()=>Lr,bytesToNumberLE:()=>Qr,concatBytes:()=>Br,createHmacDrbg:()=>Ec,ensureBytes:()=>We,equalBytes:()=>og,hexToBytes:()=>Un,hexToNumber:()=>bc,inRange:()=>Ks,isBytes:()=>Xr,memoized:()=>zn,notImplemented:()=>lg,numberToBytesBE:()=>en,numberToBytesLE:()=>Dn,numberToHexUnpadded:()=>Mn,numberToVarBytesBE:()=>ig,utf8ToBytes:()=>ag,validateObject:()=>_r});var Qi=BigInt(0),eo=BigInt(1),ng=BigInt(2);function Xr(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ys(r){if(!Xr(r))throw new Error("Uint8Array expected")}function ar(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}var sg=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Nr(r){ys(r);let e="";for(let t=0;t<r.length;t++)e+=sg[r[t]];return e}function Mn(r){let e=r.toString(16);return e.length&1?"0"+e:e}function bc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Qi:BigInt("0x"+r)}var Tr={_0:48,_9:57,A:65,F:70,a:97,f:102};function Pl(r){if(r>=Tr._0&&r<=Tr._9)return r-Tr._0;if(r>=Tr.A&&r<=Tr.F)return r-(Tr.A-10);if(r>=Tr.a&&r<=Tr.f)return r-(Tr.a-10)}function Un(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 s=0,i=0;s<t;s++,i+=2){let o=Pl(r.charCodeAt(i)),c=Pl(r.charCodeAt(i+1));if(o===void 0||c===void 0){let u=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+i)}n[s]=o*16+c}return n}function Lr(r){return bc(Nr(r))}function Qr(r){return ys(r),bc(Nr(Uint8Array.from(r).reverse()))}function en(r,e){return Un(r.toString(16).padStart(e*2,"0"))}function Dn(r,e){return en(r,e).reverse()}function ig(r){return Un(Mn(r))}function We(r,e,t){let n;if(typeof e=="string")try{n=Un(e)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(Xr(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let s=n.length;if(typeof t=="number"&&s!==t)throw new Error(r+" of length "+t+" expected, got "+s);return n}function Br(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];ys(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let i=r[n];t.set(i,s),s+=i.length}return t}function og(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 ag(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var yc=r=>typeof r=="bigint"&&Qi<=r;function Ks(r,e,t){return yc(r)&&yc(e)&&yc(t)&&e<=r&&r<t}function jt(r,e,t,n){if(!Ks(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function wc(r){let e;for(e=0;r>Qi;r>>=eo,e+=1);return e}function cg(r,e){return r>>BigInt(e)&eo}function ug(r,e,t){return r|(t?eo:Qi)<<BigInt(e)}var Hs=r=>(ng<<BigInt(r-1))-eo,_c=r=>new Uint8Array(r),Ml=r=>Uint8Array.from(r);function Ec(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=_c(r),s=_c(r),i=0,o=()=>{n.fill(1),s.fill(0),i=0},c=(...b)=>t(s,n,...b),u=(b=_c())=>{s=c(Ml([0]),b),n=c(),b.length!==0&&(s=c(Ml([1]),b),n=c())},p=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let b=0,x=[];for(;b<e;){n=c();let S=n.slice();x.push(S),b+=n.length}return Br(...x)};return(b,x)=>{o(),u(b);let S;for(;!(S=x(p()));)u();return o(),S}}var fg={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"||Xr(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 _r(r,e,t={}){let n=(s,i,o)=>{let c=fg[i];if(typeof c!="function")throw new Error("invalid validator function");let u=r[s];if(!(o&&u===void 0)&&!c(u,r))throw new Error("param "+String(s)+" is invalid. Expected "+i+", got "+u)};for(let[s,i]of Object.entries(e))n(s,i,!1);for(let[s,i]of Object.entries(t))n(s,i,!0);return r}var lg=()=>{throw new Error("not implemented")};function zn(r){let e=new WeakMap;return(t,...n)=>{let s=e.get(t);if(s!==void 0)return s;let i=r(t,...n);return e.set(t,i),i}}var _t=BigInt(0),Ce=BigInt(1),Fn=BigInt(2),dg=BigInt(3),Rc=BigInt(4),Ul=BigInt(5),Dl=BigInt(8),hg=BigInt(9),pg=BigInt(16);function ke(r,e){let t=r%e;return t>=_t?t:e+t}function mg(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 ro(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=ke(r,e),n=e,s=_t,i=Ce,o=Ce,c=_t;for(;t!==_t;){let p=n/t,m=n%t,b=s-o*p,x=i-c*p;n=t,t=m,s=o,i=c,o=b,c=x}if(n!==Ce)throw new Error("invert: does not exist");return ke(s,e)}function gg(r){let e=(r-Ce)/Fn,t,n,s;for(t=r-Ce,n=0;t%Fn===_t;t/=Fn,n++);for(s=Fn;s<r&&mg(s,e,r)!==r-Ce;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let o=(r+Ce)/Rc;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 i=(t+Ce)/Fn;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,s),t),b=c.pow(u,i),x=c.pow(u,t);for(;!c.eql(x,c.ONE);){if(c.eql(x,c.ZERO))return c.ZERO;let S=1;for(let I=c.sqr(x);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),x=c.mul(x,m),p=S}return b}}function yg(r){if(r%Rc===dg){let e=(r+Ce)/Rc;return function(n,s){let i=n.pow(s,e);if(!n.eql(n.sqr(i),s))throw new Error("Cannot find square root");return i}}if(r%Dl===Ul){let e=(r-Ul)/Dl;return function(n,s){let i=n.mul(s,Fn),o=n.pow(i,e),c=n.mul(s,o),u=n.mul(n.mul(c,Fn),o),p=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(p),s))throw new Error("Cannot find square root");return p}}return r%pg,gg(r)}var zl=(r,e)=>(ke(r,e)&Ce)===Ce,_g=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vc(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=_g.reduce((n,s)=>(n[s]="function",n),e);return _r(r,t)}function bg(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,s=e;for(;t>_t;)t&Ce&&(n=r.mul(n,s)),s=r.sqr(s),t>>=Ce;return n}function wg(r,e){let t=new Array(e.length),n=e.reduce((i,o,c)=>r.is0(o)?i:(t[c]=i,r.mul(i,o)),r.ONE),s=r.inv(n);return e.reduceRight((i,o,c)=>r.is0(o)?i:(t[c]=r.mul(i,t[c]),r.mul(i,o)),s),t}function Sc(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function tn(r,e,t=!1,n={}){if(r<=_t)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:s,nByteLength:i}=Sc(r,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o,c=Object.freeze({ORDER:r,isLE:t,BITS:s,BYTES:i,MASK:Hs(s),ZERO:_t,ONE:Ce,create:u=>ke(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=>ke(-u,r),eql:(u,p)=>u===p,sqr:u=>ke(u*u,r),add:(u,p)=>ke(u+p,r),sub:(u,p)=>ke(u-p,r),mul:(u,p)=>ke(u*p,r),pow:(u,p)=>bg(c,u,p),div:(u,p)=>ke(u*ro(p,r),r),sqrN:u=>u*u,addN:(u,p)=>u+p,subN:(u,p)=>u-p,mulN:(u,p)=>u*p,inv:u=>ro(u,r),sqrt:n.sqrt||(u=>(o||(o=yg(r)),o(c,u))),invertBatch:u=>wg(c,u),cmov:(u,p,m)=>m?p:u,toBytes:u=>t?Dn(u,i):en(u,i),fromBytes:u=>{if(u.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+u.length);return t?Qr(u):Lr(u)}});return Object.freeze(c)}function Fl(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 xc(r){let e=Fl(r);return e+Math.ceil(e/2)}function $l(r,e,t=!1){let n=r.length,s=Fl(e),i=xc(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let o=t?Qr(r):Lr(r),c=ke(o,e-Ce)+Ce;return t?Dn(c,s):en(c,s)}var Vl=BigInt(0),no=BigInt(1);function Ac(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 Ic(r,e){Wl(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function Eg(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 Rg(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 kc=new WeakMap,ql=new WeakMap;function Oc(r){return ql.get(r)||1}function so(r,e){return{constTimeNegate:Ac,hasPrecomputes(t){return Oc(t)!==1},unsafeLadder(t,n,s=r.ZERO){let i=t;for(;n>Vl;)n&no&&(s=s.add(i)),i=i.double(),n>>=no;return s},precomputeWindow(t,n){let{windows:s,windowSize:i}=Ic(n,e),o=[],c=t,u=c;for(let p=0;p<s;p++){u=c,o.push(u);for(let m=1;m<i;m++)u=u.add(c),o.push(u);c=u.double()}return o},wNAF(t,n,s){let{windows:i,windowSize:o}=Ic(t,e),c=r.ZERO,u=r.BASE,p=BigInt(2**t-1),m=2**t,b=BigInt(t);for(let x=0;x<i;x++){let S=x*o,T=Number(s&p);s>>=b,T>o&&(T-=m,s+=no);let I=S,A=S+Math.abs(T)-1,L=x%2!==0,U=T<0;T===0?u=u.add(Ac(L,n[I])):c=c.add(Ac(U,n[A]))}return{p:c,f:u}},wNAFUnsafe(t,n,s,i=r.ZERO){let{windows:o,windowSize:c}=Ic(t,e),u=BigInt(2**t-1),p=2**t,m=BigInt(t);for(let b=0;b<o;b++){let x=b*c;if(s===Vl)break;let S=Number(s&u);if(s>>=m,S>c&&(S-=p,s+=no),S===0)continue;let T=n[x+Math.abs(S)-1];S<0&&(T=T.negate()),i=i.add(T)}return i},getPrecomputes(t,n,s){let i=kc.get(n);return i||(i=this.precomputeWindow(n,t),t!==1&&kc.set(n,s(i))),i},wNAFCached(t,n,s){let i=Oc(t);return this.wNAF(i,this.getPrecomputes(i,t,s),n)},wNAFCachedUnsafe(t,n,s,i){let o=Oc(t);return o===1?this.unsafeLadder(t,n,i):this.wNAFUnsafe(o,this.getPrecomputes(o,t,s),n,i)},setWindowSize(t,n){Wl(n,e),ql.set(t,n),kc.delete(t)}}}function io(r,e,t,n){if(Eg(t,r),Rg(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,i=wc(BigInt(t.length)),o=i>12?i-3:i>4?i-2:i?2:1,c=(1<<o)-1,u=new Array(c+1).fill(s),p=Math.floor((e.BITS-1)/o)*o,m=s;for(let b=p;b>=0;b-=o){u.fill(s);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 x=s;for(let S=u.length-1,T=s;S>0;S--)T=T.add(u[S]),x=x.add(T);if(m=m.add(x),b!==0)for(let S=0;S<o;S++)m=m.double()}return m}function Gs(r){return vc(r.Fp),_r(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Sc(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var cr=BigInt(0),Kt=BigInt(1),oo=BigInt(2),vg=BigInt(8),Sg={zip215:!0};function xg(r){let e=Gs(r);return _r(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function jl(r){let e=xg(r),{Fp:t,n,prehash:s,hash:i,randomBytes:o,nByteLength:c,h:u}=e,p=oo<<BigInt(c*8)-Kt,m=t.create,b=tn(e.n,e.nBitLength),x=e.uvRatio||((d,h)=>{try{return{isValid:!0,value:t.sqrt(d*t.inv(h))}}catch{return{isValid:!1,value:cr}}}),S=e.adjustScalarBytes||(d=>d),T=e.domain||((d,h,g)=>{if(ar("phflag",g),h.length||g)throw new Error("Contexts/pre-hash are not supported");return d});function I(d,h){jt("coordinate "+d,h,cr,p)}function A(d){if(!(d instanceof B))throw new Error("ExtendedPoint expected")}let L=zn((d,h)=>{let{ex:g,ey:w,ez:v}=d,y=d.is0();h==null&&(h=y?vg:t.inv(v));let f=m(g*h),_=m(w*h),C=m(v*h);if(y)return{x:cr,y:Kt};if(C!==Kt)throw new Error("invZ was invalid");return{x:f,y:_}}),U=zn(d=>{let{a:h,d:g}=e;if(d.is0())throw new Error("bad point: ZERO");let{ex:w,ey:v,ez:y,et:f}=d,_=m(w*w),C=m(v*v),D=m(y*y),$=m(D*D),X=m(_*h),se=m(D*m(X+C)),ue=m($+m(g*m(_*C)));if(se!==ue)throw new Error("bad point: equation left != right (1)");let Be=m(w*v),he=m(y*f);if(Be!==he)throw new Error("bad point: equation left != right (2)");return!0});class B{constructor(h,g,w,v){this.ex=h,this.ey=g,this.ez=w,this.et=v,I("x",h),I("y",g),I("z",w),I("t",v),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof B)throw new Error("extended point not allowed");let{x:g,y:w}=h||{};return I("x",g),I("y",w),new B(g,w,Kt,m(g*w))}static normalizeZ(h){let g=t.invertBatch(h.map(w=>w.ez));return h.map((w,v)=>w.toAffine(g[v])).map(B.fromAffine)}static msm(h,g){return io(B,b,h,g)}_setWindowSize(h){G.setWindowSize(this,h)}assertValidity(){U(this)}equals(h){A(h);let{ex:g,ey:w,ez:v}=this,{ex:y,ey:f,ez:_}=h,C=m(g*_),D=m(y*v),$=m(w*_),X=m(f*v);return C===D&&$===X}is0(){return this.equals(B.ZERO)}negate(){return new B(m(-this.ex),this.ey,this.ez,m(-this.et))}double(){let{a:h}=e,{ex:g,ey:w,ez:v}=this,y=m(g*g),f=m(w*w),_=m(oo*m(v*v)),C=m(h*y),D=g+w,$=m(m(D*D)-y-f),X=C+f,se=X-_,ue=C-f,Be=m($*se),he=m(X*ue),me=m($*ue),Gt=m(se*X);return new B(Be,he,Gt,me)}add(h){A(h);let{a:g,d:w}=e,{ex:v,ey:y,ez:f,et:_}=this,{ex:C,ey:D,ez:$,et:X}=h;if(g===BigInt(-1)){let Ue=m((y-v)*(D+C)),De=m((y+v)*(D-C)),ts=m(De-Ue);if(ts===cr)return this.double();let ze=m(f*oo*X),Fe=m(_*oo*$),Bs=Fe+ze,$e=De+Ue,Ve=Fe-ze,Pi=m(Bs*ts),He=m($e*Ve),Ge=m(Bs*Ve),Mi=m(ts*$e);return new B(Pi,He,Mi,Ge)}let se=m(v*C),ue=m(y*D),Be=m(_*w*X),he=m(f*$),me=m((v+y)*(C+D)-se-ue),Gt=he-Be,xe=he+Be,Ne=m(ue-g*se),Bi=m(me*Gt),je=m(xe*Ne),Ke=m(me*Ne),Ci=m(Gt*xe);return new B(Bi,je,Ci,Ke)}subtract(h){return this.add(h.negate())}wNAF(h){return G.wNAFCached(this,h,B.normalizeZ)}multiply(h){let g=h;jt("scalar",g,Kt,n);let{p:w,f:v}=this.wNAF(g);return B.normalizeZ([w,v])[0]}multiplyUnsafe(h,g=B.ZERO){let w=h;return jt("scalar",w,cr,n),w===cr?te:this.is0()||w===Kt?this:G.wNAFCachedUnsafe(this,w,B.normalizeZ,g)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return G.unsafeLadder(this,n).is0()}toAffine(h){return L(this,h)}clearCofactor(){let{h}=e;return h===Kt?this:this.multiplyUnsafe(h)}static fromHex(h,g=!1){let{d:w,a:v}=e,y=t.BYTES;h=We("pointHex",h,y),ar("zip215",g);let f=h.slice(),_=h[y-1];f[y-1]=_&-129;let C=Qr(f),D=g?p:t.ORDER;jt("pointHex.y",C,cr,D);let $=m(C*C),X=m($-Kt),se=m(w*$-v),{isValid:ue,value:Be}=x(X,se);if(!ue)throw new Error("Point.fromHex: invalid y coordinate");let he=(Be&Kt)===Kt,me=(_&128)!==0;if(!g&&Be===cr&&me)throw new Error("Point.fromHex: x=0 and x_0=1");return me!==he&&(Be=m(-Be)),B.fromAffine({x:Be,y:C})}static fromPrivateKey(h){return Y(h).point}toRawBytes(){let{x:h,y:g}=this.toAffine(),w=Dn(g,t.BYTES);return w[w.length-1]|=h&Kt?128:0,w}toHex(){return Nr(this.toRawBytes())}}B.BASE=new B(e.Gx,e.Gy,Kt,m(e.Gx*e.Gy)),B.ZERO=new B(cr,Kt,Kt,cr);let{BASE:F,ZERO:te}=B,G=so(B,c*8);function Z(d){return ke(d,n)}function ee(d){return Z(Qr(d))}function Y(d){let h=t.BYTES;d=We("private key",d,h);let g=We("hashed private key",i(d),2*h),w=S(g.slice(0,h)),v=g.slice(h,2*h),y=ee(w),f=F.multiply(y),_=f.toRawBytes();return{head:w,prefix:v,scalar:y,point:f,pointBytes:_}}function Ie(d){return Y(d).pointBytes}function re(d=new Uint8Array,...h){let g=Br(...h);return ee(i(T(g,We("context",d),!!s)))}function fe(d,h,g={}){d=We("message",d),s&&(d=s(d));let{prefix:w,scalar:v,pointBytes:y}=Y(h),f=re(g.context,w,d),_=F.multiply(f).toRawBytes(),C=re(g.context,_,y,d),D=Z(f+C*v);jt("signature.s",D,cr,n);let $=Br(_,Dn(D,t.BYTES));return We("result",$,t.BYTES*2)}let E=Sg;function a(d,h,g,w=E){let{context:v,zip215:y}=w,f=t.BYTES;d=We("signature",d,2*f),h=We("message",h),g=We("publicKey",g,f),y!==void 0&&ar("zip215",y),s&&(h=s(h));let _=Qr(d.slice(f,2*f)),C,D,$;try{C=B.fromHex(g,y),D=B.fromHex(d.slice(0,f),y),$=F.multiplyUnsafe(_)}catch{return!1}if(!y&&C.isSmallOrder())return!1;let X=re(v,D.toRawBytes(),C.toRawBytes(),h);return D.add(C.multiplyUnsafe(X)).subtract($).clearCofactor().equals(B.ZERO)}return F._setWindowSize(8),{CURVE:e,getPublicKey:Ie,sign:fe,verify:a,ExtendedPoint:B,utils:{getExtendedPublicKey:Y,randomPrivateKey:()=>o(t.BYTES),precompute(d=8,h=B.BASE){return h._setWindowSize(d),h.multiply(BigInt(3)),h}}}}var Tc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Kl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),ox=BigInt(0),Ag=BigInt(1),Hl=BigInt(2),ax=BigInt(3),Ig=BigInt(5),kg=BigInt(8);function Og(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),s=BigInt(80),i=Tc,c=r*r%i*r%i,u=Pe(c,Hl,i)*c%i,p=Pe(u,Ag,i)*r%i,m=Pe(p,Ig,i)*p%i,b=Pe(m,e,i)*m%i,x=Pe(b,t,i)*b%i,S=Pe(x,n,i)*x%i,T=Pe(S,s,i)*S%i,I=Pe(T,s,i)*S%i,A=Pe(I,e,i)*m%i;return{pow_p_5_8:Pe(A,Hl,i)*r%i,b2:c}}function Tg(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Ng(r,e){let t=Tc,n=ke(e*e*e,t),s=ke(n*n*e,t),i=Og(r*s).pow_p_5_8,o=ke(r*n*i,t),c=ke(e*o*o,t),u=o,p=ke(o*Kl,t),m=c===r,b=c===ke(-r,t),x=c===ke(-r*Kl,t);return m&&(o=u),(b||x)&&(o=p),zl(o,t)&&(o=ke(-o,t)),{isValid:m||b,value:o}}var Lg=tn(Tc,void 0,!0),Bg={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Lg,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:kg,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Cl,randomBytes:Ji,adjustScalarBytes:Tg,uvRatio:Ng},$n=jl(Bg);var Su=vr(Lc()),Et=vr(Cc());var Ug=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]),rn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),nn=new Uint32Array(64),Pc=class extends gs{constructor(){super(64,32,8,!1),this.A=rn[0]|0,this.B=rn[1]|0,this.C=rn[2]|0,this.D=rn[3]|0,this.E=rn[4]|0,this.F=rn[5]|0,this.G=rn[6]|0,this.H=rn[7]|0}get(){let{A:e,B:t,C:n,D:s,E:i,F:o,G:c,H:u}=this;return[e,t,n,s,i,o,c,u]}set(e,t,n,s,i,o,c,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=i|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)nn[b]=e.getUint32(t,!1);for(let b=16;b<64;b++){let x=nn[b-15],S=nn[b-2],T=or(x,7)^or(x,18)^x>>>3,I=or(S,17)^or(S,19)^S>>>10;nn[b]=I+nn[b-7]+T+nn[b-16]|0}let{A:n,B:s,C:i,D:o,E:c,F:u,G:p,H:m}=this;for(let b=0;b<64;b++){let x=or(c,6)^or(c,11)^or(c,25),S=m+x+Nl(c,u,p)+Ug[b]+nn[b]|0,I=(or(n,2)^or(n,13)^or(n,22))+Ll(n,s,i)|0;m=p,p=u,u=c,c=o+S|0,o=i,i=s,s=n,n=S+I|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,p=p+this.G|0,m=m+this.H|0,this.set(n,s,i,o,c,u,p,m)}roundClean(){nn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Zs=ms(()=>new Pc);var Is=vr(ad()),R=vr(qc()),Bh=vr(qc());var ey=1,ty=2,ry=3,ny=4,sy=5,iy=6,oy=7,ay=8,cy=9,uy=10,fy=-32700,ly=-32603,dy=-32602,hy=-32601,py=-32600,my=-32016,gy=-32015,yy=-32014,_y=-32013,by=-32012,wy=-32011,Ey=-32010,Ry=-32009,vy=-32008,Sy=-32007,xy=-32006,Ay=-32005,Iy=-32004,ky=-32003,Oy=-32002,Ty=-32001,Ny=28e5,Ly=2800001,By=2800002,Cy=2800003,Py=2800004,My=2800005,Uy=2800006,Dy=2800007,zy=2800008,Fy=2800009,$y=2800010,Vy=323e4,Wy=32300001,qy=3230002,jy=3230003,Ky=3230004,Hy=361e4,Gy=3610001,Zy=3610002,Yy=3610003,Jy=3610004,Xy=3610005,Qy=3610006,e_=3610007,t_=3611e3,r_=3704e3,n_=3704001,s_=3704002,i_=3704003,o_=3704004,a_=4128e3,c_=4128001,u_=4128002,f_=4615e3,l_=4615001,d_=4615002,h_=4615003,p_=4615004,m_=4615005,g_=4615006,y_=4615007,__=4615008,b_=4615009,w_=4615010,E_=4615011,R_=4615012,v_=4615013,S_=4615014,x_=4615015,A_=4615016,I_=4615017,k_=4615018,O_=4615019,T_=4615020,N_=4615021,L_=4615022,B_=4615023,C_=4615024,P_=4615025,M_=4615026,U_=4615027,D_=4615028,z_=4615029,F_=4615030,$_=4615031,V_=4615032,W_=4615033,q_=4615034,j_=4615035,K_=4615036,H_=4615037,G_=4615038,Z_=4615039,Y_=4615040,J_=4615041,X_=4615042,Q_=4615043,eb=4615044,tb=4615045,rb=4615046,nb=4615047,sb=4615048,ib=4615049,ob=4615050,ab=4615051,cb=4615052,ub=4615053,fb=4615054,lb=5508e3,db=5508001,hb=5508002,pb=5508003,mb=5508004,gb=5508005,yb=5508006,_b=5508007,bb=5508008,wb=5508009,Eb=5508010,Rb=5508011,vb=5663e3,Sb=5663001,xb=5663002,Ab=5663003,Ib=5663004,kb=5663005,Ob=5663006,Tb=5663007,Nb=5663008,Lb=5663009,Bb=5663010,Cb=5663011,Pb=5663012,Mb=5663013,Ub=5663014,Db=5663015,zb=5663016,Fb=5663017,$b=5663018,Vb=5663019,Wb=705e4,qb=7050001,jb=7050002,Kb=7050003,Hb=7050004,Gb=7050005,Zb=7050006,Yb=7050007,Jb=7050008,Xb=7050009,Qb=7050010,ew=7050011,tw=7050012,rw=7050013,nw=7050014,sw=7050015,iw=7050016,ow=7050017,aw=7050018,cw=7050019,uw=7050020,fw=7050021,lw=7050022,dw=7050023,hw=7050024,pw=7050025,mw=7050026,gw=7050027,yw=7050028,_w=7050029,bw=7050030,ww=7050031,Ew=7050032,Rw=7050033,vw=7050034,Sw=7050035,xw=7050036,jc=8078e3,Kc=8078001,cd=8078002,ud=8078003,Hc=8078004,Gc=8078005,Zc=8078006,Aw=8078007,Iw=8078008,kw=8078009,Ow=8078010,Yc=8078011,Tw=8078012,fd=8078013,ld=8078014,Nw=8078015,Lw=8078016,Bw=8078017,Cw=8078018,Pw=8078019,dd=8078020,hd=8078021,Mw=8078022,Uw=81e5,Dw=8100001,zw=8100002,Fw=8100003,$w=819e4,Vw=8190001,Ww=8190002,qw=8190003,jw=8190004,Kw=99e5,Hw=9900001,Gw=9900002,Zw=9900003,Yw=9900004;function pd(r){return Array.isArray(r)?"%5B"+r.map(pd).join("%2C%20")+"%5D":typeof r=="bigint"?`${r}n`:encodeURIComponent(String(r!=null&&Object.getPrototypeOf(r)===null?{...r}:r))}function Jw([r,e]){return`${r}=${pd(e)}`}function Xw(r){let e=Object.entries(r).map(Jw).join("&");return btoa(e)}var bx={[Vy]:"Account not found at address: $address",[Ky]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[jy]:"Expected decoded account at address: $address",[qy]:"Failed to decode account data at address: $address",[Wy]:"Accounts not found at addresses: $addresses",[Fy]:"Unable to find a viable program address bump seed.",[By]:"$putativeAddress is not a base58-encoded address.",[Ny]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Cy]:"The `CryptoKey` must be an `Ed25519` public key.",[zy]:"Invalid seeds; point must fall off the Ed25519 curve.",[Py]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Uy]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Dy]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[My]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[$y]:"Program address cannot end with PDA marker.",[Ly]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[ny]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[ey]:"The network has progressed past the last block for which this transaction could have been committed.",[jc]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Mw]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[dd]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Gc]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Zc]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Hc]:"Encoder and decoder must either both be fixed-size or variable-size.",[Iw]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[cd]:"Expected a fixed-size codec, got a variable-size one.",[fd]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[ud]:"Expected a variable-size codec, got a fixed-size one.",[Pw]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Kc]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Cw]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[kw]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Ow]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Nw]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Aw]:"Expected [$codecDescription] to have $expected items, got $actual.",[Tw]:"Invalid value $value for base $base with alphabet $alphabet.",[Lw]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Yc]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[ld]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[hd]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Bw]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[t_]:"No random values implementation could be found.",[b_]:"instruction requires an uninitialized account",[B_]:"instruction tries to borrow reference for an account which is already borrowed",[C_]:"instruction left account with an outstanding borrowed reference",[N_]:"program other than the account's owner changed the size of the account data",[m_]:"account data too small for instruction",[L_]:"instruction expected an executable account",[rb]:"An account does not have enough lamports to be rent-exempt",[sb]:"Program arithmetic overflowed",[tb]:"Failed to serialize or deserialize account data: $encodedData",[fb]:"Builtin programs must consume compute units",[V_]:"Cross-program invocation call depth too deep",[G_]:"Computational budget exceeded",[M_]:"custom program error: #$code",[I_]:"instruction contains duplicate accounts",[P_]:"instruction modifications of multiply-passed account differ",[F_]:"executable accounts must be rent exempt",[D_]:"instruction changed executable accounts data",[z_]:"instruction changed the balance of an executable account",[k_]:"instruction changed executable bit of an account",[S_]:"instruction modified data of an account it does not own",[v_]:"instruction spent from the balance of an account it does not own",[l_]:"generic instruction error",[ob]:"Provided owner is not allowed",[Q_]:"Account is immutable",[eb]:"Incorrect authority provided",[y_]:"incorrect program id for instruction",[g_]:"insufficient funds for instruction",[p_]:"invalid account data for instruction",[nb]:"Invalid account owner",[d_]:"invalid program argument",[U_]:"program returned invalid error code",[h_]:"invalid instruction data",[H_]:"Failed to reallocate account data",[K_]:"Provided seeds do not result in a valid address",[ab]:"Accounts data allocations exceeded the maximum allowed per transaction",[cb]:"Max accounts exceeded",[ub]:"Max instruction trace length exceeded",[j_]:"Length of the seed is too long for address generation",[W_]:"An account required by the instruction is missing",[__]:"missing required signature for instruction",[R_]:"instruction illegally modified the program id of an account",[T_]:"insufficient account keys for instruction",[Z_]:"Cross-program invocation with unauthorized signer or writable account",[Y_]:"Failed to create program execution environment",[X_]:"Program failed to compile",[J_]:"Program failed to complete",[A_]:"instruction modified data of a read-only account",[x_]:"instruction changed the balance of a read-only account",[q_]:"Cross-program invocation reentrancy not allowed for this instruction",[O_]:"instruction modified rent epoch of an account",[E_]:"sum of account balances before and after instruction do not match",[w_]:"instruction requires an initialized account",[f_]:"",[$_]:"Unsupported program id",[ib]:"Unsupported sysvar",[a_]:"The instruction does not have any accounts.",[c_]:"The instruction does not have any data.",[u_]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[sy]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[ty]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Gw]:"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",[Yw]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[Hw]:"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",[Kw]:"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",[Zw]:"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",[ly]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[dy]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[py]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[hy]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[fy]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[by]:"$__serverMessage",[Ty]:"$__serverMessage",[Iy]:"$__serverMessage",[yy]:"$__serverMessage",[Ey]:"$__serverMessage",[Ry]:"$__serverMessage",[my]:"Minimum context slot has not been reached",[Ay]:"Node is unhealthy; behind by $numSlotsBehind slots",[vy]:"No snapshot",[Oy]:"Transaction simulation failed",[Sy]:"$__serverMessage",[wy]:"Transaction history is not available from this node",[xy]:"$__serverMessage",[_y]:"Transaction signature length mismatch",[ky]:"Transaction signature verification failure",[gy]:"$__serverMessage",[r_]:"Key pair bytes must be of length 64, got $byteLength.",[n_]:"Expected private key bytes with length 32. Actual length: $actualLength.",[s_]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[o_]:"The provided private key does not match the provided public key.",[i_]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[iy]:"Lamports value must be in the range [0, 2e64-1]",[oy]:"`$value` cannot be parsed as a `BigInt`",[uy]:"$message",[ay]:"`$value` cannot be parsed as a `Number`",[ry]:"No nonce account could be found at address `$nonceAccountAddress`",[$w]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Ww]:"WebSocket was closed before payload could be added to the send buffer",[qw]:"WebSocket connection closed",[jw]:"WebSocket failed to connect",[Vw]:"Failed to obtain a subscription id from the server",[Fw]:"Could not find an API plan for RPC method: `$method`",[Uw]:"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`.",[zw]:"HTTP error ($statusCode): $message",[Dw]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[lb]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[db]:"The provided value does not implement the `KeyPairSigner` interface",[pb]:"The provided value does not implement the `MessageModifyingSigner` interface",[mb]:"The provided value does not implement the `MessagePartialSigner` interface",[hb]:"The provided value does not implement any of the `MessageSigner` interfaces",[yb]:"The provided value does not implement the `TransactionModifyingSigner` interface",[_b]:"The provided value does not implement the `TransactionPartialSigner` interface",[bb]:"The provided value does not implement the `TransactionSendingSigner` interface",[gb]:"The provided value does not implement any of the `TransactionSigner` interfaces",[wb]:"More than one `TransactionSendingSigner` was identified.",[Eb]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[Rb]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[e_]:"Cannot export a non-extractable key.",[Gy]:"No digest implementation could be found.",[Hy]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Zy]:`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.`,[ky]:"No signature verification implementation could be found.",[Oy]:"No key generation implementation could be found.",[Ty]:"No signing implementation could be found.",[Ny]:"No key export implementation could be found.",[Fg]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Ub]:"Transaction processing left an account with an outstanding borrowed reference",[Eb]:"Account in use",[Rb]:"Account loaded twice",[Sb]:"Attempt to debit an account but found no record of a prior credit.",[qb]:"Transaction loads an address table account that doesn't exist",[kb]:"This transaction has already been processed",[Ob]:"Blockhash not found",[Tb]:"Loader call chain is too deep",[Mb]:"Transactions are currently disabled due to cluster maintenance",[Xb]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Ab]:"Insufficient funds for fee",[Jb]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Ib]:"This account may not be used to pay transaction fees",[Bb]:"Transaction contains an invalid account reference",[Kb]:"Transaction loads an address table account with invalid data",[Hb]:"Transaction address table lookup uses an invalid index",[jb]:"Transaction loads an address table account with an invalid owner",[ew]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Cb]:"This program may not be used for executing instructions",[Gb]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Fb]:"Transaction loads a writable account that cannot be written",[Qb]:"Transaction exceeded max loaded accounts data size cap",[Nb]:"Transaction requires a fee but has no signature present",[xb]:"Attempt to load a program that does not exist",[rw]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[tw]:"ResanitizationNeeded",[Pb]:"Transaction failed to sanitize accounts offsets correctly",[Lb]:"Transaction did not pass signature verification",[Wb]:"Transaction locked too many accounts",[nw]:"Sum of account balances before and after transaction do not match",[vb]:"The transaction failed with the error `$errorName`",[zb]:"Transaction version is unsupported",[Vb]:"Transaction would exceed account data limit within the block",[Yb]:"Transaction would exceed total account data limit",[$b]:"Transaction would exceed max account limit within the block",[Db]:"Transaction would exceed max Block Cost Limit",[Zb]:"Transaction would exceed max Vote Cost Limit",[gb]:"Attempted to sign a transaction with an address that is not a signer for it",[lb]:"Transaction is missing an address at index: $index.",[yb]:"Transaction has no expected signers therefore it cannot be encoded",[nb]:"Transaction does not have a blockhash lifetime",[sb]:"Transaction is not a durable nonce transaction",[ob]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[ab]:"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",[ub]:"No fee payer set in CompiledTransaction",[cb]:"Could not find program address at index $index",[bb]:"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",[wb]:"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",[db]:"Transaction is missing a fee payer.",[hb]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[mb]:"Transaction first instruction is not advance nonce account instruction.",[pb]:"Transaction with no instructions cannot be durable nonce transaction.",[tb]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[rb]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[_b]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[fb]:"Transaction is missing signatures for addresses: $addresses.",[ib]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"};function Nw(r,e={}){{let t=`Solana error #${r}; Decode this error by running \`npx @solana/errors decode -- ${r}`;return Object.keys(e).length&&(t+=` '${Tw(e)}'`),`${t}\``}}var sn=class extends Error{cause=this.cause;context;constructor(...[r,e]){let t,n;if(e){let{cause:i,...o}=e;i&&(n={cause:i}),Object.keys(o).length>0&&(t=o)}let s=Nw(r,t);super(s,n),this.context={__code:r,...t},this.name="SolanaError"}};function Bw(r,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(r)}function Yl(r){return Object.freeze({...r,encode:e=>{let t=new Uint8Array(Bw(e,r));return r.write(e,t,0),t}})}function Xl(r){return Object.freeze({...r,decode:(e,t=0)=>r.read(e,t)[0]})}function ws(r){return"fixedSize"in r&&typeof r.fixedSize=="number"}function Jl(r,e){if(ws(r)!==ws(e))throw new sn(Wc);if(ws(r)&&ws(e)&&r.fixedSize!==e.fixedSize)throw new sn(qc,{decoderFixedSize:e.fixedSize,encoderFixedSize:r.fixedSize});if(!ws(r)&&!ws(e)&&r.maxSize!==e.maxSize)throw new sn(jc,{decoderMaxSize:e.maxSize,encoderMaxSize:r.maxSize});return{...e,...r,decode:e.decode,encode:r.encode,read:e.read,write:r.write}}function Ql(r,e,t=0){if(e.length-t<=0)throw new sn($c,{codecDescription:r})}function ed(r,e,t,n=0){let s=t.length-n;if(s<e)throw new sn(Vc,{bytesLength:s,codecDescription:r,expected:e})}function Lw(r,e,t,n){if(n<e||n>t)throw new sn(Kc,{codecDescription:r,max:t,min:e,value:n})}function td(r){return r?.endian!==1}function Cw(r){return Yl({fixedSize:r.size,write(e,t,n){r.range&&Lw(r.name,r.range[0],r.range[1],e);let s=new ArrayBuffer(r.size);return r.set(new DataView(s),e,td(r.config)),t.set(new Uint8Array(s),n),n+r.size}})}function Pw(r){return Xl({fixedSize:r.size,read(e,t=0){Ql(r.name,e,t),ed(r.name,r.size,e,t);let n=new DataView(Mw(e,t,r.size));return[r.get(n,td(r.config)),t+r.size]}})}function Mw(r,e,t){let n=r.byteOffset+(e??0),s=t??r.byteLength;return r.buffer.slice(n,n+s)}var Hc=(r={})=>Cw({config:r,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),Uw=(r={})=>Pw({config:r,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),rd=(r={})=>Jl(Hc(r),Uw(r));var Gc=class extends TypeError{constructor(e,t){let n,{message:s,explanation:i,...o}=e,{path:c}=e,u=c.length===0?s:`At path: ${c.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}};function Dw(r){return Js(r)&&typeof r[Symbol.iterator]=="function"}function Js(r){return typeof r=="object"&&r!=null}function Bo(r){return Js(r)&&!Array.isArray(r)}function cr(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function zw(r){let{done:e,value:t}=r.next();return e?void 0:t}function Fw(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});let{path:s,branch:i}=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:s[s.length-1],path:s,branch:i,...r,message:u}}function*nd(r,e,t,n){Dw(r)||(r=[r]);for(let s of r){let i=Fw(s,e,t,n);i&&(yield i)}}function*Zc(r,e,t={}){let{path:n=[],branch:s=[r],coerce:i=!1,mask:o=!1}=t,c={path:n,branch:s,mask:o};i&&(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 x=Zc(m,b,{path:p===void 0?n:[...n,p],branch:p===void 0?s:[...s,m],coerce:i,mask:o,message:t.message});for(let S of x)S[0]?(u=S[0].refinement!=null?"not_refined":"not_valid",yield[S[0],void 0]):i&&(m=S[1],p===void 0?r=m:r instanceof Map?r.set(p,m):r instanceof Set?r.add(m):Js(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:s,refiner:i,coercer:o=u=>u,entries:c=function*(){}}=e;this.type=t,this.schema=n,this.entries=c,this.coercer=o,s?this.validator=(u,p)=>{let m=s(u,p);return nd(m,p,this,u)}:this.validator=()=>[],i?this.refiner=(u,p)=>{let m=i(u,p);return nd(m,p,this,u)}:this.refiner=()=>[]}assert(e,t){return sd(e,this,t)}create(e,t){return V(e,this,t)}is(e){return id(e,this)}mask(e,t){return $w(e,this,t)}validate(e,t={}){return Qs(e,this,t)}};function sd(r,e,t){let n=Qs(r,e,{message:t});if(n[0])throw n[0]}function V(r,e,t){let n=Qs(r,e,{coerce:!0,message:t});if(n[0])throw n[0];return n[1]}function $w(r,e,t){let n=Qs(r,e,{coerce:!0,mask:!0,message:t});if(n[0])throw n[0];return n[1]}function id(r,e){return!Qs(r,e)[0]}function Qs(r,e,t={}){let n=Zc(r,e,t),s=zw(n);return s[0]?[new Gc(s[0],function*(){for(let o of n)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function Vn(r,e){return new rr({type:r,schema:null,validator:e})}function od(){return Vn("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 Vn("boolean",r=>typeof r=="boolean")}function Lo(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 Vw(){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 k(){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 Yc(r,e){return new rr({type:"record",schema:null,*entries(t){if(Js(t))for(let n in t){let s=t[n];yield[n,n,r],yield[n,s,e]}},validator(t){return Bo(t)||`Expected an object, but received: ${cr(t)}`},coercer(t){return Bo(t)?{...t}:t}})}function z(){return Vn("string",r=>typeof r=="string"||`Expected a string, but received: ${cr(r)}`)}function Co(r){let e=Vw();return new rr({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let n=Math.max(r.length,t.length);for(let s=0;s<n;s++)yield[s,t[s],r[s]||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(Js(t))for(let n of e)yield[n,t[n],r[n]]},validator(t){return Bo(t)||`Expected an object, but received: ${cr(t)}`},coercer(t){return Bo(t)?{...t}:t}})}function Tt(r){let e=r.map(t=>t.type).join(" | ");return new rr({type:"union",schema:null,coercer(t,n){for(let s of r){let[i,o]=s.validate(t,{coerce:!0,mask:n.mask});if(!i)return o}return t},validator(t,n){let s=[];for(let i of r){let[...o]=Zc(t,i,n),[c]=o;if(c[0])for(let[u]of o)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${cr(t)}`,...s]}})}function Wn(){return Vn("unknown",()=>!0)}function vs(r,e,t){return new rr({...r,coercer:(n,s)=>id(n,e)?r.coercer(t(n,s),s):r.coercer(n,s)})}var mh=vr(Td());var Cd=vr($s(),1);var qn=vr(Bd(),1);var Ld=qn.default;var p1=class extends qn.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(s){n(s)}}close(r,e){this.socket.close(r,e)}addEventListener(r,e,t){this.socket.addEventListener(r,e,t)}};function Pd(r,e){return new p1(r,e)}var m1=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},Md=class extends qn.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:s=1e3,max_reconnects:i=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=s,this.max_reconnects=i,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 m1,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((s,i)=>{if(!this.ready)return i(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 i(u);this.queue[o]={promise:[s,i]},t&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],i(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 s={jsonrpc:"2.0",method:r,params:e};this.socket.send(this.dataPack.encode(s),i=>{if(i)return n(i);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=Cd.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 s=0;s<t.params.length;s++)n.push(t.params[s]);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 zd=[],Fd=[],$d=[],g1=BigInt(0),ii=BigInt(1),y1=BigInt(2),_1=BigInt(7),b1=BigInt(256),w1=BigInt(113);for(let r=0,e=ii,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],zd.push(2*(5*n+t)),Fd.push((r+1)*(r+2)/2%64);let s=g1;for(let i=0;i<7;i++)e=(e<<ii^(e>>_1)*w1)%b1,e&y1&&(s^=ii<<(ii<<BigInt(i))-ii);$d.push(s)}var[v1,E1]=ac($d,!0),Ud=(r,e,t)=>t>32?fc(r,e,t):cc(r,e,t),Dd=(r,e,t)=>t>32?lc(r,e,t):uc(r,e,t);function R1(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=Ud(p,m,1)^t[c],x=Dd(p,m,1)^t[c+1];for(let S=0;S<50;S+=10)r[o+S]^=b,r[o+S+1]^=x}let s=r[2],i=r[3];for(let o=0;o<24;o++){let c=Fd[o],u=Ud(s,i,c),p=Dd(s,i,c),m=zd[o];s=r[m],i=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]^=v1[n],r[1]^=E1[n]}t.fill(0)}var $o=class r extends Kr{constructor(e,t,n,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Vs(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ul(this.state)}keccak(){nc||sc(this.state32),R1(this.state32,this.rounds),nc||sc(this.state32),this.posOut=0,this.pos=0}update(e){Ir(this);let{blockLen:t,state:n}=this;e=Hr(e);let s=e.length;for(let i=0;i<s;){let o=Math.min(t-this.pos,s-i);for(let c=0;c<o;c++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,(t&128)!==0&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ir(this,!1),jr(e),this.finish();let t=this.state,{blockLen:n}=this;for(let s=0,i=e.length;s<i;){this.posOut>=n&&this.keccak();let o=Math.min(n-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=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 Vs(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ki(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:s,rounds:i,enableXOF:o}=this;return e||(e=new r(t,n,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}},un=(r,e,t)=>hs(()=>new $o(e,r,t)),Xx=un(6,144,224/8),Jx=un(6,136,256/8),Qx=un(6,104,384/8),eA=un(6,72,512/8),tA=un(1,144,224/8),au=un(1,136,256/8),rA=un(1,104,384/8),nA=un(1,72,512/8),Vd=(r,e,t)=>ll((n={})=>new $o(e,r,n.dkLen===void 0?t:n.dkLen,!0)),sA=Vd(31,168,128/8),iA=Vd(31,136,256/8);var Vo=class extends Kr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,cl(e);let n=Hr(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 s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Ir(this),this.iHash.update(e),this}digestInto(e){Ir(this),jr(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:s,destroyed:i,blockLen:o,outputLen:c}=this;return e=e,e.finished=s,e.destroyed=i,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()}},cu=(r,e,t)=>new Vo(r,e).update(t).digest();cu.create=(r,e)=>new Vo(r,e);function Wd(r){r.lowS!==void 0&&or("lowS",r.lowS),r.prehash!==void 0&&or("prehash",r.prehash)}function S1(r){let e=js(r);mr(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:s}=e;if(t){if(!n.eql(s,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:x1,hexToBytes:A1}=Ji,uu=class extends Error{constructor(e=""){super(e)}},Cr={Err:uu,_tlv:{encode:(r,e)=>{let{Err:t}=Cr;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,s=Ln(n);if(s.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Ln(s.length/2|128):"";return Ln(r)+i+s+e},decode(r,e){let{Err:t}=Cr,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 s=e[n++],i=!!(s&128),o=0;if(!i)o=s;else{let u=s&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}=Cr;if(r<Pr)throw new e("integer: negative integers are not allowed");let t=Ln(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}=Cr;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 x1(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Cr,s=typeof r=="string"?A1(r):r;ms(s);let{v:i,l:o}=n.decode(48,s);if(o.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:u}=n.decode(2,i),{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}=Cr,n=e.encode(2,t.encode(r.r)),s=e.encode(2,t.encode(r.s)),i=n+s;return e.encode(48,i)}},Pr=BigInt(0),wt=BigInt(1),hA=BigInt(2),qd=BigInt(3),pA=BigInt(4);function I1(r){let e=S1(r),{Fp:t}=e,n=Qr(e.n,e.nBitLength),s=e.toBytes||((I,A,B)=>{let U=A.toAffine();return Nr(Uint8Array.from([4]),t.toBytes(U.x),t.toBytes(U.y))}),i=e.fromBytes||(I=>{let A=I.subarray(1),B=t.fromBytes(A.subarray(0,t.BYTES)),U=t.fromBytes(A.subarray(t.BYTES,2*t.BYTES));return{x:B,y:U}});function o(I){let{a:A,b:B}=e,U=t.sqr(I),L=t.mul(U,I);return t.add(t.add(L,t.mul(I,A)),B)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function c(I){return Ws(I,wt,e.n)}function u(I){let{allowedPrivateKeyLengths:A,nByteLength:B,wrapPrivateKey:U,n:L}=e;if(A&&typeof I!="bigint"){if(Yr(I)&&(I=Or(I)),typeof I!="string"||!A.includes(I.length))throw new Error("invalid private key");I=I.padStart(B*2,"0")}let F;try{F=typeof I=="bigint"?I:Tr(We("private key",I,B))}catch{throw new Error("invalid private key, expected hex or "+B+" bytes, got "+typeof I)}return U&&(F=ke(F,L)),qt("private key",F,wt,L),F}function p(I){if(!(I instanceof x))throw new Error("ProjectivePoint expected")}let m=Mn((I,A)=>{let{px:B,py:U,pz:L}=I;if(t.eql(L,t.ONE))return{x:B,y:U};let F=I.is0();A==null&&(A=F?t.ONE:t.inv(L));let te=t.mul(B,A),G=t.mul(U,A),Z=t.mul(L,A);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:G}}),b=Mn(I=>{if(I.is0()){if(e.allowInfinityPoint&&!t.is0(I.py))return;throw new Error("bad point: ZERO")}let{x:A,y:B}=I.toAffine();if(!t.isValid(A)||!t.isValid(B))throw new Error("bad point: x or y not FE");let U=t.sqr(B),L=o(A);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 x{constructor(A,B,U){if(this.px=A,this.py=B,this.pz=U,A==null||!t.isValid(A))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(A){let{x:B,y:U}=A||{};if(!A||!t.isValid(B)||!t.isValid(U))throw new Error("invalid affine point");if(A instanceof x)throw new Error("projective point not allowed");let L=F=>t.eql(F,t.ZERO);return L(B)&&L(U)?x.ZERO:new x(B,U,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(A){let B=t.invertBatch(A.map(U=>U.pz));return A.map((U,L)=>U.toAffine(B[L])).map(x.fromAffine)}static fromHex(A){let B=x.fromAffine(i(We("pointHex",A)));return B.assertValidity(),B}static fromPrivateKey(A){return x.BASE.multiply(u(A))}static msm(A,B){return ro(x,n,A,B)}_setWindowSize(A){T.setWindowSize(this,A)}assertValidity(){b(this)}hasEvenY(){let{y:A}=this.toAffine();if(t.isOdd)return!t.isOdd(A);throw new Error("Field doesn't support isOdd")}equals(A){p(A);let{px:B,py:U,pz:L}=this,{px:F,py:te,pz:G}=A,Z=t.eql(t.mul(B,G),t.mul(F,L)),ee=t.eql(t.mul(U,G),t.mul(te,L));return Z&&ee}negate(){return new x(this.px,t.neg(this.py),this.pz)}double(){let{a:A,b:B}=e,U=t.mul(B,qd),{px:L,py:F,pz:te}=this,G=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),G=t.mul(A,ee),Z=t.mul(U,re),Z=t.add(G,Z),G=t.sub(Ie,Z),Z=t.add(Ie,Z),Z=t.mul(G,Z),G=t.mul(fe,G),ee=t.mul(U,ee),re=t.mul(A,re),fe=t.sub(Y,re),fe=t.mul(A,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),G=t.sub(G,Y),ee=t.mul(re,Ie),ee=t.add(ee,ee),ee=t.add(ee,ee),new x(G,Z,ee)}add(A){p(A);let{px:B,py:U,pz:L}=this,{px:F,py:te,pz:G}=A,Z=t.ZERO,ee=t.ZERO,Y=t.ZERO,Ie=e.a,re=t.mul(e.b,qd),fe=t.mul(B,F),v=t.mul(U,te),a=t.mul(L,G),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,G);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,G),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 x(Z,ee,Y)}subtract(A){return this.add(A.negate())}is0(){return this.equals(x.ZERO)}wNAF(A){return T.wNAFCached(this,A,x.normalizeZ)}multiplyUnsafe(A){let{endo:B,n:U}=e;qt("scalar",A,Pr,U);let L=x.ZERO;if(A===Pr)return L;if(this.is0()||A===wt)return this;if(!B||T.hasPrecomputes(this))return T.wNAFCachedUnsafe(this,A,x.normalizeZ);let{k1neg:F,k1:te,k2neg:G,k2:Z}=B.splitScalar(A),ee=L,Y=L,Ie=this;for(;te>Pr||Z>Pr;)te&wt&&(ee=ee.add(Ie)),Z&wt&&(Y=Y.add(Ie)),Ie=Ie.double(),te>>=wt,Z>>=wt;return F&&(ee=ee.negate()),G&&(Y=Y.negate()),Y=new x(t.mul(Y.px,B.beta),Y.py,Y.pz),ee.add(Y)}multiply(A){let{endo:B,n:U}=e;qt("scalar",A,wt,U);let L,F;if(B){let{k1neg:te,k1:G,k2neg:Z,k2:ee}=B.splitScalar(A),{p:Y,f:Ie}=this.wNAF(G),{p:re,f:fe}=this.wNAF(ee);Y=T.constTimeNegate(te,Y),re=T.constTimeNegate(Z,re),re=new x(t.mul(re.px,B.beta),re.py,re.pz),L=Y.add(re),F=Ie.add(fe)}else{let{p:te,f:G}=this.wNAF(A);L=te,F=G}return x.normalizeZ([L,F])[0]}multiplyAndAddUnsafe(A,B,U){let L=x.BASE,F=(G,Z)=>Z===Pr||Z===wt||!G.equals(L)?G.multiplyUnsafe(Z):G.multiply(Z),te=F(this,B).add(F(A,U));return te.is0()?void 0:te}toAffine(A){return m(this,A)}isTorsionFree(){let{h:A,isTorsionFree:B}=e;if(A===wt)return!0;if(B)return B(x,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:A,clearCofactor:B}=e;return A===wt?this:B?B(x,this):this.multiplyUnsafe(e.h)}toRawBytes(A=!0){return or("isCompressed",A),this.assertValidity(),s(x,this,A)}toHex(A=!0){return or("isCompressed",A),Or(this.toRawBytes(A))}}x.BASE=new x(e.Gx,e.Gy,t.ONE),x.ZERO=new x(t.ZERO,t.ONE,t.ZERO);let S=e.nBitLength,T=to(x,e.endo?Math.ceil(S/2):S);return{CURVE:e,ProjectivePoint:x,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:c}}function k1(r){let e=js(r);return mr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function jd(r){let e=k1(r),{Fp:t,n}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(a){return ke(a,n)}function c(a){return Qi(a,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:p,weierstrassEquation:m,isWithinCurveOrder:b}=I1({...e,toBytes(a,l,d){let h=l.toAffine(),g=t.toBytes(h.x),w=Nr;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===s&&(d===2||d===3)){let g=Tr(h);if(!Ws(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===i&&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=s,w=i;throw new Error("invalid Point, expected length of "+g+", or uncompressed "+w+", got "+l)}}}),x=a=>Or(Jr(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)=>Tr(a.slice(l,d));class A{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 A(I(l,0,d),I(l,d,2*d))}static fromDER(l){let{r:d,s:h}=Cr.toSig(We("DER",l));return new A(d,h)}assertValidity(){qt("r",this.r,wt,n),qt("s",this.s,wt,n)}addRecoveryBit(l){return new A(this.r,this.s,l)}recoverPublicKey(l){let{r:d,s:h,recovery:g}=this,w=G(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+x(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 A(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Cn(this.toDERHex())}toDERHex(){return Cr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Cn(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}let B={isValidPrivateKey(a){try{return p(a),!0}catch{return!1}},normPrivateKeyToScalar:p,randomPrivateKey:()=>{let a=vc(e.n);return El(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=Yr(a),d=typeof a=="string",h=(l||d)&&a.length;return l?h===s||h===i:d?h===2*s||h===2*i: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=Tr(a),d=a.length*8-e.nBitLength;return d>0?l>>BigInt(d):l},G=e.bits2int_modN||function(a){return o(te(a))},Z=qs(e.nBitLength);function ee(a){return qt("num < 2^"+e.nBitLength,a,Pr,Z),Jr(a,e.nByteLength)}function Y(a,l,d=Ie){if(["recovered","canonical"].some(se=>se 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),Wd(d),R&&(a=We("prehashed msgHash",h(a)));let f=G(a),_=p(l),C=[ee(_),ee(f)];if(y!=null&&y!==!1){let se=y===!0?g(t.BYTES):y;C.push(We("extraEntropy",se))}let D=Nr(...C),$=f;function J(se){let ue=te(se);if(!b(ue))return;let Le=c(ue),he=u.BASE.multiply(ue).toAffine(),me=o(he.x);if(me===Pr)return;let Ht=o(Le*o($+me*_));if(Ht===Pr)return;let xe=(he.x===me?0:2)|Number(he.y&wt),Ne=Ht;return w&&S(Ht)&&(Ne=T(Ht),xe^=1),new A(me,Ne,xe)}return{seed:D,k2sig:J}}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 yc(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(Wd(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"||Yr(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 A(g.r,g.s)),f){try{y!=="compact"&&(C=A.fromDER(g))}catch(xe){if(!(xe instanceof Cr.Err))throw xe}!C&&y!=="der"&&(C=A.fromCompact(g))}D=u.fromHex(d)}catch{return!1}if(!C||w&&C.hasHighS())return!1;R&&(l=e.hash(l));let{r:$,s:J}=C,se=G(l),ue=c(J),Le=o(se*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:A,utils:B}}function O1(r){return{hash:r,hmac:(e,...t)=>cu(r,e,ic(...t)),randomBytes:Gi}}function Kd(r,e){let t=n=>jd({...r,...O1(n)});return{...t(e),create:t}}var Zd=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Hd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),T1=BigInt(1),fu=BigInt(2),Gd=(r,e)=>(r+e/fu)/e;function N1(r){let e=Zd,t=BigInt(3),n=BigInt(6),s=BigInt(11),i=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,x=Pe(b,t,e)*m%e,S=Pe(x,fu,e)*p%e,T=Pe(S,s,e)*S%e,I=Pe(T,i,e)*T%e,A=Pe(I,c,e)*I%e,B=Pe(A,u,e)*A%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,G=Pe(te,fu,e);if(!lu.eql(lu.sqr(G),r))throw new Error("Cannot find square root");return G}var lu=Qr(Zd,void 0,void 0,{sqrt:N1}),oi=Kd({a:BigInt(0),b:BigInt(7),Fp:lu,n:Hd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Hd,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-T1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),c=Gd(i*r,e),u=Gd(-n*r,e),p=ke(r-c*t-u*s,e),m=ke(-c*n-u*i,e),b=p>o,x=m>o;if(b&&(p=e-p),x&&(m=e-m),p>o||m>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:b,k1:p,k2neg:x,k2:m}}}},Ks),RA=BigInt(0);var SA=oi.ProjectivePoint;var LA=Dn.utils.randomPrivateKey,Yd=()=>{let r=Dn.utils.randomPrivateKey(),e=vu(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},vu=Dn.getPublicKey;function Xd(r){try{return Dn.ExtendedPoint.fromHex(r),!0}catch{return!1}}var Pu=(r,e)=>Dn.sign(r,e.slice(0,32)),B1=Dn.verify,we=r=>ae.Buffer.isBuffer(r)?r:r instanceof Uint8Array?ae.Buffer.from(r.buffer,r.byteOffset,r.byteLength):ae.Buffer.from(r),Eu=class{constructor(e){Object.assign(this,e)}encode(){return ae.Buffer.from((0,xs.serialize)(jo,this))}static decode(e){return(0,xs.deserialize)(jo,this,e)}static decodeUnchecked(e){return(0,xs.deserializeUnchecked)(jo,this,e)}};var jo=new Map,gh,L1=32,dn=32;function C1(r){return r._bn!==void 0}var Jd=1,ce=class r extends Eu{constructor(e){if(super({}),this._bn=void 0,C1(e))this._bn=e._bn;else{if(typeof e=="string"){let t=vt.default.decode(e);if(t.length!=dn)throw new Error("Invalid public key input");this._bn=new wu.default(t)}else this._bn=new wu.default(e);if(this._bn.byteLength()>dn)throw new Error("Invalid public key input")}}static unique(){let e=new r(Jd);return Jd+=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===dn)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 s=ae.Buffer.concat([e.toBuffer(),ae.Buffer.from(t),n.toBuffer()]),i=Ks(s);return new r(i)}static createProgramAddressSync(e,t){let n=ae.Buffer.alloc(0);e.forEach(function(i){if(i.length>L1)throw new TypeError("Max seed length exceeded");n=ae.Buffer.concat([n,we(i)])}),n=ae.Buffer.concat([n,t.toBuffer(),ae.Buffer.from("ProgramDerivedAddress")]);let s=Ks(n);if(Xd(s))throw new Error("Invalid seeds, address must fall off the curve");return new r(s)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,s;for(;n!=0;){try{let i=e.concat(ae.Buffer.from([n]));s=this.createProgramAddressSync(i,t)}catch(i){if(i instanceof TypeError)throw i;n--;continue}return[s,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){let t=new r(e);return Xd(t.toBytes())}};gh=ce;ce.default=new gh("11111111111111111111111111111111");jo.set(ce,{kind:"struct",fields:[["_bn","u256"]]});var CA=new ce("BPFLoader1111111111111111111111111111111111"),Hn=1232,Mu=127,Ko=64,Ho=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Ho.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});var Go=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(Go.prototype,"name",{value:"TransactionExpiredTimeoutError"});var Kn=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(Kn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});var Rs=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((i,o)=>{n.set(i.toBase58(),o)});let s=i=>{let o=n.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}},be=(r="publicKey")=>E.blob(32,r),P1=(r="signature")=>E.blob(64,r),Es=(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),s=e;return s.decode=(i,o)=>t(i,o).chars.toString(),s.encode=(i,o,c)=>{let u={chars:ae.Buffer.from(i,"utf8")};return n(u,o,c)},s.alloc=i=>E.u32().span+E.u32().span+ae.Buffer.from(i,"utf8").length,s},M1=(r="authorized")=>E.struct([be("staker"),be("withdrawer")],r),U1=(r="lockup")=>E.struct([E.ns64("unixTimestamp"),E.ns64("epoch"),be("custodian")],r),D1=(r="voteInit")=>E.struct([be("nodePubkey"),be("authorizedVoter"),be("authorizedWithdrawer"),E.u8("commission")],r),z1=(r="voteAuthorizeWithSeedArgs")=>E.struct([E.u32("voteAuthorizationType"),be("currentAuthorityDerivedKeyOwnerPubkey"),Es("currentAuthorityDerivedKeySeed"),be("newAuthorized")],r);function yh(r,e){let t=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(e[s.property]);if("count"in s&&"elementLayout"in s){let i=e[s.property];if(Array.isArray(i))return i.length*t(s.elementLayout)}else if("fields"in s)return yh({layout:s},e[s.property]);return 0},n=0;return r.layout.fields.forEach(s=>{n+=t(s)}),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 Ae(r,e){if(!r)throw new Error(e||"Assertion failed")}var Zo=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,s=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},i=s(t);i.isSigner=!0,i.isWritable=!0;for(let o of e){s(o.programId).isInvoked=!0;for(let c of o.keys){let u=s(c.pubkey);u.isSigner||=c.isSigner,u.isWritable||=c.isWritable}}return new r(t,n)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];Ae(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),s=e.filter(([,u])=>!u.isSigner&&u.isWritable),i=e.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{Ae(t.length>0,"Expected at least one writable signer key");let[u]=t[0];Ae(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)),...s.map(([u])=>new ce(u)),...i.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),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:s},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=new Array,s=new Array;for(let[i,o]of this.keyMetaMap.entries())if(t(o)){let c=new ce(i),u=e.findIndex(p=>p.equals(c));u>=0&&(Ae(u<256,"Max lookup table index exceeded"),n.push(u),s.push(c),this.keyMetaMap.delete(i))}return[n,s]}},_h="Reached end of buffer unexpectedly";function Ur(r){if(r.length===0)throw new Error(_h);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(_h);return r.splice(...e)}var hn=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 Rs(this.staticAccountKeys)}static compile(e){let t=Zo.compile(e.instructions,e.payerKey),[n,s]=t.getMessageComponents(),o=new Rs(s).compileInstructions(e.instructions).map(c=>({programIdIndex:c.programIdIndex,accounts:c.accountKeyIndexes,data:vt.default.encode(c.data)}));return new r({header:n,accountKeys:s,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,i=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<i}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:x,programIdIndex:S}=b,T=Array.from(vt.default.decode(b.data)),I=[];Yt(I,x.length);let A=[];return Yt(A,T.length),{programIdIndex:S,keyIndicesCount:ae.Buffer.from(I),keyIndices:x,dataLength:ae.Buffer.from(A),data:T}}),s=[];Yt(s,n.length);let i=ae.Buffer.alloc(Hn);ae.Buffer.from(s).copy(i);let o=s.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,i,o);o+=S}),i=i.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(be("key"),e,"keys"),be("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=>we(b.toBytes())),recentBlockhash:vt.default.decode(this.recentBlockhash)},p=ae.Buffer.alloc(2048),m=c.encode(u,p);return i.copy(p,m),p.slice(0,m+i.length)}static from(e){let t=[...e],n=Ur(t);if(n!==(n&Mu))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let s=Ur(t),i=Ur(t),o=Zt(t),c=[];for(let x=0;x<o;x++){let S=Xt(t,0,dn);c.push(new ce(ae.Buffer.from(S)))}let u=Xt(t,0,dn),p=Zt(t),m=[];for(let x=0;x<p;x++){let S=Ur(t),T=Zt(t),I=Xt(t,0,T),A=Zt(t),B=Xt(t,0,A),U=vt.default.encode(ae.Buffer.from(B));m.push({programIdIndex:S,accounts:I,data:U})}let b={header:{numRequiredSignatures:n,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:vt.default.encode(ae.Buffer.from(u)),accountKeys:c,instructions:m};return new r(b)}},Yo=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 Rs(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 s=e-n,i=this.addressTableLookups.reduce((o,c)=>o+c.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){let s=e-t,o=n-t-this.header.numReadonlyUnsignedAccounts;return s<o}else{let s=t-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let s=e.find(i=>i.key.equals(n.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let i of n.writableIndexes)if(i<s.state.addresses.length)t.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${n.accountKey.toBase58()}`);for(let i of n.readonlyIndexes)if(i<s.state.addresses.length)t.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){let t=Zo.compile(e.instructions,e.payerKey),n=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(let m of i){let b=t.extractTableLookup(m);if(b!==void 0){let[x,{writable:S,readonly:T}]=b;n.push(x),s.writable.push(...S),s.readonly.push(...T)}}let[o,c]=t.getMessageComponents(),p=new Rs(c,s).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 s=this.serializeAddressTableLookups(),i=Array();Yt(i,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(be(),this.staticAccountKeys.length,"staticAccountKeys"),be("recentBlockhash"),E.blob(n.length,"instructionsLength"),E.blob(t.length,"serializedInstructions"),E.blob(i.length,"addressTableLookupsLength"),E.blob(s.length,"serializedAddressTableLookups")]),c=new Uint8Array(Hn),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(i),serializedAddressTableLookups:s},c);return c.slice(0,p)}serializeInstructions(){let e=0,t=new Uint8Array(Hn);for(let n of this.compiledInstructions){let s=Array();Yt(s,n.accountKeyIndexes.length);let i=Array();Yt(i,n.data.length);let o=E.struct([E.u8("programIdIndex"),E.blob(s.length,"encodedAccountKeyIndexesLength"),E.seq(E.u8(),n.accountKeyIndexes.length,"accountKeyIndexes"),E.blob(i.length,"encodedDataLength"),E.blob(n.data.length,"data")]);e+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(Hn);for(let n of this.addressTableLookups){let s=Array();Yt(s,n.writableIndexes.length);let i=Array();Yt(i,n.readonlyIndexes.length);let o=E.struct([be("accountKey"),E.blob(s.length,"encodedWritableIndexesLength"),E.seq(E.u8(),n.writableIndexes.length,"writableIndexes"),E.blob(i.length,"encodedReadonlyIndexesLength"),E.seq(E.u8(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e],n=Ur(t),s=n&Mu;Ae(n!==s,"Expected versioned message but received legacy message");let i=s;Ae(i===0,`Expected versioned message with version 0 but found version ${i}`);let o={numRequiredSignatures:Ur(t),numReadonlySignedAccounts:Ur(t),numReadonlyUnsignedAccounts:Ur(t)},c=[],u=Zt(t);for(let T=0;T<u;T++)c.push(new ce(Xt(t,0,dn)));let p=vt.default.encode(Xt(t,0,dn)),m=Zt(t),b=[];for(let T=0;T<m;T++){let I=Ur(t),A=Zt(t),B=Xt(t,0,A),U=Zt(t),L=new Uint8Array(Xt(t,0,U));b.push({programIdIndex:I,accountKeyIndexes:B,data:L})}let x=Zt(t),S=[];for(let T=0;T<x;T++){let I=new ce(Xt(t,0,dn)),A=Zt(t),B=Xt(t,0,A),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})}},na={deserializeMessageVersion(r){let e=r[0],t=e&Mu;return t===e?"legacy":t},deserialize:r=>{let e=na.deserializeMessageVersion(r);if(e==="legacy")return hn.from(r);if(e===0)return Yo.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},fn=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}({}),F1=ae.Buffer.alloc(Ko).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 s=[],i=[];t.forEach(I=>{I.keys.forEach(B=>{i.push({...B})});let A=I.programId.toString();s.includes(A)||s.push(A)}),s.forEach(I=>{i.push({pubkey:new ce(I),isSigner:!1,isWritable:!1})});let o=[];i.forEach(I=>{let A=I.pubkey.toString(),B=o.findIndex(U=>U.pubkey.toString()===A);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,A){if(I.isSigner!==A.isSigner)return I.isSigner?-1:1;if(I.isWritable!==A.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(A.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 A=o.findIndex(B=>B.pubkey.equals(I.publicKey));if(A>-1)o[A].isSigner||(o[A].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=[],x=[];o.forEach(({pubkey:I,isSigner:A,isWritable:B})=>{A?(b.push(I.toString()),u+=1,B||(p+=1)):(x.push(I.toString()),B||(m+=1))});let S=b.concat(x),T=t.map(I=>{let{data:A,programId:B}=I;return{programIdIndex:S.indexOf(B.toString()),accounts:I.keys.map(U=>S.indexOf(U.pubkey.toString())),data:vt.default.encode(A)}});return T.forEach(I=>{Ae(I.programIdIndex>=0),I.accounts.forEach(A=>Ae(A>=0))}),new hn({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((s,i)=>t[i].equals(s.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 s=n.toString();return t.has(s)?!1:(t.add(s),!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 i of e){let o=i.publicKey.toString();t.has(o)||(t.add(o),n.push(i))}this.signatures=n.map(i=>({signature:null,publicKey:i.publicKey}));let s=this._compile();this._partialSign(s,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");let t=new Set,n=[];for(let i of e){let o=i.publicKey.toString();t.has(o)||(t.add(o),n.push(i))}let s=this._compile();this._partialSign(s,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(s=>{let i=Pu(n,s.secretKey);this._addSignature(s.publicKey,we(i))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){Ae(t.length===64);let n=this.signatures.findIndex(s=>e.equals(s.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:s,publicKey:i}of this.signatures)s===null?t&&(n.missing||=[]).push(i):B1(s,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(n){let i=this._getMessageSignednessErrors(s,t);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[Yy]:"No signature verification implementation could be found.",[Jy]:"No key generation implementation could be found.",[Xy]:"No signing implementation could be found.",[Qy]:"No key export implementation could be found.",[cy]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[iw]:"Transaction processing left an account with an outstanding borrowed reference",[qb]:"Account in use",[jb]:"Account loaded twice",[Kb]:"Attempt to debit an account but found no record of a prior credit.",[dw]:"Transaction loads an address table account that doesn't exist",[Yb]:"This transaction has already been processed",[Jb]:"Blockhash not found",[Xb]:"Loader call chain is too deep",[sw]:"Transactions are currently disabled due to cluster maintenance",[bw]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Gb]:"Insufficient funds for fee",[ww]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Zb]:"This account may not be used to pay transaction fees",[ew]:"Transaction contains an invalid account reference",[pw]:"Transaction loads an address table account with invalid data",[mw]:"Transaction address table lookup uses an invalid index",[hw]:"Transaction loads an address table account with an invalid owner",[Rw]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[rw]:"This program may not be used for executing instructions",[gw]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[cw]:"Transaction loads a writable account that cannot be written",[Ew]:"Transaction exceeded max loaded accounts data size cap",[Qb]:"Transaction requires a fee but has no signature present",[Hb]:"Attempt to load a program that does not exist",[Sw]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[vw]:"ResanitizationNeeded",[nw]:"Transaction failed to sanitize accounts offsets correctly",[tw]:"Transaction did not pass signature verification",[lw]:"Transaction locked too many accounts",[xw]:"Sum of account balances before and after transaction do not match",[Wb]:"The transaction failed with the error `$errorName`",[aw]:"Transaction version is unsupported",[fw]:"Transaction would exceed account data limit within the block",[_w]:"Transaction would exceed total account data limit",[uw]:"Transaction would exceed max account limit within the block",[ow]:"Transaction would exceed max Block Cost Limit",[yw]:"Transaction would exceed max Vote Cost Limit",[Db]:"Attempted to sign a transaction with an address that is not a signer for it",[Bb]:"Transaction is missing an address at index: $index.",[zb]:"Transaction has no expected signers therefore it cannot be encoded",[xb]:"Transaction does not have a blockhash lifetime",[Ab]:"Transaction is not a durable nonce transaction",[kb]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Ob]:"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",[Nb]:"No fee payer set in CompiledTransaction",[Tb]:"Could not find program address at index $index",[$b]:"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",[Vb]:"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",[Cb]:"Transaction is missing a fee payer.",[Pb]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Ub]:"Transaction first instruction is not advance nonce account instruction.",[Mb]:"Transaction with no instructions cannot be durable nonce transaction.",[vb]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Sb]:"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.",[Lb]:"Transaction is missing signatures for addresses: $addresses.",[Ib]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"};function Qw(r,e={}){{let t=`Solana error #${r}; Decode this error by running \`npx @solana/errors decode -- ${r}`;return Object.keys(e).length&&(t+=` '${Xw(e)}'`),`${t}\``}}var an=class extends Error{cause=this.cause;context;constructor(...[r,e]){let t,n;if(e){let{cause:i,...o}=e;i&&(n={cause:i}),Object.keys(o).length>0&&(t=o)}let s=Qw(r,t);super(s,n),this.context={__code:r,...t},this.name="SolanaError"}};function e1(r,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(r)}function md(r){return Object.freeze({...r,encode:e=>{let t=new Uint8Array(e1(e,r));return r.write(e,t,0),t}})}function gd(r){return Object.freeze({...r,decode:(e,t=0)=>r.read(e,t)[0]})}function Rs(r){return"fixedSize"in r&&typeof r.fixedSize=="number"}function yd(r,e){if(Rs(r)!==Rs(e))throw new an(Hc);if(Rs(r)&&Rs(e)&&r.fixedSize!==e.fixedSize)throw new an(Gc,{decoderFixedSize:e.fixedSize,encoderFixedSize:r.fixedSize});if(!Rs(r)&&!Rs(e)&&r.maxSize!==e.maxSize)throw new an(Zc,{decoderMaxSize:e.maxSize,encoderMaxSize:r.maxSize});return{...e,...r,decode:e.decode,encode:r.encode,read:e.read,write:r.write}}function _d(r,e,t=0){if(e.length-t<=0)throw new an(jc,{codecDescription:r})}function bd(r,e,t,n=0){let s=t.length-n;if(s<e)throw new an(Kc,{bytesLength:s,codecDescription:r,expected:e})}function t1(r,e,t,n){if(n<e||n>t)throw new an(Yc,{codecDescription:r,max:t,min:e,value:n})}function wd(r){return r?.endian!==1}function r1(r){return md({fixedSize:r.size,write(e,t,n){r.range&&t1(r.name,r.range[0],r.range[1],e);let s=new ArrayBuffer(r.size);return r.set(new DataView(s),e,wd(r.config)),t.set(new Uint8Array(s),n),n+r.size}})}function n1(r){return gd({fixedSize:r.size,read(e,t=0){_d(r.name,e,t),bd(r.name,r.size,e,t);let n=new DataView(s1(e,t,r.size));return[r.get(n,wd(r.config)),t+r.size]}})}function s1(r,e,t){let n=r.byteOffset+(e??0),s=t??r.byteLength;return r.buffer.slice(n,n+s)}var Jc=(r={})=>r1({config:r,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),i1=(r={})=>n1({config:r,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),Ed=(r={})=>yd(Jc(r),i1(r));var Xc=class extends TypeError{constructor(e,t){let n,{message:s,explanation:i,...o}=e,{path:c}=e,u=c.length===0?s:`At path: ${c.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}};function o1(r){return ti(r)&&typeof r[Symbol.iterator]=="function"}function ti(r){return typeof r=="object"&&r!=null}function Po(r){return ti(r)&&!Array.isArray(r)}function ur(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function a1(r){let{done:e,value:t}=r.next();return e?void 0:t}function c1(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});let{path:s,branch:i}=e,{type:o}=t,{refinement:c,message:u=`Expected a value of type \`${o}\`${c?` with refinement \`${c}\``:""}, but received: \`${ur(n)}\``}=r;return{value:n,type:o,refinement:c,key:s[s.length-1],path:s,branch:i,...r,message:u}}function*Rd(r,e,t,n){o1(r)||(r=[r]);for(let s of r){let i=c1(s,e,t,n);i&&(yield i)}}function*Qc(r,e,t={}){let{path:n=[],branch:s=[r],coerce:i=!1,mask:o=!1}=t,c={path:n,branch:s,mask:o};i&&(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 x=Qc(m,b,{path:p===void 0?n:[...n,p],branch:p===void 0?s:[...s,m],coerce:i,mask:o,message:t.message});for(let S of x)S[0]?(u=S[0].refinement!=null?"not_refined":"not_valid",yield[S[0],void 0]):i&&(m=S[1],p===void 0?r=m:r instanceof Map?r.set(p,m):r instanceof Set?r.add(m):ti(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 nr=class{constructor(e){let{type:t,schema:n,validator:s,refiner:i,coercer:o=u=>u,entries:c=function*(){}}=e;this.type=t,this.schema=n,this.entries=c,this.coercer=o,s?this.validator=(u,p)=>{let m=s(u,p);return Rd(m,p,this,u)}:this.validator=()=>[],i?this.refiner=(u,p)=>{let m=i(u,p);return Rd(m,p,this,u)}:this.refiner=()=>[]}assert(e,t){return vd(e,this,t)}create(e,t){return V(e,this,t)}is(e){return Sd(e,this)}mask(e,t){return u1(e,this,t)}validate(e,t={}){return ri(e,this,t)}};function vd(r,e,t){let n=ri(r,e,{message:t});if(n[0])throw n[0]}function V(r,e,t){let n=ri(r,e,{coerce:!0,message:t});if(n[0])throw n[0];return n[1]}function u1(r,e,t){let n=ri(r,e,{coerce:!0,mask:!0,message:t});if(n[0])throw n[0];return n[1]}function Sd(r,e){return!ri(r,e)[0]}function ri(r,e,t={}){let n=Qc(r,e,t),s=a1(n);return s[0]?[new Xc(s[0],function*(){for(let o of n)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function jn(r,e){return new nr({type:r,schema:null,validator:e})}function xd(){return jn("any",()=>!0)}function q(r){return new nr({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: ${ur(e)}`}})}function fr(){return jn("boolean",r=>typeof r=="boolean")}function Mo(r){return jn("instance",e=>e instanceof r||`Expected a \`${r.name}\` instance, but received: ${ur(e)}`)}function Me(r){let e=ur(r),t=typeof r;return new nr({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${e}\`, but received: ${ur(n)}`}})}function f1(){return jn("never",()=>!1)}function j(r){return new nr({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function k(){return jn("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${ur(r)}`)}function ne(r){return new nr({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function eu(r,e){return new nr({type:"record",schema:null,*entries(t){if(ti(t))for(let n in t){let s=t[n];yield[n,n,r],yield[n,s,e]}},validator(t){return Po(t)||`Expected an object, but received: ${ur(t)}`},coercer(t){return Po(t)?{...t}:t}})}function z(){return jn("string",r=>typeof r=="string"||`Expected a string, but received: ${ur(r)}`)}function Uo(r){let e=f1();return new nr({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let n=Math.max(r.length,t.length);for(let s=0;s<n;s++)yield[s,t[s],r[s]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${ur(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function P(r){let e=Object.keys(r);return new nr({type:"type",schema:r,*entries(t){if(ti(t))for(let n of e)yield[n,t[n],r[n]]},validator(t){return Po(t)||`Expected an object, but received: ${ur(t)}`},coercer(t){return Po(t)?{...t}:t}})}function Nt(r){let e=r.map(t=>t.type).join(" | ");return new nr({type:"union",schema:null,coercer(t,n){for(let s of r){let[i,o]=s.validate(t,{coerce:!0,mask:n.mask});if(!i)return o}return t},validator(t,n){let s=[];for(let i of r){let[...o]=Qc(t,i,n),[c]=o;if(c[0])for(let[u]of o)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${ur(t)}`,...s]}})}function Kn(){return jn("unknown",()=>!0)}function vs(r,e,t){return new nr({...r,coercer:(n,s)=>Sd(n,e)?r.coercer(t(n,s),s):r.coercer(n,s)})}var Ch=vr(Zd());var Qd=vr(qs(),1);var Hn=vr(Jd(),1);var Xd=Hn.default;var M1=class extends Hn.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(s){n(s)}}close(r,e){this.socket.close(r,e)}addEventListener(r,e,t){this.socket.addEventListener(r,e,t)}};function eh(r,e){return new M1(r,e)}var U1=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},th=class extends Hn.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:s=1e3,max_reconnects:i=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=s,this.max_reconnects=i,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 U1,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((s,i)=>{if(!this.ready)return i(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 i(u);this.queue[o]={promise:[s,i]},t&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],i(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 s={jsonrpc:"2.0",method:r,params:e};this.socket.send(this.dataPack.encode(s),i=>{if(i)return n(i);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=Qd.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 s=0;s<t.params.length;s++)n.push(t.params[s]);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 sh=[],ih=[],oh=[],D1=BigInt(0),ci=BigInt(1),z1=BigInt(2),F1=BigInt(7),$1=BigInt(256),V1=BigInt(113);for(let r=0,e=ci,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],sh.push(2*(5*n+t)),ih.push((r+1)*(r+2)/2%64);let s=D1;for(let i=0;i<7;i++)e=(e<<ci^(e>>F1)*V1)%$1,e&z1&&(s^=ci<<(ci<<BigInt(i))-ci);oh.push(s)}var[W1,q1]=lc(oh,!0),rh=(r,e,t)=>t>32?pc(r,e,t):dc(r,e,t),nh=(r,e,t)=>t>32?mc(r,e,t):hc(r,e,t);function j1(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=rh(p,m,1)^t[c],x=nh(p,m,1)^t[c+1];for(let S=0;S<50;S+=10)r[o+S]^=b,r[o+S+1]^=x}let s=r[2],i=r[3];for(let o=0;o<24;o++){let c=ih[o],u=rh(s,i,c),p=nh(s,i,c),m=sh[o];s=r[m],i=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]^=W1[n],r[1]^=q1[n]}t.fill(0)}var qo=class r extends Gr{constructor(e,t,n,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,js(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=kl(this.state)}keccak(){ac||cc(this.state32),j1(this.state32,this.rounds),ac||cc(this.state32),this.posOut=0,this.pos=0}update(e){Or(this);let{blockLen:t,state:n}=this;e=Zr(e);let s=e.length;for(let i=0;i<s;){let o=Math.min(t-this.pos,s-i);for(let c=0;c<o;c++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,(t&128)!==0&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Or(this,!1),Hr(e),this.finish();let t=this.state,{blockLen:n}=this;for(let s=0,i=e.length;s<i;){this.posOut>=n&&this.keccak();let o=Math.min(n-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=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 js(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Zi(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:s,rounds:i,enableXOF:o}=this;return e||(e=new r(t,n,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}},ln=(r,e,t)=>ms(()=>new qo(e,r,t)),vA=ln(6,144,224/8),SA=ln(6,136,256/8),xA=ln(6,104,384/8),AA=ln(6,72,512/8),IA=ln(1,144,224/8),lu=ln(1,136,256/8),kA=ln(1,104,384/8),OA=ln(1,72,512/8),ah=(r,e,t)=>Tl((n={})=>new qo(e,r,n.dkLen===void 0?t:n.dkLen,!0)),TA=ah(31,168,128/8),NA=ah(31,136,256/8);var jo=class extends Gr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Il(e);let n=Zr(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 s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Or(this),this.iHash.update(e),this}digestInto(e){Or(this),Hr(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:s,destroyed:i,blockLen:o,outputLen:c}=this;return e=e,e.finished=s,e.destroyed=i,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()}},du=(r,e,t)=>new jo(r,e).update(t).digest();du.create=(r,e)=>new jo(r,e);function ch(r){r.lowS!==void 0&&ar("lowS",r.lowS),r.prehash!==void 0&&ar("prehash",r.prehash)}function K1(r){let e=Gs(r);_r(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:s}=e;if(t){if(!n.eql(s,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:H1,hexToBytes:G1}=to,hu=class extends Error{constructor(e=""){super(e)}},Mr={Err:hu,_tlv:{encode:(r,e)=>{let{Err:t}=Mr;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,s=Mn(n);if(s.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Mn(s.length/2|128):"";return Mn(r)+i+s+e},decode(r,e){let{Err:t}=Mr,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 s=e[n++],i=!!(s&128),o=0;if(!i)o=s;else{let u=s&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}=Mr;if(r<Ur)throw new e("integer: negative integers are not allowed");let t=Mn(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}=Mr;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 H1(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Mr,s=typeof r=="string"?G1(r):r;ys(s);let{v:i,l:o}=n.decode(48,s);if(o.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:u}=n.decode(2,i),{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}=Mr,n=e.encode(2,t.encode(r.r)),s=e.encode(2,t.encode(r.s)),i=n+s;return e.encode(48,i)}},Ur=BigInt(0),wt=BigInt(1),zA=BigInt(2),uh=BigInt(3),FA=BigInt(4);function Z1(r){let e=K1(r),{Fp:t}=e,n=tn(e.n,e.nBitLength),s=e.toBytes||((I,A,L)=>{let U=A.toAffine();return Br(Uint8Array.from([4]),t.toBytes(U.x),t.toBytes(U.y))}),i=e.fromBytes||(I=>{let A=I.subarray(1),L=t.fromBytes(A.subarray(0,t.BYTES)),U=t.fromBytes(A.subarray(t.BYTES,2*t.BYTES));return{x:L,y:U}});function o(I){let{a:A,b:L}=e,U=t.sqr(I),B=t.mul(U,I);return t.add(t.add(B,t.mul(I,A)),L)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function c(I){return Ks(I,wt,e.n)}function u(I){let{allowedPrivateKeyLengths:A,nByteLength:L,wrapPrivateKey:U,n:B}=e;if(A&&typeof I!="bigint"){if(Xr(I)&&(I=Nr(I)),typeof I!="string"||!A.includes(I.length))throw new Error("invalid private key");I=I.padStart(L*2,"0")}let F;try{F=typeof I=="bigint"?I:Lr(We("private key",I,L))}catch{throw new Error("invalid private key, expected hex or "+L+" bytes, got "+typeof I)}return U&&(F=ke(F,B)),jt("private key",F,wt,B),F}function p(I){if(!(I instanceof x))throw new Error("ProjectivePoint expected")}let m=zn((I,A)=>{let{px:L,py:U,pz:B}=I;if(t.eql(B,t.ONE))return{x:L,y:U};let F=I.is0();A==null&&(A=F?t.ONE:t.inv(B));let te=t.mul(L,A),G=t.mul(U,A),Z=t.mul(B,A);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:G}}),b=zn(I=>{if(I.is0()){if(e.allowInfinityPoint&&!t.is0(I.py))return;throw new Error("bad point: ZERO")}let{x:A,y:L}=I.toAffine();if(!t.isValid(A)||!t.isValid(L))throw new Error("bad point: x or y not FE");let U=t.sqr(L),B=o(A);if(!t.eql(U,B))throw new Error("bad point: equation left != right");if(!I.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class x{constructor(A,L,U){if(this.px=A,this.py=L,this.pz=U,A==null||!t.isValid(A))throw new Error("x required");if(L==null||!t.isValid(L))throw new Error("y required");if(U==null||!t.isValid(U))throw new Error("z required");Object.freeze(this)}static fromAffine(A){let{x:L,y:U}=A||{};if(!A||!t.isValid(L)||!t.isValid(U))throw new Error("invalid affine point");if(A instanceof x)throw new Error("projective point not allowed");let B=F=>t.eql(F,t.ZERO);return B(L)&&B(U)?x.ZERO:new x(L,U,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(A){let L=t.invertBatch(A.map(U=>U.pz));return A.map((U,B)=>U.toAffine(L[B])).map(x.fromAffine)}static fromHex(A){let L=x.fromAffine(i(We("pointHex",A)));return L.assertValidity(),L}static fromPrivateKey(A){return x.BASE.multiply(u(A))}static msm(A,L){return io(x,n,A,L)}_setWindowSize(A){T.setWindowSize(this,A)}assertValidity(){b(this)}hasEvenY(){let{y:A}=this.toAffine();if(t.isOdd)return!t.isOdd(A);throw new Error("Field doesn't support isOdd")}equals(A){p(A);let{px:L,py:U,pz:B}=this,{px:F,py:te,pz:G}=A,Z=t.eql(t.mul(L,G),t.mul(F,B)),ee=t.eql(t.mul(U,G),t.mul(te,B));return Z&&ee}negate(){return new x(this.px,t.neg(this.py),this.pz)}double(){let{a:A,b:L}=e,U=t.mul(L,uh),{px:B,py:F,pz:te}=this,G=t.ZERO,Z=t.ZERO,ee=t.ZERO,Y=t.mul(B,B),Ie=t.mul(F,F),re=t.mul(te,te),fe=t.mul(B,F);return fe=t.add(fe,fe),ee=t.mul(B,te),ee=t.add(ee,ee),G=t.mul(A,ee),Z=t.mul(U,re),Z=t.add(G,Z),G=t.sub(Ie,Z),Z=t.add(Ie,Z),Z=t.mul(G,Z),G=t.mul(fe,G),ee=t.mul(U,ee),re=t.mul(A,re),fe=t.sub(Y,re),fe=t.mul(A,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),G=t.sub(G,Y),ee=t.mul(re,Ie),ee=t.add(ee,ee),ee=t.add(ee,ee),new x(G,Z,ee)}add(A){p(A);let{px:L,py:U,pz:B}=this,{px:F,py:te,pz:G}=A,Z=t.ZERO,ee=t.ZERO,Y=t.ZERO,Ie=e.a,re=t.mul(e.b,uh),fe=t.mul(L,F),E=t.mul(U,te),a=t.mul(B,G),l=t.add(L,U),d=t.add(F,te);l=t.mul(l,d),d=t.add(fe,E),l=t.sub(l,d),d=t.add(L,B);let h=t.add(F,G);return d=t.mul(d,h),h=t.add(fe,a),d=t.sub(d,h),h=t.add(U,B),Z=t.add(te,G),h=t.mul(h,Z),Z=t.add(E,a),h=t.sub(h,Z),Y=t.mul(Ie,d),Z=t.mul(re,a),Y=t.add(Z,Y),Z=t.sub(E,Y),Y=t.add(E,Y),ee=t.mul(Z,Y),E=t.add(fe,fe),E=t.add(E,fe),a=t.mul(Ie,a),d=t.mul(re,d),E=t.add(E,a),a=t.sub(fe,a),a=t.mul(Ie,a),d=t.add(d,a),fe=t.mul(E,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,E),Y=t.mul(h,Y),Y=t.add(Y,fe),new x(Z,ee,Y)}subtract(A){return this.add(A.negate())}is0(){return this.equals(x.ZERO)}wNAF(A){return T.wNAFCached(this,A,x.normalizeZ)}multiplyUnsafe(A){let{endo:L,n:U}=e;jt("scalar",A,Ur,U);let B=x.ZERO;if(A===Ur)return B;if(this.is0()||A===wt)return this;if(!L||T.hasPrecomputes(this))return T.wNAFCachedUnsafe(this,A,x.normalizeZ);let{k1neg:F,k1:te,k2neg:G,k2:Z}=L.splitScalar(A),ee=B,Y=B,Ie=this;for(;te>Ur||Z>Ur;)te&wt&&(ee=ee.add(Ie)),Z&wt&&(Y=Y.add(Ie)),Ie=Ie.double(),te>>=wt,Z>>=wt;return F&&(ee=ee.negate()),G&&(Y=Y.negate()),Y=new x(t.mul(Y.px,L.beta),Y.py,Y.pz),ee.add(Y)}multiply(A){let{endo:L,n:U}=e;jt("scalar",A,wt,U);let B,F;if(L){let{k1neg:te,k1:G,k2neg:Z,k2:ee}=L.splitScalar(A),{p:Y,f:Ie}=this.wNAF(G),{p:re,f:fe}=this.wNAF(ee);Y=T.constTimeNegate(te,Y),re=T.constTimeNegate(Z,re),re=new x(t.mul(re.px,L.beta),re.py,re.pz),B=Y.add(re),F=Ie.add(fe)}else{let{p:te,f:G}=this.wNAF(A);B=te,F=G}return x.normalizeZ([B,F])[0]}multiplyAndAddUnsafe(A,L,U){let B=x.BASE,F=(G,Z)=>Z===Ur||Z===wt||!G.equals(B)?G.multiplyUnsafe(Z):G.multiply(Z),te=F(this,L).add(F(A,U));return te.is0()?void 0:te}toAffine(A){return m(this,A)}isTorsionFree(){let{h:A,isTorsionFree:L}=e;if(A===wt)return!0;if(L)return L(x,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:A,clearCofactor:L}=e;return A===wt?this:L?L(x,this):this.multiplyUnsafe(e.h)}toRawBytes(A=!0){return ar("isCompressed",A),this.assertValidity(),s(x,this,A)}toHex(A=!0){return ar("isCompressed",A),Nr(this.toRawBytes(A))}}x.BASE=new x(e.Gx,e.Gy,t.ONE),x.ZERO=new x(t.ZERO,t.ONE,t.ZERO);let S=e.nBitLength,T=so(x,e.endo?Math.ceil(S/2):S);return{CURVE:e,ProjectivePoint:x,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:c}}function Y1(r){let e=Gs(r);return _r(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function fh(r){let e=Y1(r),{Fp:t,n}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(a){return ke(a,n)}function c(a){return ro(a,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:p,weierstrassEquation:m,isWithinCurveOrder:b}=Z1({...e,toBytes(a,l,d){let h=l.toAffine(),g=t.toBytes(h.x),w=Br;return ar("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===s&&(d===2||d===3)){let g=Lr(h);if(!Ks(g,wt,t.ORDER))throw new Error("Point is not on curve");let w=m(g),v;try{v=t.sqrt(w)}catch(_){let C=_ instanceof Error?": "+_.message:"";throw new Error("Point is not on curve"+C)}let y=(v&wt)===wt;return(d&1)===1!==y&&(v=t.neg(v)),{x:g,y:v}}else if(l===i&&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=s,w=i;throw new Error("invalid Point, expected length of "+g+", or uncompressed "+w+", got "+l)}}}),x=a=>Nr(en(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)=>Lr(a.slice(l,d));class A{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 A(I(l,0,d),I(l,d,2*d))}static fromDER(l){let{r:d,s:h}=Mr.toSig(We("DER",l));return new A(d,h)}assertValidity(){jt("r",this.r,wt,n),jt("s",this.s,wt,n)}addRecoveryBit(l){return new A(this.r,this.s,l)}recoverPublicKey(l){let{r:d,s:h,recovery:g}=this,w=G(We("msgHash",l));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let v=g===2||g===3?d+e.n:d;if(v>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let y=(g&1)===0?"02":"03",f=u.fromHex(y+x(v)),_=c(v),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 A(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Un(this.toDERHex())}toDERHex(){return Mr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Un(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}let L={isValidPrivateKey(a){try{return p(a),!0}catch{return!1}},normPrivateKeyToScalar:p,randomPrivateKey:()=>{let a=xc(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 B(a){let l=Xr(a),d=typeof a=="string",h=(l||d)&&a.length;return l?h===s||h===i:d?h===2*s||h===2*i:a instanceof u}function F(a,l,d=!0){if(B(a))throw new Error("first arg must be private key");if(!B(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=Lr(a),d=a.length*8-e.nBitLength;return d>0?l>>BigInt(d):l},G=e.bits2int_modN||function(a){return o(te(a))},Z=Hs(e.nBitLength);function ee(a){return jt("num < 2^"+e.nBitLength,a,Ur,Z),en(a,e.nByteLength)}function Y(a,l,d=Ie){if(["recovered","canonical"].some(se=>se in d))throw new Error("sign() legacy options not supported");let{hash:h,randomBytes:g}=e,{lowS:w,prehash:v,extraEntropy:y}=d;w==null&&(w=!0),a=We("msgHash",a),ch(d),v&&(a=We("prehashed msgHash",h(a)));let f=G(a),_=p(l),C=[ee(_),ee(f)];if(y!=null&&y!==!1){let se=y===!0?g(t.BYTES):y;C.push(We("extraEntropy",se))}let D=Br(...C),$=f;function X(se){let ue=te(se);if(!b(ue))return;let Be=c(ue),he=u.BASE.multiply(ue).toAffine(),me=o(he.x);if(me===Ur)return;let Gt=o(Be*o($+me*_));if(Gt===Ur)return;let xe=(he.x===me?0:2)|Number(he.y&wt),Ne=Gt;return w&&S(Gt)&&(Ne=T(Gt),xe^=1),new A(me,Ne,xe)}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 Ec(w.hash.outputLen,w.nByteLength,w.hmac)(h,g)}u.BASE._setWindowSize(8);function E(a,l,d,h=re){let g=a;l=We("msgHash",l),d=We("publicKey",d);let{lowS:w,prehash:v,format:y}=h;if(ch(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"||Xr(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 A(g.r,g.s)),f){try{y!=="compact"&&(C=A.fromDER(g))}catch(xe){if(!(xe instanceof Mr.Err))throw xe}!C&&y!=="der"&&(C=A.fromCompact(g))}D=u.fromHex(d)}catch{return!1}if(!C||w&&C.hasHighS())return!1;v&&(l=e.hash(l));let{r:$,s:X}=C,se=G(l),ue=c(X),Be=o(se*ue),he=o($*ue),me=u.BASE.multiplyAndAddUnsafe(D,Be,he)?.toAffine();return me?o(me.x)===$:!1}return{CURVE:e,getPublicKey:U,getSharedSecret:F,sign:fe,verify:E,ProjectivePoint:u,Signature:A,utils:L}}function J1(r){return{hash:r,hmac:(e,...t)=>du(r,e,uc(...t)),randomBytes:Ji}}function lh(r,e){let t=n=>fh({...r,...J1(n)});return{...t(e),create:t}}var ph=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),dh=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),X1=BigInt(1),pu=BigInt(2),hh=(r,e)=>(r+e/pu)/e;function Q1(r){let e=ph,t=BigInt(3),n=BigInt(6),s=BigInt(11),i=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,x=Pe(b,t,e)*m%e,S=Pe(x,pu,e)*p%e,T=Pe(S,s,e)*S%e,I=Pe(T,i,e)*T%e,A=Pe(I,c,e)*I%e,L=Pe(A,u,e)*A%e,U=Pe(L,c,e)*I%e,B=Pe(U,t,e)*m%e,F=Pe(B,o,e)*T%e,te=Pe(F,n,e)*p%e,G=Pe(te,pu,e);if(!mu.eql(mu.sqr(G),r))throw new Error("Cannot find square root");return G}var mu=tn(ph,void 0,void 0,{sqrt:Q1}),ui=lh({a:BigInt(0),b:BigInt(7),Fp:mu,n:dh,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=dh,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-X1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),c=hh(i*r,e),u=hh(-n*r,e),p=ke(r-c*t-u*s,e),m=ke(-c*n-u*i,e),b=p>o,x=m>o;if(b&&(p=e-p),x&&(m=e-m),p>o||m>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:b,k1:p,k2neg:x,k2:m}}}},Zs),ZA=BigInt(0);var YA=ui.ProjectivePoint;var iI=$n.utils.randomPrivateKey,mh=()=>{let r=$n.utils.randomPrivateKey(),e=xu(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},xu=$n.getPublicKey;function gh(r){try{return $n.ExtendedPoint.fromHex(r),!0}catch{return!1}}var zu=(r,e)=>$n.sign(r,e.slice(0,32)),eE=$n.verify,we=r=>ae.Buffer.isBuffer(r)?r:r instanceof Uint8Array?ae.Buffer.from(r.buffer,r.byteOffset,r.byteLength):ae.Buffer.from(r),Au=class{constructor(e){Object.assign(this,e)}encode(){return ae.Buffer.from((0,Is.serialize)(Go,this))}static decode(e){return(0,Is.deserialize)(Go,this,e)}static decodeUnchecked(e){return(0,Is.deserializeUnchecked)(Go,this,e)}};var Go=new Map,Ph,tE=32,pn=32;function rE(r){return r._bn!==void 0}var yh=1,ce=class r extends Au{constructor(e){if(super({}),this._bn=void 0,rE(e))this._bn=e._bn;else{if(typeof e=="string"){let t=Et.default.decode(e);if(t.length!=pn)throw new Error("Invalid public key input");this._bn=new Su.default(t)}else this._bn=new Su.default(e);if(this._bn.byteLength()>pn)throw new Error("Invalid public key input")}}static unique(){let e=new r(yh);return yh+=1,new r(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Et.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===pn)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 s=ae.Buffer.concat([e.toBuffer(),ae.Buffer.from(t),n.toBuffer()]),i=Zs(s);return new r(i)}static createProgramAddressSync(e,t){let n=ae.Buffer.alloc(0);e.forEach(function(i){if(i.length>tE)throw new TypeError("Max seed length exceeded");n=ae.Buffer.concat([n,we(i)])}),n=ae.Buffer.concat([n,t.toBuffer(),ae.Buffer.from("ProgramDerivedAddress")]);let s=Zs(n);if(gh(s))throw new Error("Invalid seeds, address must fall off the curve");return new r(s)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,s;for(;n!=0;){try{let i=e.concat(ae.Buffer.from([n]));s=this.createProgramAddressSync(i,t)}catch(i){if(i instanceof TypeError)throw i;n--;continue}return[s,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){let t=new r(e);return gh(t.toBytes())}};Ph=ce;ce.default=new Ph("11111111111111111111111111111111");Go.set(ce,{kind:"struct",fields:[["_bn","u256"]]});var oI=new ce("BPFLoader1111111111111111111111111111111111"),Yn=1232,Fu=127,Zo=64,Yo=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Yo.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 Zn=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(Zn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});var xs=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((i,o)=>{n.set(i.toBase58(),o)});let s=i=>{let o=n.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}},be=(r="publicKey")=>R.blob(32,r),nE=(r="signature")=>R.blob(64,r),Ss=(r="string")=>{let e=R.struct([R.u32("length"),R.u32("lengthPadding"),R.blob(R.offset(R.u32(),-8),"chars")],r),t=e.decode.bind(e),n=e.encode.bind(e),s=e;return s.decode=(i,o)=>t(i,o).chars.toString(),s.encode=(i,o,c)=>{let u={chars:ae.Buffer.from(i,"utf8")};return n(u,o,c)},s.alloc=i=>R.u32().span+R.u32().span+ae.Buffer.from(i,"utf8").length,s},sE=(r="authorized")=>R.struct([be("staker"),be("withdrawer")],r),iE=(r="lockup")=>R.struct([R.ns64("unixTimestamp"),R.ns64("epoch"),be("custodian")],r),oE=(r="voteInit")=>R.struct([be("nodePubkey"),be("authorizedVoter"),be("authorizedWithdrawer"),R.u8("commission")],r),aE=(r="voteAuthorizeWithSeedArgs")=>R.struct([R.u32("voteAuthorizationType"),be("currentAuthorityDerivedKeyOwnerPubkey"),Ss("currentAuthorityDerivedKeySeed"),be("newAuthorized")],r);function Mh(r,e){let t=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(e[s.property]);if("count"in s&&"elementLayout"in s){let i=e[s.property];if(Array.isArray(i))return i.length*t(s.elementLayout)}else if("fields"in s)return Mh({layout:s},e[s.property]);return 0},n=0;return r.layout.fields.forEach(s=>{n+=t(s)}),n}function Yt(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 Jt(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 Ae(r,e){if(!r)throw new Error(e||"Assertion failed")}var Xo=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,s=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},i=s(t);i.isSigner=!0,i.isWritable=!0;for(let o of e){s(o.programId).isInvoked=!0;for(let c of o.keys){let u=s(c.pubkey);u.isSigner||=c.isSigner,u.isWritable||=c.isWritable}}return new r(t,n)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];Ae(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),s=e.filter(([,u])=>!u.isSigner&&u.isWritable),i=e.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{Ae(t.length>0,"Expected at least one writable signer key");let[u]=t[0];Ae(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)),...s.map(([u])=>new ce(u)),...i.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),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:s},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=new Array,s=new Array;for(let[i,o]of this.keyMetaMap.entries())if(t(o)){let c=new ce(i),u=e.findIndex(p=>p.equals(c));u>=0&&(Ae(u<256,"Max lookup table index exceeded"),n.push(u),s.push(c),this.keyMetaMap.delete(i))}return[n,s]}},Uh="Reached end of buffer unexpectedly";function zr(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 mn=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:Et.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new xs(this.staticAccountKeys)}static compile(e){let t=Xo.compile(e.instructions,e.payerKey),[n,s]=t.getMessageComponents(),o=new xs(s).compileInstructions(e.instructions).map(c=>({programIdIndex:c.programIdIndex,accounts:c.accountKeyIndexes,data:Et.default.encode(c.data)}));return new r({header:n,accountKeys:s,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,i=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<i}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=[];Jt(t,e);let n=this.instructions.map(b=>{let{accounts:x,programIdIndex:S}=b,T=Array.from(Et.default.decode(b.data)),I=[];Jt(I,x.length);let A=[];return Jt(A,T.length),{programIdIndex:S,keyIndicesCount:ae.Buffer.from(I),keyIndices:x,dataLength:ae.Buffer.from(A),data:T}}),s=[];Jt(s,n.length);let i=ae.Buffer.alloc(Yn);ae.Buffer.from(s).copy(i);let o=s.length;n.forEach(b=>{let S=R.struct([R.u8("programIdIndex"),R.blob(b.keyIndicesCount.length,"keyIndicesCount"),R.seq(R.u8("keyIndex"),b.keyIndices.length,"keyIndices"),R.blob(b.dataLength.length,"dataLength"),R.seq(R.u8("userdatum"),b.data.length,"data")]).encode(b,i,o);o+=S}),i=i.slice(0,o);let c=R.struct([R.blob(1,"numRequiredSignatures"),R.blob(1,"numReadonlySignedAccounts"),R.blob(1,"numReadonlyUnsignedAccounts"),R.blob(t.length,"keyCount"),R.seq(be("key"),e,"keys"),be("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=>we(b.toBytes())),recentBlockhash:Et.default.decode(this.recentBlockhash)},p=ae.Buffer.alloc(2048),m=c.encode(u,p);return i.copy(p,m),p.slice(0,m+i.length)}static from(e){let t=[...e],n=zr(t);if(n!==(n&Fu))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let s=zr(t),i=zr(t),o=Yt(t),c=[];for(let x=0;x<o;x++){let S=Xt(t,0,pn);c.push(new ce(ae.Buffer.from(S)))}let u=Xt(t,0,pn),p=Yt(t),m=[];for(let x=0;x<p;x++){let S=zr(t),T=Yt(t),I=Xt(t,0,T),A=Yt(t),L=Xt(t,0,A),U=Et.default.encode(ae.Buffer.from(L));m.push({programIdIndex:S,accounts:I,data:U})}let b={header:{numRequiredSignatures:n,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:Et.default.encode(ae.Buffer.from(u)),accountKeys:c,instructions:m};return new r(b)}},Qo=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 xs(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 s=e-n,i=this.addressTableLookups.reduce((o,c)=>o+c.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){let s=e-t,o=n-t-this.header.numReadonlyUnsignedAccounts;return s<o}else{let s=t-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let s=e.find(i=>i.key.equals(n.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let i of n.writableIndexes)if(i<s.state.addresses.length)t.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${n.accountKey.toBase58()}`);for(let i of n.readonlyIndexes)if(i<s.state.addresses.length)t.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){let t=Xo.compile(e.instructions,e.payerKey),n=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(let m of i){let b=t.extractTableLookup(m);if(b!==void 0){let[x,{writable:S,readonly:T}]=b;n.push(x),s.writable.push(...S),s.readonly.push(...T)}}let[o,c]=t.getMessageComponents(),p=new xs(c,s).compileInstructions(e.instructions);return new r({header:o,staticAccountKeys:c,recentBlockhash:e.recentBlockhash,compiledInstructions:p,addressTableLookups:n})}serialize(){let e=Array();Jt(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=Array();Jt(n,this.compiledInstructions.length);let s=this.serializeAddressTableLookups(),i=Array();Jt(i,this.addressTableLookups.length);let o=R.struct([R.u8("prefix"),R.struct([R.u8("numRequiredSignatures"),R.u8("numReadonlySignedAccounts"),R.u8("numReadonlyUnsignedAccounts")],"header"),R.blob(e.length,"staticAccountKeysLength"),R.seq(be(),this.staticAccountKeys.length,"staticAccountKeys"),be("recentBlockhash"),R.blob(n.length,"instructionsLength"),R.blob(t.length,"serializedInstructions"),R.blob(i.length,"addressTableLookupsLength"),R.blob(s.length,"serializedAddressTableLookups")]),c=new Uint8Array(Yn),p=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(m=>m.toBytes()),recentBlockhash:Et.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},c);return c.slice(0,p)}serializeInstructions(){let e=0,t=new Uint8Array(Yn);for(let n of this.compiledInstructions){let s=Array();Jt(s,n.accountKeyIndexes.length);let i=Array();Jt(i,n.data.length);let o=R.struct([R.u8("programIdIndex"),R.blob(s.length,"encodedAccountKeyIndexesLength"),R.seq(R.u8(),n.accountKeyIndexes.length,"accountKeyIndexes"),R.blob(i.length,"encodedDataLength"),R.blob(n.data.length,"data")]);e+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(Yn);for(let n of this.addressTableLookups){let s=Array();Jt(s,n.writableIndexes.length);let i=Array();Jt(i,n.readonlyIndexes.length);let o=R.struct([be("accountKey"),R.blob(s.length,"encodedWritableIndexesLength"),R.seq(R.u8(),n.writableIndexes.length,"writableIndexes"),R.blob(i.length,"encodedReadonlyIndexesLength"),R.seq(R.u8(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e],n=zr(t),s=n&Fu;Ae(n!==s,"Expected versioned message but received legacy message");let i=s;Ae(i===0,`Expected versioned message with version 0 but found version ${i}`);let o={numRequiredSignatures:zr(t),numReadonlySignedAccounts:zr(t),numReadonlyUnsignedAccounts:zr(t)},c=[],u=Yt(t);for(let T=0;T<u;T++)c.push(new ce(Xt(t,0,pn)));let p=Et.default.encode(Xt(t,0,pn)),m=Yt(t),b=[];for(let T=0;T<m;T++){let I=zr(t),A=Yt(t),L=Xt(t,0,A),U=Yt(t),B=new Uint8Array(Xt(t,0,U));b.push({programIdIndex:I,accountKeyIndexes:L,data:B})}let x=Yt(t),S=[];for(let T=0;T<x;T++){let I=new ce(Xt(t,0,pn)),A=Yt(t),L=Xt(t,0,A),U=Yt(t),B=Xt(t,0,U);S.push({accountKey:I,writableIndexes:L,readonlyIndexes:B})}return new r({header:o,staticAccountKeys:c,recentBlockhash:p,compiledInstructions:b,addressTableLookups:S})}},oa={deserializeMessageVersion(r){let e=r[0],t=e&Fu;return t===e?"legacy":t},deserialize:r=>{let e=oa.deserializeMessageVersion(r);if(e==="legacy")return mn.from(r);if(e===0)return Qo.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},dn=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}({}),cE=ae.Buffer.alloc(Zo).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 s=[],i=[];t.forEach(I=>{I.keys.forEach(L=>{i.push({...L})});let A=I.programId.toString();s.includes(A)||s.push(A)}),s.forEach(I=>{i.push({pubkey:new ce(I),isSigner:!1,isWritable:!1})});let o=[];i.forEach(I=>{let A=I.pubkey.toString(),L=o.findIndex(U=>U.pubkey.toString()===A);L>-1?(o[L].isWritable=o[L].isWritable||I.isWritable,o[L].isSigner=o[L].isSigner||I.isSigner):o.push(I)}),o.sort(function(I,A){if(I.isSigner!==A.isSigner)return I.isSigner?-1:1;if(I.isWritable!==A.isWritable)return I.isWritable?-1:1;let L={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return I.pubkey.toBase58().localeCompare(A.pubkey.toBase58(),"en",L)});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 A=o.findIndex(L=>L.pubkey.equals(I.publicKey));if(A>-1)o[A].isSigner||(o[A].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=[],x=[];o.forEach(({pubkey:I,isSigner:A,isWritable:L})=>{A?(b.push(I.toString()),u+=1,L||(p+=1)):(x.push(I.toString()),L||(m+=1))});let S=b.concat(x),T=t.map(I=>{let{data:A,programId:L}=I;return{programIdIndex:S.indexOf(L.toString()),accounts:I.keys.map(U=>S.indexOf(U.pubkey.toString())),data:Et.default.encode(A)}});return T.forEach(I=>{Ae(I.programIdIndex>=0),I.accounts.forEach(A=>Ae(A>=0))}),new mn({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((s,i)=>t[i].equals(s.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 s=n.toString();return t.has(s)?!1:(t.add(s),!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 i of e){let o=i.publicKey.toString();t.has(o)||(t.add(o),n.push(i))}this.signatures=n.map(i=>({signature:null,publicKey:i.publicKey}));let s=this._compile();this._partialSign(s,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");let t=new Set,n=[];for(let i of e){let o=i.publicKey.toString();t.has(o)||(t.add(o),n.push(i))}let s=this._compile();this._partialSign(s,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(s=>{let i=zu(n,s.secretKey);this._addSignature(s.publicKey,we(i))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){Ae(t.length===64);let n=this.signatures.findIndex(s=>e.equals(s.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:s,publicKey:i}of this.signatures)s===null?t&&(n.missing||=[]).push(i):eE(s,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(n){let i=this._getMessageSignednessErrors(s,t);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
6
6
  Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(c=>c.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
7
- Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(c=>c.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){let{signatures:t}=this,n=[];Yt(n,t.length);let s=n.length+t.length*64+e.length,i=ae.Buffer.alloc(s);return Ae(t.length<256),ae.Buffer.from(n).copy(i,0),t.forEach(({signature:o},c)=>{o!==null&&(Ae(o.length===64,"signature has invalid length"),ae.Buffer.from(o).copy(i,n.length+c*64))}),e.copy(i,n.length+t.length*64),Ae(i.length<=Hn,`Transaction too large: ${i.length} > ${Hn}`),i}get keys(){return Ae(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return Ae(this.instructions.length===1),this.instructions[0].programId}get data(){return Ae(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e],n=Zt(t),s=[];for(let i=0;i<n;i++){let o=Xt(t,0,Ko);s.push(vt.default.encode(ae.Buffer.from(o)))}return r.populate(hn.from(t),s)}static populate(e,t=[]){let n=new r;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((s,i)=>{let o={signature:s==vt.default.encode(F1)?null:vt.default.decode(s),publicKey:e.accountKeys[i]};n.signatures.push(o)}),e.instructions.forEach(s=>{let i=s.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:i,programId:e.accountKeys[s.programIdIndex],data:vt.default.decode(s.data)}))}),n._message=e,n._json=n.toJSON(),n}};var Xo=class r{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)Ae(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 s=0;s<e.header.numRequiredSignatures;s++)n.push(new Uint8Array(Ko));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(P1(),this.signatures.length,"signatures"),E.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let t=[...e],n=[],s=Zt(t);for(let o=0;o<s;o++)n.push(new Uint8Array(Xt(t,0,Ko)));let i=na.deserialize(new Uint8Array(t));return new r(i,n)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let s of e){let i=n.findIndex(o=>o.equals(s.publicKey));Ae(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Pu(t,s.secretKey)}}addSignature(e,t){Ae(t.byteLength===64,"Signature must be 64 bytes long");let s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));Ae(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=t}},$1=160,V1=64,W1=$1/V1,bh=1e3/W1,Mr=new ce("SysvarC1ock11111111111111111111111111111111"),PA=new ce("SysvarEpochSchedu1e111111111111111111111111"),MA=new ce("Sysvar1nstructions1111111111111111111111111"),du=new ce("SysvarRecentB1ockHashes11111111111111111111"),fi=new ce("SysvarRent111111111111111111111111111111111"),UA=new ce("SysvarRewards111111111111111111111111111111"),DA=new ce("SysvarS1otHashes111111111111111111111111111"),zA=new ce("SysvarS1otHistory11111111111111111111111111"),hu=new ce("SysvarStakeHistory1111111111111111111111111"),li=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:s}){let i=s?`Logs:
7
+ Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(c=>c.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){let{signatures:t}=this,n=[];Jt(n,t.length);let s=n.length+t.length*64+e.length,i=ae.Buffer.alloc(s);return Ae(t.length<256),ae.Buffer.from(n).copy(i,0),t.forEach(({signature:o},c)=>{o!==null&&(Ae(o.length===64,"signature has invalid length"),ae.Buffer.from(o).copy(i,n.length+c*64))}),e.copy(i,n.length+t.length*64),Ae(i.length<=Yn,`Transaction too large: ${i.length} > ${Yn}`),i}get keys(){return Ae(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return Ae(this.instructions.length===1),this.instructions[0].programId}get data(){return Ae(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e],n=Yt(t),s=[];for(let i=0;i<n;i++){let o=Xt(t,0,Zo);s.push(Et.default.encode(ae.Buffer.from(o)))}return r.populate(mn.from(t),s)}static populate(e,t=[]){let n=new r;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((s,i)=>{let o={signature:s==Et.default.encode(cE)?null:Et.default.decode(s),publicKey:e.accountKeys[i]};n.signatures.push(o)}),e.instructions.forEach(s=>{let i=s.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:i,programId:e.accountKeys[s.programIdIndex],data:Et.default.decode(s.data)}))}),n._message=e,n._json=n.toJSON(),n}};var ea=class r{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)Ae(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 s=0;s<e.header.numRequiredSignatures;s++)n.push(new Uint8Array(Zo));this.signatures=n}this.message=e}serialize(){let e=this.message.serialize(),t=Array();Jt(t,this.signatures.length);let n=R.struct([R.blob(t.length,"encodedSignaturesLength"),R.seq(nE(),this.signatures.length,"signatures"),R.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let t=[...e],n=[],s=Yt(t);for(let o=0;o<s;o++)n.push(new Uint8Array(Xt(t,0,Zo)));let i=oa.deserialize(new Uint8Array(t));return new r(i,n)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let s of e){let i=n.findIndex(o=>o.equals(s.publicKey));Ae(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=zu(t,s.secretKey)}}addSignature(e,t){Ae(t.byteLength===64,"Signature must be 64 bytes long");let s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));Ae(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=t}},uE=160,fE=64,lE=uE/fE,Dh=1e3/lE,Dr=new ce("SysvarC1ock11111111111111111111111111111111"),aI=new ce("SysvarEpochSchedu1e111111111111111111111111"),cI=new ce("Sysvar1nstructions1111111111111111111111111"),gu=new ce("SysvarRecentB1ockHashes11111111111111111111"),hi=new ce("SysvarRent111111111111111111111111111111111"),uI=new ce("SysvarRewards111111111111111111111111111111"),fI=new ce("SysvarS1otHashes111111111111111111111111111"),lI=new ce("SysvarS1otHistory11111111111111111111111111"),yu=new ce("SysvarStakeHistory1111111111111111111111111"),pi=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:s}){let i=s?`Logs:
8
8
  ${JSON.stringify(s.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}. `+i+o;break;case"simulate":c=`Simulation failed.
10
10
  Message: ${n}.
11
- `+i+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=s||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(s=>{if(s&&s.meta&&s.meta.logMessages){let i=s.meta.logMessages;this.transactionLogs=i,t(i)}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},s){super(s!=null?`${s}: ${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 s=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},i=await r.sendTransaction(e,t,s),o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await r.confirmTransaction({abortSignal:n?.abortSignal,signature:i,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:i},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(i,n&&n.commitment)).value;if(o.err)throw i!=null?new li({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function jn(r){return new Promise(e=>setTimeout(e,r))}function ve(r,e){let t=r.layout.span>=0?r.layout.span:yh(r,e),n=ae.Buffer.alloc(t),s=Object.assign({instruction:r.index},e);return r.layout.encode(s,n),n}var q1=E.nu64("lamportsPerSignature"),wh=E.struct([E.u32("version"),E.u32("state"),be("authorizedPubkey"),be("nonce"),E.struct([q1],"feeCalculator")]),eh=wh.span,Ru=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=wh.decode(we(e),0);return new r({authorizedPubkey:new ce(t.authorizedPubkey),nonce:new ce(t.nonce).toString(),feeCalculator:t.feeCalculator})}};function Ss(r){let e=(0,ph.blob)(8,r),t=e.decode.bind(e),n=e.encode.bind(e),s=e,i=rd();return s.decode=(o,c)=>{let u=t(o,c);return i.decode(u)},s.encode=(o,c,u)=>{let p=i.encode(o);return n(p,c,u)},s}var nr=Object.freeze({Create:{index:0,layout:E.struct([E.u32("instruction"),E.ns64("lamports"),E.ns64("space"),be("programId")])},Assign:{index:1,layout:E.struct([E.u32("instruction"),be("programId")])},Transfer:{index:2,layout:E.struct([E.u32("instruction"),Ss("lamports")])},CreateWithSeed:{index:3,layout:E.struct([E.u32("instruction"),be("base"),Es("seed"),E.ns64("lamports"),E.ns64("space"),be("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"),be("authorized")])},AuthorizeNonceAccount:{index:7,layout:E.struct([E.u32("instruction"),be("authorized")])},Allocate:{index:8,layout:E.struct([E.u32("instruction"),E.ns64("space")])},AllocateWithSeed:{index:9,layout:E.struct([E.u32("instruction"),be("base"),Es("seed"),E.ns64("space"),be("programId")])},AssignWithSeed:{index:10,layout:E.struct([E.u32("instruction"),be("base"),Es("seed"),be("programId")])},TransferWithSeed:{index:11,layout:E.struct([E.u32("instruction"),Ss("lamports"),Es("seed"),be("programId")])},UpgradeNonceAccount:{index:12,layout:E.struct([E.u32("instruction")])}}),zt=class r{constructor(){}static createAccount(e){let t=nr.Create,n=ve(t,{lamports:e.lamports,space:e.space,programId:we(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 s=nr.TransferWithSeed;t=ve(s,{lamports:BigInt(e.lamports),seed:e.seed,programId:we(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 s=nr.Transfer;t=ve(s,{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 s=nr.AssignWithSeed;t=ve(s,{base:we(e.basePubkey.toBuffer()),seed:e.seed,programId:we(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let s=nr.Assign;t=ve(s,{programId:we(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=ve(t,{base:we(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:we(e.programId.toBuffer())}),s=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||s.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Te({keys:s,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:eh,programId:this.programId})):t.add(r.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:eh,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=ve(t,{authorized:we(e.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:du,isSigner:!1,isWritable:!1},{pubkey:fi,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Te(s)}static nonceAdvance(e){let t=nr.AdvanceNonceAccount,n=ve(t),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:du,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Te(s)}static nonceWithdraw(e){let t=nr.WithdrawNonceAccount,n=ve(t,{lamports:e.lamports});return new Te({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:du,isSigner:!1,isWritable:!1},{pubkey:fi,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=nr.AuthorizeNonceAccount,n=ve(t,{authorized:we(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 s=nr.AllocateWithSeed;t=ve(s,{base:we(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:we(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let s=nr.Allocate;t=ve(s,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:t})}};zt.programId=new ce("11111111111111111111111111111111");var j1=Hn-300,Su=class r{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/r.chunkSize)+1+1)}static async load(e,t,n,s,i){{let b=await e.getMinimumBalanceForRentExemption(i.length),x=await e.getAccountInfo(n.publicKey,"confirmed"),S=null;if(x!==null){if(x.executable)return console.error("Program load failed, account is already executable"),!1;x.data.length!==i.length&&(S=S||new Se,S.add(zt.allocate({accountPubkey:n.publicKey,space:i.length}))),x.owner.equals(s)||(S=S||new Se,S.add(zt.assign({accountPubkey:n.publicKey,programId:s}))),x.lamports<b&&(S=S||new Se,S.add(zt.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:b-x.lamports})))}else S=new Se().add(zt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:b>0?b:1,space:i.length,programId:s}));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=i,m=[];for(;p.length>0;){let b=p.slice(0,c),x=ae.Buffer.alloc(c+16);o.encode({instruction:0,offset:u,bytes:b,bytesLength:0,bytesLengthPadding:0},x);let S=new Se().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:x});m.push(Qd(e,S,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await jn(1e3/4),u+=c,p=p.slice(c)}await Promise.all(m);{let b=E.struct([E.u32("instruction")]),x=ae.Buffer.alloc(b.span);b.encode({instruction:1},x);let S=new Se().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:fi,isSigner:!1,isWritable:!1}],programId:s,data:x}),T="processed",I=await e.sendTransaction(S,[t,n],{preflightCommitment:T}),{context:A,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})>A.slot)break}catch{}await new Promise(U=>setTimeout(U,Math.round(bh/2)))}}return!0}};Su.chunkSize=j1;var FA=new ce("BPFLoader2111111111111111111111111111111111");function K1(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var pu,th;function H1(){if(th)return pu;th=1;var r=Object.prototype.toString,e=Object.keys||function(n){var s=[];for(var i in n)s.push(i);return s};function t(n,s){var i,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(),s);if(b=r.call(n),b==="[object Array]"){for(c="[",o=n.length-1,i=0;i<o;i++)c+=t(n[i],!0)+",";return o>-1&&(c+=t(n[i],!0)),c+"]"}else if(b==="[object Object]"){for(u=e(n).sort(),o=u.length,c="",i=0;i<o;)p=u[i],m=t(n[p],!1),m!==void 0&&(c&&(c+=","),c+=JSON.stringify(p)+":"+m),i++;return"{"+c+"}"}else return JSON.stringify(n);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return pu=function(n){var s=t(n,!1);if(s!==void 0)return""+s},pu}var G1=H1(),rh=K1(G1),ai=32;function mu(r){let e=0;for(;r>1;)r/=2,e++;return e}function Z1(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 xu=class{constructor(e,t,n,s,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=mu(Z1(e+ai+1))-mu(ai)-1,n=this.getSlotsInEpoch(t),s=e-(n-ai);return[t,s]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),s=this.firstNormalEpoch+n,i=t%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*ai:(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+mu(ai)):this.slotsPerEpoch}},Y1=globalThis.fetch,Au=class extends Md{constructor(e,t,n){let s=i=>{let o=Pd(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,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 X1(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 nh=56,Jo=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=X1(J1,e),n=e.length-nh;Ae(n>=0,"lookup table is invalid"),Ae(n%32===0,"lookup table is invalid");let s=n/32,{addresses:i}=E.struct([E.seq(be(),s,"addresses")]).decode(e.slice(nh));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ce(t.authority[0]):void 0,addresses:i.map(o=>new ce(o))}}},J1={index:1,layout:E.struct([E.u32("typeIndex"),Ss("deactivationSlot"),E.nu64("lastExtendedSlot"),E.u8("lastExtendedStartIndex"),E.u8(),E.seq(be(),E.offset(E.u8(),-1),"authority")])},Q1=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function ev(r){let e=r.match(Q1);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);let[t,n,s,i]=e,o=r.startsWith("https:")?"wss:":"ws:",c=s==null?null:parseInt(s.slice(1),10),u=c==null?"":`:${c+1}`;return`${o}//${n}${u}${i}`}var qe=vs(Lo(ce),z(),r=>new ce(r)),vh=Co([z(),Me("base64")]),Uu=vs(Lo(ae.Buffer),vh,r=>ae.Buffer.from(r[0],"base64")),tv=30*1e3;function rv(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,...s}=r;e=n,t=s}return{commitment:e,config:t}}function sh(r){return r.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function Eh(r){return Tt([P({jsonrpc:Me("2.0"),id:z(),result:r}),P({jsonrpc:Me("2.0"),id:z(),error:P({code:Wn(),message:z(),data:ne(od())})})])}var nv=Eh(Wn());function ye(r){return vs(Eh(r),nv,e=>"error"in e?e:{...e,result:V(e.result,r)})}function Ze(r){return ye(P({context:P({slot:k()}),value:r}))}function sa(r){return P({context:P({slot:k()}),value:r})}function gu(r,e){return r===0?new Yo({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 hn(e)}var sv=P({foundation:k(),foundationTerm:k(),initial:k(),taper:k(),terminal:k()}),iv=ye(q(j(P({epoch:k(),effectiveSlot:k(),amount:k(),postBalance:k(),commission:ne(j(k()))})))),ov=q(P({slot:k(),prioritizationFee:k()})),av=P({total:k(),validator:k(),foundation:k(),epoch:k()}),cv=P({epoch:k(),slotIndex:k(),slotsInEpoch:k(),absoluteSlot:k(),blockHeight:ne(k()),transactionCount:ne(k())}),uv=P({slotsPerEpoch:k(),leaderScheduleSlotOffset:k(),warmup:ur(),firstNormalEpoch:k(),firstNormalSlot:k()}),fv=Yc(z(),q(k())),Gn=j(Tt([P({}),z()])),lv=P({err:Gn}),dv=Me("receivedSignature"),hv=P({"solana-core":z(),"feature-set":ne(k())}),pv=P({program:z(),programId:qe,parsed:Wn()}),mv=P({programId:qe,accounts:q(qe),data:z()}),ih=Ze(P({err:j(Tt([P({}),z()])),logs:j(q(z())),accounts:ne(j(q(j(P({executable:ur(),owner:z(),lamports:k(),data:q(z()),rentEpoch:ne(k())}))))),unitsConsumed:ne(k()),returnData:ne(j(P({programId:z(),data:Co([z(),Me("base64")])}))),innerInstructions:ne(j(q(P({index:k(),instructions:q(Tt([pv,mv]))}))))})),gv=Ze(P({byIdentity:Yc(z(),q(k())),range:P({firstSlot:k(),lastSlot:k()})}));function yv(r,e,t,n,s,i){let o=t||Y1,c;i!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return n&&(u=async(m,b)=>{let x=await new Promise((S,T)=>{try{n(m,b,(I,A)=>S([I,A]))}catch(I){T(I)}});return await o(...x)}),new mh.default(async(m,b)=>{let x={method:"POST",body:m,agent:c,headers:Object.assign({"Content-Type":"application/json"},e||{},yE)};try{let S=5,T,I=500;for(;u?T=await u(r,x):T=await o(r,x),!(T.status!==429||s===!0||(S-=1,S===0));)console.error(`Server responded with ${T.status} ${T.statusText}. Retrying after ${I}ms delay...`),await jn(I),I*=2;let A=await T.text();T.ok?b(null,A):b(new Error(`${T.status} ${T.statusText}: ${A}`))}catch(S){S instanceof Error&&b(S)}},{})}function _v(r){return(e,t)=>new Promise((n,s)=>{r.request(e,t,(i,o)=>{if(i){s(i);return}n(o)})})}function bv(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);let s=e.map(i=>r.request(i.methodName,i.args));r.request(s,(i,o)=>{if(i){n(i);return}t(o)})})}var wv=ye(sv),vv=ye(av),Ev=ye(ov),Rv=ye(cv),Sv=ye(uv),xv=ye(fv),Av=ye(k()),Iv=Ze(P({total:k(),circulating:k(),nonCirculating:k(),nonCirculatingAccounts:q(qe)})),Iu=P({amount:z(),uiAmount:j(k()),decimals:k(),uiAmountString:ne(z())}),kv=Ze(q(P({address:qe,amount:z(),uiAmount:j(k()),decimals:k(),uiAmountString:ne(z())}))),Ov=Ze(q(P({pubkey:qe,account:P({executable:ur(),owner:qe,lamports:k(),data:Uu,rentEpoch:k()})}))),ku=P({program:z(),parsed:Wn(),space:k()}),Tv=Ze(q(P({pubkey:qe,account:P({executable:ur(),owner:qe,lamports:k(),data:ku,rentEpoch:k()})}))),Nv=Ze(q(P({lamports:k(),address:qe}))),di=P({executable:ur(),owner:qe,lamports:k(),data:Uu,rentEpoch:k()}),Bv=P({pubkey:qe,account:di}),Lv=vs(Tt([Lo(ae.Buffer),ku]),Tt([vh,ku]),r=>Array.isArray(r)?V(r,Uu):r),Ou=P({executable:ur(),owner:qe,lamports:k(),data:Lv,rentEpoch:k()}),Cv=P({pubkey:qe,account:Ou}),Pv=P({state:Tt([Me("active"),Me("inactive"),Me("activating"),Me("deactivating")]),active:k(),inactive:k()}),Mv=ye(q(P({signature:z(),slot:k(),err:Gn,memo:j(z()),blockTime:ne(j(k()))}))),Uv=ye(q(P({signature:z(),slot:k(),err:Gn,memo:j(z()),blockTime:ne(j(k()))}))),Dv=P({subscription:k(),result:sa(di)}),zv=P({pubkey:qe,account:di}),Fv=P({subscription:k(),result:sa(zv)}),$v=P({parent:k(),slot:k(),root:k()}),Vv=P({subscription:k(),result:$v}),Wv=Tt([P({type:Tt([Me("firstShredReceived"),Me("completed"),Me("optimisticConfirmation"),Me("root")]),slot:k(),timestamp:k()}),P({type:Me("createdBank"),parent:k(),slot:k(),timestamp:k()}),P({type:Me("frozen"),slot:k(),timestamp:k(),stats:P({numTransactionEntries:k(),numSuccessfulTransactions:k(),numFailedTransactions:k(),maxTransactionsPerEntry:k()})}),P({type:Me("dead"),slot:k(),timestamp:k(),err:z()})]),qv=P({subscription:k(),result:Wv}),jv=P({subscription:k(),result:sa(Tt([lv,dv]))}),Kv=P({subscription:k(),result:k()}),Hv=P({pubkey:z(),gossip:j(z()),tpu:j(z()),rpc:j(z()),version:j(z())}),oh=P({votePubkey:z(),nodePubkey:z(),activatedStake:k(),epochVoteAccount:ur(),epochCredits:q(Co([k(),k(),k()])),commission:k(),lastVote:k(),rootSlot:j(k())}),Gv=ye(P({current:q(oh),delinquent:q(oh)})),Zv=Tt([Me("processed"),Me("confirmed"),Me("finalized")]),Yv=P({slot:k(),confirmations:j(k()),err:Gn,confirmationStatus:ne(Zv)}),Xv=Ze(q(j(Yv))),Jv=ye(k()),Rh=P({accountKey:qe,writableIndexes:q(k()),readonlyIndexes:q(k())}),Du=P({signatures:q(z()),message:P({accountKeys:q(z()),header:P({numRequiredSignatures:k(),numReadonlySignedAccounts:k(),numReadonlyUnsignedAccounts:k()}),instructions:q(P({accounts:q(k()),data:z(),programIdIndex:k()})),recentBlockhash:z(),addressTableLookups:ne(q(Rh))})}),Sh=P({pubkey:qe,signer:ur(),writable:ur(),source:ne(Tt([Me("transaction"),Me("lookupTable")]))}),xh=P({accountKeys:q(Sh),signatures:q(z())}),Ah=P({parsed:Wn(),program:z(),programId:qe}),Ih=P({accounts:q(qe),data:z(),programId:qe}),Qv=Tt([Ih,Ah]),eE=Tt([P({parsed:Wn(),program:z(),programId:z()}),P({accounts:q(z()),data:z(),programId:z()})]),kh=vs(Qv,eE,r=>"accounts"in r?V(r,Ih):V(r,Ah)),Oh=P({signatures:q(z()),message:P({accountKeys:q(Sh),instructions:q(kh),recentBlockhash:z(),addressTableLookups:ne(j(q(Rh)))})}),Qo=P({accountIndex:k(),mint:z(),owner:ne(z()),programId:ne(z()),uiTokenAmount:Iu}),Th=P({writable:q(qe),readonly:q(qe)}),ia=P({err:Gn,fee:k(),innerInstructions:ne(j(q(P({index:k(),instructions:q(P({accounts:q(k()),data:z(),programIdIndex:k()}))})))),preBalances:q(k()),postBalances:q(k()),logMessages:ne(j(q(z()))),preTokenBalances:ne(j(q(Qo))),postTokenBalances:ne(j(q(Qo))),loadedAddresses:ne(Th),computeUnitsConsumed:ne(k())}),zu=P({err:Gn,fee:k(),innerInstructions:ne(j(q(P({index:k(),instructions:q(kh)})))),preBalances:q(k()),postBalances:q(k()),logMessages:ne(j(q(z()))),preTokenBalances:ne(j(q(Qo))),postTokenBalances:ne(j(q(Qo))),loadedAddresses:ne(Th),computeUnitsConsumed:ne(k())}),As=Tt([Me(0),Me("legacy")]),Zn=P({pubkey:z(),lamports:k(),postBalance:j(k()),rewardType:j(z()),commission:ne(j(k()))}),tE=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:Du,meta:j(ia),version:ne(As)})),rewards:ne(q(Zn)),blockTime:j(k()),blockHeight:j(k())}))),rE=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),rewards:ne(q(Zn)),blockTime:j(k()),blockHeight:j(k())}))),nE=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:xh,meta:j(ia),version:ne(As)})),rewards:ne(q(Zn)),blockTime:j(k()),blockHeight:j(k())}))),sE=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:Oh,meta:j(zu),version:ne(As)})),rewards:ne(q(Zn)),blockTime:j(k()),blockHeight:j(k())}))),iE=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:xh,meta:j(zu),version:ne(As)})),rewards:ne(q(Zn)),blockTime:j(k()),blockHeight:j(k())}))),oE=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),rewards:ne(q(Zn)),blockTime:j(k()),blockHeight:j(k())}))),aE=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:Du,meta:j(ia)})),rewards:ne(q(Zn)),blockTime:j(k())}))),ah=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),signatures:q(z()),blockTime:j(k())}))),yu=ye(j(P({slot:k(),meta:j(ia),blockTime:ne(j(k())),transaction:Du,version:ne(As)}))),Wo=ye(j(P({slot:k(),transaction:Oh,meta:j(zu),blockTime:ne(j(k())),version:ne(As)}))),cE=Ze(P({blockhash:z(),lastValidBlockHeight:k()})),uE=Ze(ur()),fE=P({slot:k(),numTransactions:k(),numSlots:k(),samplePeriodSecs:k()}),lE=ye(q(fE)),dE=Ze(j(P({feeCalculator:P({lamportsPerSignature:k()})}))),hE=ye(z()),pE=ye(z()),mE=P({err:Gn,logs:q(z()),signature:z()}),gE=P({result:sa(mE),subscription:k()}),yE={"solana-client":"js/1.0.0-maintenance"},ea=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:x}=Be(m),S=this._buildArgs([],b,void 0,x),T=rh(S);return p[T]=p[T]??(async()=>{try{let I=await this._rpcRequest("getBlockHeight",S),A=V(I,ye(k()));if("error"in A)throw new Q(A.error,"failed to get block height information");return A.result}finally{delete p[T]}})(),await p[T]}})();let n,s,i,o,c,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,s=t.httpHeaders,i=t.fetch,o=t.fetchMiddleware,c=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=rv(e),this._rpcWsEndpoint=n||ev(e),this._rpcClient=yv(e,s,i,o,c,u),this._rpcRequest=_v(this._rpcClient),this._rpcBatchRequest=bv(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:s}=Be(t),i=this._buildArgs([e.toBase58()],n,void 0,s),o=await this._rpcRequest("getBalance",i),c=V(o,Ze(k()));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,ye(j(k())));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,ye(k()));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,Av);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]),s=V(n,Iv);if("error"in s)throw new Q(s.error,"failed to get supply");return s.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenSupply",n),i=V(s,Ze(Iu));if("error"in i)throw new Q(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenAccountBalance",n),i=V(s,Ze(Iu));if("error"in i)throw new Q(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(e,t,n){let{commitment:s,config:i}=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,s,"base64",i),u=await this._rpcRequest("getTokenAccountsByOwner",c),p=V(u,Ov);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 s=[e.toBase58()];"mint"in t?s.push({mint:t.mint.toBase58()}):s.push({programId:t.programId.toBase58()});let i=this._buildArgs(s,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),c=V(o,Tv);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]:[],s=await this._rpcRequest("getLargestAccounts",n),i=V(s,Nv);if("error"in i)throw new Q(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenLargestAccounts",n),i=V(s,kv);if("error"in i)throw new Q(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:s}=Be(t),i=this._buildArgs([e.toBase58()],n,"base64",s),o=await this._rpcRequest("getAccountInfo",i),c=V(o,Ze(j(di)));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:s}=Be(t),i=this._buildArgs([e.toBase58()],n,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),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:s}=Be(t),i=e.map(p=>p.toBase58()),o=this._buildArgs([i],n,"jsonParsed",s),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 ${i}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:s}=Be(t),i=e.map(p=>p.toBase58()),o=this._buildArgs([i],n,"base64",s),c=await this._rpcRequest("getMultipleAccounts",o),u=V(c,Ze(q(j(di))));if("error"in u)throw new Q(u.error,`failed to get info for accounts ${i}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:s,config:i}=Be(t),o=this._buildArgs([e.toBase58()],s,void 0,{...i,epoch:n??i?.epoch}),c=await this._rpcRequest("getStakeActivation",o),u=V(c,ye(Pv));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:s}=Be(t),{encoding:i,...o}=s||{},c=this._buildArgs([e.toBase58()],n,i||"base64",{...o,...o.filters?{filters:sh(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",c),p=q(Bv),m=o.withContext===!0?V(u,Ze(p)):V(u,ye(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:s}=Be(t),i=this._buildArgs([e.toBase58()],n,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),c=V(o,ye(q(Cv)));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 i=e;if(i.abortSignal?.aborted)return Promise.reject(i.abortSignal.reason);n=i.signature}let s;try{s=vt.default.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return Ae(s.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,s,i=!1,o=new Promise((u,p)=>{try{n=this.onSignature(t,(b,x)=>{n=void 0;let S={context:x,value:b};u({__type:fn.PROCESSED,response:S})},e);let m=new Promise(b=>{n==null?b():s=this._onSubscriptionStateChange(n,x=>{x==="subscribed"&&b()})});(async()=>{if(await m,i)return;let b=await this.getSignatureStatus(t);if(i||b==null)return;let{context:x,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":}i=!0,u({__type:fn.PROCESSED,response:{context:x,value:S}})}})()}catch(m){p(m)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:s}}){let i=!1,o=new Promise(b=>{let x=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let S=await x();if(!i){for(;S<=n;)if(await jn(1e3),i||(S=await x(),i))return;b({__type:fn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),p=this.getCancellationPromise(t),m;try{let b=await Promise.race([p,u,o]);if(b.__type===fn.PROCESSED)m=b.response;else throw new Ho(s)}finally{i=!0,c()}return m}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let c=!1,u=new Promise(S=>{let T=i,I=null,A=async()=>{try{let{context:B,value:U}=await this.getNonceAndContext(s,{commitment:e,minContextSlot:n});return I=B.slot,U?.nonce}catch{return T}};(async()=>{if(T=await A(),!c)for(;;){if(i!==T){S({__type:fn.NONCE_INVALID,slotInWhichNonceDidAdvance:I});return}if(await jn(2e3),c||(T=await A(),c))return}})()}),{abortConfirmation:p,confirmationPromise:m}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),b=this.getCancellationPromise(t),x;try{let S=await Promise.race([b,m,u]);if(S.__type===fn.PROCESSED)x=S.response;else{let T;for(;;){let I=await this.getSignatureStatus(o);if(I==null)break;if(I.context.slot<(S.slotInWhichNonceDidAdvance??n)){await jn(400);continue}T=I;break}if(T?.value){let I=e||"finalized",{confirmationStatus:A}=T.value;switch(I){case"processed":case"recent":if(A!=="processed"&&A!=="confirmed"&&A!=="finalized")throw new Kn(o);break;case"confirmed":case"single":case"singleGossip":if(A!=="confirmed"&&A!=="finalized")throw new Kn(o);break;case"finalized":case"max":case"root":if(A!=="finalized")throw new Kn(o);break;default:}x={context:T.context,value:{err:T.value.err}}}else throw new Kn(o)}}finally{c=!0,p()}return x}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,s=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:fn.TIMED_OUT,timeoutMs:p}),p)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),c;try{let u=await Promise.race([o,s]);if(u.__type===fn.PROCESSED)c=u.response;else throw new Go(t,u.timeoutMs/1e3)}finally{clearTimeout(n),i()}return c}async getClusterNodes(){let e=await this._rpcRequest("getClusterNodes",[]),t=V(e,ye(q(Hv)));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),s=V(n,Gv);if("error"in s)throw new Q(s.error,"failed to get vote accounts");return s.result}async getSlot(e){let{commitment:t,config:n}=Be(e),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getSlot",s),o=V(i,ye(k()));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),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getSlotLeader",s),o=V(i,ye(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],s=await this._rpcRequest("getSlotLeaders",n),i=V(s,ye(q(qe)));if("error"in i)throw new Q(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){let{context:n,value:s}=await this.getSignatureStatuses([e],t);Ae(s.length===1);let i=s[0];return{context:n,value:i}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let s=await this._rpcRequest("getSignatureStatuses",n),i=V(s,Xv);if("error"in i)throw new Q(i.error,"failed to get signature status");return i.result}async getTransactionCount(e){let{commitment:t,config:n}=Be(e),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getTransactionCount",s),o=V(i,ye(k()));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),s=V(n,wv);if("error"in s)throw new Q(s.error,"failed to get inflation");return s.result}async getInflationReward(e,t,n){let{commitment:s,config:i}=Be(n),o=this._buildArgs([e.map(p=>p.toBase58())],s,void 0,{...i,epoch:t??i?.epoch}),c=await this._rpcRequest("getInflationReward",o),u=V(c,iv);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,vv);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),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getEpochInfo",s),o=V(i,Rv);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,Sv);if("error"in t)throw new Q(t.error,"failed to get epoch schedule");let n=t.result;return new xu(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){let e=await this._rpcRequest("getLeaderSchedule",[]),t=V(e,xv);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),s=await this._rpcRequest("getMinimumBalanceForRentExemption",n),i=V(s,Jv);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.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,lE);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),s=await this._rpcRequest("getFeeCalculatorForBlockhash",n),i=V(s,dE);if("error"in i)throw new Q(i.error,"failed to get fee calculator");let{context:o,value:c}=i.result;return{context:o,value:c!==null?c.feeCalculator:null}}async getFeeForMessage(e,t){let n=we(e.serialize()).toString("base64"),s=this._buildArgs([n],t),i=await this._rpcRequest("getFeeForMessage",s),o=V(i,Ze(j(k())));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]:[],s=await this._rpcRequest("getRecentPrioritizationFees",n),i=V(s,Ev);if("error"in i)throw new Q(i.error,"failed to get recent prioritization fees");return i.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),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getLatestBlockhash",s),o=V(i,cE);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:s}=Be(t),i=this._buildArgs([e],n,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),c=V(o,uE);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,ye(hv));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,ye(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:s}=Be(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s?.transactionDetails){case"accounts":{let c=V(o,nE);if("error"in c)throw c.error;return c.result}case"none":{let c=V(o,rE);if("error"in c)throw c.error;return c.result}default:{let c=V(o,tE);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:gu(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:s}=Be(t),i=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s?.transactionDetails){case"accounts":{let c=V(o,iE);if("error"in c)throw c.error;return c.result}case"none":{let c=V(o,oE);if("error"in c)throw c.error;return c.result}default:{let c=V(o,sE);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 s=this._buildArgs([],n,"base64",t),i=await this._rpcRequest("getBlockProduction",s),o=V(i,gv);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:s}=Be(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,s),o=await this._rpcRequest("getTransaction",i),c=V(o,yu);if("error"in c)throw new Q(c.error,"failed to get transaction");let u=c.result;return u&&{...u,transaction:{...u.transaction,message:gu(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:s}=Be(t),i=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),c=V(o,Wo);if("error"in c)throw new Q(c.error,"failed to get transaction");return c.result}async getParsedTransactions(e,t){let{commitment:n,config:s}=Be(t),i=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(u=>{let p=V(u,Wo);if("error"in p)throw new Q(p.error,"failed to get transactions");return p.result})}async getTransactions(e,t){let{commitment:n,config:s}=Be(t),i=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,s)}));return(await this._rpcBatchRequest(i)).map(u=>{let p=V(u,yu);if("error"in p)throw new Q(p.error,"failed to get transactions");let m=p.result;return m&&{...m,transaction:{...m.transaction,message:gu(m.version,m.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getBlock",n),i=V(s,aE);if("error"in i)throw new Q(i.error,"failed to get confirmed block");let o=i.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 hn(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 s=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),i=await this._rpcRequest("getBlocks",s),o=V(i,ye(q(k())));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}),s=await this._rpcRequest("getBlock",n),i=V(s,ah);if("error"in i)throw new Q(i.error,"failed to get block");let o=i.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}),s=await this._rpcRequest("getBlock",n),i=V(s,ah);if("error"in i)throw new Q(i.error,"failed to get confirmed block");let o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getTransaction",n),i=V(s,yu);if("error"in i)throw new Q(i.error,"failed to get transaction");let o=i.result;if(!o)return o;let c=new hn(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"),s=await this._rpcRequest("getTransaction",n),i=V(s,Wo);if("error"in i)throw new Q(i.error,"failed to get confirmed transaction");return i.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,Wo);if("error"in c)throw new Q(c.error,"failed to get confirmed transactions");return c.result})}async getConfirmedSignaturesForAddress(e,t,n){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(t--,!(t<=0||t<i));)try{let u=await this.getConfirmedBlockSignatures(t,"finalized");u.signatures.length>0&&(s.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 s)&&(n++,!(n>o));)try{let u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(s.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,s)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let s=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=V(i,Mv);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 s=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=await this._rpcRequest("getSignaturesForAddress",s),o=V(i,Uv);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:s}=await this.getAccountInfoAndContext(e,t),i=null;return s!==null&&(i=new Jo({key:e,state:Jo.deserialize(s.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:s}=await this.getAccountInfoAndContext(e,t),i=null;return s!==null&&(i=Ru.fromAccountData(s.data)),{context:n,value:i}}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]),s=V(n,hE);if("error"in s)throw new Q(s.error,`airdrop to ${e.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await jn(100);let n=Date.now()-this._blockhashInfo.lastFetch>=tv;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 s=0;s<50;s++){let i=await this.getLatestBlockhash("finalized");if(n!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await jn(bh/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),s=this._buildArgs([],t,"base64",n),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=V(i,Ze(k()));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(),A=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=[A,B],L=await this._rpcRequest("simulateTransaction",U),F=V(L,ih);if("error"in F)throw new Error("failed to simulate transaction: "+F.error.message);return F.result}let s;if(e instanceof Se){let T=e;s=new Se,s.feePayer=T.feePayer,s.instructions=e.instructions,s.nonceInfo=T.nonceInfo,s.signatures=T.signatures}else s=Se.populate(e),s._message=s._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");let i=t;if(s.nonceInfo&&i)s.sign(...i);else{let T=this._disableBlockhashCaching;for(;;){let I=await this._blockhashWithExpiryBlockHeight(T);if(s.lastValidBlockHeight=I.lastValidBlockHeight,s.recentBlockhash=I.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");let A=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(A)&&!this._blockhashInfo.transactionSignatures.includes(A)){this._blockhashInfo.simulatedSignatures.push(A);break}else T=!0}}let o=s._compile(),c=o.serialize(),p=s._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}}i&&(m.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(m.innerInstructions=t.innerInstructions);let b=[p,m],x=await this._rpcRequest("simulateTransaction",b),S=V(x,ih);if("error"in S){let T;if("data"in S.error&&(T=S.error.data.logs,T&&Array.isArray(T))){let I=`
12
- `,A=I+T.join(I);console.error(S.error.message,A)}throw new li({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 s=t;if(e.nonceInfo)e.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){let c=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=c.lastValidBlockHeight,e.recentBlockhash=c.blockhash,e.sign(...s),!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 i=e.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(e,t){let n=we(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:"base64"},s=t&&t.skipPreflight,i=s===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),s&&(n.skipPreflight=s),i&&(n.preflightCommitment=i);let o=[e,n],c=await this._rpcRequest("sendTransaction",o),u=V(c,pE);if("error"in u){let p;throw"data"in u.error&&(p=u.error.data.logs),new li({action:s?"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 s=this._subscriptionStateChangeCallbacksByHash[e];s&&s.forEach(i=>{try{i(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let s=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return s.add(t),()=>{s.delete(t),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{let s=this._subscriptionsByHash[n];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[n],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:i,method:o}=s;try{this._setSubscription(n,{...s,state:"subscribing"});let c=await this._rpcWebSocket.call(o,i);this._setSubscription(n,{...s,serverSubscriptionId:c,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[c]=s.callbacks,await this._updateSubscriptions()}catch(c){if(console.error(`Received ${c instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:c}),!t())return;this._setSubscription(n,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(n,{...s,state:"unsubscribing"}),this._setSubscription(n,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(c){if(c instanceof Error&&console.error(`${o} error:`,c.message),!t())return;this._setSubscription(n,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(s=>{try{s(...t)}catch(i){console.error(i)}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=V(e,Dv);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,s=rh([e.method,t]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let o=this._subscriptionsByHash[s];Ae(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:s,config:i}=Be(n),o=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",i);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,Fv);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,s){let{commitment:i,config:o}=Be(n),c=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:sh(s)}: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 s=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){let{result:t,subscription:n}=V(e,gE);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=V(e,Vv);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,qv);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,s){let i=t||this._commitment;if(i||n||s){let o={};n&&(o.encoding=n),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,n,s){let i=t||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,s)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=V(e,jv);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 s=this._buildArgs([e],n||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,c)=>{if(o.type==="status"){t(o.result,c);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(e,t,n){let{commitment:s,...i}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([e],s,void 0,i),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,Kv);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}},Tu=class r{constructor(e){this._keypair=void 0,this._keypair=e??Yd()}static generate(){return new r(Yd())}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 s=e.slice(0,32),i=vu(s);for(let o=0;o<32;o++)if(n[o]!==i[o])throw new Error("provided secretKey is invalid")}return new r({publicKey:n,secretKey:e})}static fromSeed(e){let t=vu(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)}},ci=Object.freeze({CreateLookupTable:{index:0,layout:E.struct([E.u32("instruction"),Ss("recentSlot"),E.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:E.struct([E.u32("instruction")])},ExtendLookupTable:{index:2,layout:E.struct([E.u32("instruction"),Ss(),E.seq(be(),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 Nu=class{constructor(){}static createLookupTable(e){let[t,n]=ce.findProgramAddressSync([e.authority.toBuffer(),Hc().encode(e.recentSlot)],this.programId),s=ci.CreateLookupTable,i=ve(s,{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:zt.programId,isSigner:!1,isWritable:!1}];return[new Te({programId:this.programId,keys:o,data:i}),t]}static freezeLookupTable(e){let t=ci.FreezeLookupTable,n=ve(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Te({programId:this.programId,keys:s,data:n})}static extendLookupTable(e){let t=ci.ExtendLookupTable,n=ve(t,{addresses:e.addresses.map(i=>i.toBytes())}),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&s.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:zt.programId,isSigner:!1,isWritable:!1}),new Te({programId:this.programId,keys:s,data:n})}static deactivateLookupTable(e){let t=ci.DeactivateLookupTable,n=ve(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Te({programId:this.programId,keys:s,data:n})}static closeLookupTable(e){let t=ci.CloseLookupTable,n=ve(t),s=[{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:s,data:n})}};Nu.programId=new ce("AddressLookupTab1e1111111111111111111111111");var qo=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"),Ss("microLamports")])}}),Bu=class{constructor(){}static requestUnits(e){let t=qo.RequestUnits,n=ve(t,e);return new Te({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=qo.RequestHeapFrame,n=ve(t,e);return new Te({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=qo.SetComputeUnitLimit,n=ve(t,e);return new Te({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=qo.SetComputeUnitPrice,n=ve(t,{microLamports:BigInt(e.microLamports)});return new Te({keys:[],programId:this.programId,data:n})}};Bu.programId=new ce("ComputeBudget111111111111111111111111111111");var ch=64,uh=32,fh=64,lh=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")]),Lu=class r{constructor(){}static createInstructionWithPublicKey(e){let{publicKey:t,message:n,signature:s,instructionIndex:i}=e;Ae(t.length===uh,`Public Key must be ${uh} bytes but received ${t.length} bytes`),Ae(s.length===fh,`Signature must be ${fh} bytes but received ${s.length} bytes`);let o=lh.span,c=o+t.length,u=c+s.length,p=1,m=ae.Buffer.alloc(u+n.length),b=i??65535;return lh.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(s,c),m.fill(n,u),new Te({keys:[],programId:r.programId,data:m})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:s}=e;Ae(t.length===ch,`Private key must be ${ch} bytes but received ${t.length} bytes`);try{let i=Tu.fromSecretKey(t),o=i.publicKey.toBytes(),c=Pu(n,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:c,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}};Lu.programId=new ce("Ed25519SigVerify111111111111111111111111111");var _E=(r,e)=>{let t=oi.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};oi.utils.isValidPrivateKey;var bE=oi.getPublicKey,dh=32,_u=20,hh=64,wE=11,bu=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")]),Cu=class r{constructor(){}static publicKeyToEthAddress(e){Ae(e.length===hh,`Public key must be ${hh} bytes but received ${e.length} bytes`);try{return ae.Buffer.from(au(we(e))).slice(-_u)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){let{publicKey:t,message:n,signature:s,recoveryId:i,instructionIndex:o}=e;return r.createInstructionWithEthAddress({ethAddress:r.publicKeyToEthAddress(t),message:n,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(e){let{ethAddress:t,message:n,signature:s,recoveryId:i,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,Ae(c.length===_u,`Address must be ${_u} bytes but received ${c.length} bytes`);let u=1+wE,p=u,m=u+c.length,b=m+s.length+1,x=1,S=ae.Buffer.alloc(bu.span+n.length);return bu.encode({numSignatures:x,signatureOffset:m,signatureInstructionIndex:o,ethAddressOffset:p,ethAddressInstructionIndex:o,messageDataOffset:b,messageDataSize:n.length,messageInstructionIndex:o,signature:we(s),ethAddress:we(c),recoveryId:i},S),S.fill(we(n),bu.span),new Te({keys:[],programId:r.programId,data:S})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:s}=e;Ae(t.length===dh,`Private key must be ${dh} bytes but received ${t.length} bytes`);try{let i=we(t),o=bE(i,!1).slice(1),c=ae.Buffer.from(au(we(n))),[u,p]=_E(c,i);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:u,recoveryId:p,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}};Cu.programId=new ce("KeccakSecp256k11111111111111111111111111111");var Nh,vE=new ce("StakeConfig11111111111111111111111111111111");var hi=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}};Nh=hi;hi.default=new Nh(0,0,ce.default);var ln=Object.freeze({Initialize:{index:0,layout:E.struct([E.u32("instruction"),M1(),U1()])},Authorize:{index:1,layout:E.struct([E.u32("instruction"),be("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"),be("newAuthorized"),E.u32("stakeAuthorizationType"),Es("authoritySeed"),be("authorityOwner")])}}),$A=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),ta=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:s}=e,i=s||hi.default,o=ln.Initialize,c=ve(o,{authorized:{staker:we(n.staker.toBuffer()),withdrawer:we(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:we(i.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:fi,isSigner:!1,isWritable:!1}],programId:this.programId,data:c};return new Te(u)}static createAccountWithSeed(e){let t=new Se;t.add(zt.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:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:s,lockup:i}))}static createAccount(e){let t=new Se;t.add(zt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:s,lockup:i}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:s}=e,i=ln.Delegate,o=ve(i);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:Mr,isSigner:!1,isWritable:!1},{pubkey:hu,isSigner:!1,isWritable:!1},{pubkey:vE,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=e,c=ln.Authorize,u=ve(c,{newAuthorized:we(s.toBuffer()),stakeAuthorizationType:i.index}),p=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Mr,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:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:c,custodianPubkey:u}=e,p=ln.AuthorizeWithSeed,m=ve(p,{newAuthorized:we(o.toBuffer()),stakeAuthorizationType:c.index,authoritySeed:s,authorityOwner:we(i.toBuffer())}),b=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Mr,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:s,lamports:i}=e,o=ln.Split,c=ve(o,{lamports:i});return new Te({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,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(zt.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:s,splitStakePubkey:i,basePubkey:o,seed:c,lamports:u}=e,p=new Se;return p.add(zt.allocate({accountPubkey:i,basePubkey:o,seed:c,space:this.space,programId:this.programId})),t&&t>0&&p.add(zt.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),p.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:s,splitStakePubkey:i,lamports:u}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:s}=e,i=ln.Merge,o=ve(i);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Mr,isSigner:!1,isWritable:!1},{pubkey:hu,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:s,lamports:i,custodianPubkey:o}=e,c=ln.Withdraw,u=ve(c,{lamports:i}),p=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:Mr,isSigner:!1,isWritable:!1},{pubkey:hu,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,s=ln.Deactivate,i=ve(s);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Mr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}};ta.programId=new ce("Stake11111111111111111111111111111111111111");ta.space=200;var ui=Object.freeze({InitializeAccount:{index:0,layout:E.struct([E.u32("instruction"),D1()])},Authorize:{index:1,layout:E.struct([E.u32("instruction"),be("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"),z1()])}}),VA=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),ra=class r{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:s}=e,i=ui.InitializeAccount,o=ve(i,{voteInit:{nodePubkey:we(s.nodePubkey.toBuffer()),authorizedVoter:we(s.authorizedVoter.toBuffer()),authorizedWithdrawer:we(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),c={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:fi,isSigner:!1,isWritable:!1},{pubkey:Mr,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(zt.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:s,voteAuthorizationType:i}=e,o=ui.Authorize,c=ve(o,{newAuthorized:we(s.toBuffer()),voteAuthorizationType:i.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Mr,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:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:c}=e,u=ui.AuthorizeWithSeed,p=ve(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:we(n.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:we(i.toBuffer()),voteAuthorizationType:o.index}}),m=[{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:Mr,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:s,toPubkey:i}=e,o=ui.Withdraw,c=ve(o,{lamports:s}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,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:s}=e,i=ui.UpdateValidatorIdentity,o=ve(i),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Se().add({keys:c,programId:this.programId,data:o})}};ra.programId=new ce("Vote111111111111111111111111111111111111111");ra.space=3762;var WA=new ce("Va1idator1nfo111111111111111111111111111111"),qA=P({name:z(),website:ne(z()),details:ne(z()),iconUrl:ne(z()),keybaseUsername:ne(z())});var jA=new ce("Vote111111111111111111111111111111111111111"),KA=E.struct([be("nodePubkey"),be("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"),be("authorizedVoter")]),E.offset(E.u32(),-8),"authorizedVoters"),E.struct([E.seq(E.struct([be("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 Fu=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 $u(r){return Buffer.from(r.serialize({verifySignatures:!1})).toString("base64")}function Vu(r){let e=Buffer.from(r,"base64");return na.deserializeMessageVersion(e)==="legacy"?Xo.deserialize(e):Se.from(e)}function EE(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:s}=t.params,i={transaction:Vu(n),options:s};return await r({method:"signAndSendTransaction",params:i})}if(t.method==="signTransaction"){let{transaction:n}=t.params,s={transaction:Vu(n)},{signedTransaction:i}=await r({method:"signTransaction",params:s});return{signedTransaction:$u(i)}}}}function Wu(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:s}=t.params,i={transaction:$u(n)};return await r({method:"signAndSendTransaction",params:i})}if(t.method==="signTransaction"){let{transaction:n}=t.params,s={transaction:$u(n)},{signedTransaction:i}=await r({method:"signTransaction",params:s});return{signedTransaction:Vu(i)}}}}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&&"details"in t.cause&&typeof t.cause.details=="string"?t.cause.details:t.cause?.message?t.cause.message:t.details})(),s=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n?["",n?`Details: ${n}`:void 0]:[]].filter(i=>typeof i=="string").join(`
13
- `);super(s,t.cause?{cause:t.cause}:void 0),this.name="BaseError",this.cause=t.cause,this.details=n,this.shortMessage=e}},Is=class extends oa{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}},aa=class extends oa{constructor(e){super(e),this.name="InvalidToken"}};async function Bh({origin:r}){let e=await fetch(`${r}/nonce`,{method:"POST"});if(!e.ok)throw new Is({status:e.status});return await e.json()}async function Lh({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 Is({status:t.status});let n=await t.json();if(n.valid===!1)throw new aa(n.message??"unknown");return{token:n.token}}function Ch(r={}){return{origin:r.origin??"https://auth.farcaster.xyz"}}function Ph(r={}){let e=Ch(r);return{generateNonce:()=>Bh(e),verifySiwf:t=>Lh(e,t)}}var Mh="0.1.1";function Uh(){return Mh}var ca=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})(),s=t.cause instanceof r&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${s??""}`,c=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||s?["",n?`Details: ${n}`:void 0,s?`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@${Uh()}`}),this.cause=t.cause,this.details=n,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return Dh(this,e)}};function Dh(r,e){return e?.(r)?r:r&&typeof r=="object"&&"cause"in r&&r.cause?Dh(r.cause,e):e?null:r}var SE=/^(?:(?<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)?/,xE=/(?: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 zh(r){let{scheme:e,statement:t,...n}=r.match(SE)?.groups??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:c,requestId:u,...p}=r.match(xE)?.groups??{},m=r.split("Resources:")[1]?.split(`
15
- - `).slice(1);return{...n,...p,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...o?{issuedAt:new Date(o)}:{},...c?{notBefore:new Date(c)}:{},...u?{requestId:u}:{},...m?{resources:m}:{},...e?{scheme:e}:{},...t?{statement:t}:{}}}var Fh=({frameHost:r,emitter:e})=>{let t,n=null;return{visible:!1,get onback(){return n},set onback(s){n&&e.removeListener("backNavigationTriggered",n),n=s,s&&e.addListener("backNavigationTriggered",s)},async show(){await r.updateBackState({visible:!0}),this.visible=!0},async hide(){await r.updateBackState({visible:!1}),this.visible=!1},async enableWebNavigation(){t=IE({back:this,emitter:e})},async disableWebNavigation(){t?.(),t=void 0}}};function IE({emitter:r,back:e}){let t=kE();if(t)return OE({emitter:r,back:e,navigation:t});if(typeof window<"u")return TE({emitter:r,back:e,window})}function kE(){if(typeof window<"u"&&window.navigation!==void 0)return window.navigation}function OE({emitter:r,back:e,navigation:t}){function n(){t.canGoBack?e.show():e.hide()}function s(){e.visible&&t.canGoBack&&t.back()}return t.addEventListener("navigatesuccess",n),r.addListener("backNavigationTriggered",s),()=>{t.removeEventListener("navigatesuccess",n),r.removeListener("backNavigationTriggered",s)}}function TE({emitter:r,back:e,window:t}){e.show();function n(){e.visible&&t.history.back()}return r.addListener("backNavigationTriggered",n),()=>{r.removeListener("backNavigationTriggered",n)}}function ua(r,e={}){let{raw:t=!1}=e,n=r;if(t)return r;if(n.error){let{code:s}=n.error,i=s===Yn.code?Yn:s===pi.code?pi:s===Ri.code?Ri:s===vi.code?vi:s===bi.code?bi:s===Ei.code?Ei:s===_i.code?_i:s===Si.code?Si:s===mi.code?mi:s===gi.code?gi:s===yi.code?yi:s===wi.code?wi:At;throw new i(n.error)}return n.result}var At=class extends Error{constructor(e){let{code:t,message:n,data:s}=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=s}},pi=class r extends At{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(pi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});var mi=class r extends At{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(mi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});var gi=class r extends At{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(gi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});var yi=class r extends At{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(yi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});var _i=class r extends At{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(_i,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});var bi=class r extends At{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(bi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});var wi=class r extends At{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(wi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});var vi=class r extends At{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(vi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});var Ei=class r extends At{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(Ei,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});var Ri=class r extends At{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(Ri,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});var Yn=class r extends At{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(Yn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});var Si=class r extends At{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(Si,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});var br=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}},xi=class extends br{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(xi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});var Ai=class extends br{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(Ai,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});var Ii=class extends br{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(Ii,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});var ki=class extends br{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(ki,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});var Oi=class extends br{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(Oi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function Vh(){let r=new qn.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 Wh(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 s=await r.request(n);return s&&typeof s=="object"&&"jsonrpc"in s?ua(s):s}}}var qu=class extends ca{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}};function qh(r={}){let e=r.id??0;return{prepare(t){return BE({id:e++,...t})},get id(){return e}}}function BE(r){return{...r,jsonrpc:"2.0"}}var Kh=Symbol("Comlink.proxy"),CE=Symbol("Comlink.endpoint"),PE=Symbol("Comlink.releaseProxy"),ju=Symbol("Comlink.finalizer"),la=Symbol("Comlink.thrown"),Hh=r=>typeof r=="object"&&r!==null||typeof r=="function",ME={canHandle:r=>Hh(r)&&r[Kh],serialize(r){let{port1:e,port2:t}=new MessageChannel;return Zh(r,e),[t,[t]]},deserialize(r){return r.start(),Hu(r)}},UE={canHandle:r=>Hh(r)&&la 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}},Gh=new Map([["proxy",ME],["throw",UE]]);function DE(r,e){for(let t of r)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Zh(r,e=globalThis,t=["*"]){e.addEventListener("message",function n(s){if(!s||!s.data)return;if(!DE(t,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}let{id:i,type:o,path:c}=Object.assign({path:[]},s.data),u=(s.data.argumentList||[]).map(Xn),p;try{let m=c.slice(0,-1).reduce((x,S)=>x[S],r),b=c.reduce((x,S)=>x[S],r);switch(o){case"GET":p=b;break;case"SET":m[c.slice(-1)[0]]=Xn(s.data.value),p=!0;break;case"APPLY":p=b.apply(m,u);break;case"CONSTRUCT":{let x=new b(...u);p=qE(x)}break;case"ENDPOINT":{let{port1:x,port2:S}=new MessageChannel;Zh(r,S),p=WE(x,[x])}break;case"RELEASE":p=void 0;break;default:return}}catch(m){p={value:m,[la]:0}}Promise.resolve(p).catch(m=>({value:m,[la]:0})).then(m=>{let[b,x]=pa(m);e.postMessage(Object.assign(Object.assign({},b),{id:i}),x),o==="RELEASE"&&(e.removeEventListener("message",n),Yh(e),ju in r&&typeof r[ju]=="function"&&r[ju]())}).catch(m=>{let[b,x]=pa({value:new TypeError("Unserializable return value"),[la]:0});e.postMessage(Object.assign(Object.assign({},b),{id:i}),x)})}),e.start&&e.start()}function zE(r){return r.constructor.name==="MessagePort"}function Yh(r){zE(r)&&r.close()}function Hu(r,e){let t=new Map;return r.addEventListener("message",function(s){let{data:i}=s;if(!i||!i.id)return;let o=t.get(i.id);if(o)try{o(i)}finally{t.delete(i.id)}}),Ku(r,t,[],e)}function fa(r){if(r)throw new Error("Proxy has been released and is not useable")}function Xh(r){return ks(r,new Map,{type:"RELEASE"}).then(()=>{Yh(r)})}var da=new WeakMap,ha="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{let e=(da.get(r)||0)-1;da.set(r,e),e===0&&Xh(r)});function FE(r,e){let t=(da.get(e)||0)+1;da.set(e,t),ha&&ha.register(r,e,r)}function $E(r){ha&&ha.unregister(r)}function Ku(r,e,t=[],n=function(){}){let s=!1,i=new Proxy(n,{get(o,c){if(fa(s),c===PE)return()=>{$E(i),Xh(r),e.clear(),s=!0};if(c==="then"){if(t.length===0)return{then:()=>i};let u=ks(r,e,{type:"GET",path:t.map(p=>p.toString())}).then(Xn);return u.then.bind(u)}return Ku(r,e,[...t,c])},set(o,c,u){fa(s);let[p,m]=pa(u);return ks(r,e,{type:"SET",path:[...t,c].map(b=>b.toString()),value:p},m).then(Xn)},apply(o,c,u){fa(s);let p=t[t.length-1];if(p===CE)return ks(r,e,{type:"ENDPOINT"}).then(Xn);if(p==="bind")return Ku(r,e,t.slice(0,-1));let[m,b]=jh(u);return ks(r,e,{type:"APPLY",path:t.map(x=>x.toString()),argumentList:m},b).then(Xn)},construct(o,c){fa(s);let[u,p]=jh(c);return ks(r,e,{type:"CONSTRUCT",path:t.map(m=>m.toString()),argumentList:u},p).then(Xn)}});return FE(i,r),i}function VE(r){return Array.prototype.concat.apply([],r)}function jh(r){let e=r.map(pa);return[e.map(t=>t[0]),VE(e.map(t=>t[1]))]}var Jh=new WeakMap;function WE(r,e){return Jh.set(r,e),r}function qE(r){return Object.assign(r,{[Kh]:!0})}function Qh(r,e=globalThis,t="*"){return{postMessage:(n,s)=>r.postMessage(n,t,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function pa(r){for(let[e,t]of Gh)if(t.canHandle(r)){let[n,s]=t.serialize(r);return[{type:"HANDLER",name:e,value:n},s]}return[{type:"RAW",value:r},Jh.get(r)||[]]}function Xn(r){switch(r.type){case"HANDLER":return Gh.get(r.name).deserialize(r.value);case"RAW":return r.value}}function ks(r,e,t,n){return new Promise(s=>{let i=jE();e.set(i,s),r.start&&r.start(),r.postMessage(Object.assign({id:i},t),n)})}function jE(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var KE={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},HE={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)}},e0=typeof window>"u"?KE:window?.ReactNativeWebView?HE:Qh(window?.parent??window);var de=Hu(e0);var Gu=Vh(),GE=qh();function ZE({code:r,details:e}){switch(r){case 4001:return new xi;case 4100:return new Ai;case 4200:return new Ii;case 4900:return new ki;case 4901:return new Oi;default:return new br(r,e??"Unknown provider RPC error")}}var Os=Wh({...Gu,async request(r){let e=GE.prepare(r);try{let t=await de.ethProviderRequestV2(e).then(n=>ua(n,{request:e,raw:!0}));if(t.error)throw ZE(t.error);return t.result}catch(t){if(t instanceof Error&&t.message.match(/cannot read property 'apply'/i))return await de.ethProviderRequest(e);throw t instanceof br||t instanceof At?t:new Yn({message:t instanceof Error?t.message:void 0})}}});async function t0(){try{let r=await de.getCapabilities();return!r.includes("wallet.getEthereumProvider")&&!r.includes("wallet.getEvmProvider")?void 0:Os}catch{return Os}}function r0(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",()=>{de.eip6963RequestProvider()}),document.addEventListener("FarcasterFrameEthProviderEvent",r=>{if(r instanceof MessageEvent){let e=r.data;Gu.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",r=>{if(r instanceof MessageEvent){let e=r.data;e.event==="eip6963:announceProvider"&&r0({info:e.info,provider:Os})}}));typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{de.eip6963RequestProvider()}),window.addEventListener("message",r=>{if(r instanceof MessageEvent&&r.data.type==="frameEthProviderEvent"){let e=r.data;Gu.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"&&r0({info:e.info,provider:Os})}}));function YE(){let r=new Ld;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 It=YE();var{solanaProviderRequest:n0}=de,s0;n0&&(s0=Fu(Wu(n0)));async function Zu(){let r;try{r=await de.getCapabilities()}catch{}if(r?.includes("wallet.getSolanaProvider"))return s0}var i0=null;async function XE(r=50){if(i0===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;let e=await Promise.race([de.context.then(t=>!!t),new Promise(t=>{setTimeout(()=>t(!1),r)})]).catch(()=>!1);return e&&(i0=!0),e}var o0=async(r={})=>{let e=Ph({origin:r.quickAuthServerOrigin}),{nonce:t}=await e.generateNonce(),n=await de.signIn({nonce:t,acceptAuthAddress:!0});if(n.result){let s=zh(n.result.message);if(!s.domain)throw new Error("Missing domain on SIWE message");return await e.verifySiwf({domain:s.domain,message:n.result.message,signature:n.result.signature})}throw n.error.type==="rejected_by_user"?new es.RejectedByUser:new Error("Unreachable")},a0=async()=>{let r=await de.addFrame();if(r.result)return r.result;throw r.error.type==="invalid_domain_manifest"?new Qn.InvalidDomainManifest:r.error.type==="rejected_by_user"?new Qn.RejectedByUser:new Error("Unreachable")},Yu={...It,getCapabilities:de.getCapabilities,getChains:de.getChains,isInMiniApp:XE,context:de.context,back:Fh({frameHost:de,emitter:It}),actions:{setPrimaryButton:de.setPrimaryButton.bind(de),ready:async(r={})=>await de.ready(r),close:de.close.bind(de),viewCast:de.viewCast.bind(de),viewProfile:de.viewProfile.bind(de),signIn:async r=>{let e=await de.signIn(r);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new es.RejectedByUser:new Error("Unreachable")},openUrl:r=>{let e=typeof r=="string"?r:r.url;return de.openUrl(e.trim())},addFrame:a0,addMiniApp:a0,composeCast(r={}){return de.composeCast(r)},viewToken:de.viewToken.bind(de),sendToken:de.sendToken.bind(de),swapToken:de.swapToken.bind(de),quickAuth:o0},experimental:{getSolanaProvider:Zu,quickAuth:o0},wallet:{ethProvider:Os,getEthereumProvider:t0,getSolanaProvider:Zu},haptics:{impactOccurred:de.impactOccurred.bind(de),notificationOccurred:de.notificationOccurred.bind(de),selectionChanged:de.selectionChanged.bind(de)}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",r=>{if(r instanceof MessageEvent){let e=r.data;e.event==="primary_button_clicked"?It.emit("primaryButtonClicked"):e.event==="frame_added"?It.emit("frameAdded",{notificationDetails:e.notificationDetails}):e.event==="frame_add_rejected"?It.emit("frameAddRejected",{reason:e.reason}):e.event==="frame_removed"?It.emit("frameRemoved"):e.event==="notifications_enabled"?It.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?It.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&It.emit("backNavigationTriggered")}});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"?It.emit("primaryButtonClicked"):e.event==="frame_added"?It.emit("frameAdded",{notificationDetails:e.notificationDetails}):e.event==="frame_add_rejected"?It.emit("frameAddRejected",{reason:e.reason}):e.event==="frame_removed"?It.emit("frameRemoved"):e.event==="notifications_enabled"?It.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?It.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&It.emit("backNavigationTriggered")}});var JE=Yu;return Ca(QE);})();
11
+ `+i+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=s||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(s=>{if(s&&s.meta&&s.meta.logMessages){let i=s.meta.logMessages;this.transactionLogs=i,t(i)}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},s){super(s!=null?`${s}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}};async function _h(r,e,t,n){let s=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},i=await r.sendTransaction(e,t,s),o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await r.confirmTransaction({abortSignal:n?.abortSignal,signature:i,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:i},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(i,n&&n.commitment)).value;if(o.err)throw i!=null?new pi({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function Gn(r){return new Promise(e=>setTimeout(e,r))}function Ee(r,e){let t=r.layout.span>=0?r.layout.span:Mh(r,e),n=ae.Buffer.alloc(t),s=Object.assign({instruction:r.index},e);return r.layout.encode(s,n),n}var dE=R.nu64("lamportsPerSignature"),zh=R.struct([R.u32("version"),R.u32("state"),be("authorizedPubkey"),be("nonce"),R.struct([dE],"feeCalculator")]),bh=zh.span,Iu=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=zh.decode(we(e),0);return new r({authorizedPubkey:new ce(t.authorizedPubkey),nonce:new ce(t.nonce).toString(),feeCalculator:t.feeCalculator})}};function As(r){let e=(0,Bh.blob)(8,r),t=e.decode.bind(e),n=e.encode.bind(e),s=e,i=Ed();return s.decode=(o,c)=>{let u=t(o,c);return i.decode(u)},s.encode=(o,c,u)=>{let p=i.encode(o);return n(p,c,u)},s}var sr=Object.freeze({Create:{index:0,layout:R.struct([R.u32("instruction"),R.ns64("lamports"),R.ns64("space"),be("programId")])},Assign:{index:1,layout:R.struct([R.u32("instruction"),be("programId")])},Transfer:{index:2,layout:R.struct([R.u32("instruction"),As("lamports")])},CreateWithSeed:{index:3,layout:R.struct([R.u32("instruction"),be("base"),Ss("seed"),R.ns64("lamports"),R.ns64("space"),be("programId")])},AdvanceNonceAccount:{index:4,layout:R.struct([R.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:R.struct([R.u32("instruction"),R.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:R.struct([R.u32("instruction"),be("authorized")])},AuthorizeNonceAccount:{index:7,layout:R.struct([R.u32("instruction"),be("authorized")])},Allocate:{index:8,layout:R.struct([R.u32("instruction"),R.ns64("space")])},AllocateWithSeed:{index:9,layout:R.struct([R.u32("instruction"),be("base"),Ss("seed"),R.ns64("space"),be("programId")])},AssignWithSeed:{index:10,layout:R.struct([R.u32("instruction"),be("base"),Ss("seed"),be("programId")])},TransferWithSeed:{index:11,layout:R.struct([R.u32("instruction"),As("lamports"),Ss("seed"),be("programId")])},UpgradeNonceAccount:{index:12,layout:R.struct([R.u32("instruction")])}}),Ft=class r{constructor(){}static createAccount(e){let t=sr.Create,n=Ee(t,{lamports:e.lamports,space:e.space,programId:we(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 s=sr.TransferWithSeed;t=Ee(s,{lamports:BigInt(e.lamports),seed:e.seed,programId:we(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 s=sr.Transfer;t=Ee(s,{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 s=sr.AssignWithSeed;t=Ee(s,{base:we(e.basePubkey.toBuffer()),seed:e.seed,programId:we(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let s=sr.Assign;t=Ee(s,{programId:we(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=sr.CreateWithSeed,n=Ee(t,{base:we(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:we(e.programId.toBuffer())}),s=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||s.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Te({keys:s,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:bh,programId:this.programId})):t.add(r.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:bh,programId:this.programId}));let n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){let t=sr.InitializeNonceAccount,n=Ee(t,{authorized:we(e.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:gu,isSigner:!1,isWritable:!1},{pubkey:hi,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Te(s)}static nonceAdvance(e){let t=sr.AdvanceNonceAccount,n=Ee(t),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:gu,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Te(s)}static nonceWithdraw(e){let t=sr.WithdrawNonceAccount,n=Ee(t,{lamports:e.lamports});return new Te({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:gu,isSigner:!1,isWritable:!1},{pubkey:hi,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=sr.AuthorizeNonceAccount,n=Ee(t,{authorized:we(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 s=sr.AllocateWithSeed;t=Ee(s,{base:we(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:we(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let s=sr.Allocate;t=Ee(s,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Te({keys:n,programId:this.programId,data:t})}};Ft.programId=new ce("11111111111111111111111111111111");var hE=Yn-300,ku=class r{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/r.chunkSize)+1+1)}static async load(e,t,n,s,i){{let b=await e.getMinimumBalanceForRentExemption(i.length),x=await e.getAccountInfo(n.publicKey,"confirmed"),S=null;if(x!==null){if(x.executable)return console.error("Program load failed, account is already executable"),!1;x.data.length!==i.length&&(S=S||new Se,S.add(Ft.allocate({accountPubkey:n.publicKey,space:i.length}))),x.owner.equals(s)||(S=S||new Se,S.add(Ft.assign({accountPubkey:n.publicKey,programId:s}))),x.lamports<b&&(S=S||new Se,S.add(Ft.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:b-x.lamports})))}else S=new Se().add(Ft.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:b>0?b:1,space:i.length,programId:s}));S!==null&&await _h(e,S,[t,n],{commitment:"confirmed"})}let o=R.struct([R.u32("instruction"),R.u32("offset"),R.u32("bytesLength"),R.u32("bytesLengthPadding"),R.seq(R.u8("byte"),R.offset(R.u32(),-8),"bytes")]),c=r.chunkSize,u=0,p=i,m=[];for(;p.length>0;){let b=p.slice(0,c),x=ae.Buffer.alloc(c+16);o.encode({instruction:0,offset:u,bytes:b,bytesLength:0,bytesLengthPadding:0},x);let S=new Se().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:x});m.push(_h(e,S,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await Gn(1e3/4),u+=c,p=p.slice(c)}await Promise.all(m);{let b=R.struct([R.u32("instruction")]),x=ae.Buffer.alloc(b.span);b.encode({instruction:1},x);let S=new Se().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:hi,isSigner:!1,isWritable:!1}],programId:s,data:x}),T="processed",I=await e.sendTransaction(S,[t,n],{preflightCommitment:T}),{context:A,value:L}=await e.confirmTransaction({signature:I,lastValidBlockHeight:S.lastValidBlockHeight,blockhash:S.recentBlockhash},T);if(L.err)throw new Error(`Transaction ${I} failed (${JSON.stringify(L)})`);for(;;){try{if(await e.getSlot({commitment:T})>A.slot)break}catch{}await new Promise(U=>setTimeout(U,Math.round(Dh/2)))}}return!0}};ku.chunkSize=hE;var dI=new ce("BPFLoader2111111111111111111111111111111111");function pE(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var _u,wh;function mE(){if(wh)return _u;wh=1;var r=Object.prototype.toString,e=Object.keys||function(n){var s=[];for(var i in n)s.push(i);return s};function t(n,s){var i,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(),s);if(b=r.call(n),b==="[object Array]"){for(c="[",o=n.length-1,i=0;i<o;i++)c+=t(n[i],!0)+",";return o>-1&&(c+=t(n[i],!0)),c+"]"}else if(b==="[object Object]"){for(u=e(n).sort(),o=u.length,c="",i=0;i<o;)p=u[i],m=t(n[p],!1),m!==void 0&&(c&&(c+=","),c+=JSON.stringify(p)+":"+m),i++;return"{"+c+"}"}else return JSON.stringify(n);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return _u=function(n){var s=t(n,!1);if(s!==void 0)return""+s},_u}var gE=mE(),Eh=pE(gE),fi=32;function bu(r){let e=0;for(;r>1;)r/=2,e++;return e}function yE(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 Ou=class{constructor(e,t,n,s,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=bu(yE(e+fi+1))-bu(fi)-1,n=this.getSlotsInEpoch(t),s=e-(n-fi);return[t,s]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),s=this.firstNormalEpoch+n,i=t%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*fi:(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+bu(fi)):this.slotsPerEpoch}},_E=globalThis.fetch,Tu=class extends th{constructor(e,t,n){let s=i=>{let o=eh(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,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 bE(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 Rh=56,ta=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=bE(wE,e),n=e.length-Rh;Ae(n>=0,"lookup table is invalid"),Ae(n%32===0,"lookup table is invalid");let s=n/32,{addresses:i}=R.struct([R.seq(be(),s,"addresses")]).decode(e.slice(Rh));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ce(t.authority[0]):void 0,addresses:i.map(o=>new ce(o))}}},wE={index:1,layout:R.struct([R.u32("typeIndex"),As("deactivationSlot"),R.nu64("lastExtendedSlot"),R.u8("lastExtendedStartIndex"),R.u8(),R.seq(be(),R.offset(R.u8(),-1),"authority")])},EE=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function RE(r){let e=r.match(EE);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);let[t,n,s,i]=e,o=r.startsWith("https:")?"wss:":"ws:",c=s==null?null:parseInt(s.slice(1),10),u=c==null?"":`:${c+1}`;return`${o}//${n}${u}${i}`}var qe=vs(Mo(ce),z(),r=>new ce(r)),Fh=Uo([z(),Me("base64")]),$u=vs(Mo(ae.Buffer),Fh,r=>ae.Buffer.from(r[0],"base64")),vE=30*1e3;function SE(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function Le(r){let e,t;if(typeof r=="string")e=r;else if(r){let{commitment:n,...s}=r;e=n,t=s}return{commitment:e,config:t}}function vh(r){return r.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function $h(r){return Nt([P({jsonrpc:Me("2.0"),id:z(),result:r}),P({jsonrpc:Me("2.0"),id:z(),error:P({code:Kn(),message:z(),data:ne(xd())})})])}var xE=$h(Kn());function ye(r){return vs($h(r),xE,e=>"error"in e?e:{...e,result:V(e.result,r)})}function Ze(r){return ye(P({context:P({slot:k()}),value:r}))}function aa(r){return P({context:P({slot:k()}),value:r})}function wu(r,e){return r===0?new Qo({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:Et.default.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new mn(e)}var AE=P({foundation:k(),foundationTerm:k(),initial:k(),taper:k(),terminal:k()}),IE=ye(q(j(P({epoch:k(),effectiveSlot:k(),amount:k(),postBalance:k(),commission:ne(j(k()))})))),kE=q(P({slot:k(),prioritizationFee:k()})),OE=P({total:k(),validator:k(),foundation:k(),epoch:k()}),TE=P({epoch:k(),slotIndex:k(),slotsInEpoch:k(),absoluteSlot:k(),blockHeight:ne(k()),transactionCount:ne(k())}),NE=P({slotsPerEpoch:k(),leaderScheduleSlotOffset:k(),warmup:fr(),firstNormalEpoch:k(),firstNormalSlot:k()}),LE=eu(z(),q(k())),Jn=j(Nt([P({}),z()])),BE=P({err:Jn}),CE=Me("receivedSignature"),PE=P({"solana-core":z(),"feature-set":ne(k())}),ME=P({program:z(),programId:qe,parsed:Kn()}),UE=P({programId:qe,accounts:q(qe),data:z()}),Sh=Ze(P({err:j(Nt([P({}),z()])),logs:j(q(z())),accounts:ne(j(q(j(P({executable:fr(),owner:z(),lamports:k(),data:q(z()),rentEpoch:ne(k())}))))),unitsConsumed:ne(k()),returnData:ne(j(P({programId:z(),data:Uo([z(),Me("base64")])}))),innerInstructions:ne(j(q(P({index:k(),instructions:q(Nt([ME,UE]))}))))})),DE=Ze(P({byIdentity:eu(z(),q(k())),range:P({firstSlot:k(),lastSlot:k()})}));function zE(r,e,t,n,s,i){let o=t||_E,c;i!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return n&&(u=async(m,b)=>{let x=await new Promise((S,T)=>{try{n(m,b,(I,A)=>S([I,A]))}catch(I){T(I)}});return await o(...x)}),new Ch.default(async(m,b)=>{let x={method:"POST",body:m,agent:c,headers:Object.assign({"Content-Type":"application/json"},e||{},zR)};try{let S=5,T,I=500;for(;u?T=await u(r,x):T=await o(r,x),!(T.status!==429||s===!0||(S-=1,S===0));)console.error(`Server responded with ${T.status} ${T.statusText}. Retrying after ${I}ms delay...`),await Gn(I),I*=2;let A=await T.text();T.ok?b(null,A):b(new Error(`${T.status} ${T.statusText}: ${A}`))}catch(S){S instanceof Error&&b(S)}},{})}function FE(r){return(e,t)=>new Promise((n,s)=>{r.request(e,t,(i,o)=>{if(i){s(i);return}n(o)})})}function $E(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);let s=e.map(i=>r.request(i.methodName,i.args));r.request(s,(i,o)=>{if(i){n(i);return}t(o)})})}var VE=ye(AE),WE=ye(OE),qE=ye(kE),jE=ye(TE),KE=ye(NE),HE=ye(LE),GE=ye(k()),ZE=Ze(P({total:k(),circulating:k(),nonCirculating:k(),nonCirculatingAccounts:q(qe)})),Nu=P({amount:z(),uiAmount:j(k()),decimals:k(),uiAmountString:ne(z())}),YE=Ze(q(P({address:qe,amount:z(),uiAmount:j(k()),decimals:k(),uiAmountString:ne(z())}))),JE=Ze(q(P({pubkey:qe,account:P({executable:fr(),owner:qe,lamports:k(),data:$u,rentEpoch:k()})}))),Lu=P({program:z(),parsed:Kn(),space:k()}),XE=Ze(q(P({pubkey:qe,account:P({executable:fr(),owner:qe,lamports:k(),data:Lu,rentEpoch:k()})}))),QE=Ze(q(P({lamports:k(),address:qe}))),mi=P({executable:fr(),owner:qe,lamports:k(),data:$u,rentEpoch:k()}),eR=P({pubkey:qe,account:mi}),tR=vs(Nt([Mo(ae.Buffer),Lu]),Nt([Fh,Lu]),r=>Array.isArray(r)?V(r,$u):r),Bu=P({executable:fr(),owner:qe,lamports:k(),data:tR,rentEpoch:k()}),rR=P({pubkey:qe,account:Bu}),nR=P({state:Nt([Me("active"),Me("inactive"),Me("activating"),Me("deactivating")]),active:k(),inactive:k()}),sR=ye(q(P({signature:z(),slot:k(),err:Jn,memo:j(z()),blockTime:ne(j(k()))}))),iR=ye(q(P({signature:z(),slot:k(),err:Jn,memo:j(z()),blockTime:ne(j(k()))}))),oR=P({subscription:k(),result:aa(mi)}),aR=P({pubkey:qe,account:mi}),cR=P({subscription:k(),result:aa(aR)}),uR=P({parent:k(),slot:k(),root:k()}),fR=P({subscription:k(),result:uR}),lR=Nt([P({type:Nt([Me("firstShredReceived"),Me("completed"),Me("optimisticConfirmation"),Me("root")]),slot:k(),timestamp:k()}),P({type:Me("createdBank"),parent:k(),slot:k(),timestamp:k()}),P({type:Me("frozen"),slot:k(),timestamp:k(),stats:P({numTransactionEntries:k(),numSuccessfulTransactions:k(),numFailedTransactions:k(),maxTransactionsPerEntry:k()})}),P({type:Me("dead"),slot:k(),timestamp:k(),err:z()})]),dR=P({subscription:k(),result:lR}),hR=P({subscription:k(),result:aa(Nt([BE,CE]))}),pR=P({subscription:k(),result:k()}),mR=P({pubkey:z(),gossip:j(z()),tpu:j(z()),rpc:j(z()),version:j(z())}),xh=P({votePubkey:z(),nodePubkey:z(),activatedStake:k(),epochVoteAccount:fr(),epochCredits:q(Uo([k(),k(),k()])),commission:k(),lastVote:k(),rootSlot:j(k())}),gR=ye(P({current:q(xh),delinquent:q(xh)})),yR=Nt([Me("processed"),Me("confirmed"),Me("finalized")]),_R=P({slot:k(),confirmations:j(k()),err:Jn,confirmationStatus:ne(yR)}),bR=Ze(q(j(_R))),wR=ye(k()),Vh=P({accountKey:qe,writableIndexes:q(k()),readonlyIndexes:q(k())}),Vu=P({signatures:q(z()),message:P({accountKeys:q(z()),header:P({numRequiredSignatures:k(),numReadonlySignedAccounts:k(),numReadonlyUnsignedAccounts:k()}),instructions:q(P({accounts:q(k()),data:z(),programIdIndex:k()})),recentBlockhash:z(),addressTableLookups:ne(q(Vh))})}),Wh=P({pubkey:qe,signer:fr(),writable:fr(),source:ne(Nt([Me("transaction"),Me("lookupTable")]))}),qh=P({accountKeys:q(Wh),signatures:q(z())}),jh=P({parsed:Kn(),program:z(),programId:qe}),Kh=P({accounts:q(qe),data:z(),programId:qe}),ER=Nt([Kh,jh]),RR=Nt([P({parsed:Kn(),program:z(),programId:z()}),P({accounts:q(z()),data:z(),programId:z()})]),Hh=vs(ER,RR,r=>"accounts"in r?V(r,Kh):V(r,jh)),Gh=P({signatures:q(z()),message:P({accountKeys:q(Wh),instructions:q(Hh),recentBlockhash:z(),addressTableLookups:ne(j(q(Vh)))})}),ra=P({accountIndex:k(),mint:z(),owner:ne(z()),programId:ne(z()),uiTokenAmount:Nu}),Zh=P({writable:q(qe),readonly:q(qe)}),ca=P({err:Jn,fee:k(),innerInstructions:ne(j(q(P({index:k(),instructions:q(P({accounts:q(k()),data:z(),programIdIndex:k()}))})))),preBalances:q(k()),postBalances:q(k()),logMessages:ne(j(q(z()))),preTokenBalances:ne(j(q(ra))),postTokenBalances:ne(j(q(ra))),loadedAddresses:ne(Zh),computeUnitsConsumed:ne(k())}),Wu=P({err:Jn,fee:k(),innerInstructions:ne(j(q(P({index:k(),instructions:q(Hh)})))),preBalances:q(k()),postBalances:q(k()),logMessages:ne(j(q(z()))),preTokenBalances:ne(j(q(ra))),postTokenBalances:ne(j(q(ra))),loadedAddresses:ne(Zh),computeUnitsConsumed:ne(k())}),ks=Nt([Me(0),Me("legacy")]),Xn=P({pubkey:z(),lamports:k(),postBalance:j(k()),rewardType:j(z()),commission:ne(j(k()))}),vR=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:Vu,meta:j(ca),version:ne(ks)})),rewards:ne(q(Xn)),blockTime:j(k()),blockHeight:j(k())}))),SR=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),rewards:ne(q(Xn)),blockTime:j(k()),blockHeight:j(k())}))),xR=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:qh,meta:j(ca),version:ne(ks)})),rewards:ne(q(Xn)),blockTime:j(k()),blockHeight:j(k())}))),AR=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:Gh,meta:j(Wu),version:ne(ks)})),rewards:ne(q(Xn)),blockTime:j(k()),blockHeight:j(k())}))),IR=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:qh,meta:j(Wu),version:ne(ks)})),rewards:ne(q(Xn)),blockTime:j(k()),blockHeight:j(k())}))),kR=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),rewards:ne(q(Xn)),blockTime:j(k()),blockHeight:j(k())}))),OR=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),transactions:q(P({transaction:Vu,meta:j(ca)})),rewards:ne(q(Xn)),blockTime:j(k())}))),Ah=ye(j(P({blockhash:z(),previousBlockhash:z(),parentSlot:k(),signatures:q(z()),blockTime:j(k())}))),Eu=ye(j(P({slot:k(),meta:j(ca),blockTime:ne(j(k())),transaction:Vu,version:ne(ks)}))),Ko=ye(j(P({slot:k(),transaction:Gh,meta:j(Wu),blockTime:ne(j(k())),version:ne(ks)}))),TR=Ze(P({blockhash:z(),lastValidBlockHeight:k()})),NR=Ze(fr()),LR=P({slot:k(),numTransactions:k(),numSlots:k(),samplePeriodSecs:k()}),BR=ye(q(LR)),CR=Ze(j(P({feeCalculator:P({lamportsPerSignature:k()})}))),PR=ye(z()),MR=ye(z()),UR=P({err:Jn,logs:q(z()),signature:z()}),DR=P({result:aa(UR),subscription:k()}),zR={"solana-client":"js/1.0.0-maintenance"},na=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:x}=Le(m),S=this._buildArgs([],b,void 0,x),T=Eh(S);return p[T]=p[T]??(async()=>{try{let I=await this._rpcRequest("getBlockHeight",S),A=V(I,ye(k()));if("error"in A)throw new Q(A.error,"failed to get block height information");return A.result}finally{delete p[T]}})(),await p[T]}})();let n,s,i,o,c,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,s=t.httpHeaders,i=t.fetch,o=t.fetchMiddleware,c=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=SE(e),this._rpcWsEndpoint=n||RE(e),this._rpcClient=zE(e,s,i,o,c,u),this._rpcRequest=FE(this._rpcClient),this._rpcBatchRequest=$E(this._rpcClient),this._rpcWebSocket=new Tu(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:s}=Le(t),i=this._buildArgs([e.toBase58()],n,void 0,s),o=await this._rpcRequest("getBalance",i),c=V(o,Ze(k()));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,ye(j(k())));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,ye(k()));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,GE);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]),s=V(n,ZE);if("error"in s)throw new Q(s.error,"failed to get supply");return s.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenSupply",n),i=V(s,Ze(Nu));if("error"in i)throw new Q(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenAccountBalance",n),i=V(s,Ze(Nu));if("error"in i)throw new Q(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(e,t,n){let{commitment:s,config:i}=Le(n),o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});let c=this._buildArgs(o,s,"base64",i),u=await this._rpcRequest("getTokenAccountsByOwner",c),p=V(u,JE);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 s=[e.toBase58()];"mint"in t?s.push({mint:t.mint.toBase58()}):s.push({programId:t.programId.toBase58()});let i=this._buildArgs(s,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),c=V(o,XE);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]:[],s=await this._rpcRequest("getLargestAccounts",n),i=V(s,QE);if("error"in i)throw new Q(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenLargestAccounts",n),i=V(s,YE);if("error"in i)throw new Q(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:s}=Le(t),i=this._buildArgs([e.toBase58()],n,"base64",s),o=await this._rpcRequest("getAccountInfo",i),c=V(o,Ze(j(mi)));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:s}=Le(t),i=this._buildArgs([e.toBase58()],n,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),c=V(o,Ze(j(Bu)));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:s}=Le(t),i=e.map(p=>p.toBase58()),o=this._buildArgs([i],n,"jsonParsed",s),c=await this._rpcRequest("getMultipleAccounts",o),u=V(c,Ze(q(j(Bu))));if("error"in u)throw new Q(u.error,`failed to get info for accounts ${i}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:s}=Le(t),i=e.map(p=>p.toBase58()),o=this._buildArgs([i],n,"base64",s),c=await this._rpcRequest("getMultipleAccounts",o),u=V(c,Ze(q(j(mi))));if("error"in u)throw new Q(u.error,`failed to get info for accounts ${i}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:s,config:i}=Le(t),o=this._buildArgs([e.toBase58()],s,void 0,{...i,epoch:n??i?.epoch}),c=await this._rpcRequest("getStakeActivation",o),u=V(c,ye(nR));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:s}=Le(t),{encoding:i,...o}=s||{},c=this._buildArgs([e.toBase58()],n,i||"base64",{...o,...o.filters?{filters:vh(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",c),p=q(eR),m=o.withContext===!0?V(u,Ze(p)):V(u,ye(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:s}=Le(t),i=this._buildArgs([e.toBase58()],n,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),c=V(o,ye(q(rR)));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 i=e;if(i.abortSignal?.aborted)return Promise.reject(i.abortSignal.reason);n=i.signature}let s;try{s=Et.default.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return Ae(s.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,s,i=!1,o=new Promise((u,p)=>{try{n=this.onSignature(t,(b,x)=>{n=void 0;let S={context:x,value:b};u({__type:dn.PROCESSED,response:S})},e);let m=new Promise(b=>{n==null?b():s=this._onSubscriptionStateChange(n,x=>{x==="subscribed"&&b()})});(async()=>{if(await m,i)return;let b=await this.getSignatureStatus(t);if(i||b==null)return;let{context:x,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":}i=!0,u({__type:dn.PROCESSED,response:{context:x,value:S}})}})()}catch(m){p(m)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:s}}){let i=!1,o=new Promise(b=>{let x=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let S=await x();if(!i){for(;S<=n;)if(await Gn(1e3),i||(S=await x(),i))return;b({__type:dn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),p=this.getCancellationPromise(t),m;try{let b=await Promise.race([p,u,o]);if(b.__type===dn.PROCESSED)m=b.response;else throw new Yo(s)}finally{i=!0,c()}return m}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let c=!1,u=new Promise(S=>{let T=i,I=null,A=async()=>{try{let{context:L,value:U}=await this.getNonceAndContext(s,{commitment:e,minContextSlot:n});return I=L.slot,U?.nonce}catch{return T}};(async()=>{if(T=await A(),!c)for(;;){if(i!==T){S({__type:dn.NONCE_INVALID,slotInWhichNonceDidAdvance:I});return}if(await Gn(2e3),c||(T=await A(),c))return}})()}),{abortConfirmation:p,confirmationPromise:m}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),b=this.getCancellationPromise(t),x;try{let S=await Promise.race([b,m,u]);if(S.__type===dn.PROCESSED)x=S.response;else{let T;for(;;){let I=await this.getSignatureStatus(o);if(I==null)break;if(I.context.slot<(S.slotInWhichNonceDidAdvance??n)){await Gn(400);continue}T=I;break}if(T?.value){let I=e||"finalized",{confirmationStatus:A}=T.value;switch(I){case"processed":case"recent":if(A!=="processed"&&A!=="confirmed"&&A!=="finalized")throw new Zn(o);break;case"confirmed":case"single":case"singleGossip":if(A!=="confirmed"&&A!=="finalized")throw new Zn(o);break;case"finalized":case"max":case"root":if(A!=="finalized")throw new Zn(o);break;default:}x={context:T.context,value:{err:T.value.err}}}else throw new Zn(o)}}finally{c=!0,p()}return x}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,s=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:dn.TIMED_OUT,timeoutMs:p}),p)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),c;try{let u=await Promise.race([o,s]);if(u.__type===dn.PROCESSED)c=u.response;else throw new Jo(t,u.timeoutMs/1e3)}finally{clearTimeout(n),i()}return c}async getClusterNodes(){let e=await this._rpcRequest("getClusterNodes",[]),t=V(e,ye(q(mR)));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),s=V(n,gR);if("error"in s)throw new Q(s.error,"failed to get vote accounts");return s.result}async getSlot(e){let{commitment:t,config:n}=Le(e),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getSlot",s),o=V(i,ye(k()));if("error"in o)throw new Q(o.error,"failed to get slot");return o.result}async getSlotLeader(e){let{commitment:t,config:n}=Le(e),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getSlotLeader",s),o=V(i,ye(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],s=await this._rpcRequest("getSlotLeaders",n),i=V(s,ye(q(qe)));if("error"in i)throw new Q(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){let{context:n,value:s}=await this.getSignatureStatuses([e],t);Ae(s.length===1);let i=s[0];return{context:n,value:i}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let s=await this._rpcRequest("getSignatureStatuses",n),i=V(s,bR);if("error"in i)throw new Q(i.error,"failed to get signature status");return i.result}async getTransactionCount(e){let{commitment:t,config:n}=Le(e),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getTransactionCount",s),o=V(i,ye(k()));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),s=V(n,VE);if("error"in s)throw new Q(s.error,"failed to get inflation");return s.result}async getInflationReward(e,t,n){let{commitment:s,config:i}=Le(n),o=this._buildArgs([e.map(p=>p.toBase58())],s,void 0,{...i,epoch:t??i?.epoch}),c=await this._rpcRequest("getInflationReward",o),u=V(c,IE);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,WE);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}=Le(e),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getEpochInfo",s),o=V(i,jE);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,KE);if("error"in t)throw new Q(t.error,"failed to get epoch schedule");let n=t.result;return new Ou(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){let e=await this._rpcRequest("getLeaderSchedule",[]),t=V(e,HE);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),s=await this._rpcRequest("getMinimumBalanceForRentExemption",n),i=V(s,wR);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.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,BR);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),s=await this._rpcRequest("getFeeCalculatorForBlockhash",n),i=V(s,CR);if("error"in i)throw new Q(i.error,"failed to get fee calculator");let{context:o,value:c}=i.result;return{context:o,value:c!==null?c.feeCalculator:null}}async getFeeForMessage(e,t){let n=we(e.serialize()).toString("base64"),s=this._buildArgs([n],t),i=await this._rpcRequest("getFeeForMessage",s),o=V(i,Ze(j(k())));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]:[],s=await this._rpcRequest("getRecentPrioritizationFees",n),i=V(s,qE);if("error"in i)throw new Q(i.error,"failed to get recent prioritization fees");return i.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}=Le(e),s=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getLatestBlockhash",s),o=V(i,TR);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:s}=Le(t),i=this._buildArgs([e],n,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),c=V(o,NR);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,ye(PE));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,ye(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:s}=Le(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s?.transactionDetails){case"accounts":{let c=V(o,xR);if("error"in c)throw c.error;return c.result}case"none":{let c=V(o,SR);if("error"in c)throw c.error;return c.result}default:{let c=V(o,vR);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:wu(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:s}=Le(t),i=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s?.transactionDetails){case"accounts":{let c=V(o,IR);if("error"in c)throw c.error;return c.result}case"none":{let c=V(o,kR);if("error"in c)throw c.error;return c.result}default:{let c=V(o,AR);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 s=this._buildArgs([],n,"base64",t),i=await this._rpcRequest("getBlockProduction",s),o=V(i,DE);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:s}=Le(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,s),o=await this._rpcRequest("getTransaction",i),c=V(o,Eu);if("error"in c)throw new Q(c.error,"failed to get transaction");let u=c.result;return u&&{...u,transaction:{...u.transaction,message:wu(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:s}=Le(t),i=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),c=V(o,Ko);if("error"in c)throw new Q(c.error,"failed to get transaction");return c.result}async getParsedTransactions(e,t){let{commitment:n,config:s}=Le(t),i=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(u=>{let p=V(u,Ko);if("error"in p)throw new Q(p.error,"failed to get transactions");return p.result})}async getTransactions(e,t){let{commitment:n,config:s}=Le(t),i=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,s)}));return(await this._rpcBatchRequest(i)).map(u=>{let p=V(u,Eu);if("error"in p)throw new Q(p.error,"failed to get transactions");let m=p.result;return m&&{...m,transaction:{...m.transaction,message:wu(m.version,m.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getBlock",n),i=V(s,OR);if("error"in i)throw new Q(i.error,"failed to get confirmed block");let o=i.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 mn(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 s=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),i=await this._rpcRequest("getBlocks",s),o=V(i,ye(q(k())));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}),s=await this._rpcRequest("getBlock",n),i=V(s,Ah);if("error"in i)throw new Q(i.error,"failed to get block");let o=i.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}),s=await this._rpcRequest("getBlock",n),i=V(s,Ah);if("error"in i)throw new Q(i.error,"failed to get confirmed block");let o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getTransaction",n),i=V(s,Eu);if("error"in i)throw new Q(i.error,"failed to get transaction");let o=i.result;if(!o)return o;let c=new mn(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"),s=await this._rpcRequest("getTransaction",n),i=V(s,Ko);if("error"in i)throw new Q(i.error,"failed to get confirmed transaction");return i.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,Ko);if("error"in c)throw new Q(c.error,"failed to get confirmed transactions");return c.result})}async getConfirmedSignaturesForAddress(e,t,n){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(t--,!(t<=0||t<i));)try{let u=await this.getConfirmedBlockSignatures(t,"finalized");u.signatures.length>0&&(s.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 s)&&(n++,!(n>o));)try{let u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(s.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,s)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let s=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=V(i,sR);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 s=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=await this._rpcRequest("getSignaturesForAddress",s),o=V(i,iR);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:s}=await this.getAccountInfoAndContext(e,t),i=null;return s!==null&&(i=new ta({key:e,state:ta.deserialize(s.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:s}=await this.getAccountInfoAndContext(e,t),i=null;return s!==null&&(i=Iu.fromAccountData(s.data)),{context:n,value:i}}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]),s=V(n,PR);if("error"in s)throw new Q(s.error,`airdrop to ${e.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await Gn(100);let n=Date.now()-this._blockhashInfo.lastFetch>=vE;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 s=0;s<50;s++){let i=await this.getLatestBlockhash("finalized");if(n!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await Gn(Dh/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}=Le(e),s=this._buildArgs([],t,"base64",n),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=V(i,Ze(k()));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(),A=ae.Buffer.from(I).toString("base64");if(Array.isArray(t)||n!==void 0)throw new Error("Invalid arguments");let L=t||{};L.encoding="base64","commitment"in L||(L.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(L.innerInstructions=t.innerInstructions);let U=[A,L],B=await this._rpcRequest("simulateTransaction",U),F=V(B,Sh);if("error"in F)throw new Error("failed to simulate transaction: "+F.error.message);return F.result}let s;if(e instanceof Se){let T=e;s=new Se,s.feePayer=T.feePayer,s.instructions=e.instructions,s.nonceInfo=T.nonceInfo,s.signatures=T.signatures}else s=Se.populate(e),s._message=s._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");let i=t;if(s.nonceInfo&&i)s.sign(...i);else{let T=this._disableBlockhashCaching;for(;;){let I=await this._blockhashWithExpiryBlockHeight(T);if(s.lastValidBlockHeight=I.lastValidBlockHeight,s.recentBlockhash=I.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");let A=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(A)&&!this._blockhashInfo.transactionSignatures.includes(A)){this._blockhashInfo.simulatedSignatures.push(A);break}else T=!0}}let o=s._compile(),c=o.serialize(),p=s._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}}i&&(m.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(m.innerInstructions=t.innerInstructions);let b=[p,m],x=await this._rpcRequest("simulateTransaction",b),S=V(x,Sh);if("error"in S){let T;if("data"in S.error&&(T=S.error.data.logs,T&&Array.isArray(T))){let I=`
12
+ `,A=I+T.join(I);console.error(S.error.message,A)}throw new pi({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 s=t;if(e.nonceInfo)e.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){let c=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=c.lastValidBlockHeight,e.recentBlockhash=c.blockhash,e.sign(...s),!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 i=e.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(e,t){let n=we(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:"base64"},s=t&&t.skipPreflight,i=s===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),s&&(n.skipPreflight=s),i&&(n.preflightCommitment=i);let o=[e,n],c=await this._rpcRequest("sendTransaction",o),u=V(c,MR);if("error"in u){let p;throw"data"in u.error&&(p=u.error.data.logs),new pi({action:s?"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 s=this._subscriptionStateChangeCallbacksByHash[e];s&&s.forEach(i=>{try{i(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let s=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return s.add(t),()=>{s.delete(t),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{let s=this._subscriptionsByHash[n];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[n],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:i,method:o}=s;try{this._setSubscription(n,{...s,state:"subscribing"});let c=await this._rpcWebSocket.call(o,i);this._setSubscription(n,{...s,serverSubscriptionId:c,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[c]=s.callbacks,await this._updateSubscriptions()}catch(c){if(console.error(`Received ${c instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:c}),!t())return;this._setSubscription(n,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(n,{...s,state:"unsubscribing"}),this._setSubscription(n,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(c){if(c instanceof Error&&console.error(`${o} error:`,c.message),!t())return;this._setSubscription(n,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(s=>{try{s(...t)}catch(i){console.error(i)}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=V(e,oR);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,s=Eh([e.method,t]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let o=this._subscriptionsByHash[s];Ae(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:s,config:i}=Le(n),o=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",i);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,cR);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,s){let{commitment:i,config:o}=Le(n),c=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:vh(s)}: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 s=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){let{result:t,subscription:n}=V(e,DR);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=V(e,fR);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,dR);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,s){let i=t||this._commitment;if(i||n||s){let o={};n&&(o.encoding=n),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,n,s){let i=t||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,s)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=V(e,hR);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 s=this._buildArgs([e],n||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,c)=>{if(o.type==="status"){t(o.result,c);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(e,t,n){let{commitment:s,...i}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([e],s,void 0,i),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,pR);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}},Cu=class r{constructor(e){this._keypair=void 0,this._keypair=e??mh()}static generate(){return new r(mh())}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 s=e.slice(0,32),i=xu(s);for(let o=0;o<32;o++)if(n[o]!==i[o])throw new Error("provided secretKey is invalid")}return new r({publicKey:n,secretKey:e})}static fromSeed(e){let t=xu(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)}},li=Object.freeze({CreateLookupTable:{index:0,layout:R.struct([R.u32("instruction"),As("recentSlot"),R.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:R.struct([R.u32("instruction")])},ExtendLookupTable:{index:2,layout:R.struct([R.u32("instruction"),As(),R.seq(be(),R.offset(R.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:R.struct([R.u32("instruction")])},CloseLookupTable:{index:4,layout:R.struct([R.u32("instruction")])}});var Pu=class{constructor(){}static createLookupTable(e){let[t,n]=ce.findProgramAddressSync([e.authority.toBuffer(),Jc().encode(e.recentSlot)],this.programId),s=li.CreateLookupTable,i=Ee(s,{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:Ft.programId,isSigner:!1,isWritable:!1}];return[new Te({programId:this.programId,keys:o,data:i}),t]}static freezeLookupTable(e){let t=li.FreezeLookupTable,n=Ee(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Te({programId:this.programId,keys:s,data:n})}static extendLookupTable(e){let t=li.ExtendLookupTable,n=Ee(t,{addresses:e.addresses.map(i=>i.toBytes())}),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&s.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Ft.programId,isSigner:!1,isWritable:!1}),new Te({programId:this.programId,keys:s,data:n})}static deactivateLookupTable(e){let t=li.DeactivateLookupTable,n=Ee(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Te({programId:this.programId,keys:s,data:n})}static closeLookupTable(e){let t=li.CloseLookupTable,n=Ee(t),s=[{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:s,data:n})}};Pu.programId=new ce("AddressLookupTab1e1111111111111111111111111");var Ho=Object.freeze({RequestUnits:{index:0,layout:R.struct([R.u8("instruction"),R.u32("units"),R.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:R.struct([R.u8("instruction"),R.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:R.struct([R.u8("instruction"),R.u32("units")])},SetComputeUnitPrice:{index:3,layout:R.struct([R.u8("instruction"),As("microLamports")])}}),Mu=class{constructor(){}static requestUnits(e){let t=Ho.RequestUnits,n=Ee(t,e);return new Te({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=Ho.RequestHeapFrame,n=Ee(t,e);return new Te({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=Ho.SetComputeUnitLimit,n=Ee(t,e);return new Te({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=Ho.SetComputeUnitPrice,n=Ee(t,{microLamports:BigInt(e.microLamports)});return new Te({keys:[],programId:this.programId,data:n})}};Mu.programId=new ce("ComputeBudget111111111111111111111111111111");var Ih=64,kh=32,Oh=64,Th=R.struct([R.u8("numSignatures"),R.u8("padding"),R.u16("signatureOffset"),R.u16("signatureInstructionIndex"),R.u16("publicKeyOffset"),R.u16("publicKeyInstructionIndex"),R.u16("messageDataOffset"),R.u16("messageDataSize"),R.u16("messageInstructionIndex")]),Uu=class r{constructor(){}static createInstructionWithPublicKey(e){let{publicKey:t,message:n,signature:s,instructionIndex:i}=e;Ae(t.length===kh,`Public Key must be ${kh} bytes but received ${t.length} bytes`),Ae(s.length===Oh,`Signature must be ${Oh} bytes but received ${s.length} bytes`);let o=Th.span,c=o+t.length,u=c+s.length,p=1,m=ae.Buffer.alloc(u+n.length),b=i??65535;return Th.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(s,c),m.fill(n,u),new Te({keys:[],programId:r.programId,data:m})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:s}=e;Ae(t.length===Ih,`Private key must be ${Ih} bytes but received ${t.length} bytes`);try{let i=Cu.fromSecretKey(t),o=i.publicKey.toBytes(),c=zu(n,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:c,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}};Uu.programId=new ce("Ed25519SigVerify111111111111111111111111111");var FR=(r,e)=>{let t=ui.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};ui.utils.isValidPrivateKey;var $R=ui.getPublicKey,Nh=32,Ru=20,Lh=64,VR=11,vu=R.struct([R.u8("numSignatures"),R.u16("signatureOffset"),R.u8("signatureInstructionIndex"),R.u16("ethAddressOffset"),R.u8("ethAddressInstructionIndex"),R.u16("messageDataOffset"),R.u16("messageDataSize"),R.u8("messageInstructionIndex"),R.blob(20,"ethAddress"),R.blob(64,"signature"),R.u8("recoveryId")]),Du=class r{constructor(){}static publicKeyToEthAddress(e){Ae(e.length===Lh,`Public key must be ${Lh} bytes but received ${e.length} bytes`);try{return ae.Buffer.from(lu(we(e))).slice(-Ru)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){let{publicKey:t,message:n,signature:s,recoveryId:i,instructionIndex:o}=e;return r.createInstructionWithEthAddress({ethAddress:r.publicKeyToEthAddress(t),message:n,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(e){let{ethAddress:t,message:n,signature:s,recoveryId:i,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,Ae(c.length===Ru,`Address must be ${Ru} bytes but received ${c.length} bytes`);let u=1+VR,p=u,m=u+c.length,b=m+s.length+1,x=1,S=ae.Buffer.alloc(vu.span+n.length);return vu.encode({numSignatures:x,signatureOffset:m,signatureInstructionIndex:o,ethAddressOffset:p,ethAddressInstructionIndex:o,messageDataOffset:b,messageDataSize:n.length,messageInstructionIndex:o,signature:we(s),ethAddress:we(c),recoveryId:i},S),S.fill(we(n),vu.span),new Te({keys:[],programId:r.programId,data:S})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:s}=e;Ae(t.length===Nh,`Private key must be ${Nh} bytes but received ${t.length} bytes`);try{let i=we(t),o=$R(i,!1).slice(1),c=ae.Buffer.from(lu(we(n))),[u,p]=FR(c,i);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:u,recoveryId:p,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}};Du.programId=new ce("KeccakSecp256k11111111111111111111111111111");var Yh,WR=new ce("StakeConfig11111111111111111111111111111111");var gi=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}};Yh=gi;gi.default=new Yh(0,0,ce.default);var hn=Object.freeze({Initialize:{index:0,layout:R.struct([R.u32("instruction"),sE(),iE()])},Authorize:{index:1,layout:R.struct([R.u32("instruction"),be("newAuthorized"),R.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:R.struct([R.u32("instruction")])},Split:{index:3,layout:R.struct([R.u32("instruction"),R.ns64("lamports")])},Withdraw:{index:4,layout:R.struct([R.u32("instruction"),R.ns64("lamports")])},Deactivate:{index:5,layout:R.struct([R.u32("instruction")])},Merge:{index:7,layout:R.struct([R.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:R.struct([R.u32("instruction"),be("newAuthorized"),R.u32("stakeAuthorizationType"),Ss("authoritySeed"),be("authorityOwner")])}}),hI=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),sa=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:s}=e,i=s||gi.default,o=hn.Initialize,c=Ee(o,{authorized:{staker:we(n.staker.toBuffer()),withdrawer:we(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:we(i.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:hi,isSigner:!1,isWritable:!1}],programId:this.programId,data:c};return new Te(u)}static createAccountWithSeed(e){let t=new Se;t.add(Ft.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:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:s,lockup:i}))}static createAccount(e){let t=new Se;t.add(Ft.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:s,lockup:i}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:s}=e,i=hn.Delegate,o=Ee(i);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:Dr,isSigner:!1,isWritable:!1},{pubkey:yu,isSigner:!1,isWritable:!1},{pubkey:WR,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=e,c=hn.Authorize,u=Ee(c,{newAuthorized:we(s.toBuffer()),stakeAuthorizationType:i.index}),p=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Dr,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:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:c,custodianPubkey:u}=e,p=hn.AuthorizeWithSeed,m=Ee(p,{newAuthorized:we(o.toBuffer()),stakeAuthorizationType:c.index,authoritySeed:s,authorityOwner:we(i.toBuffer())}),b=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Dr,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:s,lamports:i}=e,o=hn.Split,c=Ee(o,{lamports:i});return new Te({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,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(Ft.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:s,splitStakePubkey:i,basePubkey:o,seed:c,lamports:u}=e,p=new Se;return p.add(Ft.allocate({accountPubkey:i,basePubkey:o,seed:c,space:this.space,programId:this.programId})),t&&t>0&&p.add(Ft.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),p.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:s,splitStakePubkey:i,lamports:u}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:s}=e,i=hn.Merge,o=Ee(i);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Dr,isSigner:!1,isWritable:!1},{pubkey:yu,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:s,lamports:i,custodianPubkey:o}=e,c=hn.Withdraw,u=Ee(c,{lamports:i}),p=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:Dr,isSigner:!1,isWritable:!1},{pubkey:yu,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,s=hn.Deactivate,i=Ee(s);return new Se().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Dr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}};sa.programId=new ce("Stake11111111111111111111111111111111111111");sa.space=200;var di=Object.freeze({InitializeAccount:{index:0,layout:R.struct([R.u32("instruction"),oE()])},Authorize:{index:1,layout:R.struct([R.u32("instruction"),be("newAuthorized"),R.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:R.struct([R.u32("instruction"),R.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:R.struct([R.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:R.struct([R.u32("instruction"),aE()])}}),pI=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),ia=class r{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:s}=e,i=di.InitializeAccount,o=Ee(i,{voteInit:{nodePubkey:we(s.nodePubkey.toBuffer()),authorizedVoter:we(s.authorizedVoter.toBuffer()),authorizedWithdrawer:we(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),c={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:hi,isSigner:!1,isWritable:!1},{pubkey:Dr,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(Ft.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:s,voteAuthorizationType:i}=e,o=di.Authorize,c=Ee(o,{newAuthorized:we(s.toBuffer()),voteAuthorizationType:i.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Dr,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:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:c}=e,u=di.AuthorizeWithSeed,p=Ee(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:we(n.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:we(i.toBuffer()),voteAuthorizationType:o.index}}),m=[{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:Dr,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:s,toPubkey:i}=e,o=di.Withdraw,c=Ee(o,{lamports:s}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,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:s}=e,i=di.UpdateValidatorIdentity,o=Ee(i),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Se().add({keys:c,programId:this.programId,data:o})}};ia.programId=new ce("Vote111111111111111111111111111111111111111");ia.space=3762;var mI=new ce("Va1idator1nfo111111111111111111111111111111"),gI=P({name:z(),website:ne(z()),details:ne(z()),iconUrl:ne(z()),keybaseUsername:ne(z())});var yI=new ce("Vote111111111111111111111111111111111111111"),_I=R.struct([be("nodePubkey"),be("authorizedWithdrawer"),R.u8("commission"),R.nu64(),R.seq(R.struct([R.nu64("slot"),R.u32("confirmationCount")]),R.offset(R.u32(),-8),"votes"),R.u8("rootSlotValid"),R.nu64("rootSlot"),R.nu64(),R.seq(R.struct([R.nu64("epoch"),be("authorizedVoter")]),R.offset(R.u32(),-8),"authorizedVoters"),R.struct([R.seq(R.struct([be("authorizedPubkey"),R.nu64("epochOfLastAuthorizedSwitch"),R.nu64("targetEpoch")]),32,"buf"),R.nu64("idx"),R.u8("isEmpty")],"priorVoters"),R.nu64(),R.seq(R.struct([R.nu64("epoch"),R.nu64("credits"),R.nu64("prevCredits")]),R.offset(R.u32(),-8),"epochCredits"),R.struct([R.nu64("slot"),R.nu64("timestamp")],"lastTimestamp")]);var qu=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 ju(r){return Buffer.from(r.serialize({verifySignatures:!1})).toString("base64")}function Ku(r){let e=Buffer.from(r,"base64");return oa.deserializeMessageVersion(e)==="legacy"?ea.deserialize(e):Se.from(e)}function qR(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:s}=t.params,i={transaction:Ku(n),options:s};return await r({method:"signAndSendTransaction",params:i})}if(t.method==="signTransaction"){let{transaction:n}=t.params,s={transaction:Ku(n)},{signedTransaction:i}=await r({method:"signTransaction",params:s});return{signedTransaction:ju(i)}}}}function Hu(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:s}=t.params,i={transaction:ju(n)};return await r({method:"signAndSendTransaction",params:i})}if(t.method==="signTransaction"){let{transaction:n}=t.params,s={transaction:ju(n)},{signedTransaction:i}=await r({method:"signTransaction",params:s});return{signedTransaction:Ku(i)}}}}var Jh=({frameHost:r,emitter:e})=>{let t,n=null;return{visible:!1,get onback(){return n},set onback(s){n&&e.removeListener("backNavigationTriggered",n),n=s,s&&e.addListener("backNavigationTriggered",s)},async show(){await r.updateBackState({visible:!0}),this.visible=!0},async hide(){await r.updateBackState({visible:!1}),this.visible=!1},async enableWebNavigation(){t=jR({back:this,emitter:e})},async disableWebNavigation(){t?.(),t=void 0}}};function jR({emitter:r,back:e}){let t=KR();if(t)return HR({emitter:r,back:e,navigation:t});if(typeof window<"u")return GR({emitter:r,back:e,window})}function KR(){if(typeof window<"u"&&window.navigation!==void 0)return window.navigation}function HR({emitter:r,back:e,navigation:t}){function n(){t.canGoBack?e.show():e.hide()}function s(){e.visible&&t.canGoBack&&t.back()}return t.addEventListener("navigatesuccess",n),r.addListener("backNavigationTriggered",s),()=>{t.removeEventListener("navigatesuccess",n),r.removeListener("backNavigationTriggered",s)}}function GR({emitter:r,back:e,window:t}){e.show();function n(){e.visible&&t.history.back()}return r.addListener("backNavigationTriggered",n),()=>{r.removeListener("backNavigationTriggered",n)}}var Xh="0.1.1";function Qh(){return Xh}var ua=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})(),s=t.cause instanceof r&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${s??""}`,c=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||s?["",n?`Details: ${n}`:void 0,s?`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@${Qh()}`}),this.cause=t.cause,this.details=n,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return e0(this,e)}};function e0(r,e){return e?.(r)?r:r&&typeof r=="object"&&"cause"in r&&r.cause?e0(r.cause,e):e?null:r}function fa(r,e={}){let{raw:t=!1}=e,n=r;if(t)return r;if(n.error){let{code:s}=n.error,i=s===Qn.code?Qn:s===yi.code?yi:s===Ai.code?Ai:s===Si.code?Si:s===Ri.code?Ri:s===xi.code?xi:s===Ei.code?Ei:s===Ii.code?Ii:s===_i.code?_i:s===bi.code?bi:s===wi.code?wi:s===vi.code?vi:At;throw new i(n.error)}return n.result}var At=class extends Error{constructor(e){let{code:t,message:n,data:s}=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=s}},yi=class r extends At{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(yi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});var _i=class r extends At{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(_i,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});var bi=class r extends At{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(bi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});var wi=class r extends At{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(wi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});var Ei=class r extends At{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(Ei,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});var Ri=class r extends At{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(Ri,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});var vi=class r extends At{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(vi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});var Si=class r extends At{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(Si,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});var xi=class r extends At{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(xi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});var Ai=class r extends At{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(Ai,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});var Qn=class r extends At{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(Qn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});var Ii=class r extends At{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(Ii,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});var Rr=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}},ki=class extends Rr{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(ki,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});var Oi=class extends Rr{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(Oi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});var Ti=class extends Rr{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(Ti,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});var Ni=class extends Rr{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(Ni,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});var Li=class extends Rr{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(Li,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function r0(){let r=new Hn.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 n0(r,e={}){let{includeEvents:t=!0}=e;if(!r)throw new Gu;return{...t?{on:r.on?.bind(r),removeListener:r.removeListener?.bind(r)}:{},async request(n){let s=await r.request(n);return s&&typeof s=="object"&&"jsonrpc"in s?fa(s):s}}}var Gu=class extends ua{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}};function s0(r={}){let e=r.id??0;return{prepare(t){return JR({id:e++,...t})},get id(){return e}}}function JR(r){return{...r,jsonrpc:"2.0"}}var o0=Symbol("Comlink.proxy"),QR=Symbol("Comlink.endpoint"),ev=Symbol("Comlink.releaseProxy"),Zu=Symbol("Comlink.finalizer"),da=Symbol("Comlink.thrown"),a0=r=>typeof r=="object"&&r!==null||typeof r=="function",tv={canHandle:r=>a0(r)&&r[o0],serialize(r){let{port1:e,port2:t}=new MessageChannel;return u0(r,e),[t,[t]]},deserialize(r){return r.start(),Ju(r)}},rv={canHandle:r=>a0(r)&&da 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}},c0=new Map([["proxy",tv],["throw",rv]]);function nv(r,e){for(let t of r)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function u0(r,e=globalThis,t=["*"]){e.addEventListener("message",function n(s){if(!s||!s.data)return;if(!nv(t,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}let{id:i,type:o,path:c}=Object.assign({path:[]},s.data),u=(s.data.argumentList||[]).map(es),p;try{let m=c.slice(0,-1).reduce((x,S)=>x[S],r),b=c.reduce((x,S)=>x[S],r);switch(o){case"GET":p=b;break;case"SET":m[c.slice(-1)[0]]=es(s.data.value),p=!0;break;case"APPLY":p=b.apply(m,u);break;case"CONSTRUCT":{let x=new b(...u);p=uv(x)}break;case"ENDPOINT":{let{port1:x,port2:S}=new MessageChannel;u0(r,S),p=cv(x,[x])}break;case"RELEASE":p=void 0;break;default:return}}catch(m){p={value:m,[da]:0}}Promise.resolve(p).catch(m=>({value:m,[da]:0})).then(m=>{let[b,x]=ma(m);e.postMessage(Object.assign(Object.assign({},b),{id:i}),x),o==="RELEASE"&&(e.removeEventListener("message",n),f0(e),Zu in r&&typeof r[Zu]=="function"&&r[Zu]())}).catch(m=>{let[b,x]=ma({value:new TypeError("Unserializable return value"),[da]:0});e.postMessage(Object.assign(Object.assign({},b),{id:i}),x)})}),e.start&&e.start()}function sv(r){return r.constructor.name==="MessagePort"}function f0(r){sv(r)&&r.close()}function Ju(r,e){let t=new Map;return r.addEventListener("message",function(s){let{data:i}=s;if(!i||!i.id)return;let o=t.get(i.id);if(o)try{o(i)}finally{t.delete(i.id)}}),Yu(r,t,[],e)}function la(r){if(r)throw new Error("Proxy has been released and is not useable")}function l0(r){return Os(r,new Map,{type:"RELEASE"}).then(()=>{f0(r)})}var ha=new WeakMap,pa="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{let e=(ha.get(r)||0)-1;ha.set(r,e),e===0&&l0(r)});function iv(r,e){let t=(ha.get(e)||0)+1;ha.set(e,t),pa&&pa.register(r,e,r)}function ov(r){pa&&pa.unregister(r)}function Yu(r,e,t=[],n=function(){}){let s=!1,i=new Proxy(n,{get(o,c){if(la(s),c===ev)return()=>{ov(i),l0(r),e.clear(),s=!0};if(c==="then"){if(t.length===0)return{then:()=>i};let u=Os(r,e,{type:"GET",path:t.map(p=>p.toString())}).then(es);return u.then.bind(u)}return Yu(r,e,[...t,c])},set(o,c,u){la(s);let[p,m]=ma(u);return Os(r,e,{type:"SET",path:[...t,c].map(b=>b.toString()),value:p},m).then(es)},apply(o,c,u){la(s);let p=t[t.length-1];if(p===QR)return Os(r,e,{type:"ENDPOINT"}).then(es);if(p==="bind")return Yu(r,e,t.slice(0,-1));let[m,b]=i0(u);return Os(r,e,{type:"APPLY",path:t.map(x=>x.toString()),argumentList:m},b).then(es)},construct(o,c){la(s);let[u,p]=i0(c);return Os(r,e,{type:"CONSTRUCT",path:t.map(m=>m.toString()),argumentList:u},p).then(es)}});return iv(i,r),i}function av(r){return Array.prototype.concat.apply([],r)}function i0(r){let e=r.map(ma);return[e.map(t=>t[0]),av(e.map(t=>t[1]))]}var d0=new WeakMap;function cv(r,e){return d0.set(r,e),r}function uv(r){return Object.assign(r,{[o0]:!0})}function h0(r,e=globalThis,t="*"){return{postMessage:(n,s)=>r.postMessage(n,t,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function ma(r){for(let[e,t]of c0)if(t.canHandle(r)){let[n,s]=t.serialize(r);return[{type:"HANDLER",name:e,value:n},s]}return[{type:"RAW",value:r},d0.get(r)||[]]}function es(r){switch(r.type){case"HANDLER":return c0.get(r.name).deserialize(r.value);case"RAW":return r.value}}function Os(r,e,t,n){return new Promise(s=>{let i=fv();e.set(i,s),r.start&&r.start(),r.postMessage(Object.assign({id:i},t),n)})}function fv(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var lv={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},dv={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)}},p0=typeof window>"u"?lv:window?.ReactNativeWebView?dv:h0(window?.parent??window);var le=Ju(p0);var Xu=r0(),hv=s0();function pv({code:r,details:e}){switch(r){case 4001:return new ki;case 4100:return new Oi;case 4200:return new Ti;case 4900:return new Ni;case 4901:return new Li;default:return new Rr(r,e??"Unknown provider RPC error")}}var Ts=n0({...Xu,async request(r){let e=hv.prepare(r);try{let t=await le.ethProviderRequestV2(e).then(n=>fa(n,{request:e,raw:!0}));if(t.error)throw pv(t.error);return t.result}catch(t){if(t instanceof Error&&t.message.match(/cannot read property 'apply'/i))return await le.ethProviderRequest(e);throw t instanceof Rr||t instanceof At?t:new Qn({message:t instanceof Error?t.message:void 0})}}});async function m0(){try{let r=await le.getCapabilities();return!r.includes("wallet.getEthereumProvider")&&!r.includes("wallet.getEvmProvider")?void 0:Ts}catch{return Ts}}function g0(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",()=>{le.eip6963RequestProvider()}),document.addEventListener("FarcasterFrameEthProviderEvent",r=>{if(r instanceof MessageEvent){let e=r.data;Xu.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",r=>{if(r instanceof MessageEvent){let e=r.data;e.event==="eip6963:announceProvider"&&g0({info:e.info,provider:Ts})}}));typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{le.eip6963RequestProvider()}),window.addEventListener("message",r=>{if(r instanceof MessageEvent&&r.data.type==="frameEthProviderEvent"){let e=r.data;Xu.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"&&g0({info:e.info,provider:Ts})}}));var pf={};dr(pf,{quickAuth:()=>Ls});var mv=new TextEncoder,ga=new TextDecoder,jI=2**32;var gv=r=>{let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t},y0=r=>{let e=r;e instanceof Uint8Array&&(e=ga.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return gv(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};var _0=y0;function _v(r){return typeof r=="object"&&r!==null}function Qu(r){if(!_v(r)||Object.prototype.toString.call(r)!=="[object Object]")return!1;if(Object.getPrototypeOf(r)===null)return!0;let e=r;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e}var It=class extends Error{constructor(e,t){super(e,t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};It.code="ERR_JOSE_GENERIC";var ef=class extends It{constructor(e,t,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:t}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=n,this.reason=s,this.payload=t}};ef.code="ERR_JWT_CLAIM_VALIDATION_FAILED";var tf=class extends It{constructor(e,t,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:t}}),this.code="ERR_JWT_EXPIRED",this.claim=n,this.reason=s,this.payload=t}};tf.code="ERR_JWT_EXPIRED";var rf=class extends It{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}};rf.code="ERR_JOSE_ALG_NOT_ALLOWED";var nf=class extends It{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}};nf.code="ERR_JOSE_NOT_SUPPORTED";var sf=class extends It{constructor(e="decryption operation failed",t){super(e,t),this.code="ERR_JWE_DECRYPTION_FAILED"}};sf.code="ERR_JWE_DECRYPTION_FAILED";var of=class extends It{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}};of.code="ERR_JWE_INVALID";var af=class extends It{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}};af.code="ERR_JWS_INVALID";var lr=class extends It{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}};lr.code="ERR_JWT_INVALID";var cf=class extends It{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}};cf.code="ERR_JWK_INVALID";var uf=class extends It{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}};uf.code="ERR_JWKS_INVALID";var ff=class extends It{constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_NO_MATCHING_KEY"}};ff.code="ERR_JWKS_NO_MATCHING_KEY";var lf=class extends It{constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}};lf.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";var df=class extends It{constructor(e="request timed out",t){super(e,t),this.code="ERR_JWKS_TIMEOUT"}};df.code="ERR_JWKS_TIMEOUT";var hf=class extends It{constructor(e="signature verification failed",t){super(e,t),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}};hf.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function b0(r){if(typeof r!="string")throw new lr("JWTs must use Compact JWS serialization, JWT must be a string");let{1:e,length:t}=r.split(".");if(t===5)throw new lr("Only JWTs using Compact JWS serialization can be decoded");if(t!==3)throw new lr("Invalid JWT");if(!e)throw new lr("JWTs must contain a payload");let n;try{n=_0(e)}catch{throw new lr("Failed to base64url decode the payload")}let s;try{s=JSON.parse(ga.decode(n))}catch{throw new lr("Failed to parse the decoded payload as JSON")}if(!Qu(s))throw new lr("Invalid JWT Claims Set");return s}function w0(r){return b0(r)}var ya=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})(),s=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n?["",n?`Details: ${n}`:void 0]:[]].filter(i=>typeof i=="string").join(`
14
+ `);super(s,t.cause?{cause:t.cause}:void 0),this.name="BaseError",this.cause=t.cause,this.details=n,this.shortMessage=e}},Ns=class extends ya{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}},_a=class extends ya{constructor(e){super(e),this.name="InvalidToken"}};async function E0({origin:r}){let e=await fetch(`${r}/nonce`,{method:"POST"});if(!e.ok)throw new Ns({status:e.status});return await e.json()}async function R0({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 Ns({status:t.status});let n=await t.json();if(n.valid===!1)throw new _a(n.message??"unknown");return{token:n.token}}function v0(r={}){return{origin:r.origin??"https://auth.farcaster.xyz"}}function S0(r={}){let e=v0(r);return{generateNonce:()=>E0(e),verifySiwf:t=>R0(e,t)}}var bv=/^(?:(?<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)?/,wv=/(?: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 x0(r){let{scheme:e,statement:t,...n}=r.match(bv)?.groups??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:c,requestId:u,...p}=r.match(wv)?.groups??{},m=r.split("Resources:")[1]?.split(`
15
+ - `).slice(1);return{...n,...p,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...o?{issuedAt:new Date(o)}:{},...c?{notBefore:new Date(c)}:{},...u?{requestId:u}:{},...m?{resources:m}:{},...e?{scheme:e}:{},...t?{statement:t}:{}}}var Ls=(()=>{let r,e;async function t(n){let s=S0({origin:n.quickAuthServerOrigin}),{nonce:i}=await s.generateNonce(),o=await le.signIn({nonce:i,acceptAuthAddress:!0});if(o.result){let c=x0(o.result.message);if(!c.domain)throw new Error("Missing domain on SIWE message");let u=await s.verifySiwf({domain:c.domain,message:o.result.message,signature:o.result.signature});return r={token:u.token,payload:w0(u.token)},u}throw o.error.type==="rejected_by_user"?new gn.RejectedByUser:new Error("Unreachable")}return{get token(){if(r&&new Date(r.payload.exp*1e3)>new Date(Date.now()+15e3))return r.token},async getToken(n={}){let s=n.force??!1;return r&&!s&&new Date(r.payload.exp*1e3)>new Date(Date.now()+15e3)?{token:r.token}:(e||(e=t(n)),e.finally(()=>{e=void 0}),e)},async fetch(n,s){let{token:i}=await this.getToken(),o=new Headers(s?.headers);return o.set("Authorization",`Bearer ${i}`),fetch(n,{...s,headers:o})}}})();function Rv(){let r=new Xd;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 kt=Rv();var{solanaProviderRequest:A0}=le,I0;A0&&(I0=qu(Hu(A0)));async function mf(){let r;try{r=await le.getCapabilities()}catch{}if(r?.includes("wallet.getSolanaProvider"))return I0}var k0=null;async function vv(r=50){if(k0===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;let e=await Promise.race([le.context.then(t=>!!t),new Promise(t=>{setTimeout(()=>t(!1),r)})]).catch(()=>!1);return e&&(k0=!0),e}var O0=async()=>{let r=await le.addFrame();if(r.result)return r.result;throw r.error.type==="invalid_domain_manifest"?new rs.InvalidDomainManifest:r.error.type==="rejected_by_user"?new rs.RejectedByUser:new Error("Unreachable")},gf={...kt,getCapabilities:le.getCapabilities,getChains:le.getChains,isInMiniApp:vv,context:le.context,back:Jh({frameHost:le,emitter:kt}),quickAuth:Ls,actions:{setPrimaryButton:le.setPrimaryButton.bind(le),ready:async(r={})=>await le.ready(r),close:le.close.bind(le),viewCast:le.viewCast.bind(le),viewProfile:le.viewProfile.bind(le),signIn:async r=>{let e=await le.signIn(r);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new gn.RejectedByUser:new Error("Unreachable")},openUrl:r=>{let e=typeof r=="string"?r:r.url;return le.openUrl(e.trim())},addFrame:O0,addMiniApp:O0,composeCast(r={}){return le.composeCast(r)},viewToken:le.viewToken.bind(le),sendToken:le.sendToken.bind(le),swapToken:le.swapToken.bind(le)},experimental:{getSolanaProvider:mf,quickAuth(r){return Ls.getToken(r)}},wallet:{ethProvider:Ts,getEthereumProvider:m0,getSolanaProvider:mf},haptics:{impactOccurred:le.impactOccurred.bind(le),notificationOccurred:le.notificationOccurred.bind(le),selectionChanged:le.selectionChanged.bind(le)}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",r=>{if(r instanceof MessageEvent){let e=r.data;e.event==="primary_button_clicked"?kt.emit("primaryButtonClicked"):e.event==="frame_added"?kt.emit("frameAdded",{notificationDetails:e.notificationDetails}):e.event==="frame_add_rejected"?kt.emit("frameAddRejected",{reason:e.reason}):e.event==="frame_removed"?kt.emit("frameRemoved"):e.event==="notifications_enabled"?kt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?kt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&kt.emit("backNavigationTriggered")}});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"?kt.emit("primaryButtonClicked"):e.event==="frame_added"?kt.emit("frameAdded",{notificationDetails:e.notificationDetails}):e.event==="frame_add_rejected"?kt.emit("frameAddRejected",{reason:e.reason}):e.event==="frame_removed"?kt.emit("frameRemoved"):e.event==="notifications_enabled"?kt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?kt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&kt.emit("backNavigationTriggered")}});var Sv=gf;return Da(xv);})();
16
16
  /*! Bundled license information:
17
17
 
18
18
  ieee754/index.js: