@magic-ext/solana 27.0.0 → 28.0.0-canary.7f8ab55.0
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/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +3 -3
- package/dist/es/index.js +1 -1
- package/dist/es/index.js.map +3 -3
- package/dist/es/index.mjs +1 -1
- package/dist/es/index.mjs.map +3 -3
- package/dist/extension.js +1 -1
- package/dist/types/index.d.ts +5 -6
- package/package.json +4 -4
package/dist/extension.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var MagicSolanaExtension=(()=>{var af=Object.create;var Dn=Object.defineProperty;var cf=Object.getOwnPropertyDescriptor;var uf=Object.getOwnPropertyNames;var ff=Object.getPrototypeOf,lf=Object.prototype.hasOwnProperty;var ye=(r,t)=>()=>(r&&(t=r(r=0)),t);var at=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),_i=(r,t)=>{for(var e in t)Dn(r,e,{get:t[e],enumerable:!0})},Ea=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of uf(t))!lf.call(r,o)&&o!==e&&Dn(r,o,{get:()=>t[o],enumerable:!(n=cf(t,o))||n.enumerable});return r};var Re=(r,t,e)=>(e=r!=null?af(ff(r)):{},Ea(t||!r||!r.__esModule?Dn(e,"default",{value:r,enumerable:!0}):e,r)),Ii=r=>Ea(Dn({},"__esModule",{value:!0}),r);var Ia=at((U0,_a)=>{"use strict";_a.exports=Magic});var Ra=at(Kn=>{"use strict";Kn.byteLength=df;Kn.toByteArray=yf;Kn.fromByteArray=bf;var Oe=[],Ee=[],hf=typeof Uint8Array<"u"?Uint8Array:Array,Ai="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(vr=0,Aa=Ai.length;vr<Aa;++vr)Oe[vr]=Ai[vr],Ee[Ai.charCodeAt(vr)]=vr;var vr,Aa;Ee[45]=62;Ee[95]=63;function La(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function df(r){var t=La(r),e=t[0],n=t[1];return(e+n)*3/4-n}function pf(r,t,e){return(t+e)*3/4-e}function yf(r){var t,e=La(r),n=e[0],o=e[1],i=new hf(pf(r,n,o)),s=0,h=o>0?n-4:n,l;for(l=0;l<h;l+=4)t=Ee[r.charCodeAt(l)]<<18|Ee[r.charCodeAt(l+1)]<<12|Ee[r.charCodeAt(l+2)]<<6|Ee[r.charCodeAt(l+3)],i[s++]=t>>16&255,i[s++]=t>>8&255,i[s++]=t&255;return o===2&&(t=Ee[r.charCodeAt(l)]<<2|Ee[r.charCodeAt(l+1)]>>4,i[s++]=t&255),o===1&&(t=Ee[r.charCodeAt(l)]<<10|Ee[r.charCodeAt(l+1)]<<4|Ee[r.charCodeAt(l+2)]>>2,i[s++]=t>>8&255,i[s++]=t&255),i}function gf(r){return Oe[r>>18&63]+Oe[r>>12&63]+Oe[r>>6&63]+Oe[r&63]}function mf(r,t,e){for(var n,o=[],i=t;i<e;i+=3)n=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(r[i+2]&255),o.push(gf(n));return o.join("")}function bf(r){for(var t,e=r.length,n=e%3,o=[],i=16383,s=0,h=e-n;s<h;s+=i)o.push(mf(r,s,s+i>h?h:s+i));return n===1?(t=r[e-1],o.push(Oe[t>>2]+Oe[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],o.push(Oe[t>>10]+Oe[t>>4&63]+Oe[t<<2&63]+"=")),o.join("")}});var Ta=at(Li=>{"use strict";Li.read=function(r,t,e,n,o){var i,s,h=o*8-n-1,l=(1<<h)-1,b=l>>1,x=-7,k=e?o-1:0,R=e?-1:1,I=r[t+k];for(k+=R,i=I&(1<<-x)-1,I>>=-x,x+=h;x>0;i=i*256+r[t+k],k+=R,x-=8);for(s=i&(1<<-x)-1,i>>=-x,x+=n;x>0;s=s*256+r[t+k],k+=R,x-=8);if(i===0)i=1-b;else{if(i===l)return s?NaN:(I?-1:1)*(1/0);s=s+Math.pow(2,n),i=i-b}return(I?-1:1)*s*Math.pow(2,i-n)};Li.write=function(r,t,e,n,o,i){var s,h,l,b=i*8-o-1,x=(1<<b)-1,k=x>>1,R=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=n?0:i-1,P=n?1:-1,B=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(h=isNaN(t)?1:0,s=x):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+k>=1?t+=R/l:t+=R*Math.pow(2,1-k),t*l>=2&&(s++,l/=2),s+k>=x?(h=0,s=x):s+k>=1?(h=(t*l-1)*Math.pow(2,o),s=s+k):(h=t*Math.pow(2,k-1)*Math.pow(2,o),s=0));o>=8;r[e+I]=h&255,I+=P,h/=256,o-=8);for(s=s<<o|h,b+=o;b>0;r[e+I]=s&255,I+=P,s/=256,b-=8);r[e+I-P]|=B*128}});var Vn=at(zr=>{"use strict";var Ri=Ra(),Ur=Ta(),Ma=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;zr.Buffer=L;zr.SlowBuffer=Bf;zr.INSPECT_MAX_BYTES=50;var Wn=2147483647;zr.kMaxLength=Wn;L.TYPED_ARRAY_SUPPORT=wf();!L.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 wf(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(L.prototype,"parent",{enumerable:!0,get:function(){if(L.isBuffer(this))return this.buffer}});Object.defineProperty(L.prototype,"offset",{enumerable:!0,get:function(){if(L.isBuffer(this))return this.byteOffset}});function De(r){if(r>Wn)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,L.prototype),t}function L(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ci(r)}return Ua(r,t,e)}L.poolSize=8192;function Ua(r,t,e){if(typeof r=="string")return vf(r,t);if(ArrayBuffer.isView(r))return kf(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(Ue(r,ArrayBuffer)||r&&Ue(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ue(r,SharedArrayBuffer)||r&&Ue(r.buffer,SharedArrayBuffer)))return Mi(r,t,e);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 L.from(n,t,e);let o=Sf(r);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return L.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}L.from=function(r,t,e){return Ua(r,t,e)};Object.setPrototypeOf(L.prototype,Uint8Array.prototype);Object.setPrototypeOf(L,Uint8Array);function Na(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 xf(r,t,e){return Na(r),r<=0?De(r):t!==void 0?typeof e=="string"?De(r).fill(t,e):De(r).fill(t):De(r)}L.alloc=function(r,t,e){return xf(r,t,e)};function Ci(r){return Na(r),De(r<0?0:Oi(r)|0)}L.allocUnsafe=function(r){return Ci(r)};L.allocUnsafeSlow=function(r){return Ci(r)};function vf(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!L.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=za(r,t)|0,n=De(e),o=n.write(r,t);return o!==e&&(n=n.slice(0,o)),n}function Ti(r){let t=r.length<0?0:Oi(r.length)|0,e=De(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function kf(r){if(Ue(r,Uint8Array)){let t=new Uint8Array(r);return Mi(t.buffer,t.byteOffset,t.byteLength)}return Ti(r)}function Mi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,L.prototype),n}function Sf(r){if(L.isBuffer(r)){let t=Oi(r.length)|0,e=De(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Ni(r.length)?De(0):Ti(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Ti(r.data)}function Oi(r){if(r>=Wn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Wn.toString(16)+" bytes");return r|0}function Bf(r){return+r!=r&&(r=0),L.alloc(+r)}L.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==L.prototype};L.compare=function(t,e){if(Ue(t,Uint8Array)&&(t=L.from(t,t.offset,t.byteLength)),Ue(e,Uint8Array)&&(e=L.from(e,e.offset,e.byteLength)),!L.isBuffer(t)||!L.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,o=e.length;for(let i=0,s=Math.min(n,o);i<s;++i)if(t[i]!==e[i]){n=t[i],o=e[i];break}return n<o?-1:o<n?1:0};L.isEncoding=function(t){switch(String(t).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}};L.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return L.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let o=L.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){let s=t[n];if(Ue(s,Uint8Array))i+s.length>o.length?(L.isBuffer(s)||(s=L.from(s)),s.copy(o,i)):Uint8Array.prototype.set.call(o,s,i);else if(L.isBuffer(s))s.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return o};function za(r,t){if(L.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Ue(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 e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Pi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ja(r).length;default:if(o)return n?-1:Pi(r).length;t=(""+t).toLowerCase(),o=!0}}L.byteLength=za;function Ef(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Of(this,t,e);case"utf8":case"utf-8":return Fa(this,t,e);case"ascii":return Pf(this,t,e);case"latin1":case"binary":return Cf(this,t,e);case"base64":return Tf(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Uf(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}L.prototype._isBuffer=!0;function kr(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}L.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)kr(this,e,e+1);return this};L.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)kr(this,e,e+3),kr(this,e+1,e+2);return this};L.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)kr(this,e,e+7),kr(this,e+1,e+6),kr(this,e+2,e+5),kr(this,e+3,e+4);return this};L.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Fa(this,0,t):Ef.apply(this,arguments)};L.prototype.toLocaleString=L.prototype.toString;L.prototype.equals=function(t){if(!L.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:L.compare(this,t)===0};L.prototype.inspect=function(){let t="",e=zr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};Ma&&(L.prototype[Ma]=L.prototype.inspect);L.prototype.compare=function(t,e,n,o,i){if(Ue(t,Uint8Array)&&(t=L.from(t,t.offset,t.byteLength)),!L.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>t.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===t)return 0;let s=i-o,h=n-e,l=Math.min(s,h),b=this.slice(o,i),x=t.slice(e,n);for(let k=0;k<l;++k)if(b[k]!==x[k]){s=b[k],h=x[k];break}return s<h?-1:h<s?1:0};function qa(r,t,e,n,o){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Ni(e)&&(e=o?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(o)return-1;e=r.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof t=="string"&&(t=L.from(t,n)),L.isBuffer(t))return t.length===0?-1:Pa(r,t,e,n,o);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Pa(r,[t],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Pa(r,t,e,n,o){let i=1,s=r.length,h=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;i=2,s/=2,h/=2,e/=2}function l(x,k){return i===1?x[k]:x.readUInt16BE(k*i)}let b;if(o){let x=-1;for(b=e;b<s;b++)if(l(r,b)===l(t,x===-1?0:b-x)){if(x===-1&&(x=b),b-x+1===h)return x*i}else x!==-1&&(b-=b-x),x=-1}else for(e+h>s&&(e=s-h),b=e;b>=0;b--){let x=!0;for(let k=0;k<h;k++)if(l(r,b+k)!==l(t,k)){x=!1;break}if(x)return b}return-1}L.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};L.prototype.indexOf=function(t,e,n){return qa(this,t,e,n,!0)};L.prototype.lastIndexOf=function(t,e,n){return qa(this,t,e,n,!1)};function _f(r,t,e,n){e=Number(e)||0;let o=r.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;let i=t.length;n>i/2&&(n=i/2);let s;for(s=0;s<n;++s){let h=parseInt(t.substr(s*2,2),16);if(Ni(h))return s;r[e+s]=h}return s}function If(r,t,e,n){return Hn(Pi(t,r.length-e),r,e,n)}function Af(r,t,e,n){return Hn(Ff(t),r,e,n)}function Lf(r,t,e,n){return Hn(ja(t),r,e,n)}function Rf(r,t,e,n){return Hn(Df(t,r.length-e),r,e,n)}L.prototype.write=function(t,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-e;if((n===void 0||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return _f(this,t,e,n);case"utf8":case"utf-8":return If(this,t,e,n);case"ascii":case"latin1":case"binary":return Af(this,t,e,n);case"base64":return Lf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rf(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};L.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tf(r,t,e){return t===0&&e===r.length?Ri.fromByteArray(r):Ri.fromByteArray(r.slice(t,e))}function Fa(r,t,e){e=Math.min(r.length,e);let n=[],o=t;for(;o<e;){let i=r[o],s=null,h=i>239?4:i>223?3:i>191?2:1;if(o+h<=e){let l,b,x,k;switch(h){case 1:i<128&&(s=i);break;case 2:l=r[o+1],(l&192)===128&&(k=(i&31)<<6|l&63,k>127&&(s=k));break;case 3:l=r[o+1],b=r[o+2],(l&192)===128&&(b&192)===128&&(k=(i&15)<<12|(l&63)<<6|b&63,k>2047&&(k<55296||k>57343)&&(s=k));break;case 4:l=r[o+1],b=r[o+2],x=r[o+3],(l&192)===128&&(b&192)===128&&(x&192)===128&&(k=(i&15)<<18|(l&63)<<12|(b&63)<<6|x&63,k>65535&&k<1114112&&(s=k))}}s===null?(s=65533,h=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),o+=h}return Mf(n)}var Ca=4096;function Mf(r){let t=r.length;if(t<=Ca)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Ca));return e}function Pf(r,t,e){let n="";e=Math.min(r.length,e);for(let o=t;o<e;++o)n+=String.fromCharCode(r[o]&127);return n}function Cf(r,t,e){let n="";e=Math.min(r.length,e);for(let o=t;o<e;++o)n+=String.fromCharCode(r[o]);return n}function Of(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let o="";for(let i=t;i<e;++i)o+=Kf[r[i]];return o}function Uf(r,t,e){let n=r.slice(t,e),o="";for(let i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}L.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let o=this.subarray(t,e);return Object.setPrototypeOf(o,L.prototype),o};function se(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}L.prototype.readUintLE=L.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||se(t,e,this.length);let o=this[t],i=1,s=0;for(;++s<e&&(i*=256);)o+=this[t+s]*i;return o};L.prototype.readUintBE=L.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||se(t,e,this.length);let o=this[t+--e],i=1;for(;e>0&&(i*=256);)o+=this[t+--e]*i;return o};L.prototype.readUint8=L.prototype.readUInt8=function(t,e){return t=t>>>0,e||se(t,1,this.length),this[t]};L.prototype.readUint16LE=L.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||se(t,2,this.length),this[t]|this[t+1]<<8};L.prototype.readUint16BE=L.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||se(t,2,this.length),this[t]<<8|this[t+1]};L.prototype.readUint32LE=L.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||se(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};L.prototype.readUint32BE=L.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||se(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};L.prototype.readBigUInt64LE=rr(function(t){t=t>>>0,Nr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nn(t,this.length-8);let o=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,i=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(o)+(BigInt(i)<<BigInt(32))});L.prototype.readBigUInt64BE=rr(function(t){t=t>>>0,Nr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nn(t,this.length-8);let o=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],i=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(o)<<BigInt(32))+BigInt(i)});L.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||se(t,e,this.length);let o=this[t],i=1,s=0;for(;++s<e&&(i*=256);)o+=this[t+s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};L.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||se(t,e,this.length);let o=e,i=1,s=this[t+--o];for(;o>0&&(i*=256);)s+=this[t+--o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*e)),s};L.prototype.readInt8=function(t,e){return t=t>>>0,e||se(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};L.prototype.readInt16LE=function(t,e){t=t>>>0,e||se(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};L.prototype.readInt16BE=function(t,e){t=t>>>0,e||se(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};L.prototype.readInt32LE=function(t,e){return t=t>>>0,e||se(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};L.prototype.readInt32BE=function(t,e){return t=t>>>0,e||se(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};L.prototype.readBigInt64LE=rr(function(t){t=t>>>0,Nr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nn(t,this.length-8);let o=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(o)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});L.prototype.readBigInt64BE=rr(function(t){t=t>>>0,Nr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nn(t,this.length-8);let o=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(o)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});L.prototype.readFloatLE=function(t,e){return t=t>>>0,e||se(t,4,this.length),Ur.read(this,t,!0,23,4)};L.prototype.readFloatBE=function(t,e){return t=t>>>0,e||se(t,4,this.length),Ur.read(this,t,!1,23,4)};L.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||se(t,8,this.length),Ur.read(this,t,!0,52,8)};L.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||se(t,8,this.length),Ur.read(this,t,!1,52,8)};function we(r,t,e,n,o,i){if(!L.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}L.prototype.writeUintLE=L.prototype.writeUIntLE=function(t,e,n,o){if(t=+t,e=e>>>0,n=n>>>0,!o){let h=Math.pow(2,8*n)-1;we(this,t,e,n,h,0)}let i=1,s=0;for(this[e]=t&255;++s<n&&(i*=256);)this[e+s]=t/i&255;return e+n};L.prototype.writeUintBE=L.prototype.writeUIntBE=function(t,e,n,o){if(t=+t,e=e>>>0,n=n>>>0,!o){let h=Math.pow(2,8*n)-1;we(this,t,e,n,h,0)}let i=n-1,s=1;for(this[e+i]=t&255;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+n};L.prototype.writeUint8=L.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,1,255,0),this[e]=t&255,e+1};L.prototype.writeUint16LE=L.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};L.prototype.writeUint16BE=L.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};L.prototype.writeUint32LE=L.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};L.prototype.writeUint32BE=L.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Da(r,t,e,n,o){$a(t,n,o,r,e,7);let i=Number(t&BigInt(4294967295));r[e++]=i,i=i>>8,r[e++]=i,i=i>>8,r[e++]=i,i=i>>8,r[e++]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,e}function Ka(r,t,e,n,o){$a(t,n,o,r,e,7);let i=Number(t&BigInt(4294967295));r[e+7]=i,i=i>>8,r[e+6]=i,i=i>>8,r[e+5]=i,i=i>>8,r[e+4]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=s,s=s>>8,r[e+2]=s,s=s>>8,r[e+1]=s,s=s>>8,r[e]=s,e+8}L.prototype.writeBigUInt64LE=rr(function(t,e=0){return Da(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});L.prototype.writeBigUInt64BE=rr(function(t,e=0){return Ka(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});L.prototype.writeIntLE=function(t,e,n,o){if(t=+t,e=e>>>0,!o){let l=Math.pow(2,8*n-1);we(this,t,e,n,l-1,-l)}let i=0,s=1,h=0;for(this[e]=t&255;++i<n&&(s*=256);)t<0&&h===0&&this[e+i-1]!==0&&(h=1),this[e+i]=(t/s>>0)-h&255;return e+n};L.prototype.writeIntBE=function(t,e,n,o){if(t=+t,e=e>>>0,!o){let l=Math.pow(2,8*n-1);we(this,t,e,n,l-1,-l)}let i=n-1,s=1,h=0;for(this[e+i]=t&255;--i>=0&&(s*=256);)t<0&&h===0&&this[e+i+1]!==0&&(h=1),this[e+i]=(t/s>>0)-h&255;return e+n};L.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};L.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};L.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};L.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};L.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};L.prototype.writeBigInt64LE=rr(function(t,e=0){return Da(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});L.prototype.writeBigInt64BE=rr(function(t,e=0){return Ka(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Wa(r,t,e,n,o,i){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ha(r,t,e,n,o){return t=+t,e=e>>>0,o||Wa(r,t,e,4,34028234663852886e22,-34028234663852886e22),Ur.write(r,t,e,n,23,4),e+4}L.prototype.writeFloatLE=function(t,e,n){return Ha(this,t,e,!0,n)};L.prototype.writeFloatBE=function(t,e,n){return Ha(this,t,e,!1,n)};function Va(r,t,e,n,o){return t=+t,e=e>>>0,o||Wa(r,t,e,8,17976931348623157e292,-17976931348623157e292),Ur.write(r,t,e,n,52,8),e+8}L.prototype.writeDoubleLE=function(t,e,n){return Va(this,t,e,!0,n)};L.prototype.writeDoubleBE=function(t,e,n){return Va(this,t,e,!1,n)};L.prototype.copy=function(t,e,n,o){if(!L.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),e>=t.length&&(e=t.length),e||(e=0),o>0&&o<n&&(o=n),o===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-e<o-n&&(o=t.length-e+n);let i=o-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,o):Uint8Array.prototype.set.call(t,this.subarray(n,o),e),i};L.prototype.fill=function(t,e,n,o){if(typeof t=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!L.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(t.length===1){let s=t.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let i;if(typeof t=="number")for(i=e;i<n;++i)this[i]=t;else{let s=L.isBuffer(t)?t:L.from(t,o),h=s.length;if(h===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=s[i%h]}return this};var Or={};function Ui(r,t,e){Or[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Ui("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ui("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);Ui("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,o=e;return Number.isInteger(e)&&Math.abs(e)>2**32?o=Oa(String(e)):typeof e=="bigint"&&(o=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(o=Oa(o)),o+="n"),n+=` It must be ${t}. Received ${o}`,n},RangeError);function Oa(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function Nf(r,t,e){Nr(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&nn(t,r.length-(e+1))}function $a(r,t,e,n,o,i){if(r>e||r<t){let s=typeof t=="bigint"?"n":"",h;throw i>3?t===0||t===BigInt(0)?h=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:h=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:h=`>= ${t}${s} and <= ${e}${s}`,new Or.ERR_OUT_OF_RANGE("value",h,r)}Nf(n,o,i)}function Nr(r,t){if(typeof r!="number")throw new Or.ERR_INVALID_ARG_TYPE(t,"number",r)}function nn(r,t,e){throw Math.floor(r)!==r?(Nr(r,e),new Or.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new Or.ERR_BUFFER_OUT_OF_BOUNDS:new Or.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var zf=/[^+/0-9A-Za-z-_]/g;function qf(r){if(r=r.split("=")[0],r=r.trim().replace(zf,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Pi(r,t){t=t||1/0;let e,n=r.length,o=null,i=[];for(let s=0;s<n;++s){if(e=r.charCodeAt(s),e>55295&&e<57344){if(!o){if(e>56319){(t-=3)>-1&&i.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(t-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((t-=1)<0)break;i.push(e)}else if(e<2048){if((t-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function Ff(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Df(r,t){let e,n,o,i=[];for(let s=0;s<r.length&&!((t-=2)<0);++s)e=r.charCodeAt(s),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function ja(r){return Ri.toByteArray(qf(r))}function Hn(r,t,e,n){let o;for(o=0;o<n&&!(o+e>=t.length||o>=r.length);++o)t[o+e]=r[o];return o}function Ue(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Ni(r){return r!==r}var Kf=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let o=0;o<16;++o)t[n+o]=r[e]+r[o]}return t}();function rr(r){return typeof BigInt>"u"?Wf:r}function Wf(){throw new Error("BigInt not supported")}});var hc=at(()=>{"use strict"});var is=at((dc,os)=>{"use strict";(function(r,t){"use strict";function e(v,a){if(!v)throw new Error(a||"Assertion failed")}function n(v,a){v.super_=a;var u=function(){};u.prototype=a.prototype,v.prototype=new u,v.prototype.constructor=v}function o(v,a,u){if(o.isBN(v))return v;this.negative=0,this.words=null,this.length=0,this.red=null,v!==null&&((a==="le"||a==="be")&&(u=a,a=10),this._init(v||0,a||10,u||"be"))}typeof r=="object"?r.exports=o:t.BN=o,o.BN=o,o.wordSize=26;var i;try{typeof window<"u"&&typeof window.Buffer<"u"?i=window.Buffer:i=hc().Buffer}catch{}o.isBN=function(a){return a instanceof o?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===o.wordSize&&Array.isArray(a.words)},o.max=function(a,u){return a.cmp(u)>0?a:u},o.min=function(a,u){return a.cmp(u)<0?a:u},o.prototype._init=function(a,u,f){if(typeof a=="number")return this._initNumber(a,u,f);if(typeof a=="object")return this._initArray(a,u,f);u==="hex"&&(u=16),e(u===(u|0)&&u>=2&&u<=36),a=a.toString().replace(/\s+/g,"");var d=0;a[0]==="-"&&(d++,this.negative=1),d<a.length&&(u===16?this._parseHex(a,d,f):(this._parseBase(a,u,d),f==="le"&&this._initArray(this.toArray(),u,f)))},o.prototype._initNumber=function(a,u,f){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):(e(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),f==="le"&&this._initArray(this.toArray(),u,f)},o.prototype._initArray=function(a,u,f){if(e(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 d=0;d<this.length;d++)this.words[d]=0;var p,g,w=0;if(f==="be")for(d=a.length-1,p=0;d>=0;d-=3)g=a[d]|a[d-1]<<8|a[d-2]<<16,this.words[p]|=g<<w&67108863,this.words[p+1]=g>>>26-w&67108863,w+=24,w>=26&&(w-=26,p++);else if(f==="le")for(d=0,p=0;d<a.length;d+=3)g=a[d]|a[d+1]<<8|a[d+2]<<16,this.words[p]|=g<<w&67108863,this.words[p+1]=g>>>26-w&67108863,w+=24,w>=26&&(w-=26,p++);return this._strip()};function s(v,a){var u=v.charCodeAt(a);if(u>=48&&u<=57)return u-48;if(u>=65&&u<=70)return u-55;if(u>=97&&u<=102)return u-87;e(!1,"Invalid character in "+v)}function h(v,a,u){var f=s(v,u);return u-1>=a&&(f|=s(v,u-1)<<4),f}o.prototype._parseHex=function(a,u,f){this.length=Math.ceil((a.length-u)/6),this.words=new Array(this.length);for(var d=0;d<this.length;d++)this.words[d]=0;var p=0,g=0,w;if(f==="be")for(d=a.length-1;d>=u;d-=2)w=h(a,u,d)<<p,this.words[g]|=w&67108863,p>=18?(p-=18,g+=1,this.words[g]|=w>>>26):p+=8;else{var y=a.length-u;for(d=y%2===0?u+1:u;d<a.length;d+=2)w=h(a,u,d)<<p,this.words[g]|=w&67108863,p>=18?(p-=18,g+=1,this.words[g]|=w>>>26):p+=8}this._strip()};function l(v,a,u,f){for(var d=0,p=0,g=Math.min(v.length,u),w=a;w<g;w++){var y=v.charCodeAt(w)-48;d*=f,y>=49?p=y-49+10:y>=17?p=y-17+10:p=y,e(y>=0&&p<f,"Invalid character"),d+=p}return d}o.prototype._parseBase=function(a,u,f){this.words=[0],this.length=1;for(var d=0,p=1;p<=67108863;p*=u)d++;d--,p=p/u|0;for(var g=a.length-f,w=g%d,y=Math.min(g,g-w)+f,c=0,m=f;m<y;m+=d)c=l(a,m,m+d,u),this.imuln(p),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(w!==0){var M=1;for(c=l(a,m,a.length,u),m=0;m<w;m++)M*=u;this.imuln(M),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},o.prototype.copy=function(a){a.words=new Array(this.length);for(var u=0;u<this.length;u++)a.words[u]=this.words[u];a.length=this.length,a.negative=this.negative,a.red=this.red};function b(v,a){v.words=a.words,v.length=a.length,v.negative=a.negative,v.red=a.red}if(o.prototype._move=function(a){b(a,this)},o.prototype.clone=function(){var a=new o(null);return this.copy(a),a},o.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=x}catch{o.prototype.inspect=x}else o.prototype.inspect=x;function x(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var k=["","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"],R=[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],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(a,u){a=a||10,u=u|0||1;var f;if(a===16||a==="hex"){f="";for(var d=0,p=0,g=0;g<this.length;g++){var w=this.words[g],y=((w<<d|p)&16777215).toString(16);p=w>>>24-d&16777215,d+=2,d>=26&&(d-=26,g--),p!==0||g!==this.length-1?f=k[6-y.length]+y+f:f=y+f}for(p!==0&&(f=p.toString(16)+f);f.length%u!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(a===(a|0)&&a>=2&&a<=36){var c=R[a],m=I[a];f="";var M=this.clone();for(M.negative=0;!M.isZero();){var U=M.modrn(m).toString(a);M=M.idivn(m),M.isZero()?f=U+f:f=k[c-U.length]+U+f}for(this.isZero()&&(f="0"+f);f.length%u!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}e(!1,"Base should be between 2 and 36")},o.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&&e(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},o.prototype.toJSON=function(){return this.toString(16,2)},i&&(o.prototype.toBuffer=function(a,u){return this.toArrayLike(i,a,u)}),o.prototype.toArray=function(a,u){return this.toArrayLike(Array,a,u)};var P=function(a,u){return a.allocUnsafe?a.allocUnsafe(u):new a(u)};o.prototype.toArrayLike=function(a,u,f){this._strip();var d=this.byteLength(),p=f||Math.max(1,d);e(d<=p,"byte array longer than desired length"),e(p>0,"Requested array length <= 0");var g=P(a,p),w=u==="le"?"LE":"BE";return this["_toArrayLike"+w](g,d),g},o.prototype._toArrayLikeLE=function(a,u){for(var f=0,d=0,p=0,g=0;p<this.length;p++){var w=this.words[p]<<g|d;a[f++]=w&255,f<a.length&&(a[f++]=w>>8&255),f<a.length&&(a[f++]=w>>16&255),g===6?(f<a.length&&(a[f++]=w>>24&255),d=0,g=0):(d=w>>>24,g+=2)}if(f<a.length)for(a[f++]=d;f<a.length;)a[f++]=0},o.prototype._toArrayLikeBE=function(a,u){for(var f=a.length-1,d=0,p=0,g=0;p<this.length;p++){var w=this.words[p]<<g|d;a[f--]=w&255,f>=0&&(a[f--]=w>>8&255),f>=0&&(a[f--]=w>>16&255),g===6?(f>=0&&(a[f--]=w>>24&255),d=0,g=0):(d=w>>>24,g+=2)}if(f>=0)for(a[f--]=d;f>=0;)a[f--]=0},Math.clz32?o.prototype._countBits=function(a){return 32-Math.clz32(a)}:o.prototype._countBits=function(a){var u=a,f=0;return u>=4096&&(f+=13,u>>>=13),u>=64&&(f+=7,u>>>=7),u>=8&&(f+=4,u>>>=4),u>=2&&(f+=2,u>>>=2),f+u},o.prototype._zeroBits=function(a){if(a===0)return 26;var u=a,f=0;return(u&8191)===0&&(f+=13,u>>>=13),(u&127)===0&&(f+=7,u>>>=7),(u&15)===0&&(f+=4,u>>>=4),(u&3)===0&&(f+=2,u>>>=2),(u&1)===0&&f++,f},o.prototype.bitLength=function(){var a=this.words[this.length-1],u=this._countBits(a);return(this.length-1)*26+u};function B(v){for(var a=new Array(v.bitLength()),u=0;u<a.length;u++){var f=u/26|0,d=u%26;a[u]=v.words[f]>>>d&1}return a}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,u=0;u<this.length;u++){var f=this._zeroBits(this.words[u]);if(a+=f,f!==26)break}return a},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},o.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var u=0;u<a.length;u++)this.words[u]=this.words[u]|a.words[u];return this._strip()},o.prototype.ior=function(a){return e((this.negative|a.negative)===0),this.iuor(a)},o.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},o.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},o.prototype.iuand=function(a){var u;this.length>a.length?u=a:u=this;for(var f=0;f<u.length;f++)this.words[f]=this.words[f]&a.words[f];return this.length=u.length,this._strip()},o.prototype.iand=function(a){return e((this.negative|a.negative)===0),this.iuand(a)},o.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},o.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},o.prototype.iuxor=function(a){var u,f;this.length>a.length?(u=this,f=a):(u=a,f=this);for(var d=0;d<f.length;d++)this.words[d]=u.words[d]^f.words[d];if(this!==u)for(;d<u.length;d++)this.words[d]=u.words[d];return this.length=u.length,this._strip()},o.prototype.ixor=function(a){return e((this.negative|a.negative)===0),this.iuxor(a)},o.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},o.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},o.prototype.inotn=function(a){e(typeof a=="number"&&a>=0);var u=Math.ceil(a/26)|0,f=a%26;this._expand(u),f>0&&u--;for(var d=0;d<u;d++)this.words[d]=~this.words[d]&67108863;return f>0&&(this.words[d]=~this.words[d]&67108863>>26-f),this._strip()},o.prototype.notn=function(a){return this.clone().inotn(a)},o.prototype.setn=function(a,u){e(typeof a=="number"&&a>=0);var f=a/26|0,d=a%26;return this._expand(f+1),u?this.words[f]=this.words[f]|1<<d:this.words[f]=this.words[f]&~(1<<d),this._strip()},o.prototype.iadd=function(a){var u;if(this.negative!==0&&a.negative===0)return this.negative=0,u=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,u=this.isub(a),a.negative=1,u._normSign();var f,d;this.length>a.length?(f=this,d=a):(f=a,d=this);for(var p=0,g=0;g<d.length;g++)u=(f.words[g]|0)+(d.words[g]|0)+p,this.words[g]=u&67108863,p=u>>>26;for(;p!==0&&g<f.length;g++)u=(f.words[g]|0)+p,this.words[g]=u&67108863,p=u>>>26;if(this.length=f.length,p!==0)this.words[this.length]=p,this.length++;else if(f!==this)for(;g<f.length;g++)this.words[g]=f.words[g];return this},o.prototype.add=function(a){var u;return a.negative!==0&&this.negative===0?(a.negative=0,u=this.sub(a),a.negative^=1,u):a.negative===0&&this.negative!==0?(this.negative=0,u=a.sub(this),this.negative=1,u):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},o.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var u=this.iadd(a);return a.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var f=this.cmp(a);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var d,p;f>0?(d=this,p=a):(d=a,p=this);for(var g=0,w=0;w<p.length;w++)u=(d.words[w]|0)-(p.words[w]|0)+g,g=u>>26,this.words[w]=u&67108863;for(;g!==0&&w<d.length;w++)u=(d.words[w]|0)+g,g=u>>26,this.words[w]=u&67108863;if(g===0&&w<d.length&&d!==this)for(;w<d.length;w++)this.words[w]=d.words[w];return this.length=Math.max(this.length,w),d!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(a){return this.clone().isub(a)};function A(v,a,u){u.negative=a.negative^v.negative;var f=v.length+a.length|0;u.length=f,f=f-1|0;var d=v.words[0]|0,p=a.words[0]|0,g=d*p,w=g&67108863,y=g/67108864|0;u.words[0]=w;for(var c=1;c<f;c++){for(var m=y>>>26,M=y&67108863,U=Math.min(c,a.length-1),O=Math.max(0,c-v.length+1);O<=U;O++){var D=c-O|0;d=v.words[D]|0,p=a.words[O]|0,g=d*p+M,m+=g/67108864|0,M=g&67108863}u.words[c]=M|0,y=m|0}return y!==0?u.words[c]=y|0:u.length--,u._strip()}var T=function(a,u,f){var d=a.words,p=u.words,g=f.words,w=0,y,c,m,M=d[0]|0,U=M&8191,O=M>>>13,D=d[1]|0,Y=D&8191,J=D>>>13,mt=d[2]|0,Q=mt&8191,tt=mt>>>13,re=d[3]|0,ht=re&8191,dt=re>>>13,er=d[4]|0,Bt=er&8191,Lt=er>>>13,qn=d[5]|0,Rt=qn&8191,Tt=qn>>>13,tn=d[6]|0,Et=tn&8191,xt=tn>>>13,en=d[7]|0,_t=en&8191,It=en>>>13,rn=d[8]|0,At=rn&8191,Mt=rn>>>13,Fn=d[9]|0,Pt=Fn&8191,Ct=Fn>>>13,ya=p[0]|0,Ut=ya&8191,Nt=ya>>>13,ga=p[1]|0,zt=ga&8191,qt=ga>>>13,ma=p[2]|0,Ft=ma&8191,Dt=ma>>>13,ba=p[3]|0,Kt=ba&8191,Wt=ba>>>13,wa=p[4]|0,Ht=wa&8191,Vt=wa>>>13,xa=p[5]|0,$t=xa&8191,jt=xa>>>13,va=p[6]|0,Gt=va&8191,Yt=va>>>13,ka=p[7]|0,Zt=ka&8191,Jt=ka>>>13,Sa=p[8]|0,Xt=Sa&8191,Qt=Sa>>>13,Ba=p[9]|0,te=Ba&8191,ee=Ba>>>13;f.negative=a.negative^u.negative,f.length=19,y=Math.imul(U,Ut),c=Math.imul(U,Nt),c=c+Math.imul(O,Ut)|0,m=Math.imul(O,Nt);var ai=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(ai>>>26)|0,ai&=67108863,y=Math.imul(Y,Ut),c=Math.imul(Y,Nt),c=c+Math.imul(J,Ut)|0,m=Math.imul(J,Nt),y=y+Math.imul(U,zt)|0,c=c+Math.imul(U,qt)|0,c=c+Math.imul(O,zt)|0,m=m+Math.imul(O,qt)|0;var ci=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(ci>>>26)|0,ci&=67108863,y=Math.imul(Q,Ut),c=Math.imul(Q,Nt),c=c+Math.imul(tt,Ut)|0,m=Math.imul(tt,Nt),y=y+Math.imul(Y,zt)|0,c=c+Math.imul(Y,qt)|0,c=c+Math.imul(J,zt)|0,m=m+Math.imul(J,qt)|0,y=y+Math.imul(U,Ft)|0,c=c+Math.imul(U,Dt)|0,c=c+Math.imul(O,Ft)|0,m=m+Math.imul(O,Dt)|0;var ui=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(ui>>>26)|0,ui&=67108863,y=Math.imul(ht,Ut),c=Math.imul(ht,Nt),c=c+Math.imul(dt,Ut)|0,m=Math.imul(dt,Nt),y=y+Math.imul(Q,zt)|0,c=c+Math.imul(Q,qt)|0,c=c+Math.imul(tt,zt)|0,m=m+Math.imul(tt,qt)|0,y=y+Math.imul(Y,Ft)|0,c=c+Math.imul(Y,Dt)|0,c=c+Math.imul(J,Ft)|0,m=m+Math.imul(J,Dt)|0,y=y+Math.imul(U,Kt)|0,c=c+Math.imul(U,Wt)|0,c=c+Math.imul(O,Kt)|0,m=m+Math.imul(O,Wt)|0;var fi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(fi>>>26)|0,fi&=67108863,y=Math.imul(Bt,Ut),c=Math.imul(Bt,Nt),c=c+Math.imul(Lt,Ut)|0,m=Math.imul(Lt,Nt),y=y+Math.imul(ht,zt)|0,c=c+Math.imul(ht,qt)|0,c=c+Math.imul(dt,zt)|0,m=m+Math.imul(dt,qt)|0,y=y+Math.imul(Q,Ft)|0,c=c+Math.imul(Q,Dt)|0,c=c+Math.imul(tt,Ft)|0,m=m+Math.imul(tt,Dt)|0,y=y+Math.imul(Y,Kt)|0,c=c+Math.imul(Y,Wt)|0,c=c+Math.imul(J,Kt)|0,m=m+Math.imul(J,Wt)|0,y=y+Math.imul(U,Ht)|0,c=c+Math.imul(U,Vt)|0,c=c+Math.imul(O,Ht)|0,m=m+Math.imul(O,Vt)|0;var li=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(li>>>26)|0,li&=67108863,y=Math.imul(Rt,Ut),c=Math.imul(Rt,Nt),c=c+Math.imul(Tt,Ut)|0,m=Math.imul(Tt,Nt),y=y+Math.imul(Bt,zt)|0,c=c+Math.imul(Bt,qt)|0,c=c+Math.imul(Lt,zt)|0,m=m+Math.imul(Lt,qt)|0,y=y+Math.imul(ht,Ft)|0,c=c+Math.imul(ht,Dt)|0,c=c+Math.imul(dt,Ft)|0,m=m+Math.imul(dt,Dt)|0,y=y+Math.imul(Q,Kt)|0,c=c+Math.imul(Q,Wt)|0,c=c+Math.imul(tt,Kt)|0,m=m+Math.imul(tt,Wt)|0,y=y+Math.imul(Y,Ht)|0,c=c+Math.imul(Y,Vt)|0,c=c+Math.imul(J,Ht)|0,m=m+Math.imul(J,Vt)|0,y=y+Math.imul(U,$t)|0,c=c+Math.imul(U,jt)|0,c=c+Math.imul(O,$t)|0,m=m+Math.imul(O,jt)|0;var hi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(hi>>>26)|0,hi&=67108863,y=Math.imul(Et,Ut),c=Math.imul(Et,Nt),c=c+Math.imul(xt,Ut)|0,m=Math.imul(xt,Nt),y=y+Math.imul(Rt,zt)|0,c=c+Math.imul(Rt,qt)|0,c=c+Math.imul(Tt,zt)|0,m=m+Math.imul(Tt,qt)|0,y=y+Math.imul(Bt,Ft)|0,c=c+Math.imul(Bt,Dt)|0,c=c+Math.imul(Lt,Ft)|0,m=m+Math.imul(Lt,Dt)|0,y=y+Math.imul(ht,Kt)|0,c=c+Math.imul(ht,Wt)|0,c=c+Math.imul(dt,Kt)|0,m=m+Math.imul(dt,Wt)|0,y=y+Math.imul(Q,Ht)|0,c=c+Math.imul(Q,Vt)|0,c=c+Math.imul(tt,Ht)|0,m=m+Math.imul(tt,Vt)|0,y=y+Math.imul(Y,$t)|0,c=c+Math.imul(Y,jt)|0,c=c+Math.imul(J,$t)|0,m=m+Math.imul(J,jt)|0,y=y+Math.imul(U,Gt)|0,c=c+Math.imul(U,Yt)|0,c=c+Math.imul(O,Gt)|0,m=m+Math.imul(O,Yt)|0;var di=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(di>>>26)|0,di&=67108863,y=Math.imul(_t,Ut),c=Math.imul(_t,Nt),c=c+Math.imul(It,Ut)|0,m=Math.imul(It,Nt),y=y+Math.imul(Et,zt)|0,c=c+Math.imul(Et,qt)|0,c=c+Math.imul(xt,zt)|0,m=m+Math.imul(xt,qt)|0,y=y+Math.imul(Rt,Ft)|0,c=c+Math.imul(Rt,Dt)|0,c=c+Math.imul(Tt,Ft)|0,m=m+Math.imul(Tt,Dt)|0,y=y+Math.imul(Bt,Kt)|0,c=c+Math.imul(Bt,Wt)|0,c=c+Math.imul(Lt,Kt)|0,m=m+Math.imul(Lt,Wt)|0,y=y+Math.imul(ht,Ht)|0,c=c+Math.imul(ht,Vt)|0,c=c+Math.imul(dt,Ht)|0,m=m+Math.imul(dt,Vt)|0,y=y+Math.imul(Q,$t)|0,c=c+Math.imul(Q,jt)|0,c=c+Math.imul(tt,$t)|0,m=m+Math.imul(tt,jt)|0,y=y+Math.imul(Y,Gt)|0,c=c+Math.imul(Y,Yt)|0,c=c+Math.imul(J,Gt)|0,m=m+Math.imul(J,Yt)|0,y=y+Math.imul(U,Zt)|0,c=c+Math.imul(U,Jt)|0,c=c+Math.imul(O,Zt)|0,m=m+Math.imul(O,Jt)|0;var pi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(pi>>>26)|0,pi&=67108863,y=Math.imul(At,Ut),c=Math.imul(At,Nt),c=c+Math.imul(Mt,Ut)|0,m=Math.imul(Mt,Nt),y=y+Math.imul(_t,zt)|0,c=c+Math.imul(_t,qt)|0,c=c+Math.imul(It,zt)|0,m=m+Math.imul(It,qt)|0,y=y+Math.imul(Et,Ft)|0,c=c+Math.imul(Et,Dt)|0,c=c+Math.imul(xt,Ft)|0,m=m+Math.imul(xt,Dt)|0,y=y+Math.imul(Rt,Kt)|0,c=c+Math.imul(Rt,Wt)|0,c=c+Math.imul(Tt,Kt)|0,m=m+Math.imul(Tt,Wt)|0,y=y+Math.imul(Bt,Ht)|0,c=c+Math.imul(Bt,Vt)|0,c=c+Math.imul(Lt,Ht)|0,m=m+Math.imul(Lt,Vt)|0,y=y+Math.imul(ht,$t)|0,c=c+Math.imul(ht,jt)|0,c=c+Math.imul(dt,$t)|0,m=m+Math.imul(dt,jt)|0,y=y+Math.imul(Q,Gt)|0,c=c+Math.imul(Q,Yt)|0,c=c+Math.imul(tt,Gt)|0,m=m+Math.imul(tt,Yt)|0,y=y+Math.imul(Y,Zt)|0,c=c+Math.imul(Y,Jt)|0,c=c+Math.imul(J,Zt)|0,m=m+Math.imul(J,Jt)|0,y=y+Math.imul(U,Xt)|0,c=c+Math.imul(U,Qt)|0,c=c+Math.imul(O,Xt)|0,m=m+Math.imul(O,Qt)|0;var yi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(yi>>>26)|0,yi&=67108863,y=Math.imul(Pt,Ut),c=Math.imul(Pt,Nt),c=c+Math.imul(Ct,Ut)|0,m=Math.imul(Ct,Nt),y=y+Math.imul(At,zt)|0,c=c+Math.imul(At,qt)|0,c=c+Math.imul(Mt,zt)|0,m=m+Math.imul(Mt,qt)|0,y=y+Math.imul(_t,Ft)|0,c=c+Math.imul(_t,Dt)|0,c=c+Math.imul(It,Ft)|0,m=m+Math.imul(It,Dt)|0,y=y+Math.imul(Et,Kt)|0,c=c+Math.imul(Et,Wt)|0,c=c+Math.imul(xt,Kt)|0,m=m+Math.imul(xt,Wt)|0,y=y+Math.imul(Rt,Ht)|0,c=c+Math.imul(Rt,Vt)|0,c=c+Math.imul(Tt,Ht)|0,m=m+Math.imul(Tt,Vt)|0,y=y+Math.imul(Bt,$t)|0,c=c+Math.imul(Bt,jt)|0,c=c+Math.imul(Lt,$t)|0,m=m+Math.imul(Lt,jt)|0,y=y+Math.imul(ht,Gt)|0,c=c+Math.imul(ht,Yt)|0,c=c+Math.imul(dt,Gt)|0,m=m+Math.imul(dt,Yt)|0,y=y+Math.imul(Q,Zt)|0,c=c+Math.imul(Q,Jt)|0,c=c+Math.imul(tt,Zt)|0,m=m+Math.imul(tt,Jt)|0,y=y+Math.imul(Y,Xt)|0,c=c+Math.imul(Y,Qt)|0,c=c+Math.imul(J,Xt)|0,m=m+Math.imul(J,Qt)|0,y=y+Math.imul(U,te)|0,c=c+Math.imul(U,ee)|0,c=c+Math.imul(O,te)|0,m=m+Math.imul(O,ee)|0;var gi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(gi>>>26)|0,gi&=67108863,y=Math.imul(Pt,zt),c=Math.imul(Pt,qt),c=c+Math.imul(Ct,zt)|0,m=Math.imul(Ct,qt),y=y+Math.imul(At,Ft)|0,c=c+Math.imul(At,Dt)|0,c=c+Math.imul(Mt,Ft)|0,m=m+Math.imul(Mt,Dt)|0,y=y+Math.imul(_t,Kt)|0,c=c+Math.imul(_t,Wt)|0,c=c+Math.imul(It,Kt)|0,m=m+Math.imul(It,Wt)|0,y=y+Math.imul(Et,Ht)|0,c=c+Math.imul(Et,Vt)|0,c=c+Math.imul(xt,Ht)|0,m=m+Math.imul(xt,Vt)|0,y=y+Math.imul(Rt,$t)|0,c=c+Math.imul(Rt,jt)|0,c=c+Math.imul(Tt,$t)|0,m=m+Math.imul(Tt,jt)|0,y=y+Math.imul(Bt,Gt)|0,c=c+Math.imul(Bt,Yt)|0,c=c+Math.imul(Lt,Gt)|0,m=m+Math.imul(Lt,Yt)|0,y=y+Math.imul(ht,Zt)|0,c=c+Math.imul(ht,Jt)|0,c=c+Math.imul(dt,Zt)|0,m=m+Math.imul(dt,Jt)|0,y=y+Math.imul(Q,Xt)|0,c=c+Math.imul(Q,Qt)|0,c=c+Math.imul(tt,Xt)|0,m=m+Math.imul(tt,Qt)|0,y=y+Math.imul(Y,te)|0,c=c+Math.imul(Y,ee)|0,c=c+Math.imul(J,te)|0,m=m+Math.imul(J,ee)|0;var mi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(mi>>>26)|0,mi&=67108863,y=Math.imul(Pt,Ft),c=Math.imul(Pt,Dt),c=c+Math.imul(Ct,Ft)|0,m=Math.imul(Ct,Dt),y=y+Math.imul(At,Kt)|0,c=c+Math.imul(At,Wt)|0,c=c+Math.imul(Mt,Kt)|0,m=m+Math.imul(Mt,Wt)|0,y=y+Math.imul(_t,Ht)|0,c=c+Math.imul(_t,Vt)|0,c=c+Math.imul(It,Ht)|0,m=m+Math.imul(It,Vt)|0,y=y+Math.imul(Et,$t)|0,c=c+Math.imul(Et,jt)|0,c=c+Math.imul(xt,$t)|0,m=m+Math.imul(xt,jt)|0,y=y+Math.imul(Rt,Gt)|0,c=c+Math.imul(Rt,Yt)|0,c=c+Math.imul(Tt,Gt)|0,m=m+Math.imul(Tt,Yt)|0,y=y+Math.imul(Bt,Zt)|0,c=c+Math.imul(Bt,Jt)|0,c=c+Math.imul(Lt,Zt)|0,m=m+Math.imul(Lt,Jt)|0,y=y+Math.imul(ht,Xt)|0,c=c+Math.imul(ht,Qt)|0,c=c+Math.imul(dt,Xt)|0,m=m+Math.imul(dt,Qt)|0,y=y+Math.imul(Q,te)|0,c=c+Math.imul(Q,ee)|0,c=c+Math.imul(tt,te)|0,m=m+Math.imul(tt,ee)|0;var bi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(bi>>>26)|0,bi&=67108863,y=Math.imul(Pt,Kt),c=Math.imul(Pt,Wt),c=c+Math.imul(Ct,Kt)|0,m=Math.imul(Ct,Wt),y=y+Math.imul(At,Ht)|0,c=c+Math.imul(At,Vt)|0,c=c+Math.imul(Mt,Ht)|0,m=m+Math.imul(Mt,Vt)|0,y=y+Math.imul(_t,$t)|0,c=c+Math.imul(_t,jt)|0,c=c+Math.imul(It,$t)|0,m=m+Math.imul(It,jt)|0,y=y+Math.imul(Et,Gt)|0,c=c+Math.imul(Et,Yt)|0,c=c+Math.imul(xt,Gt)|0,m=m+Math.imul(xt,Yt)|0,y=y+Math.imul(Rt,Zt)|0,c=c+Math.imul(Rt,Jt)|0,c=c+Math.imul(Tt,Zt)|0,m=m+Math.imul(Tt,Jt)|0,y=y+Math.imul(Bt,Xt)|0,c=c+Math.imul(Bt,Qt)|0,c=c+Math.imul(Lt,Xt)|0,m=m+Math.imul(Lt,Qt)|0,y=y+Math.imul(ht,te)|0,c=c+Math.imul(ht,ee)|0,c=c+Math.imul(dt,te)|0,m=m+Math.imul(dt,ee)|0;var wi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(wi>>>26)|0,wi&=67108863,y=Math.imul(Pt,Ht),c=Math.imul(Pt,Vt),c=c+Math.imul(Ct,Ht)|0,m=Math.imul(Ct,Vt),y=y+Math.imul(At,$t)|0,c=c+Math.imul(At,jt)|0,c=c+Math.imul(Mt,$t)|0,m=m+Math.imul(Mt,jt)|0,y=y+Math.imul(_t,Gt)|0,c=c+Math.imul(_t,Yt)|0,c=c+Math.imul(It,Gt)|0,m=m+Math.imul(It,Yt)|0,y=y+Math.imul(Et,Zt)|0,c=c+Math.imul(Et,Jt)|0,c=c+Math.imul(xt,Zt)|0,m=m+Math.imul(xt,Jt)|0,y=y+Math.imul(Rt,Xt)|0,c=c+Math.imul(Rt,Qt)|0,c=c+Math.imul(Tt,Xt)|0,m=m+Math.imul(Tt,Qt)|0,y=y+Math.imul(Bt,te)|0,c=c+Math.imul(Bt,ee)|0,c=c+Math.imul(Lt,te)|0,m=m+Math.imul(Lt,ee)|0;var xi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(xi>>>26)|0,xi&=67108863,y=Math.imul(Pt,$t),c=Math.imul(Pt,jt),c=c+Math.imul(Ct,$t)|0,m=Math.imul(Ct,jt),y=y+Math.imul(At,Gt)|0,c=c+Math.imul(At,Yt)|0,c=c+Math.imul(Mt,Gt)|0,m=m+Math.imul(Mt,Yt)|0,y=y+Math.imul(_t,Zt)|0,c=c+Math.imul(_t,Jt)|0,c=c+Math.imul(It,Zt)|0,m=m+Math.imul(It,Jt)|0,y=y+Math.imul(Et,Xt)|0,c=c+Math.imul(Et,Qt)|0,c=c+Math.imul(xt,Xt)|0,m=m+Math.imul(xt,Qt)|0,y=y+Math.imul(Rt,te)|0,c=c+Math.imul(Rt,ee)|0,c=c+Math.imul(Tt,te)|0,m=m+Math.imul(Tt,ee)|0;var vi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(vi>>>26)|0,vi&=67108863,y=Math.imul(Pt,Gt),c=Math.imul(Pt,Yt),c=c+Math.imul(Ct,Gt)|0,m=Math.imul(Ct,Yt),y=y+Math.imul(At,Zt)|0,c=c+Math.imul(At,Jt)|0,c=c+Math.imul(Mt,Zt)|0,m=m+Math.imul(Mt,Jt)|0,y=y+Math.imul(_t,Xt)|0,c=c+Math.imul(_t,Qt)|0,c=c+Math.imul(It,Xt)|0,m=m+Math.imul(It,Qt)|0,y=y+Math.imul(Et,te)|0,c=c+Math.imul(Et,ee)|0,c=c+Math.imul(xt,te)|0,m=m+Math.imul(xt,ee)|0;var ki=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(ki>>>26)|0,ki&=67108863,y=Math.imul(Pt,Zt),c=Math.imul(Pt,Jt),c=c+Math.imul(Ct,Zt)|0,m=Math.imul(Ct,Jt),y=y+Math.imul(At,Xt)|0,c=c+Math.imul(At,Qt)|0,c=c+Math.imul(Mt,Xt)|0,m=m+Math.imul(Mt,Qt)|0,y=y+Math.imul(_t,te)|0,c=c+Math.imul(_t,ee)|0,c=c+Math.imul(It,te)|0,m=m+Math.imul(It,ee)|0;var Si=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(Si>>>26)|0,Si&=67108863,y=Math.imul(Pt,Xt),c=Math.imul(Pt,Qt),c=c+Math.imul(Ct,Xt)|0,m=Math.imul(Ct,Qt),y=y+Math.imul(At,te)|0,c=c+Math.imul(At,ee)|0,c=c+Math.imul(Mt,te)|0,m=m+Math.imul(Mt,ee)|0;var Bi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(Bi>>>26)|0,Bi&=67108863,y=Math.imul(Pt,te),c=Math.imul(Pt,ee),c=c+Math.imul(Ct,te)|0,m=Math.imul(Ct,ee);var Ei=(w+y|0)+((c&8191)<<13)|0;return w=(m+(c>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,g[0]=ai,g[1]=ci,g[2]=ui,g[3]=fi,g[4]=li,g[5]=hi,g[6]=di,g[7]=pi,g[8]=yi,g[9]=gi,g[10]=mi,g[11]=bi,g[12]=wi,g[13]=xi,g[14]=vi,g[15]=ki,g[16]=Si,g[17]=Bi,g[18]=Ei,w!==0&&(g[19]=w,f.length++),f};Math.imul||(T=A);function F(v,a,u){u.negative=a.negative^v.negative,u.length=v.length+a.length;for(var f=0,d=0,p=0;p<u.length-1;p++){var g=d;d=0;for(var w=f&67108863,y=Math.min(p,a.length-1),c=Math.max(0,p-v.length+1);c<=y;c++){var m=p-c,M=v.words[m]|0,U=a.words[c]|0,O=M*U,D=O&67108863;g=g+(O/67108864|0)|0,D=D+w|0,w=D&67108863,g=g+(D>>>26)|0,d+=g>>>26,g&=67108863}u.words[p]=w,f=g,g=d}return f!==0?u.words[p]=f:u.length--,u._strip()}function N(v,a,u){return F(v,a,u)}o.prototype.mulTo=function(a,u){var f,d=this.length+a.length;return this.length===10&&a.length===10?f=T(this,a,u):d<63?f=A(this,a,u):d<1024?f=F(this,a,u):f=N(this,a,u),f};function W(v,a){this.x=v,this.y=a}W.prototype.makeRBT=function(a){for(var u=new Array(a),f=o.prototype._countBits(a)-1,d=0;d<a;d++)u[d]=this.revBin(d,f,a);return u},W.prototype.revBin=function(a,u,f){if(a===0||a===f-1)return a;for(var d=0,p=0;p<u;p++)d|=(a&1)<<u-p-1,a>>=1;return d},W.prototype.permute=function(a,u,f,d,p,g){for(var w=0;w<g;w++)d[w]=u[a[w]],p[w]=f[a[w]]},W.prototype.transform=function(a,u,f,d,p,g){this.permute(g,a,u,f,d,p);for(var w=1;w<p;w<<=1)for(var y=w<<1,c=Math.cos(2*Math.PI/y),m=Math.sin(2*Math.PI/y),M=0;M<p;M+=y)for(var U=c,O=m,D=0;D<w;D++){var Y=f[M+D],J=d[M+D],mt=f[M+D+w],Q=d[M+D+w],tt=U*mt-O*Q;Q=U*Q+O*mt,mt=tt,f[M+D]=Y+mt,d[M+D]=J+Q,f[M+D+w]=Y-mt,d[M+D+w]=J-Q,D!==y&&(tt=c*U-m*O,O=c*O+m*U,U=tt)}},W.prototype.guessLen13b=function(a,u){var f=Math.max(u,a)|1,d=f&1,p=0;for(f=f/2|0;f;f=f>>>1)p++;return 1<<p+1+d},W.prototype.conjugate=function(a,u,f){if(!(f<=1))for(var d=0;d<f/2;d++){var p=a[d];a[d]=a[f-d-1],a[f-d-1]=p,p=u[d],u[d]=-u[f-d-1],u[f-d-1]=-p}},W.prototype.normalize13b=function(a,u){for(var f=0,d=0;d<u/2;d++){var p=Math.round(a[2*d+1]/u)*8192+Math.round(a[2*d]/u)+f;a[d]=p&67108863,p<67108864?f=0:f=p/67108864|0}return a},W.prototype.convert13b=function(a,u,f,d){for(var p=0,g=0;g<u;g++)p=p+(a[g]|0),f[2*g]=p&8191,p=p>>>13,f[2*g+1]=p&8191,p=p>>>13;for(g=2*u;g<d;++g)f[g]=0;e(p===0),e((p&-8192)===0)},W.prototype.stub=function(a){for(var u=new Array(a),f=0;f<a;f++)u[f]=0;return u},W.prototype.mulp=function(a,u,f){var d=2*this.guessLen13b(a.length,u.length),p=this.makeRBT(d),g=this.stub(d),w=new Array(d),y=new Array(d),c=new Array(d),m=new Array(d),M=new Array(d),U=new Array(d),O=f.words;O.length=d,this.convert13b(a.words,a.length,w,d),this.convert13b(u.words,u.length,m,d),this.transform(w,g,y,c,d,p),this.transform(m,g,M,U,d,p);for(var D=0;D<d;D++){var Y=y[D]*M[D]-c[D]*U[D];c[D]=y[D]*U[D]+c[D]*M[D],y[D]=Y}return this.conjugate(y,c,d),this.transform(y,c,O,g,d,p),this.conjugate(O,g,d),this.normalize13b(O,d),f.negative=a.negative^u.negative,f.length=a.length+u.length,f._strip()},o.prototype.mul=function(a){var u=new o(null);return u.words=new Array(this.length+a.length),this.mulTo(a,u)},o.prototype.mulf=function(a){var u=new o(null);return u.words=new Array(this.length+a.length),N(this,a,u)},o.prototype.imul=function(a){return this.clone().mulTo(a,this)},o.prototype.imuln=function(a){var u=a<0;u&&(a=-a),e(typeof a=="number"),e(a<67108864);for(var f=0,d=0;d<this.length;d++){var p=(this.words[d]|0)*a,g=(p&67108863)+(f&67108863);f>>=26,f+=p/67108864|0,f+=g>>>26,this.words[d]=g&67108863}return f!==0&&(this.words[d]=f,this.length++),u?this.ineg():this},o.prototype.muln=function(a){return this.clone().imuln(a)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(a){var u=B(a);if(u.length===0)return new o(1);for(var f=this,d=0;d<u.length&&u[d]===0;d++,f=f.sqr());if(++d<u.length)for(var p=f.sqr();d<u.length;d++,p=p.sqr())u[d]!==0&&(f=f.mul(p));return f},o.prototype.iushln=function(a){e(typeof a=="number"&&a>=0);var u=a%26,f=(a-u)/26,d=67108863>>>26-u<<26-u,p;if(u!==0){var g=0;for(p=0;p<this.length;p++){var w=this.words[p]&d,y=(this.words[p]|0)-w<<u;this.words[p]=y|g,g=w>>>26-u}g&&(this.words[p]=g,this.length++)}if(f!==0){for(p=this.length-1;p>=0;p--)this.words[p+f]=this.words[p];for(p=0;p<f;p++)this.words[p]=0;this.length+=f}return this._strip()},o.prototype.ishln=function(a){return e(this.negative===0),this.iushln(a)},o.prototype.iushrn=function(a,u,f){e(typeof a=="number"&&a>=0);var d;u?d=(u-u%26)/26:d=0;var p=a%26,g=Math.min((a-p)/26,this.length),w=67108863^67108863>>>p<<p,y=f;if(d-=g,d=Math.max(0,d),y){for(var c=0;c<g;c++)y.words[c]=this.words[c];y.length=g}if(g!==0)if(this.length>g)for(this.length-=g,c=0;c<this.length;c++)this.words[c]=this.words[c+g];else this.words[0]=0,this.length=1;var m=0;for(c=this.length-1;c>=0&&(m!==0||c>=d);c--){var M=this.words[c]|0;this.words[c]=m<<26-p|M>>>p,m=M&w}return y&&m!==0&&(y.words[y.length++]=m),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(a,u,f){return e(this.negative===0),this.iushrn(a,u,f)},o.prototype.shln=function(a){return this.clone().ishln(a)},o.prototype.ushln=function(a){return this.clone().iushln(a)},o.prototype.shrn=function(a){return this.clone().ishrn(a)},o.prototype.ushrn=function(a){return this.clone().iushrn(a)},o.prototype.testn=function(a){e(typeof a=="number"&&a>=0);var u=a%26,f=(a-u)/26,d=1<<u;if(this.length<=f)return!1;var p=this.words[f];return!!(p&d)},o.prototype.imaskn=function(a){e(typeof a=="number"&&a>=0);var u=a%26,f=(a-u)/26;if(e(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(u!==0&&f++,this.length=Math.min(f,this.length),u!==0){var d=67108863^67108863>>>u<<u;this.words[this.length-1]&=d}return this._strip()},o.prototype.maskn=function(a){return this.clone().imaskn(a)},o.prototype.iaddn=function(a){return e(typeof a=="number"),e(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)},o.prototype._iaddn=function(a){this.words[0]+=a;for(var u=0;u<this.length&&this.words[u]>=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},o.prototype.isubn=function(a){if(e(typeof a=="number"),e(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 u=0;u<this.length&&this.words[u]<0;u++)this.words[u]+=67108864,this.words[u+1]-=1;return this._strip()},o.prototype.addn=function(a){return this.clone().iaddn(a)},o.prototype.subn=function(a){return this.clone().isubn(a)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(a,u,f){var d=a.length+f,p;this._expand(d);var g,w=0;for(p=0;p<a.length;p++){g=(this.words[p+f]|0)+w;var y=(a.words[p]|0)*u;g-=y&67108863,w=(g>>26)-(y/67108864|0),this.words[p+f]=g&67108863}for(;p<this.length-f;p++)g=(this.words[p+f]|0)+w,w=g>>26,this.words[p+f]=g&67108863;if(w===0)return this._strip();for(e(w===-1),w=0,p=0;p<this.length;p++)g=-(this.words[p]|0)+w,w=g>>26,this.words[p]=g&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(a,u){var f=this.length-a.length,d=this.clone(),p=a,g=p.words[p.length-1]|0,w=this._countBits(g);f=26-w,f!==0&&(p=p.ushln(f),d.iushln(f),g=p.words[p.length-1]|0);var y=d.length-p.length,c;if(u!=="mod"){c=new o(null),c.length=y+1,c.words=new Array(c.length);for(var m=0;m<c.length;m++)c.words[m]=0}var M=d.clone()._ishlnsubmul(p,1,y);M.negative===0&&(d=M,c&&(c.words[y]=1));for(var U=y-1;U>=0;U--){var O=(d.words[p.length+U]|0)*67108864+(d.words[p.length+U-1]|0);for(O=Math.min(O/g|0,67108863),d._ishlnsubmul(p,O,U);d.negative!==0;)O--,d.negative=0,d._ishlnsubmul(p,1,U),d.isZero()||(d.negative^=1);c&&(c.words[U]=O)}return c&&c._strip(),d._strip(),u!=="div"&&f!==0&&d.iushrn(f),{div:c||null,mod:d}},o.prototype.divmod=function(a,u,f){if(e(!a.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var d,p,g;return this.negative!==0&&a.negative===0?(g=this.neg().divmod(a,u),u!=="mod"&&(d=g.div.neg()),u!=="div"&&(p=g.mod.neg(),f&&p.negative!==0&&p.iadd(a)),{div:d,mod:p}):this.negative===0&&a.negative!==0?(g=this.divmod(a.neg(),u),u!=="mod"&&(d=g.div.neg()),{div:d,mod:g.mod}):(this.negative&a.negative)!==0?(g=this.neg().divmod(a.neg(),u),u!=="div"&&(p=g.mod.neg(),f&&p.negative!==0&&p.isub(a)),{div:g.div,mod:p}):a.length>this.length||this.cmp(a)<0?{div:new o(0),mod:this}:a.length===1?u==="div"?{div:this.divn(a.words[0]),mod:null}:u==="mod"?{div:null,mod:new o(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new o(this.modrn(a.words[0]))}:this._wordDiv(a,u)},o.prototype.div=function(a){return this.divmod(a,"div",!1).div},o.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},o.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},o.prototype.divRound=function(a){var u=this.divmod(a);if(u.mod.isZero())return u.div;var f=u.div.negative!==0?u.mod.isub(a):u.mod,d=a.ushrn(1),p=a.andln(1),g=f.cmp(d);return g<0||p===1&&g===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},o.prototype.modrn=function(a){var u=a<0;u&&(a=-a),e(a<=67108863);for(var f=(1<<26)%a,d=0,p=this.length-1;p>=0;p--)d=(f*d+(this.words[p]|0))%a;return u?-d:d},o.prototype.modn=function(a){return this.modrn(a)},o.prototype.idivn=function(a){var u=a<0;u&&(a=-a),e(a<=67108863);for(var f=0,d=this.length-1;d>=0;d--){var p=(this.words[d]|0)+f*67108864;this.words[d]=p/a|0,f=p%a}return this._strip(),u?this.ineg():this},o.prototype.divn=function(a){return this.clone().idivn(a)},o.prototype.egcd=function(a){e(a.negative===0),e(!a.isZero());var u=this,f=a.clone();u.negative!==0?u=u.umod(a):u=u.clone();for(var d=new o(1),p=new o(0),g=new o(0),w=new o(1),y=0;u.isEven()&&f.isEven();)u.iushrn(1),f.iushrn(1),++y;for(var c=f.clone(),m=u.clone();!u.isZero();){for(var M=0,U=1;(u.words[0]&U)===0&&M<26;++M,U<<=1);if(M>0)for(u.iushrn(M);M-- >0;)(d.isOdd()||p.isOdd())&&(d.iadd(c),p.isub(m)),d.iushrn(1),p.iushrn(1);for(var O=0,D=1;(f.words[0]&D)===0&&O<26;++O,D<<=1);if(O>0)for(f.iushrn(O);O-- >0;)(g.isOdd()||w.isOdd())&&(g.iadd(c),w.isub(m)),g.iushrn(1),w.iushrn(1);u.cmp(f)>=0?(u.isub(f),d.isub(g),p.isub(w)):(f.isub(u),g.isub(d),w.isub(p))}return{a:g,b:w,gcd:f.iushln(y)}},o.prototype._invmp=function(a){e(a.negative===0),e(!a.isZero());var u=this,f=a.clone();u.negative!==0?u=u.umod(a):u=u.clone();for(var d=new o(1),p=new o(0),g=f.clone();u.cmpn(1)>0&&f.cmpn(1)>0;){for(var w=0,y=1;(u.words[0]&y)===0&&w<26;++w,y<<=1);if(w>0)for(u.iushrn(w);w-- >0;)d.isOdd()&&d.iadd(g),d.iushrn(1);for(var c=0,m=1;(f.words[0]&m)===0&&c<26;++c,m<<=1);if(c>0)for(f.iushrn(c);c-- >0;)p.isOdd()&&p.iadd(g),p.iushrn(1);u.cmp(f)>=0?(u.isub(f),d.isub(p)):(f.isub(u),p.isub(d))}var M;return u.cmpn(1)===0?M=d:M=p,M.cmpn(0)<0&&M.iadd(a),M},o.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var u=this.clone(),f=a.clone();u.negative=0,f.negative=0;for(var d=0;u.isEven()&&f.isEven();d++)u.iushrn(1),f.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;f.isEven();)f.iushrn(1);var p=u.cmp(f);if(p<0){var g=u;u=f,f=g}else if(p===0||f.cmpn(1)===0)break;u.isub(f)}while(!0);return f.iushln(d)},o.prototype.invm=function(a){return this.egcd(a).a.umod(a)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(a){return this.words[0]&a},o.prototype.bincn=function(a){e(typeof a=="number");var u=a%26,f=(a-u)/26,d=1<<u;if(this.length<=f)return this._expand(f+1),this.words[f]|=d,this;for(var p=d,g=f;p!==0&&g<this.length;g++){var w=this.words[g]|0;w+=p,p=w>>>26,w&=67108863,this.words[g]=w}return p!==0&&(this.words[g]=p,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(a){var u=a<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this._strip();var f;if(this.length>1)f=1;else{u&&(a=-a),e(a<=67108863,"Number is too big");var d=this.words[0]|0;f=d===a?0:d<a?-1:1}return this.negative!==0?-f|0:f},o.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var u=this.ucmp(a);return this.negative!==0?-u|0:u},o.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var u=0,f=this.length-1;f>=0;f--){var d=this.words[f]|0,p=a.words[f]|0;if(d!==p){d<p?u=-1:d>p&&(u=1);break}}return u},o.prototype.gtn=function(a){return this.cmpn(a)===1},o.prototype.gt=function(a){return this.cmp(a)===1},o.prototype.gten=function(a){return this.cmpn(a)>=0},o.prototype.gte=function(a){return this.cmp(a)>=0},o.prototype.ltn=function(a){return this.cmpn(a)===-1},o.prototype.lt=function(a){return this.cmp(a)===-1},o.prototype.lten=function(a){return this.cmpn(a)<=0},o.prototype.lte=function(a){return this.cmp(a)<=0},o.prototype.eqn=function(a){return this.cmpn(a)===0},o.prototype.eq=function(a){return this.cmp(a)===0},o.red=function(a){return new G(a)},o.prototype.toRed=function(a){return e(!this.red,"Already a number in reduction context"),e(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},o.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(a){return this.red=a,this},o.prototype.forceRed=function(a){return e(!this.red,"Already a number in reduction context"),this._forceRed(a)},o.prototype.redAdd=function(a){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},o.prototype.redIAdd=function(a){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},o.prototype.redSub=function(a){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},o.prototype.redISub=function(a){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},o.prototype.redShl=function(a){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},o.prototype.redMul=function(a){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},o.prototype.redIMul=function(a){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},o.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(a){return e(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var q={k256:null,p224:null,p192:null,p25519:null};function z(v,a){this.name=v,this.p=new o(a,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var a=new o(null);return a.words=new Array(Math.ceil(this.n/13)),a},z.prototype.ireduce=function(a){var u=a,f;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),f=u.bitLength();while(f>this.n);var d=f<this.n?-1:u.ucmp(this.p);return d===0?(u.words[0]=0,u.length=1):d>0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},z.prototype.split=function(a,u){a.iushrn(this.n,0,u)},z.prototype.imulK=function(a){return a.imul(this.k)};function H(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(H,z),H.prototype.split=function(a,u){for(var f=4194303,d=Math.min(a.length,9),p=0;p<d;p++)u.words[p]=a.words[p];if(u.length=d,a.length<=9){a.words[0]=0,a.length=1;return}var g=a.words[9];for(u.words[u.length++]=g&f,p=10;p<a.length;p++){var w=a.words[p]|0;a.words[p-10]=(w&f)<<4|g>>>22,g=w}g>>>=22,a.words[p-10]=g,g===0&&a.length>10?a.length-=10:a.length-=9},H.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var u=0,f=0;f<a.length;f++){var d=a.words[f]|0;u+=d*977,a.words[f]=u&67108863,u=d*64+(u/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function j(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(j,z);function ot(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(ot,z);function nt(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(nt,z),nt.prototype.imulK=function(a){for(var u=0,f=0;f<a.length;f++){var d=(a.words[f]|0)*19+u,p=d&67108863;d>>>=26,a.words[f]=p,u=d}return u!==0&&(a.words[a.length++]=u),a},o._prime=function(a){if(q[a])return q[a];var u;if(a==="k256")u=new H;else if(a==="p224")u=new j;else if(a==="p192")u=new ot;else if(a==="p25519")u=new nt;else throw new Error("Unknown prime "+a);return q[a]=u,u};function G(v){if(typeof v=="string"){var a=o._prime(v);this.m=a.p,this.prime=a}else e(v.gtn(1),"modulus must be greater than 1"),this.m=v,this.prime=null}G.prototype._verify1=function(a){e(a.negative===0,"red works only with positives"),e(a.red,"red works only with red numbers")},G.prototype._verify2=function(a,u){e((a.negative|u.negative)===0,"red works only with positives"),e(a.red&&a.red===u.red,"red works only with red numbers")},G.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(b(a,a.umod(this.m)._forceRed(this)),a)},G.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},G.prototype.add=function(a,u){this._verify2(a,u);var f=a.add(u);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},G.prototype.iadd=function(a,u){this._verify2(a,u);var f=a.iadd(u);return f.cmp(this.m)>=0&&f.isub(this.m),f},G.prototype.sub=function(a,u){this._verify2(a,u);var f=a.sub(u);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},G.prototype.isub=function(a,u){this._verify2(a,u);var f=a.isub(u);return f.cmpn(0)<0&&f.iadd(this.m),f},G.prototype.shl=function(a,u){return this._verify1(a),this.imod(a.ushln(u))},G.prototype.imul=function(a,u){return this._verify2(a,u),this.imod(a.imul(u))},G.prototype.mul=function(a,u){return this._verify2(a,u),this.imod(a.mul(u))},G.prototype.isqr=function(a){return this.imul(a,a.clone())},G.prototype.sqr=function(a){return this.mul(a,a)},G.prototype.sqrt=function(a){if(a.isZero())return a.clone();var u=this.m.andln(3);if(e(u%2===1),u===3){var f=this.m.add(new o(1)).iushrn(2);return this.pow(a,f)}for(var d=this.m.subn(1),p=0;!d.isZero()&&d.andln(1)===0;)p++,d.iushrn(1);e(!d.isZero());var g=new o(1).toRed(this),w=g.redNeg(),y=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);this.pow(c,y).cmp(w)!==0;)c.redIAdd(w);for(var m=this.pow(c,d),M=this.pow(a,d.addn(1).iushrn(1)),U=this.pow(a,d),O=p;U.cmp(g)!==0;){for(var D=U,Y=0;D.cmp(g)!==0;Y++)D=D.redSqr();e(Y<O);var J=this.pow(m,new o(1).iushln(O-Y-1));M=M.redMul(J),m=J.redSqr(),U=U.redMul(m),O=Y}return M},G.prototype.invm=function(a){var u=a._invmp(this.m);return u.negative!==0?(u.negative=0,this.imod(u).redNeg()):this.imod(u)},G.prototype.pow=function(a,u){if(u.isZero())return new o(1).toRed(this);if(u.cmpn(1)===0)return a.clone();var f=4,d=new Array(1<<f);d[0]=new o(1).toRed(this),d[1]=a;for(var p=2;p<d.length;p++)d[p]=this.mul(d[p-1],a);var g=d[0],w=0,y=0,c=u.bitLength()%26;for(c===0&&(c=26),p=u.length-1;p>=0;p--){for(var m=u.words[p],M=c-1;M>=0;M--){var U=m>>M&1;if(g!==d[0]&&(g=this.sqr(g)),U===0&&w===0){y=0;continue}w<<=1,w|=U,y++,!(y!==f&&(p!==0||M!==0))&&(g=this.mul(g,d[w]),y=0,w=0)}c=26}return g},G.prototype.convertTo=function(a){var u=a.umod(this.m);return u===a?u.clone():u},G.prototype.convertFrom=function(a){var u=a.clone();return u.red=null,u},o.mont=function(a){return new lt(a)};function lt(v){G.call(this,v),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(lt,G),lt.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},lt.prototype.convertFrom=function(a){var u=this.imod(a.mul(this.rinv));return u.red=null,u},lt.prototype.imul=function(a,u){if(a.isZero()||u.isZero())return a.words[0]=0,a.length=1,a;var f=a.imul(u),d=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),p=f.isub(d).iushrn(this.shift),g=p;return p.cmp(this.m)>=0?g=p.isub(this.m):p.cmpn(0)<0&&(g=p.iadd(this.m)),g._forceRed(this)},lt.prototype.mul=function(a,u){if(a.isZero()||u.isZero())return new o(0)._forceRed(this);var f=a.mul(u),d=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),p=f.isub(d).iushrn(this.shift),g=p;return p.cmp(this.m)>=0?g=p.isub(this.m):p.cmpn(0)<0&&(g=p.iadd(this.m)),g._forceRed(this)},lt.prototype.invm=function(a){var u=this.imod(a._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(typeof os>"u"||os,dc)});var gc=at((ss,yc)=>{"use strict";var so=Vn(),ze=so.Buffer;function pc(r,t){for(var e in r)t[e]=r[e]}ze.from&&ze.alloc&&ze.allocUnsafe&&ze.allocUnsafeSlow?yc.exports=so:(pc(so,ss),ss.Buffer=Ir);function Ir(r,t,e){return ze(r,t,e)}Ir.prototype=Object.create(ze.prototype);pc(ze,Ir);Ir.from=function(r,t,e){if(typeof r=="number")throw new TypeError("Argument must not be a number");return ze(r,t,e)};Ir.alloc=function(r,t,e){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=ze(r);return t!==void 0?typeof e=="string"?n.fill(t,e):n.fill(t):n.fill(0),n};Ir.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return ze(r)};Ir.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return so.SlowBuffer(r)}});var bc=at((Ap,mc)=>{"use strict";var ao=gc().Buffer;function Kl(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var n=0;n<r.length;n++){var o=r.charAt(n),i=o.charCodeAt(0);if(t[i]!==255)throw new TypeError(o+" is ambiguous");t[i]=n}var s=r.length,h=r.charAt(0),l=Math.log(s)/Math.log(256),b=Math.log(256)/Math.log(s);function x(I){if((Array.isArray(I)||I instanceof Uint8Array)&&(I=ao.from(I)),!ao.isBuffer(I))throw new TypeError("Expected Buffer");if(I.length===0)return"";for(var P=0,B=0,A=0,T=I.length;A!==T&&I[A]===0;)A++,P++;for(var F=(T-A)*b+1>>>0,N=new Uint8Array(F);A!==T;){for(var W=I[A],q=0,z=F-1;(W!==0||q<B)&&z!==-1;z--,q++)W+=256*N[z]>>>0,N[z]=W%s>>>0,W=W/s>>>0;if(W!==0)throw new Error("Non-zero carry");B=q,A++}for(var H=F-B;H!==F&&N[H]===0;)H++;for(var j=h.repeat(P);H<F;++H)j+=r.charAt(N[H]);return j}function k(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return ao.alloc(0);for(var P=0,B=0,A=0;I[P]===h;)B++,P++;for(var T=(I.length-P)*l+1>>>0,F=new Uint8Array(T);P<I.length;){var N=I.charCodeAt(P);if(N>255)return;var W=t[N];if(W===255)return;for(var q=0,z=T-1;(W!==0||q<A)&&z!==-1;z--,q++)W+=s*F[z]>>>0,F[z]=W%256>>>0,W=W/256>>>0;if(W!==0)throw new Error("Non-zero carry");A=q,P++}for(var H=T-A;H!==T&&F[H]===0;)H++;var j=ao.allocUnsafe(B+(T-H));j.fill(0,0,B);for(var ot=B;H!==T;)j[ot++]=F[H++];return j}function R(I){var P=k(I);if(P)return P;throw new Error("Non-base"+s+" character")}return{encode:x,decodeUnsafe:k,decode:R}}mc.exports=Kl});var as=at((Lp,wc)=>{"use strict";var Wl=bc(),Hl="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";wc.exports=Wl(Hl)});var xc=at(ls=>{"use strict";function je(r,t,e){return t<=r&&r<=e}function ho(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function Gl(r){for(var t=String(r),e=t.length,n=0,o=[];n<e;){var i=t.charCodeAt(n);if(i<55296||i>57343)o.push(i);else if(56320<=i&&i<=57343)o.push(65533);else if(55296<=i&&i<=56319)if(n===e-1)o.push(65533);else{var s=r.charCodeAt(n+1);if(56320<=s&&s<=57343){var h=i&1023,l=s&1023;o.push(65536+(h<<10)+l),n+=1}else o.push(65533)}n+=1}return o}function Yl(r){for(var t="",e=0;e<r.length;++e){var n=r[e];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return t}var co=-1;function fs(r){this.tokens=[].slice.call(r)}fs.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():co},prepend:function(r){if(Array.isArray(r))for(var t=r;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var t=r;t.length;)this.tokens.push(t.shift());else this.tokens.push(r)}};var Dr=-1;function us(r,t){if(r)throw TypeError("Decoder error");return t||65533}var uo="utf-8";function fo(r,t){if(!(this instanceof fo))return new fo(r,t);if(r=r!==void 0?String(r).toLowerCase():uo,r!==uo)throw new Error("Encoding not supported. Only utf-8 is supported");t=ho(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}fo.prototype={decode:function(t,e){var n;typeof t=="object"&&t instanceof ArrayBuffer?n=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):n=new Uint8Array(0),e=ho(e),this._streaming||(this._decoder=new Zl({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var o=new fs(n),i=[],s;!o.endOfStream()&&(s=this._decoder.handler(o,o.read()),s!==Dr);)s!==null&&(Array.isArray(s)?i.push.apply(i,s):i.push(s));if(!this._streaming){do{if(s=this._decoder.handler(o,o.read()),s===Dr)break;s!==null&&(Array.isArray(s)?i.push.apply(i,s):i.push(s))}while(!o.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),Yl(i)}};function lo(r,t){if(!(this instanceof lo))return new lo(r,t);if(r=r!==void 0?String(r).toLowerCase():uo,r!==uo)throw new Error("Encoding not supported. Only utf-8 is supported");t=ho(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}lo.prototype={encode:function(t,e){t=t?String(t):"",e=ho(e),this._streaming||(this._encoder=new Jl(this._options)),this._streaming=!!e.stream;for(var n=[],o=new fs(Gl(t)),i;!o.endOfStream()&&(i=this._encoder.handler(o,o.read()),i!==Dr);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(o,o.read()),i!==Dr;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}};function Zl(r){var t=r.fatal,e=0,n=0,o=0,i=128,s=191;this.handler=function(h,l){if(l===co&&o!==0)return o=0,us(t);if(l===co)return Dr;if(o===0){if(je(l,0,127))return l;if(je(l,194,223))o=1,e=l-192;else if(je(l,224,239))l===224&&(i=160),l===237&&(s=159),o=2,e=l-224;else if(je(l,240,244))l===240&&(i=144),l===244&&(s=143),o=3,e=l-240;else return us(t);return e=e<<6*o,null}if(!je(l,i,s))return e=o=n=0,i=128,s=191,h.prepend(l),us(t);if(i=128,s=191,n+=1,e+=l-128<<6*(o-n),n!==o)return null;var b=e;return e=o=n=0,b}}function Jl(r){var t=r.fatal;this.handler=function(e,n){if(n===co)return Dr;if(je(n,0,127))return n;var o,i;je(n,128,2047)?(o=1,i=192):je(n,2048,65535)?(o=2,i=224):je(n,65536,1114111)&&(o=3,i=240);for(var s=[(n>>6*o)+i];o>0;){var h=n>>6*(o-1);s.push(128|h&63),o-=1}return s}}ls.TextEncoder=lo;ls.TextDecoder=fo});var Ec=at(yt=>{"use strict";var Xl=yt&&yt.__createBinding||(Object.create?function(r,t,e,n){n===void 0&&(n=e),Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[e]}})}:function(r,t,e,n){n===void 0&&(n=e),r[n]=t[e]}),Ql=yt&&yt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),qe=yt&&yt.__decorate||function(r,t,e,n){var o=arguments.length,i=o<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,t,e,n);else for(var h=r.length-1;h>=0;h--)(s=r[h])&&(i=(o<3?s(i):o>3?s(t,e,i):s(t,e))||i);return o>3&&i&&Object.defineProperty(t,e,i),i},th=yt&&yt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)e!=="default"&&Object.hasOwnProperty.call(r,e)&&Xl(t,r,e);return Ql(t,r),t},vc=yt&&yt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(yt,"__esModule",{value:!0});yt.deserializeUnchecked=yt.deserialize=yt.serialize=yt.BinaryReader=yt.BinaryWriter=yt.BorshError=yt.baseDecode=yt.baseEncode=void 0;var lr=vc(is()),kc=vc(as()),eh=th(xc()),rh=typeof TextDecoder!="function"?eh.TextDecoder:TextDecoder,nh=new rh("utf-8",{fatal:!0});function oh(r){return typeof r=="string"&&(r=Buffer.from(r,"utf8")),kc.default.encode(Buffer.from(r))}yt.baseEncode=oh;function ih(r){return Buffer.from(kc.default.decode(r))}yt.baseDecode=ih;var hs=1024,ae=class extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}};yt.BorshError=ae;var po=class{constructor(){this.buf=Buffer.alloc(hs),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(hs)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new lr.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new lr.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new lr.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new lr.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(hs)]),this.length+=t.length}writeString(t){this.maybeResize();let e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(let n of t)this.maybeResize(),e(n)}toArray(){return this.buf.subarray(0,this.length)}};yt.BinaryWriter=po;function Fe(r,t,e){let n=e.value;e.value=function(...o){try{return n.apply(this,o)}catch(i){if(i instanceof RangeError){let s=i.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(s)>=0)throw new ae("Reached the end of buffer when deserializing")}throw i}}}var ge=class{constructor(t){this.buf=t,this.offset=0}readU8(){let t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){let t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){let t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){let t=this.readBuffer(8);return new lr.default(t,"le")}readU128(){let t=this.readBuffer(16);return new lr.default(t,"le")}readU256(){let t=this.readBuffer(32);return new lr.default(t,"le")}readU512(){let t=this.readBuffer(64);return new lr.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new ae(`Expected buffer length ${t} isn't within bounds`);let e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){let t=this.readU32(),e=this.readBuffer(t);try{return nh.decode(e)}catch(n){throw new ae(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){let e=this.readU32(),n=Array();for(let o=0;o<e;++o)n.push(t());return n}};qe([Fe],ge.prototype,"readU8",null);qe([Fe],ge.prototype,"readU16",null);qe([Fe],ge.prototype,"readU32",null);qe([Fe],ge.prototype,"readU64",null);qe([Fe],ge.prototype,"readU128",null);qe([Fe],ge.prototype,"readU256",null);qe([Fe],ge.prototype,"readU512",null);qe([Fe],ge.prototype,"readString",null);qe([Fe],ge.prototype,"readFixedArray",null);qe([Fe],ge.prototype,"readArray",null);yt.BinaryReader=ge;function Sc(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Ar(r,t,e,n,o){try{if(typeof n=="string")o[`write${Sc(n)}`](e);else if(n instanceof Array)if(typeof n[0]=="number"){if(e.length!==n[0])throw new ae(`Expecting byte array of length ${n[0]}, but got ${e.length} bytes`);o.writeFixedArray(e)}else if(n.length===2&&typeof n[1]=="number"){if(e.length!==n[1])throw new ae(`Expecting byte array of length ${n[1]}, but got ${e.length} bytes`);for(let i=0;i<n[1];i++)Ar(r,null,e[i],n[0],o)}else o.writeArray(e,i=>{Ar(r,t,i,n[0],o)});else if(n.kind!==void 0)switch(n.kind){case"option":{e==null?o.writeU8(0):(o.writeU8(1),Ar(r,t,e,n.type,o));break}case"map":{o.writeU32(e.size),e.forEach((i,s)=>{Ar(r,t,s,n.key,o),Ar(r,t,i,n.value,o)});break}default:throw new ae(`FieldType ${n} unrecognized`)}else Bc(r,e,o)}catch(i){throw i instanceof ae&&i.addToFieldPath(t),i}}function Bc(r,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}let n=r.get(t.constructor);if(!n)throw new ae(`Class ${t.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([o,i])=>{Ar(r,o,t[o],i,e)});else if(n.kind==="enum"){let o=t[n.field];for(let i=0;i<n.values.length;++i){let[s,h]=n.values[i];if(s===o){e.writeU8(i),Ar(r,s,t[s],h,e);break}}}else throw new ae(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function sh(r,t,e=po){let n=new e;return Bc(r,t,n),n.toArray()}yt.serialize=sh;function Lr(r,t,e,n){try{if(typeof e=="string")return n[`read${Sc(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return n.readFixedArray(e[0]);if(typeof e[1]=="number"){let o=[];for(let i=0;i<e[1];i++)o.push(Lr(r,null,e[0],n));return o}else return n.readArray(()=>Lr(r,t,e[0],n))}if(e.kind==="option")return n.readU8()?Lr(r,t,e.type,n):void 0;if(e.kind==="map"){let o=new Map,i=n.readU32();for(let s=0;s<i;s++){let h=Lr(r,t,e.key,n),l=Lr(r,t,e.value,n);o.set(h,l)}return o}return ds(r,e,n)}catch(o){throw o instanceof ae&&o.addToFieldPath(t),o}}function ds(r,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);let n=r.get(t);if(!n)throw new ae(`Class ${t.name} is missing in schema`);if(n.kind==="struct"){let o={};for(let[i,s]of r.get(t).fields)o[i]=Lr(r,i,s,e);return new t(o)}if(n.kind==="enum"){let o=e.readU8();if(o>=n.values.length)throw new ae(`Enum index: ${o} is out of range`);let[i,s]=n.values[o],h=Lr(r,i,s,e);return new t({[i]:h})}throw new ae(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function ah(r,t,e,n=ge){let o=new n(e),i=ds(r,t,o);if(o.offset<e.length)throw new ae(`Unexpected ${e.length-o.offset} bytes after deserialized data`);return i}yt.deserialize=ah;function ch(r,t,e,n=ge){let o=new n(e);return ds(r,t,o)}yt.deserializeUnchecked=ch});var ms=at(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.s16=_.s8=_.nu64be=_.u48be=_.u40be=_.u32be=_.u24be=_.u16be=_.nu64=_.u48=_.u40=_.u32=_.u24=_.u16=_.u8=_.offset=_.greedy=_.Constant=_.UTF8=_.CString=_.Blob=_.Boolean=_.BitField=_.BitStructure=_.VariantLayout=_.Union=_.UnionLayoutDiscriminator=_.UnionDiscriminator=_.Structure=_.Sequence=_.DoubleBE=_.Double=_.FloatBE=_.Float=_.NearInt64BE=_.NearInt64=_.NearUInt64BE=_.NearUInt64=_.IntBE=_.Int=_.UIntBE=_.UInt=_.OffsetLayout=_.GreedyCount=_.ExternalLayout=_.bindConstructorLayout=_.nameWithProperty=_.Layout=_.uint8ArrayToBuffer=_.checkUint8Array=void 0;_.constant=_.utf8=_.cstr=_.blob=_.unionLayoutDiscriminator=_.union=_.seq=_.bits=_.struct=_.f64be=_.f64=_.f32be=_.f32=_.ns64be=_.s48be=_.s40be=_.s32be=_.s24be=_.s16be=_.ns64=_.s48=_.s40=_.s32=_.s24=void 0;var ys=Vn();function Hr(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}_.checkUint8Array=Hr;function ct(r){return Hr(r),ys.Buffer.from(r.buffer,r.byteOffset,r.length)}_.uint8ArrayToBuffer=ct;var ft=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){let e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};_.Layout=ft;function gs(r,t){return t.property?r+"["+t.property+"]":r}_.nameWithProperty=gs;function uh(r,t){if(typeof r!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(r,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof ft))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=t,t.boundConstructor_=r,t.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(r,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}_.bindConstructorLayout=uh;var ue=class extends ft{isCount(){throw new Error("ExternalLayout is abstract")}};_.ExternalLayout=ue;var yo=class extends ue{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){Hr(t);let n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}};_.GreedyCount=yo;var fn=class extends ue{constructor(t,e=0,n){if(!(t instanceof ft))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof xe||this.layout instanceof Be}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,n=0){return this.layout.encode(t,e,n+this.offset)}};_.OffsetLayout=fn;var xe=class extends ft{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return ct(t).readUIntLE(e,this.span)}encode(t,e,n=0){return ct(e).writeUIntLE(t,n,this.span),this.span}};_.UInt=xe;var Be=class extends ft{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return ct(t).readUIntBE(e,this.span)}encode(t,e,n=0){return ct(e).writeUIntBE(t,n,this.span),this.span}};_.UIntBE=Be;var Ge=class extends ft{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return ct(t).readIntLE(e,this.span)}encode(t,e,n=0){return ct(e).writeIntLE(t,n,this.span),this.span}};_.Int=Ge;var hr=class extends ft{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return ct(t).readIntBE(e,this.span)}encode(t,e,n=0){return ct(e).writeIntBE(t,n,this.span),this.span}};_.IntBE=hr;var ps=Math.pow(2,32);function Mo(r){let t=Math.floor(r/ps),e=r-t*ps;return{hi32:t,lo32:e}}function Po(r,t){return r*ps+t}var go=class extends ft{constructor(t){super(8,t)}decode(t,e=0){let n=ct(t),o=n.readUInt32LE(e),i=n.readUInt32LE(e+4);return Po(i,o)}encode(t,e,n=0){let o=Mo(t),i=ct(e);return i.writeUInt32LE(o.lo32,n),i.writeUInt32LE(o.hi32,n+4),8}};_.NearUInt64=go;var mo=class extends ft{constructor(t){super(8,t)}decode(t,e=0){let n=ct(t),o=n.readUInt32BE(e),i=n.readUInt32BE(e+4);return Po(o,i)}encode(t,e,n=0){let o=Mo(t),i=ct(e);return i.writeUInt32BE(o.hi32,n),i.writeUInt32BE(o.lo32,n+4),8}};_.NearUInt64BE=mo;var bo=class extends ft{constructor(t){super(8,t)}decode(t,e=0){let n=ct(t),o=n.readUInt32LE(e),i=n.readInt32LE(e+4);return Po(i,o)}encode(t,e,n=0){let o=Mo(t),i=ct(e);return i.writeUInt32LE(o.lo32,n),i.writeInt32LE(o.hi32,n+4),8}};_.NearInt64=bo;var wo=class extends ft{constructor(t){super(8,t)}decode(t,e=0){let n=ct(t),o=n.readInt32BE(e),i=n.readUInt32BE(e+4);return Po(o,i)}encode(t,e,n=0){let o=Mo(t),i=ct(e);return i.writeInt32BE(o.hi32,n),i.writeUInt32BE(o.lo32,n+4),8}};_.NearInt64BE=wo;var xo=class extends ft{constructor(t){super(4,t)}decode(t,e=0){return ct(t).readFloatLE(e)}encode(t,e,n=0){return ct(e).writeFloatLE(t,n),4}};_.Float=xo;var vo=class extends ft{constructor(t){super(4,t)}decode(t,e=0){return ct(t).readFloatBE(e)}encode(t,e,n=0){return ct(e).writeFloatBE(t,n),4}};_.FloatBE=vo;var ko=class extends ft{constructor(t){super(8,t)}decode(t,e=0){return ct(t).readDoubleLE(e)}encode(t,e,n=0){return ct(e).writeDoubleLE(t,n),8}};_.Double=ko;var So=class extends ft{constructor(t){super(8,t)}decode(t,e=0){return ct(t).readDoubleBE(e)}encode(t,e,n=0){return ct(e).writeDoubleBE(t,n),8}};_.DoubleBE=So;var Bo=class extends ft{constructor(t,e,n){if(!(t instanceof ft))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof ue&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let o=-1;!(e instanceof ue)&&0<t.span&&(o=e*t.span),super(o,n),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0,o=this.count;if(o instanceof ue&&(o=o.decode(t,e)),0<this.elementLayout.span)n=o*this.elementLayout.span;else{let i=0;for(;i<o;)n+=this.elementLayout.getSpan(t,e+n),++i}return n}decode(t,e=0){let n=[],o=0,i=this.count;for(i instanceof ue&&(i=i.decode(t,e));o<i;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),o+=1;return n}encode(t,e,n=0){let o=this.elementLayout,i=t.reduce((s,h)=>s+o.encode(h,e,n+s),0);return this.count instanceof ue&&this.count.encode(t.length,e,n),i}};_.Sequence=Bo;var Eo=class extends ft{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((i,s)=>i&&s instanceof ft,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(let i of t)if(0>i.span&&i.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let o=-1;try{o=t.reduce((i,s)=>i+s.getSpan(),0)}catch{}super(o,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((o,i)=>{let s=i.getSpan(t,e);return e+=s,o+s},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e=0){Hr(t);let n=this.makeDestinationObject();for(let o of this.fields)if(o.property!==void 0&&(n[o.property]=o.decode(t,e)),e+=o.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n=0){let o=n,i=0,s=0;for(let h of this.fields){let l=h.span;if(s=0<l?l:0,h.property!==void 0){let b=t[h.property];b!==void 0&&(s=h.encode(b,e,n),0>l&&(l=h.getSpan(e,n)))}i=n,n+=l}return i+s-o}fromArray(t){let e=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(let e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(let n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}};_.Structure=Eo;var ln=class{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}};_.UnionDiscriminator=ln;var Wr=class extends ln{constructor(t,e){if(!(t instanceof ue&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}};_.UnionLayoutDiscriminator=Wr;var hn=class extends ft{constructor(t,e,n){let o;if(t instanceof xe||t instanceof Be)o=new Wr(new fn(t));else if(t instanceof ue&&t.isCount())o=new Wr(t);else if(t instanceof ln)o=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof ft))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&(t instanceof xe||t instanceof Be)&&(i+=o.layout.span)),super(i,n),this.discriminator=o,this.usesPrefixDiscriminator=t instanceof xe||t instanceof Be,this.defaultLayout=e,this.registry={};let s=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(h){return s(h)},this.configGetSourceVariant=function(h){s=h.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;let n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;let e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(let e in this.registry){let n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n,o=this.discriminator,i=o.decode(t,e),s=this.registry[i];if(s===void 0){let h=this.defaultLayout,l=0;this.usesPrefixDiscriminator&&(l=o.layout.span),n=this.makeDestinationObject(),n[o.property]=i,n[h.property]=h.decode(t,e+l)}else n=s.decode(t,e);return n}encode(t,e,n=0){let o=this.getSourceVariant(t);if(o===void 0){let i=this.discriminator,s=this.defaultLayout,h=0;return this.usesPrefixDiscriminator&&(h=i.layout.span),i.encode(t[i.property],e,n),h+s.encode(t[s.property],e,n+h)}return o.encode(t,e,n)}addVariant(t,e,n){let o=new _o(this,t,e,n);return this.registry[t]=o,o}getVariant(t,e=0){let n;return t instanceof Uint8Array?n=this.discriminator.decode(t,e):n=t,this.registry[n]}};_.Union=hn;var _o=class extends ft{constructor(t,e,n,o){if(!(t instanceof hn))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&o===void 0&&(o=n,n=null),n){if(!(n instanceof ft))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof o!="string")throw new TypeError("variant must have a String property")}let i=t.span;0>t.span&&(i=n?n.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,o),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let o=0;return this.layout&&(o=this.layout.getSpan(t,e+n)),n+o}decode(t,e=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let o=0;return this.union.usesPrefixDiscriminator&&(o=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+o):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n=0){let o=0;if(this.union.usesPrefixDiscriminator&&(o=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let i=o;if(this.layout&&(this.layout.encode(t[this.property],e,n+o),i+=this.layout.getSpan(e,n+o),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};_.VariantLayout=_o;function Kr(r){return 0>r&&(r+=4294967296),r}var dn=class extends ft{constructor(t,e,n){if(!(t instanceof xe||t instanceof Be))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&n===void 0&&(n=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let o=0;this._packedSetValue=function(i){return o=Kr(i),this},this._packedGetValue=function(){return o}}decode(t,e=0){let n=this.makeDestinationObject(),o=this.word.decode(t,e);this._packedSetValue(o);for(let i of this.fields)i.property!==void 0&&(n[i.property]=i.decode(t));return n}encode(t,e,n=0){let o=this.word.decode(e,n);this._packedSetValue(o);for(let i of this.fields)if(i.property!==void 0){let s=t[i.property];s!==void 0&&i.encode(s)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){let n=new pn(this,t,e);return this.fields.push(n),n}addBoolean(t){let e=new Io(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(let e of this.fields)if(e.property===t)return e}};_.BitStructure=dn;var pn=class{constructor(t,e,n){if(!(t instanceof dn))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");let o=8*t.span,i=t.fields.reduce((s,h)=>s+h.bits,0);if(e+i>o)throw new Error("bits too long for span remainder ("+(o-i)+" of "+o+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=o-i-e),this.wordMask=Kr(this.valueMask<<this.start),this.property=n}decode(t,e){let n=this.container._packedGetValue();return Kr(n&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==Kr(t&this.valueMask))throw new TypeError(gs("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let e=this.container._packedGetValue(),n=Kr(t<<this.start);this.container._packedSetValue(Kr(e&~this.wordMask)|n)}};_.BitField=pn;var Io=class extends pn{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};_.Boolean=Io;var Ao=class extends ft{constructor(t,e){if(!(t instanceof ue&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof ue||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e=0){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),ct(t).slice(e,e+n)}encode(t,e,n){let o=this.length;if(this.length instanceof ue&&(o=t.length),!(t instanceof Uint8Array&&o===t.length))throw new TypeError(gs("Blob.encode",this)+" requires (length "+o+") Uint8Array as src");if(n+o>e.length)throw new RangeError("encoding overruns Uint8Array");let i=ct(t);return ct(e).write(i.toString("hex"),n,o,"hex"),this.length instanceof ue&&this.length.encode(o,e,n),o}};_.Blob=Ao;var Lo=class extends ft{constructor(t){super(-1,t)}getSpan(t,e=0){Hr(t);let n=e;for(;n<t.length&&t[n]!==0;)n+=1;return 1+n-e}decode(t,e=0){let n=this.getSpan(t,e);return ct(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));let o=ys.Buffer.from(t,"utf8"),i=o.length;if(n+i>e.length)throw new RangeError("encoding overruns Buffer");let s=ct(e);return o.copy(s,n),s[n+i]=0,i+1}};_.CString=Lo;var Ro=class extends ft{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Hr(t),t.length-e}decode(t,e=0){let n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return ct(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));let o=ys.Buffer.from(t,"utf8"),i=o.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(n+i>e.length)throw new RangeError("encoding overruns Buffer");return o.copy(ct(e),n),i}};_.UTF8=Ro;var To=class extends ft{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}};_.Constant=To;_.greedy=(r,t)=>new yo(r,t);_.offset=(r,t,e)=>new fn(r,t,e);_.u8=r=>new xe(1,r);_.u16=r=>new xe(2,r);_.u24=r=>new xe(3,r);_.u32=r=>new xe(4,r);_.u40=r=>new xe(5,r);_.u48=r=>new xe(6,r);_.nu64=r=>new go(r);_.u16be=r=>new Be(2,r);_.u24be=r=>new Be(3,r);_.u32be=r=>new Be(4,r);_.u40be=r=>new Be(5,r);_.u48be=r=>new Be(6,r);_.nu64be=r=>new mo(r);_.s8=r=>new Ge(1,r);_.s16=r=>new Ge(2,r);_.s24=r=>new Ge(3,r);_.s32=r=>new Ge(4,r);_.s40=r=>new Ge(5,r);_.s48=r=>new Ge(6,r);_.ns64=r=>new bo(r);_.s16be=r=>new hr(2,r);_.s24be=r=>new hr(3,r);_.s32be=r=>new hr(4,r);_.s40be=r=>new hr(5,r);_.s48be=r=>new hr(6,r);_.ns64be=r=>new wo(r);_.f32=r=>new xo(r);_.f32be=r=>new vo(r);_.f64=r=>new ko(r);_.f64be=r=>new So(r);_.struct=(r,t,e)=>new Eo(r,t,e);_.bits=(r,t,e)=>new dn(r,t,e);_.seq=(r,t,e)=>new Bo(r,t,e);_.union=(r,t,e)=>new hn(r,t,e);_.unionLayoutDiscriminator=(r,t)=>new Wr(r,t);_.blob=(r,t)=>new Ao(r,t);_.cstr=r=>new Lo(r);_.utf8=(r,t)=>new Ro(r,t);_.constant=(r,t)=>new To(r,t)});var _c=at(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});var Co;function fh(r){{let t=Buffer.from(r);t.reverse();let e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}return Co.toBigInt(r,!1)}Vr.toBigIntLE=fh;function lh(r){{let t=r.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}return Co.toBigInt(r,!0)}Vr.toBigIntBE=lh;function hh(r,t){{let e=r.toString(16),n=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return n.reverse(),n}return Co.fromBigInt(r,Buffer.allocUnsafe(t),!1)}Vr.toBufferLE=hh;function dh(r,t){{let e=r.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}return Co.fromBigInt(r,Buffer.allocUnsafe(t),!0)}Vr.toBufferBE=dh});function gn(){if(!No&&(No=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!No))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return No(wh)}var No,wh,vs=ye(()=>{"use strict";wh=new Uint8Array(16)});var Tc,Mc=ye(()=>{"use strict";Tc=/^(?:[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 xh(r){return typeof r=="string"&&Tc.test(r)}var pr,mn=ye(()=>{"use strict";Mc();pr=xh});function vh(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(ce[r[t+0]]+ce[r[t+1]]+ce[r[t+2]]+ce[r[t+3]]+"-"+ce[r[t+4]]+ce[r[t+5]]+"-"+ce[r[t+6]]+ce[r[t+7]]+"-"+ce[r[t+8]]+ce[r[t+9]]+"-"+ce[r[t+10]]+ce[r[t+11]]+ce[r[t+12]]+ce[r[t+13]]+ce[r[t+14]]+ce[r[t+15]]).toLowerCase();if(!pr(e))throw TypeError("Stringified UUID is invalid");return e}var ce,zo,yr,bn=ye(()=>{"use strict";mn();ce=[];for(zo=0;zo<256;++zo)ce.push((zo+256).toString(16).substr(1));yr=vh});function kh(r,t,e){var n=t&&e||0,o=t||new Array(16);r=r||{};var i=r.node||Pc,s=r.clockseq!==void 0?r.clockseq:ks;if(i==null||s==null){var h=r.random||(r.rng||gn)();i==null&&(i=Pc=[h[0]|1,h[1],h[2],h[3],h[4],h[5]]),s==null&&(s=ks=(h[6]<<8|h[7])&16383)}var l=r.msecs!==void 0?r.msecs:Date.now(),b=r.nsecs!==void 0?r.nsecs:Bs+1,x=l-Ss+(b-Bs)/1e4;if(x<0&&r.clockseq===void 0&&(s=s+1&16383),(x<0||l>Ss)&&r.nsecs===void 0&&(b=0),b>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ss=l,Bs=b,ks=s,l+=122192928e5;var k=((l&268435455)*1e4+b)%4294967296;o[n++]=k>>>24&255,o[n++]=k>>>16&255,o[n++]=k>>>8&255,o[n++]=k&255;var R=l/4294967296*1e4&268435455;o[n++]=R>>>8&255,o[n++]=R&255,o[n++]=R>>>24&15|16,o[n++]=R>>>16&255,o[n++]=s>>>8|128,o[n++]=s&255;for(var I=0;I<6;++I)o[n+I]=i[I];return t||yr(o)}var Pc,ks,Ss,Bs,Cc,Oc=ye(()=>{"use strict";vs();bn();Ss=0,Bs=0;Cc=kh});function Sh(r){if(!pr(r))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(r.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(r.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(r.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(r.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(r.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}var qo,Es=ye(()=>{"use strict";mn();qo=Sh});function Bh(r){r=unescape(encodeURIComponent(r));for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e));return t}function Fo(r,t,e){function n(o,i,s,h){if(typeof o=="string"&&(o=Bh(o)),typeof i=="string"&&(i=qo(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var l=new Uint8Array(16+o.length);if(l.set(i),l.set(o,i.length),l=e(l),l[6]=l[6]&15|t,l[8]=l[8]&63|128,s){h=h||0;for(var b=0;b<16;++b)s[h+b]=l[b];return s}return yr(l)}try{n.name=r}catch{}return n.DNS=Eh,n.URL=_h,n}var Eh,_h,_s=ye(()=>{"use strict";bn();Es();Eh="6ba7b810-9dad-11d1-80b4-00c04fd430c8",_h="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function Ih(r){if(typeof r=="string"){var t=unescape(encodeURIComponent(r));r=new Uint8Array(t.length);for(var e=0;e<t.length;++e)r[e]=t.charCodeAt(e)}return Ah(Lh(Rh(r),r.length*8))}function Ah(r){for(var t=[],e=r.length*32,n="0123456789abcdef",o=0;o<e;o+=8){var i=r[o>>5]>>>o%32&255,s=parseInt(n.charAt(i>>>4&15)+n.charAt(i&15),16);t.push(s)}return t}function Uc(r){return(r+64>>>9<<4)+14+1}function Lh(r,t){r[t>>5]|=128<<t%32,r[Uc(t)-1]=t;for(var e=1732584193,n=-271733879,o=-1732584194,i=271733878,s=0;s<r.length;s+=16){var h=e,l=n,b=o,x=i;e=fe(e,n,o,i,r[s],7,-680876936),i=fe(i,e,n,o,r[s+1],12,-389564586),o=fe(o,i,e,n,r[s+2],17,606105819),n=fe(n,o,i,e,r[s+3],22,-1044525330),e=fe(e,n,o,i,r[s+4],7,-176418897),i=fe(i,e,n,o,r[s+5],12,1200080426),o=fe(o,i,e,n,r[s+6],17,-1473231341),n=fe(n,o,i,e,r[s+7],22,-45705983),e=fe(e,n,o,i,r[s+8],7,1770035416),i=fe(i,e,n,o,r[s+9],12,-1958414417),o=fe(o,i,e,n,r[s+10],17,-42063),n=fe(n,o,i,e,r[s+11],22,-1990404162),e=fe(e,n,o,i,r[s+12],7,1804603682),i=fe(i,e,n,o,r[s+13],12,-40341101),o=fe(o,i,e,n,r[s+14],17,-1502002290),n=fe(n,o,i,e,r[s+15],22,1236535329),e=le(e,n,o,i,r[s+1],5,-165796510),i=le(i,e,n,o,r[s+6],9,-1069501632),o=le(o,i,e,n,r[s+11],14,643717713),n=le(n,o,i,e,r[s],20,-373897302),e=le(e,n,o,i,r[s+5],5,-701558691),i=le(i,e,n,o,r[s+10],9,38016083),o=le(o,i,e,n,r[s+15],14,-660478335),n=le(n,o,i,e,r[s+4],20,-405537848),e=le(e,n,o,i,r[s+9],5,568446438),i=le(i,e,n,o,r[s+14],9,-1019803690),o=le(o,i,e,n,r[s+3],14,-187363961),n=le(n,o,i,e,r[s+8],20,1163531501),e=le(e,n,o,i,r[s+13],5,-1444681467),i=le(i,e,n,o,r[s+2],9,-51403784),o=le(o,i,e,n,r[s+7],14,1735328473),n=le(n,o,i,e,r[s+12],20,-1926607734),e=he(e,n,o,i,r[s+5],4,-378558),i=he(i,e,n,o,r[s+8],11,-2022574463),o=he(o,i,e,n,r[s+11],16,1839030562),n=he(n,o,i,e,r[s+14],23,-35309556),e=he(e,n,o,i,r[s+1],4,-1530992060),i=he(i,e,n,o,r[s+4],11,1272893353),o=he(o,i,e,n,r[s+7],16,-155497632),n=he(n,o,i,e,r[s+10],23,-1094730640),e=he(e,n,o,i,r[s+13],4,681279174),i=he(i,e,n,o,r[s],11,-358537222),o=he(o,i,e,n,r[s+3],16,-722521979),n=he(n,o,i,e,r[s+6],23,76029189),e=he(e,n,o,i,r[s+9],4,-640364487),i=he(i,e,n,o,r[s+12],11,-421815835),o=he(o,i,e,n,r[s+15],16,530742520),n=he(n,o,i,e,r[s+2],23,-995338651),e=de(e,n,o,i,r[s],6,-198630844),i=de(i,e,n,o,r[s+7],10,1126891415),o=de(o,i,e,n,r[s+14],15,-1416354905),n=de(n,o,i,e,r[s+5],21,-57434055),e=de(e,n,o,i,r[s+12],6,1700485571),i=de(i,e,n,o,r[s+3],10,-1894986606),o=de(o,i,e,n,r[s+10],15,-1051523),n=de(n,o,i,e,r[s+1],21,-2054922799),e=de(e,n,o,i,r[s+8],6,1873313359),i=de(i,e,n,o,r[s+15],10,-30611744),o=de(o,i,e,n,r[s+6],15,-1560198380),n=de(n,o,i,e,r[s+13],21,1309151649),e=de(e,n,o,i,r[s+4],6,-145523070),i=de(i,e,n,o,r[s+11],10,-1120210379),o=de(o,i,e,n,r[s+2],15,718787259),n=de(n,o,i,e,r[s+9],21,-343485551),e=gr(e,h),n=gr(n,l),o=gr(o,b),i=gr(i,x)}return[e,n,o,i]}function Rh(r){if(r.length===0)return[];for(var t=r.length*8,e=new Uint32Array(Uc(t)),n=0;n<t;n+=8)e[n>>5]|=(r[n/8]&255)<<n%32;return e}function gr(r,t){var e=(r&65535)+(t&65535),n=(r>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function Th(r,t){return r<<t|r>>>32-t}function Do(r,t,e,n,o,i){return gr(Th(gr(gr(t,r),gr(n,i)),o),e)}function fe(r,t,e,n,o,i,s){return Do(t&e|~t&n,r,t,o,i,s)}function le(r,t,e,n,o,i,s){return Do(t&n|e&~n,r,t,o,i,s)}function he(r,t,e,n,o,i,s){return Do(t^e^n,r,t,o,i,s)}function de(r,t,e,n,o,i,s){return Do(e^(t|~n),r,t,o,i,s)}var Nc,zc=ye(()=>{"use strict";Nc=Ih});var Mh,qc,Fc=ye(()=>{"use strict";_s();zc();Mh=Fo("v3",48,Nc),qc=Mh});function Ph(r,t,e){r=r||{};var n=r.random||(r.rng||gn)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var o=0;o<16;++o)t[e+o]=n[o];return t}return yr(n)}var Dc,Kc=ye(()=>{"use strict";vs();bn();Dc=Ph});function Ch(r,t,e,n){switch(r){case 0:return t&e^~t&n;case 1:return t^e^n;case 2:return t&e^t&n^e&n;case 3:return t^e^n}}function Is(r,t){return r<<t|r>>>32-t}function Oh(r){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var o=0;o<n.length;++o)r.push(n.charCodeAt(o))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var i=r.length/4+2,s=Math.ceil(i/16),h=new Array(s),l=0;l<s;++l){for(var b=new Uint32Array(16),x=0;x<16;++x)b[x]=r[l*64+x*4]<<24|r[l*64+x*4+1]<<16|r[l*64+x*4+2]<<8|r[l*64+x*4+3];h[l]=b}h[s-1][14]=(r.length-1)*8/Math.pow(2,32),h[s-1][14]=Math.floor(h[s-1][14]),h[s-1][15]=(r.length-1)*8&4294967295;for(var k=0;k<s;++k){for(var R=new Uint32Array(80),I=0;I<16;++I)R[I]=h[k][I];for(var P=16;P<80;++P)R[P]=Is(R[P-3]^R[P-8]^R[P-14]^R[P-16],1);for(var B=e[0],A=e[1],T=e[2],F=e[3],N=e[4],W=0;W<80;++W){var q=Math.floor(W/20),z=Is(B,5)+Ch(q,A,T,F)+N+t[q]+R[W]>>>0;N=F,F=T,T=Is(A,30)>>>0,A=B,B=z}e[0]=e[0]+B>>>0,e[1]=e[1]+A>>>0,e[2]=e[2]+T>>>0,e[3]=e[3]+F>>>0,e[4]=e[4]+N>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var Wc,Hc=ye(()=>{"use strict";Wc=Oh});var Uh,Vc,$c=ye(()=>{"use strict";_s();Hc();Uh=Fo("v5",80,Wc),Vc=Uh});var jc,Gc=ye(()=>{"use strict";jc="00000000-0000-0000-0000-000000000000"});function Nh(r){if(!pr(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}var Yc,Zc=ye(()=>{"use strict";mn();Yc=Nh});var As={};_i(As,{NIL:()=>jc,parse:()=>qo,stringify:()=>yr,v1:()=>Cc,v3:()=>qc,v4:()=>Dc,v5:()=>Vc,validate:()=>pr,version:()=>Yc});var Ls=ye(()=>{"use strict";Oc();Fc();Kc();$c();Gc();Zc();mn();bn();Es()});var Xc=at((vy,Jc)=>{"use strict";var zh=(Ls(),Ii(As)).v4,qh=function(r,t,e,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};let o=typeof n.version=="number"?n.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");let i={method:r};if(o===2&&(i.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");i.params=t}if(typeof e>"u"){let s=typeof n.generator=="function"?n.generator:function(){return zh()};i.id=s(i,n)}else o===2&&e===null?n.notificationIdNull&&(i.id=null):i.id=e;return i};Jc.exports=qh});var tu=at((ky,Qc)=>{"use strict";var Fh=(Ls(),Ii(As)).v4,Dh=Xc(),wn=function(r,t){if(!(this instanceof wn))return new wn(r,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return Fh()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=r};Qc.exports=wn;wn.prototype.request=function(r,t,e,n){let o=this,i=null,s=Array.isArray(r)&&typeof t=="function";if(this.options.version===1&&s)throw new TypeError("JSON-RPC 1.0 does not support batching");if(s||!s&&r&&typeof r=="object"&&typeof t=="function")n=t,i=r;else{typeof e=="function"&&(n=e,e=void 0);let b=typeof n=="function";try{i=Dh(r,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(x){if(b)return n(x);throw x}if(!b)return i}let l;try{l=JSON.stringify(i,this.options.replacer)}catch(b){return n(b)}return this.callServer(l,function(b,x){o._parseResponse(b,x,n)}),i};wn.prototype._parseResponse=function(r,t,e){if(r){e(r);return}if(!t)return e();let n;try{n=JSON.parse(t,this.options.reviver)}catch(o){return e(o)}if(e.length===3)if(Array.isArray(n)){let o=function(s){return typeof s.error<"u"},i=function(s){return!o(s)};return e(null,n.filter(o),n.filter(i))}else return e(null,n.error,n.result);e(null,n)}});var Rs=at((Sy,xn)=>{"use strict";function Kh(r){return r&&r.__esModule?r:{default:r}}xn.exports=Kh,xn.exports.__esModule=!0,xn.exports.default=xn.exports});var Yr=at((By,Ye)=>{"use strict";function Ts(r){"@babel/helpers - typeof";return Ye.exports=Ts=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ye.exports.__esModule=!0,Ye.exports.default=Ye.exports,Ts(r)}Ye.exports=Ts,Ye.exports.__esModule=!0,Ye.exports.default=Ye.exports});var nu=at((Ey,Ze)=>{"use strict";var eu=Yr().default;function ru(){"use strict";Ze.exports=ru=function(){return t},Ze.exports.__esModule=!0,Ze.exports.default=Ze.exports;var r,t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(f,d,p){f[d]=p.value},i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",h=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function b(f,d,p){return Object.defineProperty(f,d,{value:p,enumerable:!0,configurable:!0,writable:!0}),f[d]}try{b({},"")}catch{b=function(p,g,w){return p[g]=w}}function x(f,d,p,g){var w=d&&d.prototype instanceof T?d:T,y=Object.create(w.prototype),c=new a(g||[]);return o(y,"_invoke",{value:nt(f,p,c)}),y}function k(f,d,p){try{return{type:"normal",arg:f.call(d,p)}}catch(g){return{type:"throw",arg:g}}}t.wrap=x;var R="suspendedStart",I="suspendedYield",P="executing",B="completed",A={};function T(){}function F(){}function N(){}var W={};b(W,s,function(){return this});var q=Object.getPrototypeOf,z=q&&q(q(u([])));z&&z!==e&&n.call(z,s)&&(W=z);var H=N.prototype=T.prototype=Object.create(W);function j(f){["next","throw","return"].forEach(function(d){b(f,d,function(p){return this._invoke(d,p)})})}function ot(f,d){function p(w,y,c,m){var M=k(f[w],f,y);if(M.type!=="throw"){var U=M.arg,O=U.value;return O&&eu(O)=="object"&&n.call(O,"__await")?d.resolve(O.__await).then(function(D){p("next",D,c,m)},function(D){p("throw",D,c,m)}):d.resolve(O).then(function(D){U.value=D,c(U)},function(D){return p("throw",D,c,m)})}m(M.arg)}var g;o(this,"_invoke",{value:function(y,c){function m(){return new d(function(M,U){p(y,c,M,U)})}return g=g?g.then(m,m):m()}})}function nt(f,d,p){var g=R;return function(w,y){if(g===P)throw Error("Generator is already running");if(g===B){if(w==="throw")throw y;return{value:r,done:!0}}for(p.method=w,p.arg=y;;){var c=p.delegate;if(c){var m=G(c,p);if(m){if(m===A)continue;return m}}if(p.method==="next")p.sent=p._sent=p.arg;else if(p.method==="throw"){if(g===R)throw g=B,p.arg;p.dispatchException(p.arg)}else p.method==="return"&&p.abrupt("return",p.arg);g=P;var M=k(f,d,p);if(M.type==="normal"){if(g=p.done?B:I,M.arg===A)continue;return{value:M.arg,done:p.done}}M.type==="throw"&&(g=B,p.method="throw",p.arg=M.arg)}}}function G(f,d){var p=d.method,g=f.iterator[p];if(g===r)return d.delegate=null,p==="throw"&&f.iterator.return&&(d.method="return",d.arg=r,G(f,d),d.method==="throw")||p!=="return"&&(d.method="throw",d.arg=new TypeError("The iterator does not provide a '"+p+"' method")),A;var w=k(g,f.iterator,d.arg);if(w.type==="throw")return d.method="throw",d.arg=w.arg,d.delegate=null,A;var y=w.arg;return y?y.done?(d[f.resultName]=y.value,d.next=f.nextLoc,d.method!=="return"&&(d.method="next",d.arg=r),d.delegate=null,A):y:(d.method="throw",d.arg=new TypeError("iterator result is not an object"),d.delegate=null,A)}function lt(f){var d={tryLoc:f[0]};1 in f&&(d.catchLoc=f[1]),2 in f&&(d.finallyLoc=f[2],d.afterLoc=f[3]),this.tryEntries.push(d)}function v(f){var d=f.completion||{};d.type="normal",delete d.arg,f.completion=d}function a(f){this.tryEntries=[{tryLoc:"root"}],f.forEach(lt,this),this.reset(!0)}function u(f){if(f||f===""){var d=f[s];if(d)return d.call(f);if(typeof f.next=="function")return f;if(!isNaN(f.length)){var p=-1,g=function w(){for(;++p<f.length;)if(n.call(f,p))return w.value=f[p],w.done=!1,w;return w.value=r,w.done=!0,w};return g.next=g}}throw new TypeError(eu(f)+" is not iterable")}return F.prototype=N,o(H,"constructor",{value:N,configurable:!0}),o(N,"constructor",{value:F,configurable:!0}),F.displayName=b(N,l,"GeneratorFunction"),t.isGeneratorFunction=function(f){var d=typeof f=="function"&&f.constructor;return!!d&&(d===F||(d.displayName||d.name)==="GeneratorFunction")},t.mark=function(f){return Object.setPrototypeOf?Object.setPrototypeOf(f,N):(f.__proto__=N,b(f,l,"GeneratorFunction")),f.prototype=Object.create(H),f},t.awrap=function(f){return{__await:f}},j(ot.prototype),b(ot.prototype,h,function(){return this}),t.AsyncIterator=ot,t.async=function(f,d,p,g,w){w===void 0&&(w=Promise);var y=new ot(x(f,d,p,g),w);return t.isGeneratorFunction(d)?y:y.next().then(function(c){return c.done?c.value:y.next()})},j(H),b(H,l,"Generator"),b(H,s,function(){return this}),b(H,"toString",function(){return"[object Generator]"}),t.keys=function(f){var d=Object(f),p=[];for(var g in d)p.push(g);return p.reverse(),function w(){for(;p.length;){var y=p.pop();if(y in d)return w.value=y,w.done=!1,w}return w.done=!0,w}},t.values=u,a.prototype={constructor:a,reset:function(d){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(v),!d)for(var p in this)p.charAt(0)==="t"&&n.call(this,p)&&!isNaN(+p.slice(1))&&(this[p]=r)},stop:function(){this.done=!0;var d=this.tryEntries[0].completion;if(d.type==="throw")throw d.arg;return this.rval},dispatchException:function(d){if(this.done)throw d;var p=this;function g(U,O){return c.type="throw",c.arg=d,p.next=U,O&&(p.method="next",p.arg=r),!!O}for(var w=this.tryEntries.length-1;w>=0;--w){var y=this.tryEntries[w],c=y.completion;if(y.tryLoc==="root")return g("end");if(y.tryLoc<=this.prev){var m=n.call(y,"catchLoc"),M=n.call(y,"finallyLoc");if(m&&M){if(this.prev<y.catchLoc)return g(y.catchLoc,!0);if(this.prev<y.finallyLoc)return g(y.finallyLoc)}else if(m){if(this.prev<y.catchLoc)return g(y.catchLoc,!0)}else{if(!M)throw Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return g(y.finallyLoc)}}}},abrupt:function(d,p){for(var g=this.tryEntries.length-1;g>=0;--g){var w=this.tryEntries[g];if(w.tryLoc<=this.prev&&n.call(w,"finallyLoc")&&this.prev<w.finallyLoc){var y=w;break}}y&&(d==="break"||d==="continue")&&y.tryLoc<=p&&p<=y.finallyLoc&&(y=null);var c=y?y.completion:{};return c.type=d,c.arg=p,y?(this.method="next",this.next=y.finallyLoc,A):this.complete(c)},complete:function(d,p){if(d.type==="throw")throw d.arg;return d.type==="break"||d.type==="continue"?this.next=d.arg:d.type==="return"?(this.rval=this.arg=d.arg,this.method="return",this.next="end"):d.type==="normal"&&p&&(this.next=p),A},finish:function(d){for(var p=this.tryEntries.length-1;p>=0;--p){var g=this.tryEntries[p];if(g.finallyLoc===d)return this.complete(g.completion,g.afterLoc),v(g),A}},catch:function(d){for(var p=this.tryEntries.length-1;p>=0;--p){var g=this.tryEntries[p];if(g.tryLoc===d){var w=g.completion;if(w.type==="throw"){var y=w.arg;v(g)}return y}}throw Error("illegal catch attempt")},delegateYield:function(d,p,g){return this.delegate={iterator:u(d),resultName:p,nextLoc:g},this.method==="next"&&(this.arg=r),A}},t}Ze.exports=ru,Ze.exports.__esModule=!0,Ze.exports.default=Ze.exports});var iu=at((_y,ou)=>{"use strict";var Ko=nu()();ou.exports=Ko;try{regeneratorRuntime=Ko}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Ko:Function("r","regeneratorRuntime = r")(Ko)}});var au=at((Iy,vn)=>{"use strict";function su(r,t,e,n,o,i,s){try{var h=r[i](s),l=h.value}catch(b){return void e(b)}h.done?t(l):Promise.resolve(l).then(n,o)}function Wh(r){return function(){var t=this,e=arguments;return new Promise(function(n,o){var i=r.apply(t,e);function s(l){su(i,n,o,s,h,"next",l)}function h(l){su(i,n,o,s,h,"throw",l)}s(void 0)})}}vn.exports=Wh,vn.exports.__esModule=!0,vn.exports.default=vn.exports});var Ms=at((Ay,kn)=>{"use strict";function Hh(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}kn.exports=Hh,kn.exports.__esModule=!0,kn.exports.default=kn.exports});var uu=at((Ly,Sn)=>{"use strict";var cu=Yr().default;function Vh(r,t){if(cu(r)!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t||"default");if(cu(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}Sn.exports=Vh,Sn.exports.__esModule=!0,Sn.exports.default=Sn.exports});var fu=at((Ry,Bn)=>{"use strict";var $h=Yr().default,jh=uu();function Gh(r){var t=jh(r,"string");return $h(t)=="symbol"?t:t+""}Bn.exports=Gh,Bn.exports.__esModule=!0,Bn.exports.default=Bn.exports});var Ps=at((Ty,En)=>{"use strict";var Yh=fu();function lu(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Yh(n.key),n)}}function Zh(r,t,e){return t&&lu(r.prototype,t),e&&lu(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}En.exports=Zh,En.exports.__esModule=!0,En.exports.default=En.exports});var hu=at((My,Je)=>{"use strict";function Cs(r,t){return Je.exports=Cs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},Je.exports.__esModule=!0,Je.exports.default=Je.exports,Cs(r,t)}Je.exports=Cs,Je.exports.__esModule=!0,Je.exports.default=Je.exports});var Os=at((Py,_n)=>{"use strict";var Jh=hu();function Xh(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&Jh(r,t)}_n.exports=Xh,_n.exports.__esModule=!0,_n.exports.default=_n.exports});var du=at((Cy,In)=>{"use strict";function Qh(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}In.exports=Qh,In.exports.__esModule=!0,In.exports.default=In.exports});var Us=at((Oy,An)=>{"use strict";var td=Yr().default,ed=du();function rd(r,t){if(t&&(td(t)=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ed(r)}An.exports=rd,An.exports.__esModule=!0,An.exports.default=An.exports});var zs=at((Uy,Xe)=>{"use strict";function Ns(r){return Xe.exports=Ns=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xe.exports.__esModule=!0,Xe.exports.default=Xe.exports,Ns(r)}Xe.exports=Ns,Xe.exports.__esModule=!0,Xe.exports.default=Xe.exports});var Fs=at((Ny,qs)=>{"use strict";var nd=Object.prototype.hasOwnProperty,be="~";function Ln(){}Object.create&&(Ln.prototype=Object.create(null),new Ln().__proto__||(be=!1));function od(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function pu(r,t,e,n,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var i=new od(e,n||r,o),s=be?be+t:t;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Wo(r,t){--r._eventsCount===0?r._events=new Ln:delete r._events[t]}function pe(){this._events=new Ln,this._eventsCount=0}pe.prototype.eventNames=function(){var t=[],e,n;if(this._eventsCount===0)return t;for(n in e=this._events)nd.call(e,n)&&t.push(be?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};pe.prototype.listeners=function(t){var e=be?be+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};pe.prototype.listenerCount=function(t){var e=be?be+t:t,n=this._events[e];return n?n.fn?1:n.length:0};pe.prototype.emit=function(t,e,n,o,i,s){var h=be?be+t:t;if(!this._events[h])return!1;var l=this._events[h],b=arguments.length,x,k;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),b){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,s),!0}for(k=1,x=new Array(b-1);k<b;k++)x[k-1]=arguments[k];l.fn.apply(l.context,x)}else{var R=l.length,I;for(k=0;k<R;k++)switch(l[k].once&&this.removeListener(t,l[k].fn,void 0,!0),b){case 1:l[k].fn.call(l[k].context);break;case 2:l[k].fn.call(l[k].context,e);break;case 3:l[k].fn.call(l[k].context,e,n);break;case 4:l[k].fn.call(l[k].context,e,n,o);break;default:if(!x)for(I=1,x=new Array(b-1);I<b;I++)x[I-1]=arguments[I];l[k].fn.apply(l[k].context,x)}}return!0};pe.prototype.on=function(t,e,n){return pu(this,t,e,n,!1)};pe.prototype.once=function(t,e,n){return pu(this,t,e,n,!0)};pe.prototype.removeListener=function(t,e,n,o){var i=be?be+t:t;if(!this._events[i])return this;if(!e)return Wo(this,i),this;var s=this._events[i];if(s.fn)s.fn===e&&(!o||s.once)&&(!n||s.context===n)&&Wo(this,i);else{for(var h=0,l=[],b=s.length;h<b;h++)(s[h].fn!==e||o&&!s[h].once||n&&s[h].context!==n)&&l.push(s[h]);l.length?this._events[i]=l.length===1?l[0]:l:Wo(this,i)}return this};pe.prototype.removeAllListeners=function(t){var e;return t?(e=be?be+t:t,this._events[e]&&Wo(this,e)):(this._events=new Ln,this._eventsCount=0),this};pe.prototype.off=pe.prototype.removeListener;pe.prototype.addListener=pe.prototype.on;pe.prefixed=be;pe.EventEmitter=pe;typeof qs<"u"&&(qs.exports=pe)});var gu=at(Vo=>{"use strict";var br=Rs();Object.defineProperty(Vo,"__esModule",{value:!0});Vo.default=void 0;var mr=br(iu()),Ho=br(au()),id=br(Yr()),sd=br(Ms()),ad=br(Ps()),cd=br(Os()),ud=br(Us()),yu=br(zs()),fd=Fs();function ld(r){var t=hd();return function(){var n=(0,yu.default)(r),o;if(t){var i=(0,yu.default)(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return(0,ud.default)(this,o)}}function hd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var dd=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(r);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(r,n[o])&&(e[n[o]]=r[n[o]]);return e},pd=function(r){(0,cd.default)(e,r);var t=ld(e);function e(n){var o,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ws://localhost:8080",s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},h=arguments.length>3?arguments[3]:void 0;(0,sd.default)(this,e);var l=s.autoconnect,b=l===void 0?!0:l,x=s.reconnect,k=x===void 0?!0:x,R=s.reconnect_interval,I=R===void 0?1e3:R,P=s.max_reconnects,B=P===void 0?5:P,A=dd(s,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return o=t.call(this),o.webSocketFactory=n,o.queue={},o.rpc_id=0,o.address=i,o.autoconnect=b,o.ready=!1,o.reconnect=k,o.reconnect_timer_id=void 0,o.reconnect_interval=I,o.max_reconnects=B,o.rest_options=A,o.current_reconnects=0,o.generate_request_id=h||function(){return++o.rpc_id},o.autoconnect&&o._connect(o.address,Object.assign({autoconnect:o.autoconnect,reconnect:o.reconnect,reconnect_interval:o.reconnect_interval,max_reconnects:o.max_reconnects},o.rest_options)),o}return(0,ad.default)(e,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(o,i,s,h){var l=this;return!h&&(0,id.default)(s)==="object"&&(h=s,s=null),new Promise(function(b,x){if(!l.ready)return x(new Error("socket not ready"));var k=l.generate_request_id(o,i),R={jsonrpc:"2.0",method:o,params:i||null,id:k};l.socket.send(JSON.stringify(R),h,function(I){if(I)return x(I);l.queue[k]={promise:[b,x]},s&&(l.queue[k].timeout=setTimeout(function(){delete l.queue[k],x(new Error("reply timeout"))},s))})})}},{key:"login",value:function(){var n=(0,Ho.default)(mr.default.mark(function i(s){var h;return mr.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.call("rpc.login",s);case 2:if(h=b.sent,h){b.next=5;break}throw new Error("authentication failed");case 5:return b.abrupt("return",h);case 6:case"end":return b.stop()}},i,this)}));function o(i){return n.apply(this,arguments)}return o}()},{key:"listMethods",value:function(){var n=(0,Ho.default)(mr.default.mark(function i(){return mr.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.call("__listMethods");case 2:return h.abrupt("return",h.sent);case 3:case"end":return h.stop()}},i,this)}));function o(){return n.apply(this,arguments)}return o}()},{key:"notify",value:function(o,i){var s=this;return new Promise(function(h,l){if(!s.ready)return l(new Error("socket not ready"));var b={jsonrpc:"2.0",method:o,params:i||null};s.socket.send(JSON.stringify(b),function(x){if(x)return l(x);h()})})}},{key:"subscribe",value:function(){var n=(0,Ho.default)(mr.default.mark(function i(s){var h;return mr.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return typeof s=="string"&&(s=[s]),b.next=3,this.call("rpc.on",s);case 3:if(h=b.sent,!(typeof s=="string"&&h[s]!=="ok")){b.next=6;break}throw new Error("Failed subscribing to an event '"+s+"' with: "+h[s]);case 6:return b.abrupt("return",h);case 7:case"end":return b.stop()}},i,this)}));function o(i){return n.apply(this,arguments)}return o}()},{key:"unsubscribe",value:function(){var n=(0,Ho.default)(mr.default.mark(function i(s){var h;return mr.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return typeof s=="string"&&(s=[s]),b.next=3,this.call("rpc.off",s);case 3:if(h=b.sent,!(typeof s=="string"&&h[s]!=="ok")){b.next=6;break}throw new Error("Failed unsubscribing from an event with: "+h);case 6:return b.abrupt("return",h);case 7:case"end":return b.stop()}},i,this)}));function o(i){return n.apply(this,arguments)}return o}()},{key:"close",value:function(o,i){this.socket.close(o||1e3,i)}},{key:"_connect",value:function(o,i){var s=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(o,i),this.socket.addEventListener("open",function(){s.ready=!0,s.emit("open"),s.current_reconnects=0}),this.socket.addEventListener("message",function(h){var l=h.data;l instanceof ArrayBuffer&&(l=Buffer.from(l).toString());try{l=JSON.parse(l)}catch{return}if(l.notification&&s.listeners(l.notification).length){if(!Object.keys(l.params).length)return s.emit(l.notification);var b=[l.notification];if(l.params.constructor===Object)b.push(l.params);else for(var x=0;x<l.params.length;x++)b.push(l.params[x]);return Promise.resolve().then(function(){s.emit.apply(s,b)})}if(!s.queue[l.id])return l.method&&l.params?Promise.resolve().then(function(){s.emit(l.method,l.params)}):void 0;"error"in l=="result"in l&&s.queue[l.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),s.queue[l.id].timeout&&clearTimeout(s.queue[l.id].timeout),l.error?s.queue[l.id].promise[1](l.error):s.queue[l.id].promise[0](l.result),delete s.queue[l.id]}),this.socket.addEventListener("error",function(h){return s.emit("error",h)}),this.socket.addEventListener("close",function(h){var l=h.code,b=h.reason;s.ready&&setTimeout(function(){return s.emit("close",l,b)},0),s.ready=!1,s.socket=void 0,l!==1e3&&(s.current_reconnects++,s.reconnect&&(s.max_reconnects>s.current_reconnects||s.max_reconnects===0)&&(s.reconnect_timer_id=setTimeout(function(){return s._connect(o,i)},s.reconnect_interval)))})}}]),e}(fd.EventEmitter);Vo.default=pd});var bu=at(Ds=>{"use strict";var Rn=Rs();Object.defineProperty(Ds,"__esModule",{value:!0});Ds.default=Sd;var yd=Rn(Ms()),gd=Rn(Ps()),md=Rn(Os()),bd=Rn(Us()),mu=Rn(zs()),wd=Fs();function xd(r){var t=vd();return function(){var n=(0,mu.default)(r),o;if(t){var i=(0,mu.default)(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return(0,bd.default)(this,o)}}function vd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var kd=function(r){(0,md.default)(e,r);var t=xd(e);function e(n,o,i){var s;return(0,yd.default)(this,e),s=t.call(this),s.socket=new window.WebSocket(n,i),s.socket.onopen=function(){return s.emit("open")},s.socket.onmessage=function(h){return s.emit("message",h.data)},s.socket.onerror=function(h){return s.emit("error",h)},s.socket.onclose=function(h){s.emit("close",h.code,h.reason)},s}return(0,gd.default)(e,[{key:"send",value:function(o,i,s){var h=s||i;try{this.socket.send(o),h()}catch(l){h(l)}}},{key:"close",value:function(o,i){this.socket.close(o,i)}},{key:"addEventListener",value:function(o,i,s){this.socket.addEventListener(o,i,s)}}]),e}(wd.EventEmitter);function Sd(r,t){return new kd(r,t)}});var C0={};_i(C0,{default:()=>P0});var sf=Re(Ia());var X=Re(Vn());function on(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function sn(r,...t){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function Ga(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");on(r.outputLen),on(r.blockLen)}function Ke(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function $n(r,t){sn(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var jn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Ya=r=>r instanceof Uint8Array;var Za=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),Gn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Te=(r,t)=>r<<32-t|r>>>t,Hf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Hf)throw new Error("Non little-endian hardware is not supported");function zi(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function or(r){if(typeof r=="string"&&(r=zi(r)),!Ya(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Yn(...r){let t=new Uint8Array(r.reduce((n,o)=>n+o.length,0)),e=0;return r.forEach(n=>{if(!Ya(n))throw new Error("Uint8Array expected");t.set(n,e),e+=n.length}),t}var nr=class{clone(){return this._cloneInto()}},H0={}.toString;function qr(r){let t=n=>r().update(or(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ja(r){let t=(n,o)=>r(o).update(or(n)).digest(),e=r({});return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=n=>r(n),t}function Zn(r=32){if(jn&&typeof jn.getRandomValues=="function")return jn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Vf(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),h=Number(e&i),l=n?4:0,b=n?0:4;r.setUint32(t+l,s,n),r.setUint32(t+b,h,n)}var Fr=class extends nr{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Gn(this.buffer)}update(t){Ke(this);let{view:e,buffer:n,blockLen:o}=this;t=or(t);let i=t.length;for(let s=0;s<i;){let h=Math.min(o-this.pos,i-s);if(h===o){let l=Gn(t);for(;o<=i-s;s+=o)this.process(l,s);continue}n.set(t.subarray(s,s+h),this.pos),this.pos+=h,s+=h,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ke(this),$n(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let k=s;k<o;k++)e[k]=0;Vf(n,o-8,BigInt(this.length*8),i),this.process(n,0);let h=Gn(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let b=l/4,x=this.get();if(b>x.length)throw new Error("_sha2: outputLen bigger than state");for(let k=0;k<b;k++)h.setUint32(4*k,x[k],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:h}=this;return t.length=o,t.pos=h,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var Jn=BigInt(4294967295),qi=BigInt(32);function Xa(r,t=!1){return t?{h:Number(r&Jn),l:Number(r>>qi&Jn)}:{h:Number(r>>qi&Jn)|0,l:Number(r&Jn)|0}}function Fi(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=Xa(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var $f=(r,t)=>BigInt(r>>>0)<<qi|BigInt(t>>>0),jf=(r,t,e)=>r>>>e,Gf=(r,t,e)=>r<<32-e|t>>>e,Yf=(r,t,e)=>r>>>e|t<<32-e,Zf=(r,t,e)=>r<<32-e|t>>>e,Jf=(r,t,e)=>r<<64-e|t>>>e-32,Xf=(r,t,e)=>r>>>e-32|t<<64-e,Qf=(r,t)=>t,tl=(r,t)=>r,Di=(r,t,e)=>r<<e|t>>>32-e,Ki=(r,t,e)=>t<<e|r>>>32-e,Wi=(r,t,e)=>t<<e-32|r>>>64-e,Hi=(r,t,e)=>r<<e-32|t>>>64-e;function el(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var rl=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),nl=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ol=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),il=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,sl=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),al=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var cl={fromBig:Xa,split:Fi,toBig:$f,shrSH:jf,shrSL:Gf,rotrSH:Yf,rotrSL:Zf,rotrBH:Jf,rotrBL:Xf,rotr32H:Qf,rotr32L:tl,rotlSH:Di,rotlSL:Ki,rotlBH:Wi,rotlBL:Hi,add:el,add3L:rl,add3H:nl,add4L:ol,add4H:il,add5H:al,add5L:sl},et=cl;var[ul,fl]=et.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))),ir=new Uint32Array(80),sr=new Uint32Array(80),Vi=class extends Fr{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:t,Al:e,Bh:n,Bl:o,Ch:i,Cl:s,Dh:h,Dl:l,Eh:b,El:x,Fh:k,Fl:R,Gh:I,Gl:P,Hh:B,Hl:A}=this;return[t,e,n,o,i,s,h,l,b,x,k,R,I,P,B,A]}set(t,e,n,o,i,s,h,l,b,x,k,R,I,P,B,A){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=h|0,this.Dl=l|0,this.Eh=b|0,this.El=x|0,this.Fh=k|0,this.Fl=R|0,this.Gh=I|0,this.Gl=P|0,this.Hh=B|0,this.Hl=A|0}process(t,e){for(let N=0;N<16;N++,e+=4)ir[N]=t.getUint32(e),sr[N]=t.getUint32(e+=4);for(let N=16;N<80;N++){let W=ir[N-15]|0,q=sr[N-15]|0,z=et.rotrSH(W,q,1)^et.rotrSH(W,q,8)^et.shrSH(W,q,7),H=et.rotrSL(W,q,1)^et.rotrSL(W,q,8)^et.shrSL(W,q,7),j=ir[N-2]|0,ot=sr[N-2]|0,nt=et.rotrSH(j,ot,19)^et.rotrBH(j,ot,61)^et.shrSH(j,ot,6),G=et.rotrSL(j,ot,19)^et.rotrBL(j,ot,61)^et.shrSL(j,ot,6),lt=et.add4L(H,G,sr[N-7],sr[N-16]),v=et.add4H(lt,z,nt,ir[N-7],ir[N-16]);ir[N]=v|0,sr[N]=lt|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:h,Cl:l,Dh:b,Dl:x,Eh:k,El:R,Fh:I,Fl:P,Gh:B,Gl:A,Hh:T,Hl:F}=this;for(let N=0;N<80;N++){let W=et.rotrSH(k,R,14)^et.rotrSH(k,R,18)^et.rotrBH(k,R,41),q=et.rotrSL(k,R,14)^et.rotrSL(k,R,18)^et.rotrBL(k,R,41),z=k&I^~k&B,H=R&P^~R&A,j=et.add5L(F,q,H,fl[N],sr[N]),ot=et.add5H(j,T,W,z,ul[N],ir[N]),nt=j|0,G=et.rotrSH(n,o,28)^et.rotrBH(n,o,34)^et.rotrBH(n,o,39),lt=et.rotrSL(n,o,28)^et.rotrBL(n,o,34)^et.rotrBL(n,o,39),v=n&i^n&h^i&h,a=o&s^o&l^s&l;T=B|0,F=A|0,B=I|0,A=P|0,I=k|0,P=R|0,{h:k,l:R}=et.add(b|0,x|0,ot|0,nt|0),b=h|0,x=l|0,h=i|0,l=s|0,i=n|0,s=o|0;let u=et.add3L(nt,lt,a);n=et.add3H(u,ot,G,v),o=u|0}({h:n,l:o}=et.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=et.add(this.Bh|0,this.Bl|0,i|0,s|0),{h,l}=et.add(this.Ch|0,this.Cl|0,h|0,l|0),{h:b,l:x}=et.add(this.Dh|0,this.Dl|0,b|0,x|0),{h:k,l:R}=et.add(this.Eh|0,this.El|0,k|0,R|0),{h:I,l:P}=et.add(this.Fh|0,this.Fl|0,I|0,P|0),{h:B,l:A}=et.add(this.Gh|0,this.Gl|0,B|0,A|0),{h:T,l:F}=et.add(this.Hh|0,this.Hl|0,T|0,F|0),this.set(n,o,i,s,h,l,b,x,k,R,I,P,B,A,T,F)}roundClean(){ir.fill(0),sr.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 $i=qr(()=>new Vi);var to={};_i(to,{bitGet:()=>ml,bitLen:()=>gl,bitMask:()=>an,bitSet:()=>bl,bytesToHex:()=>We,bytesToNumberBE:()=>He,bytesToNumberLE:()=>ar,concatBytes:()=>Ve,createHmacDrbg:()=>Yi,ensureBytes:()=>Ot,equalBytes:()=>pl,hexToBytes:()=>Sr,hexToNumber:()=>Gi,numberToBytesBE:()=>cr,numberToBytesLE:()=>Br,numberToHexUnpadded:()=>ec,numberToVarBytesBE:()=>dl,utf8ToBytes:()=>yl,validateObject:()=>Ne});var tc=BigInt(0),Xn=BigInt(1),ll=BigInt(2),Qn=r=>r instanceof Uint8Array,hl=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function We(r){if(!Qn(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=hl[r[e]];return t}function ec(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Gi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Sr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let e=new Uint8Array(t/2);for(let n=0;n<e.length;n++){let o=n*2,i=r.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");e[n]=s}return e}function He(r){return Gi(We(r))}function ar(r){if(!Qn(r))throw new Error("Uint8Array expected");return Gi(We(Uint8Array.from(r).reverse()))}function cr(r,t){return Sr(r.toString(16).padStart(t*2,"0"))}function Br(r,t){return cr(r,t).reverse()}function dl(r){return Sr(ec(r))}function Ot(r,t,e){let n;if(typeof t=="string")try{n=Sr(t)}catch(i){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Qn(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function Ve(...r){let t=new Uint8Array(r.reduce((n,o)=>n+o.length,0)),e=0;return r.forEach(n=>{if(!Qn(n))throw new Error("Uint8Array expected");t.set(n,e),e+=n.length}),t}function pl(r,t){if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}function yl(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function gl(r){let t;for(t=0;r>tc;r>>=Xn,t+=1);return t}function ml(r,t){return r>>BigInt(t)&Xn}var bl=(r,t,e)=>r|(e?Xn:tc)<<BigInt(t),an=r=>(ll<<BigInt(r-1))-Xn,ji=r=>new Uint8Array(r),Qa=r=>Uint8Array.from(r);function Yi(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=ji(r),o=ji(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},h=(...k)=>e(o,n,...k),l=(k=ji())=>{o=h(Qa([0]),k),n=h(),k.length!==0&&(o=h(Qa([1]),k),n=h())},b=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let k=0,R=[];for(;k<t;){n=h();let I=n.slice();R.push(I),k+=n.length}return Ve(...R)};return(k,R)=>{s(),l(k);let I;for(;!(I=R(b()));)l();return s(),I}}var wl={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"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Ne(r,t,e={}){let n=(o,i,s)=>{let h=wl[i];if(typeof h!="function")throw new Error(`Invalid validator "${i}", expected function`);let l=r[o];if(!(s&&l===void 0)&&!h(l,r))throw new Error(`Invalid param ${String(o)}=${l} (${typeof l}), expected ${i}`)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var ne=BigInt(0),vt=BigInt(1),Er=BigInt(2),xl=BigInt(3),Zi=BigInt(4),rc=BigInt(5),nc=BigInt(8),vl=BigInt(9),kl=BigInt(16);function pt(r,t){let e=r%t;return e>=ne?e:t+e}function Sl(r,t,e){if(e<=ne||t<ne)throw new Error("Expected power/modulo > 0");if(e===vt)return ne;let n=vt;for(;t>ne;)t&vt&&(n=n*r%e),r=r*r%e,t>>=vt;return n}function kt(r,t,e){let n=r;for(;t-- >ne;)n*=n,n%=e;return n}function eo(r,t){if(r===ne||t<=ne)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=pt(r,t),n=t,o=ne,i=vt,s=vt,h=ne;for(;e!==ne;){let b=n/e,x=n%e,k=o-s*b,R=i-h*b;n=e,e=x,o=s,i=h,s=k,h=R}if(n!==vt)throw new Error("invert: does not exist");return pt(o,t)}function Bl(r){let t=(r-vt)/Er,e,n,o;for(e=r-vt,n=0;e%Er===ne;e/=Er,n++);for(o=Er;o<r&&Sl(o,t,r)!==r-vt;o++);if(n===1){let s=(r+vt)/Zi;return function(l,b){let x=l.pow(b,s);if(!l.eql(l.sqr(x),b))throw new Error("Cannot find square root");return x}}let i=(e+vt)/Er;return function(h,l){if(h.pow(l,t)===h.neg(h.ONE))throw new Error("Cannot find square root");let b=n,x=h.pow(h.mul(h.ONE,o),e),k=h.pow(l,i),R=h.pow(l,e);for(;!h.eql(R,h.ONE);){if(h.eql(R,h.ZERO))return h.ZERO;let I=1;for(let B=h.sqr(R);I<b&&!h.eql(B,h.ONE);I++)B=h.sqr(B);let P=h.pow(x,vt<<BigInt(b-I-1));x=h.sqr(P),k=h.mul(k,P),R=h.mul(R,x),b=I}return k}}function El(r){if(r%Zi===xl){let t=(r+vt)/Zi;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%nc===rc){let t=(r-rc)/nc;return function(n,o){let i=n.mul(o,Er),s=n.pow(i,t),h=n.mul(o,s),l=n.mul(n.mul(h,Er),s),b=n.mul(h,n.sub(l,n.ONE));if(!n.eql(n.sqr(b),o))throw new Error("Cannot find square root");return b}}return r%kl,Bl(r)}var oc=(r,t)=>(pt(r,t)&vt)===vt,_l=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ji(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=_l.reduce((n,o)=>(n[o]="function",n),t);return Ne(r,e)}function Il(r,t,e){if(e<ne)throw new Error("Expected power > 0");if(e===ne)return r.ONE;if(e===vt)return t;let n=r.ONE,o=t;for(;e>ne;)e&vt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=vt;return n}function Al(r,t){let e=new Array(t.length),n=t.reduce((i,s,h)=>r.is0(s)?i:(e[h]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return t.reduceRight((i,s,h)=>r.is0(s)?i:(e[h]=r.mul(i,e[h]),r.mul(i,s)),o),e}function Xi(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function ro(r,t,e=!1,n={}){if(r<=ne)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Xi(r,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=El(r),h=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:an(o),ZERO:ne,ONE:vt,create:l=>pt(l,r),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return ne<=l&&l<r},is0:l=>l===ne,isOdd:l=>(l&vt)===vt,neg:l=>pt(-l,r),eql:(l,b)=>l===b,sqr:l=>pt(l*l,r),add:(l,b)=>pt(l+b,r),sub:(l,b)=>pt(l-b,r),mul:(l,b)=>pt(l*b,r),pow:(l,b)=>Il(h,l,b),div:(l,b)=>pt(l*eo(b,r),r),sqrN:l=>l*l,addN:(l,b)=>l+b,subN:(l,b)=>l-b,mulN:(l,b)=>l*b,inv:l=>eo(l,r),sqrt:n.sqrt||(l=>s(h,l)),invertBatch:l=>Al(h,l),cmov:(l,b,x)=>x?b:l,toBytes:l=>e?Br(l,i):cr(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return e?ar(l):He(l)}});return Object.freeze(h)}function ic(r,t){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let e=r.sqrt(t);return r.isOdd(e)?r.neg(e):e}function sc(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Qi(r){let t=sc(r);return t+Math.ceil(t/2)}function ac(r,t,e=!1){let n=r.length,o=sc(t),i=Qi(t);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=e?He(r):ar(r),h=pt(s,t-vt)+vt;return e?Br(h,o):cr(h,o)}var Rl=BigInt(0),ts=BigInt(1);function no(r,t){let e=(o,i)=>{let s=i.negate();return o?s:i},n=o=>{let i=Math.ceil(t/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:e,unsafeLadder(o,i){let s=r.ZERO,h=o;for(;i>Rl;)i&ts&&(s=s.add(h)),h=h.double(),i>>=ts;return s},precomputeWindow(o,i){let{windows:s,windowSize:h}=n(i),l=[],b=o,x=b;for(let k=0;k<s;k++){x=b,l.push(x);for(let R=1;R<h;R++)x=x.add(b),l.push(x);b=x.double()}return l},wNAF(o,i,s){let{windows:h,windowSize:l}=n(o),b=r.ZERO,x=r.BASE,k=BigInt(2**o-1),R=2**o,I=BigInt(o);for(let P=0;P<h;P++){let B=P*l,A=Number(s&k);s>>=I,A>l&&(A-=R,s+=ts);let T=B,F=B+Math.abs(A)-1,N=P%2!==0,W=A<0;A===0?x=x.add(e(N,i[T])):b=b.add(e(W,i[F]))}return{p:b,f:x}},wNAFCached(o,i,s,h){let l=o._WINDOW_SIZE||1,b=i.get(o);return b||(b=this.precomputeWindow(o,l),l!==1&&i.set(o,h(b))),this.wNAF(l,b,s)}}}function cn(r){return Ji(r.Fp),Ne(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Xi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Me=BigInt(0),Se=BigInt(1),oo=BigInt(2),Tl=BigInt(8),Ml={zip215:!0};function Pl(r){let t=cn(r);return Ne(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function io(r){let t=Pl(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:h,h:l}=t,b=oo<<BigInt(h*8)-Se,x=e.create,k=t.uvRatio||((p,g)=>{try{return{isValid:!0,value:e.sqrt(p*e.inv(g))}}catch{return{isValid:!1,value:Me}}}),R=t.adjustScalarBytes||(p=>p),I=t.domain||((p,g,w)=>{if(g.length||w)throw new Error("Contexts/pre-hash are not supported");return p}),P=p=>typeof p=="bigint"&&Me<p,B=(p,g)=>P(p)&&P(g)&&p<g,A=p=>p===Me||B(p,b);function T(p,g){if(B(p,g))return p;throw new Error(`Expected valid scalar < ${g}, got ${typeof p} ${p}`)}function F(p){return p===Me?p:T(p,n)}let N=new Map;function W(p){if(!(p instanceof q))throw new Error("ExtendedPoint expected")}class q{constructor(g,w,y,c){if(this.ex=g,this.ey=w,this.ez=y,this.et=c,!A(g))throw new Error("x required");if(!A(w))throw new Error("y required");if(!A(y))throw new Error("z required");if(!A(c))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof q)throw new Error("extended point not allowed");let{x:w,y}=g||{};if(!A(w)||!A(y))throw new Error("invalid affine point");return new q(w,y,Se,x(w*y))}static normalizeZ(g){let w=e.invertBatch(g.map(y=>y.ez));return g.map((y,c)=>y.toAffine(w[c])).map(q.fromAffine)}_setWindowSize(g){this._WINDOW_SIZE=g,N.delete(this)}assertValidity(){let{a:g,d:w}=t;if(this.is0())throw new Error("bad point: ZERO");let{ex:y,ey:c,ez:m,et:M}=this,U=x(y*y),O=x(c*c),D=x(m*m),Y=x(D*D),J=x(U*g),mt=x(D*x(J+O)),Q=x(Y+x(w*x(U*O)));if(mt!==Q)throw new Error("bad point: equation left != right (1)");let tt=x(y*c),re=x(m*M);if(tt!==re)throw new Error("bad point: equation left != right (2)")}equals(g){W(g);let{ex:w,ey:y,ez:c}=this,{ex:m,ey:M,ez:U}=g,O=x(w*U),D=x(m*c),Y=x(y*U),J=x(M*c);return O===D&&Y===J}is0(){return this.equals(q.ZERO)}negate(){return new q(x(-this.ex),this.ey,this.ez,x(-this.et))}double(){let{a:g}=t,{ex:w,ey:y,ez:c}=this,m=x(w*w),M=x(y*y),U=x(oo*x(c*c)),O=x(g*m),D=w+y,Y=x(x(D*D)-m-M),J=O+M,mt=J-U,Q=O-M,tt=x(Y*mt),re=x(J*Q),ht=x(Y*Q),dt=x(mt*J);return new q(tt,re,dt,ht)}add(g){W(g);let{a:w,d:y}=t,{ex:c,ey:m,ez:M,et:U}=this,{ex:O,ey:D,ez:Y,et:J}=g;if(w===BigInt(-1)){let tn=x((m-c)*(D+O)),Et=x((m+c)*(D-O)),xt=x(Et-tn);if(xt===Me)return this.double();let en=x(M*oo*J),_t=x(U*oo*Y),It=_t+en,rn=Et+tn,At=_t-en,Mt=x(It*xt),Fn=x(rn*At),Pt=x(It*At),Ct=x(xt*rn);return new q(Mt,Fn,Ct,Pt)}let mt=x(c*O),Q=x(m*D),tt=x(U*y*J),re=x(M*Y),ht=x((c+m)*(O+D)-mt-Q),dt=re-tt,er=re+tt,Bt=x(Q-w*mt),Lt=x(ht*dt),qn=x(er*Bt),Rt=x(ht*Bt),Tt=x(dt*er);return new q(Lt,qn,Tt,Rt)}subtract(g){return this.add(g.negate())}wNAF(g){return j.wNAFCached(this,N,g,q.normalizeZ)}multiply(g){let{p:w,f:y}=this.wNAF(T(g,n));return q.normalizeZ([w,y])[0]}multiplyUnsafe(g){let w=F(g);return w===Me?H:this.equals(H)||w===Se?this:this.equals(z)?this.wNAF(w).p:j.unsafeLadder(this,w)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return j.unsafeLadder(this,n).is0()}toAffine(g){let{ex:w,ey:y,ez:c}=this,m=this.is0();g==null&&(g=m?Tl:e.inv(c));let M=x(w*g),U=x(y*g),O=x(c*g);if(m)return{x:Me,y:Se};if(O!==Se)throw new Error("invZ was invalid");return{x:M,y:U}}clearCofactor(){let{h:g}=t;return g===Se?this:this.multiplyUnsafe(g)}static fromHex(g,w=!1){let{d:y,a:c}=t,m=e.BYTES;g=Ot("pointHex",g,m);let M=g.slice(),U=g[m-1];M[m-1]=U&-129;let O=ar(M);O===Me||(w?T(O,b):T(O,e.ORDER));let D=x(O*O),Y=x(D-Se),J=x(y*D-c),{isValid:mt,value:Q}=k(Y,J);if(!mt)throw new Error("Point.fromHex: invalid y coordinate");let tt=(Q&Se)===Se,re=(U&128)!==0;if(!w&&Q===Me&&re)throw new Error("Point.fromHex: x=0 and x_0=1");return re!==tt&&(Q=x(-Q)),q.fromAffine({x:Q,y:O})}static fromPrivateKey(g){return G(g).point}toRawBytes(){let{x:g,y:w}=this.toAffine(),y=Br(w,e.BYTES);return y[y.length-1]|=g&Se?128:0,y}toHex(){return We(this.toRawBytes())}}q.BASE=new q(t.Gx,t.Gy,Se,x(t.Gx*t.Gy)),q.ZERO=new q(Me,Se,Se,Me);let{BASE:z,ZERO:H}=q,j=no(q,h*8);function ot(p){return pt(p,n)}function nt(p){return ot(ar(p))}function G(p){let g=h;p=Ot("private key",p,g);let w=Ot("hashed private key",i(p),2*g),y=R(w.slice(0,g)),c=w.slice(g,2*g),m=nt(y),M=z.multiply(m),U=M.toRawBytes();return{head:y,prefix:c,scalar:m,point:M,pointBytes:U}}function lt(p){return G(p).pointBytes}function v(p=new Uint8Array,...g){let w=Ve(...g);return nt(i(I(w,Ot("context",p),!!o)))}function a(p,g,w={}){p=Ot("message",p),o&&(p=o(p));let{prefix:y,scalar:c,pointBytes:m}=G(g),M=v(w.context,y,p),U=z.multiply(M).toRawBytes(),O=v(w.context,U,m,p),D=ot(M+O*c);F(D);let Y=Ve(U,Br(D,e.BYTES));return Ot("result",Y,h*2)}let u=Ml;function f(p,g,w,y=u){let{context:c,zip215:m}=y,M=e.BYTES;p=Ot("signature",p,2*M),g=Ot("message",g),o&&(g=o(g));let U=ar(p.slice(M,2*M)),O,D,Y;try{O=q.fromHex(w,m),D=q.fromHex(p.slice(0,M),m),Y=z.multiplyUnsafe(U)}catch{return!1}if(!m&&O.isSmallOrder())return!1;let J=v(c,D.toRawBytes(),O.toRawBytes(),g);return D.add(O.multiplyUnsafe(J)).subtract(Y).clearCofactor().equals(q.ZERO)}return z._setWindowSize(8),{CURVE:t,getPublicKey:lt,sign:a,verify:f,ExtendedPoint:q,utils:{getExtendedPublicKey:G,randomPrivateKey:()=>s(e.BYTES),precompute(p=8,g=q.BASE){return g._setWindowSize(p),g.multiply(BigInt(3)),g}}}}var rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),cc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),hp=BigInt(0),Cl=BigInt(1),es=BigInt(2),Ol=BigInt(5),uc=BigInt(10),Ul=BigInt(20),Nl=BigInt(40),fc=BigInt(80);function zl(r){let t=rs,n=r*r%t*r%t,o=kt(n,es,t)*n%t,i=kt(o,Cl,t)*r%t,s=kt(i,Ol,t)*i%t,h=kt(s,uc,t)*s%t,l=kt(h,Ul,t)*h%t,b=kt(l,Nl,t)*l%t,x=kt(b,fc,t)*b%t,k=kt(x,fc,t)*b%t,R=kt(k,uc,t)*s%t;return{pow_p_5_8:kt(R,es,t)*r%t,b2:n}}function ql(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Fl(r,t){let e=rs,n=pt(t*t*t,e),o=pt(n*n*t,e),i=zl(r*o).pow_p_5_8,s=pt(r*n*i,e),h=pt(t*s*s,e),l=s,b=pt(s*cc,e),x=h===r,k=h===pt(-r,e),R=h===pt(-r*cc,e);return x&&(s=l),(k||R)&&(s=b),oc(s,e)&&(s=pt(-s,e)),{isValid:x||k,value:s}}var $e=ro(rs,void 0,!0),ns={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:$e,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:$i,randomBytes:Zn,adjustScalarBytes:ql,uvRatio:Fl},_r=io(ns);function lc(r,t,e){if(t.length>255)throw new Error("Context is too big");return Yn(zi("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var dp=io({...ns,domain:lc}),pp=io({...ns,domain:lc,prehash:$i});var Dl=($e.ORDER+BigInt(3))/BigInt(8),yp=$e.pow(es,Dl),gp=$e.sqrt($e.neg($e.ONE)),mp=($e.ORDER-BigInt(5))/BigInt(8),bp=BigInt(486662);var wp=ic($e,$e.neg(BigInt(486664)));var xp=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),vp=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),kp=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Sp=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Bp=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Zs=Re(is()),ve=Re(as());var Vl=(r,t,e)=>r&t^~r&e,$l=(r,t,e)=>r&t^r&e^t&e,jl=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]),ur=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fr=new Uint32Array(64),cs=class extends Fr{constructor(){super(64,32,8,!1),this.A=ur[0]|0,this.B=ur[1]|0,this.C=ur[2]|0,this.D=ur[3]|0,this.E=ur[4]|0,this.F=ur[5]|0,this.G=ur[6]|0,this.H=ur[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:h,H:l}=this;return[t,e,n,o,i,s,h,l]}set(t,e,n,o,i,s,h,l){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=h|0,this.H=l|0}process(t,e){for(let k=0;k<16;k++,e+=4)fr[k]=t.getUint32(e,!1);for(let k=16;k<64;k++){let R=fr[k-15],I=fr[k-2],P=Te(R,7)^Te(R,18)^R>>>3,B=Te(I,17)^Te(I,19)^I>>>10;fr[k]=B+fr[k-7]+P+fr[k-16]|0}let{A:n,B:o,C:i,D:s,E:h,F:l,G:b,H:x}=this;for(let k=0;k<64;k++){let R=Te(h,6)^Te(h,11)^Te(h,25),I=x+R+Vl(h,l,b)+jl[k]+fr[k]|0,B=(Te(n,2)^Te(n,13)^Te(n,22))+$l(n,o,i)|0;x=b,b=l,l=h,h=s+I|0,s=i,i=o,o=n,n=I+B|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,h=h+this.E|0,l=l+this.F|0,b=b+this.G|0,x=x+this.H|0,this.set(n,o,i,s,h,l,b,x)}roundClean(){fr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var un=qr(()=>new cs);var Xr=Re(Ec()),S=Re(ms()),Wu=Re(ms()),zn=Re(_c());var bs=class extends TypeError{constructor(t,e){let n,{message:o,...i}=t,{path:s}=t,h=s.length===0?o:"At path: "+s.join(".")+" -- "+o;super(h),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>{var l;return(l=n)!=null?l:n=[t,...e()]}}};function ph(r){return dr(r)&&typeof r[Symbol.iterator]=="function"}function dr(r){return typeof r=="object"&&r!=null}function Pe(r){return typeof r=="string"?JSON.stringify(r):""+r}function yh(r){let{done:t,value:e}=r.next();return t?void 0:e}function gh(r,t,e,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});let{path:o,branch:i}=t,{type:s}=e,{refinement:h,message:l="Expected a value of type `"+s+"`"+(h?" with refinement `"+h+"`":"")+", but received: `"+Pe(n)+"`"}=r;return{value:n,type:s,refinement:h,key:o[o.length-1],path:o,branch:i,...r,message:l}}function*Ic(r,t,e,n){ph(r)||(r=[r]);for(let o of r){let i=gh(o,t,e,n);i&&(yield i)}}function*ws(r,t,e={}){let{path:n=[],branch:o=[r],coerce:i=!1,mask:s=!1}=e,h={path:n,branch:o};if(i&&(r=t.coercer(r,h),s&&t.type!=="type"&&dr(t.schema)&&dr(r)&&!Array.isArray(r)))for(let b in r)t.schema[b]===void 0&&delete r[b];let l=!0;for(let b of t.validator(r,h))l=!1,yield[b,void 0];for(let[b,x,k]of t.entries(r,h)){let R=ws(x,k,{path:b===void 0?n:[...n,b],branch:b===void 0?o:[...o,x],coerce:i,mask:s});for(let I of R)I[0]?(l=!1,yield[I[0],void 0]):i&&(x=I[1],b===void 0?r=x:r instanceof Map?r.set(b,x):r instanceof Set?r.add(x):dr(r)&&(r[b]=x))}if(l)for(let b of t.refiner(r,h))l=!1,yield[b,void 0];l&&(yield[void 0,r])}var _e=class{constructor(t){let{type:e,schema:n,validator:o,refiner:i,coercer:s=l=>l,entries:h=function*(){}}=t;this.type=e,this.schema=n,this.entries=h,this.coercer=s,o?this.validator=(l,b)=>{let x=o(l,b);return Ic(x,b,this,l)}:this.validator=()=>[],i?this.refiner=(l,b)=>{let x=i(l,b);return Ic(x,b,this,l)}:this.refiner=()=>[]}assert(t){return Ac(t,this)}create(t){return $r(t,this)}is(t){return Lc(t,this)}mask(t){return mh(t,this)}validate(t,e={}){return yn(t,this,e)}};function Ac(r,t){let e=yn(r,t);if(e[0])throw e[0]}function $r(r,t){let e=yn(r,t,{coerce:!0});if(e[0])throw e[0];return e[1]}function mh(r,t){let e=yn(r,t,{coerce:!0,mask:!0});if(e[0])throw e[0];return e[1]}function Lc(r,t){return!yn(r,t)[0]}function yn(r,t,e={}){let n=ws(r,t,e),o=yh(n);return o[0]?[new bs(o[0],function*(){for(let s of n)s[0]&&(yield s[0])}),void 0]:[void 0,o[1]]}function Rr(r,t){return new _e({type:r,schema:null,validator:t})}function Rc(){return Rr("any",()=>!0)}function $(r){return new _e({type:"array",schema:r,*entries(t){if(r&&Array.isArray(t))for(let[e,n]of t.entries())yield[e,n,r]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||"Expected an array value, but received: "+Pe(t)}})}function Ce(){return Rr("boolean",r=>typeof r=="boolean")}function Oo(r){return Rr("instance",t=>t instanceof r||"Expected a `"+r.name+"` instance, but received: "+Pe(t))}function St(r){let t=Pe(r),e=typeof r;return new _e({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?r:null,validator(n){return n===r||"Expected the literal `"+t+"`, but received: "+Pe(n)}})}function bh(){return Rr("never",()=>!1)}function V(r){return new _e({...r,validator:(t,e)=>t===null||r.validator(t,e),refiner:(t,e)=>t===null||r.refiner(t,e)})}function E(){return Rr("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+Pe(r))}function Z(r){return new _e({...r,validator:(t,e)=>t===void 0||r.validator(t,e),refiner:(t,e)=>t===void 0||r.refiner(t,e)})}function xs(r,t){return new _e({type:"record",schema:null,*entries(e){if(dr(e))for(let n in e){let o=e[n];yield[n,n,r],yield[n,o,t]}},validator(e){return dr(e)||"Expected an object, but received: "+Pe(e)}})}function K(){return Rr("string",r=>typeof r=="string"||"Expected a string, but received: "+Pe(r))}function Uo(r){let t=bh();return new _e({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){let n=Math.max(r.length,e.length);for(let o=0;o<n;o++)yield[o,e[o],r[o]||t]}},validator(e){return Array.isArray(e)||"Expected an array, but received: "+Pe(e)}})}function C(r){let t=Object.keys(r);return new _e({type:"type",schema:r,*entries(e){if(dr(e))for(let n of t)yield[n,e[n],r[n]]},validator(e){return dr(e)||"Expected an object, but received: "+Pe(e)}})}function me(r){let t=r.map(e=>e.type).join(" | ");return new _e({type:"union",schema:null,validator(e,n){let o=[];for(let i of r){let[...s]=ws(e,i,n),[h]=s;if(h[0])for(let[l]of s)l&&o.push(l);else return[]}return["Expected the value to satisfy a union of `"+t+"`, but received: "+Pe(e),...o]}})}function jr(){return Rr("unknown",()=>!0)}function Gr(r,t,e){return new _e({...r,coercer:(n,o)=>Lc(n,t)?r.coercer(e(n,o),o):r.coercer(n,o)})}var Fd=Re(tu()),Dd=Re(gu()),Kd=Re(bu());var[vu,ku,Su]=[[],[],[]],Bd=BigInt(0),Tn=BigInt(1),Ed=BigInt(2),_d=BigInt(7),Id=BigInt(256),Ad=BigInt(113);for(let r=0,t=Tn,e=1,n=0;r<24;r++){[e,n]=[n,(2*e+3*n)%5],vu.push(2*(5*n+e)),ku.push((r+1)*(r+2)/2%64);let o=Bd;for(let i=0;i<7;i++)t=(t<<Tn^(t>>_d)*Ad)%Id,t&Ed&&(o^=Tn<<(Tn<<BigInt(i))-Tn);Su.push(o)}var[Ld,Rd]=Fi(Su,!0),wu=(r,t,e)=>e>32?Wi(r,t,e):Di(r,t,e),xu=(r,t,e)=>e>32?Hi(r,t,e):Ki(r,t,e);function Td(r,t=24){let e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let s=0;s<10;s++)e[s]=r[s]^r[s+10]^r[s+20]^r[s+30]^r[s+40];for(let s=0;s<10;s+=2){let h=(s+8)%10,l=(s+2)%10,b=e[l],x=e[l+1],k=wu(b,x,1)^e[h],R=xu(b,x,1)^e[h+1];for(let I=0;I<50;I+=10)r[s+I]^=k,r[s+I+1]^=R}let o=r[2],i=r[3];for(let s=0;s<24;s++){let h=ku[s],l=wu(o,i,h),b=xu(o,i,h),x=vu[s];o=r[x],i=r[x+1],r[x]=l,r[x+1]=b}for(let s=0;s<50;s+=10){for(let h=0;h<10;h++)e[h]=r[s+h];for(let h=0;h<10;h++)r[s+h]^=~e[(h+2)%10]&e[(h+4)%10]}r[0]^=Ld[n],r[1]^=Rd[n]}e.fill(0)}var $o=class r extends nr{constructor(t,e,n,o=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=o,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,on(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Za(this.state)}keccak(){Td(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Ke(this);let{blockLen:e,state:n}=this;t=or(t);let o=t.length;for(let i=0;i<o;){let s=Math.min(e-this.pos,o-i);for(let h=0;h<s;h++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:e,pos:n,blockLen:o}=this;t[n]^=e,(e&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){Ke(this,!1),sn(t),this.finish();let e=this.state,{blockLen:n}=this;for(let o=0,i=t.length;o<i;){this.posOut>=n&&this.keccak();let s=Math.min(n-this.posOut,i-o);t.set(e.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return on(t),this.xofInto(new Uint8Array(t))}digestInto(t){if($n(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:e,suffix:n,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new r(e,n,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}},wr=(r,t,e)=>qr(()=>new $o(t,r,e)),Wy=wr(6,144,224/8),Hy=wr(6,136,256/8),Vy=wr(6,104,384/8),$y=wr(6,72,512/8),jy=wr(1,144,224/8),Ks=wr(1,136,256/8),Gy=wr(1,104,384/8),Yy=wr(1,72,512/8),Bu=(r,t,e)=>Ja((n={})=>new $o(t,r,n.dkLen===void 0?e:n.dkLen,!0)),Zy=Bu(31,168,128/8),Jy=Bu(31,136,256/8);function Md(r){let t=cn(r);Ne(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Pd,hexToBytes:Cd}=to,Tr={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Tr;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Pd(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Tr,e=typeof r=="string"?Cd(r):r;if(!(e instanceof Uint8Array))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:o,l:i}=Tr._parseInt(e.subarray(2)),{d:s,l:h}=Tr._parseInt(i);if(h.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(r){let t=b=>Number.parseInt(b[0],16)&8?"00"+b:b,e=b=>{let x=b.toString(16);return x.length&1?`0${x}`:x},n=t(e(r.s)),o=t(e(r.r)),i=n.length/2,s=o.length/2,h=e(i),l=e(s);return`30${e(s+i+4)}02${l}${o}02${h}${n}`}},Qe=BigInt(0),Ie=BigInt(1),rg=BigInt(2),Eu=BigInt(3),ng=BigInt(4);function Od(r){let t=Md(r),{Fp:e}=t,n=t.toBytes||((P,B,A)=>{let T=B.toAffine();return Ve(Uint8Array.from([4]),e.toBytes(T.x),e.toBytes(T.y))}),o=t.fromBytes||(P=>{let B=P.subarray(1),A=e.fromBytes(B.subarray(0,e.BYTES)),T=e.fromBytes(B.subarray(e.BYTES,2*e.BYTES));return{x:A,y:T}});function i(P){let{a:B,b:A}=t,T=e.sqr(P),F=e.mul(T,P);return e.add(e.add(F,e.mul(P,B)),A)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(P){return typeof P=="bigint"&&Qe<P&&P<t.n}function h(P){if(!s(P))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(P){let{allowedPrivateKeyLengths:B,nByteLength:A,wrapPrivateKey:T,n:F}=t;if(B&&typeof P!="bigint"){if(P instanceof Uint8Array&&(P=We(P)),typeof P!="string"||!B.includes(P.length))throw new Error("Invalid key");P=P.padStart(A*2,"0")}let N;try{N=typeof P=="bigint"?P:He(Ot("private key",P,A))}catch{throw new Error(`private key must be ${A} bytes, hex or bigint, not ${typeof P}`)}return T&&(N=pt(N,F)),h(N),N}let b=new Map;function x(P){if(!(P instanceof k))throw new Error("ProjectivePoint expected")}class k{constructor(B,A,T){if(this.px=B,this.py=A,this.pz=T,B==null||!e.isValid(B))throw new Error("x required");if(A==null||!e.isValid(A))throw new Error("y required");if(T==null||!e.isValid(T))throw new Error("z required")}static fromAffine(B){let{x:A,y:T}=B||{};if(!B||!e.isValid(A)||!e.isValid(T))throw new Error("invalid affine point");if(B instanceof k)throw new Error("projective point not allowed");let F=N=>e.eql(N,e.ZERO);return F(A)&&F(T)?k.ZERO:new k(A,T,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(B){let A=e.invertBatch(B.map(T=>T.pz));return B.map((T,F)=>T.toAffine(A[F])).map(k.fromAffine)}static fromHex(B){let A=k.fromAffine(o(Ot("pointHex",B)));return A.assertValidity(),A}static fromPrivateKey(B){return k.BASE.multiply(l(B))}_setWindowSize(B){this._WINDOW_SIZE=B,b.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:B,y:A}=this.toAffine();if(!e.isValid(B)||!e.isValid(A))throw new Error("bad point: x or y not FE");let T=e.sqr(A),F=i(B);if(!e.eql(T,F))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:B}=this.toAffine();if(e.isOdd)return!e.isOdd(B);throw new Error("Field doesn't support isOdd")}equals(B){x(B);let{px:A,py:T,pz:F}=this,{px:N,py:W,pz:q}=B,z=e.eql(e.mul(A,q),e.mul(N,F)),H=e.eql(e.mul(T,q),e.mul(W,F));return z&&H}negate(){return new k(this.px,e.neg(this.py),this.pz)}double(){let{a:B,b:A}=t,T=e.mul(A,Eu),{px:F,py:N,pz:W}=this,q=e.ZERO,z=e.ZERO,H=e.ZERO,j=e.mul(F,F),ot=e.mul(N,N),nt=e.mul(W,W),G=e.mul(F,N);return G=e.add(G,G),H=e.mul(F,W),H=e.add(H,H),q=e.mul(B,H),z=e.mul(T,nt),z=e.add(q,z),q=e.sub(ot,z),z=e.add(ot,z),z=e.mul(q,z),q=e.mul(G,q),H=e.mul(T,H),nt=e.mul(B,nt),G=e.sub(j,nt),G=e.mul(B,G),G=e.add(G,H),H=e.add(j,j),j=e.add(H,j),j=e.add(j,nt),j=e.mul(j,G),z=e.add(z,j),nt=e.mul(N,W),nt=e.add(nt,nt),j=e.mul(nt,G),q=e.sub(q,j),H=e.mul(nt,ot),H=e.add(H,H),H=e.add(H,H),new k(q,z,H)}add(B){x(B);let{px:A,py:T,pz:F}=this,{px:N,py:W,pz:q}=B,z=e.ZERO,H=e.ZERO,j=e.ZERO,ot=t.a,nt=e.mul(t.b,Eu),G=e.mul(A,N),lt=e.mul(T,W),v=e.mul(F,q),a=e.add(A,T),u=e.add(N,W);a=e.mul(a,u),u=e.add(G,lt),a=e.sub(a,u),u=e.add(A,F);let f=e.add(N,q);return u=e.mul(u,f),f=e.add(G,v),u=e.sub(u,f),f=e.add(T,F),z=e.add(W,q),f=e.mul(f,z),z=e.add(lt,v),f=e.sub(f,z),j=e.mul(ot,u),z=e.mul(nt,v),j=e.add(z,j),z=e.sub(lt,j),j=e.add(lt,j),H=e.mul(z,j),lt=e.add(G,G),lt=e.add(lt,G),v=e.mul(ot,v),u=e.mul(nt,u),lt=e.add(lt,v),v=e.sub(G,v),v=e.mul(ot,v),u=e.add(u,v),G=e.mul(lt,u),H=e.add(H,G),G=e.mul(f,u),z=e.mul(a,z),z=e.sub(z,G),G=e.mul(a,lt),j=e.mul(f,j),j=e.add(j,G),new k(z,H,j)}subtract(B){return this.add(B.negate())}is0(){return this.equals(k.ZERO)}wNAF(B){return I.wNAFCached(this,b,B,A=>{let T=e.invertBatch(A.map(F=>F.pz));return A.map((F,N)=>F.toAffine(T[N])).map(k.fromAffine)})}multiplyUnsafe(B){let A=k.ZERO;if(B===Qe)return A;if(h(B),B===Ie)return this;let{endo:T}=t;if(!T)return I.unsafeLadder(this,B);let{k1neg:F,k1:N,k2neg:W,k2:q}=T.splitScalar(B),z=A,H=A,j=this;for(;N>Qe||q>Qe;)N&Ie&&(z=z.add(j)),q&Ie&&(H=H.add(j)),j=j.double(),N>>=Ie,q>>=Ie;return F&&(z=z.negate()),W&&(H=H.negate()),H=new k(e.mul(H.px,T.beta),H.py,H.pz),z.add(H)}multiply(B){h(B);let A=B,T,F,{endo:N}=t;if(N){let{k1neg:W,k1:q,k2neg:z,k2:H}=N.splitScalar(A),{p:j,f:ot}=this.wNAF(q),{p:nt,f:G}=this.wNAF(H);j=I.constTimeNegate(W,j),nt=I.constTimeNegate(z,nt),nt=new k(e.mul(nt.px,N.beta),nt.py,nt.pz),T=j.add(nt),F=ot.add(G)}else{let{p:W,f:q}=this.wNAF(A);T=W,F=q}return k.normalizeZ([T,F])[0]}multiplyAndAddUnsafe(B,A,T){let F=k.BASE,N=(q,z)=>z===Qe||z===Ie||!q.equals(F)?q.multiplyUnsafe(z):q.multiply(z),W=N(this,A).add(N(B,T));return W.is0()?void 0:W}toAffine(B){let{px:A,py:T,pz:F}=this,N=this.is0();B==null&&(B=N?e.ONE:e.inv(F));let W=e.mul(A,B),q=e.mul(T,B),z=e.mul(F,B);if(N)return{x:e.ZERO,y:e.ZERO};if(!e.eql(z,e.ONE))throw new Error("invZ was invalid");return{x:W,y:q}}isTorsionFree(){let{h:B,isTorsionFree:A}=t;if(B===Ie)return!0;if(A)return A(k,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:B,clearCofactor:A}=t;return B===Ie?this:A?A(k,this):this.multiplyUnsafe(t.h)}toRawBytes(B=!0){return this.assertValidity(),n(k,this,B)}toHex(B=!0){return We(this.toRawBytes(B))}}k.BASE=new k(t.Gx,t.Gy,e.ONE),k.ZERO=new k(e.ZERO,e.ONE,e.ZERO);let R=t.nBitLength,I=no(k,t.endo?Math.ceil(R/2):R);return{CURVE:t,ProjectivePoint:k,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:s}}function Ud(r){let t=cn(r);return Ne(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function _u(r){let t=Ud(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(u){return Qe<u&&u<e.ORDER}function h(u){return pt(u,n)}function l(u){return eo(u,n)}let{ProjectivePoint:b,normPrivateKeyToScalar:x,weierstrassEquation:k,isWithinCurveOrder:R}=Od({...t,toBytes(u,f,d){let p=f.toAffine(),g=e.toBytes(p.x),w=Ve;return d?w(Uint8Array.from([f.hasEvenY()?2:3]),g):w(Uint8Array.from([4]),g,e.toBytes(p.y))},fromBytes(u){let f=u.length,d=u[0],p=u.subarray(1);if(f===o&&(d===2||d===3)){let g=He(p);if(!s(g))throw new Error("Point is not on curve");let w=k(g),y=e.sqrt(w),c=(y&Ie)===Ie;return(d&1)===1!==c&&(y=e.neg(y)),{x:g,y}}else if(f===i&&d===4){let g=e.fromBytes(p.subarray(0,e.BYTES)),w=e.fromBytes(p.subarray(e.BYTES,2*e.BYTES));return{x:g,y:w}}else throw new Error(`Point of length ${f} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),I=u=>We(cr(u,t.nByteLength));function P(u){let f=n>>Ie;return u>f}function B(u){return P(u)?h(-u):u}let A=(u,f,d)=>He(u.slice(f,d));class T{constructor(f,d,p){this.r=f,this.s=d,this.recovery=p,this.assertValidity()}static fromCompact(f){let d=t.nByteLength;return f=Ot("compactSignature",f,d*2),new T(A(f,0,d),A(f,d,2*d))}static fromDER(f){let{r:d,s:p}=Tr.toSig(Ot("DER",f));return new T(d,p)}assertValidity(){if(!R(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!R(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(f){return new T(this.r,this.s,f)}recoverPublicKey(f){let{r:d,s:p,recovery:g}=this,w=H(Ot("msgHash",f));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let y=g===2||g===3?d+t.n:d;if(y>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let c=(g&1)===0?"02":"03",m=b.fromHex(c+I(y)),M=l(y),U=h(-w*M),O=h(p*M),D=b.BASE.multiplyAndAddUnsafe(m,U,O);if(!D)throw new Error("point at infinify");return D.assertValidity(),D}hasHighS(){return P(this.s)}normalizeS(){return this.hasHighS()?new T(this.r,h(-this.s),this.recovery):this}toDERRawBytes(){return Sr(this.toDERHex())}toDERHex(){return Tr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Sr(this.toCompactHex())}toCompactHex(){return I(this.r)+I(this.s)}}let F={isValidPrivateKey(u){try{return x(u),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{let u=Qi(t.n);return ac(t.randomBytes(u),t.n)},precompute(u=8,f=b.BASE){return f._setWindowSize(u),f.multiply(BigInt(3)),f}};function N(u,f=!0){return b.fromPrivateKey(u).toRawBytes(f)}function W(u){let f=u instanceof Uint8Array,d=typeof u=="string",p=(f||d)&&u.length;return f?p===o||p===i:d?p===2*o||p===2*i:u instanceof b}function q(u,f,d=!0){if(W(u))throw new Error("first arg must be private key");if(!W(f))throw new Error("second arg must be public key");return b.fromHex(f).multiply(x(u)).toRawBytes(d)}let z=t.bits2int||function(u){let f=He(u),d=u.length*8-t.nBitLength;return d>0?f>>BigInt(d):f},H=t.bits2int_modN||function(u){return h(z(u))},j=an(t.nBitLength);function ot(u){if(typeof u!="bigint")throw new Error("bigint expected");if(!(Qe<=u&&u<j))throw new Error(`bigint expected < 2^${t.nBitLength}`);return cr(u,t.nByteLength)}function nt(u,f,d=G){if(["recovered","canonical"].some(J=>J in d))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:g}=t,{lowS:w,prehash:y,extraEntropy:c}=d;w==null&&(w=!0),u=Ot("msgHash",u),y&&(u=Ot("prehashed msgHash",p(u)));let m=H(u),M=x(f),U=[ot(M),ot(m)];if(c!=null){let J=c===!0?g(e.BYTES):c;U.push(Ot("extraEntropy",J))}let O=Ve(...U),D=m;function Y(J){let mt=z(J);if(!R(mt))return;let Q=l(mt),tt=b.BASE.multiply(mt).toAffine(),re=h(tt.x);if(re===Qe)return;let ht=h(Q*h(D+re*M));if(ht===Qe)return;let dt=(tt.x===re?0:2)|Number(tt.y&Ie),er=ht;return w&&P(ht)&&(er=B(ht),dt^=1),new T(re,er,dt)}return{seed:O,k2sig:Y}}let G={lowS:t.lowS,prehash:!1},lt={lowS:t.lowS,prehash:!1};function v(u,f,d=G){let{seed:p,k2sig:g}=nt(u,f,d),w=t;return Yi(w.hash.outputLen,w.nByteLength,w.hmac)(p,g)}b.BASE._setWindowSize(8);function a(u,f,d,p=lt){let g=u;if(f=Ot("msgHash",f),d=Ot("publicKey",d),"strict"in p)throw new Error("options.strict was renamed to lowS");let{lowS:w,prehash:y}=p,c,m;try{if(typeof g=="string"||g instanceof Uint8Array)try{c=T.fromDER(g)}catch(tt){if(!(tt instanceof Tr.Err))throw tt;c=T.fromCompact(g)}else if(typeof g=="object"&&typeof g.r=="bigint"&&typeof g.s=="bigint"){let{r:tt,s:re}=g;c=new T(tt,re)}else throw new Error("PARSE");m=b.fromHex(d)}catch(tt){if(tt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(w&&c.hasHighS())return!1;y&&(f=t.hash(f));let{r:M,s:U}=c,O=H(f),D=l(U),Y=h(O*D),J=h(M*D),mt=b.BASE.multiplyAndAddUnsafe(m,Y,J)?.toAffine();return mt?h(mt.x)===M:!1}return{CURVE:t,getPublicKey:N,getSharedSecret:q,sign:v,verify:a,ProjectivePoint:b,Signature:T,utils:F}}var jo=class extends nr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Ga(t);let n=or(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return Ke(this),this.iHash.update(t),this}digestInto(t){Ke(this),sn(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:h}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=h,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ws=(r,t,e)=>new jo(r,t).update(e).digest();Ws.create=(r,t)=>new jo(r,t);function Nd(r){return{hash:r,hmac:(t,...e)=>Ws(r,t,Yn(...e)),randomBytes:Zn}}function Iu(r,t){let e=n=>_u({...r,...Nd(n)});return Object.freeze({...e(t),create:e})}var Ru=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Au=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),zd=BigInt(1),Hs=BigInt(2),Lu=(r,t)=>(r+t/Hs)/t;function qd(r){let t=Ru,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),h=BigInt(44),l=BigInt(88),b=r*r*r%t,x=b*b*r%t,k=kt(x,e,t)*x%t,R=kt(k,e,t)*x%t,I=kt(R,Hs,t)*b%t,P=kt(I,o,t)*I%t,B=kt(P,i,t)*P%t,A=kt(B,h,t)*B%t,T=kt(A,l,t)*A%t,F=kt(T,h,t)*B%t,N=kt(F,e,t)*x%t,W=kt(N,s,t)*P%t,q=kt(W,n,t)*b%t,z=kt(q,Hs,t);if(!Vs.eql(Vs.sqr(z),r))throw new Error("Cannot find square root");return z}var Vs=ro(Ru,void 0,void 0,{sqrt:qd}),Mn=Iu({a:BigInt(0),b:BigInt(7),Fp:Vs,n:Au,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Au,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-zd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),h=Lu(i*r,t),l=Lu(-n*r,t),b=pt(r-h*e-l*o,t),x=pt(-h*n-l*i,t),k=b>s,R=x>s;if(k&&(b=t-b),R&&(x=t-x),b>s||x>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:k,k1:b,k2neg:R,k2:x}}}},un),yg=BigInt(0);var gg=Mn.ProjectivePoint;var Sg=_r.utils.randomPrivateKey,Tu=()=>{let r=_r.utils.randomPrivateKey(),t=Js(r),e=new Uint8Array(64);return e.set(r),e.set(t,32),{publicKey:t,secretKey:e}},Js=_r.getPublicKey;function Mu(r){try{return _r.ExtendedPoint.fromHex(r),!0}catch{return!1}}var Hu=(r,t)=>_r.sign(r,t.slice(0,32)),Wd=_r.verify,ut=r=>X.Buffer.isBuffer(r)?r:r instanceof Uint8Array?X.Buffer.from(r.buffer,r.byteOffset,r.byteLength):X.Buffer.from(r),Xs=class{constructor(t){Object.assign(this,t)}encode(){return X.Buffer.from((0,Xr.serialize)(Zo,this))}static decode(t){return(0,Xr.deserialize)(Zo,this,t)}static decodeUnchecked(t){return(0,Xr.deserializeUnchecked)(Zo,this,t)}};var Zo=new Map,Vu,$u,Hd=32,Mr=32;function Vd(r){return r._bn!==void 0}var Pu=1;$u=Symbol.toStringTag;var rt=class r extends Xs{constructor(t){if(super({}),this._bn=void 0,Vd(t))this._bn=t._bn;else{if(typeof t=="string"){let e=ve.default.decode(t);if(e.length!=Mr)throw new Error("Invalid public key input");this._bn=new Zs.default(e)}else this._bn=new Zs.default(t);if(this._bn.byteLength()>Mr)throw new Error("Invalid public key input")}}static unique(){let t=new r(Pu);return Pu+=1,new r(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ve.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){let t=this._bn.toArrayLike(X.Buffer);if(t.length===Mr)return t;let e=X.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[$u](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,n){let o=X.Buffer.concat([t.toBuffer(),X.Buffer.from(e),n.toBuffer()]),i=un(o);return new r(i)}static createProgramAddressSync(t,e){let n=X.Buffer.alloc(0);t.forEach(function(i){if(i.length>Hd)throw new TypeError("Max seed length exceeded");n=X.Buffer.concat([n,ut(i)])}),n=X.Buffer.concat([n,e.toBuffer(),X.Buffer.from("ProgramDerivedAddress")]);let o=un(n);if(Mu(o))throw new Error("Invalid seeds, address must fall off the curve");return new r(o)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n=255,o;for(;n!=0;){try{let i=t.concat(X.Buffer.from([n]));o=this.createProgramAddressSync(i,e)}catch(i){if(i instanceof TypeError)throw i;n--;continue}return[o,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){let e=new r(t);return Mu(e.toBytes())}};Vu=rt;rt.default=new Vu("11111111111111111111111111111111");Zo.set(rt,{kind:"struct",fields:[["_bn","u256"]]});var Bg=new rt("BPFLoader1111111111111111111111111111111111"),Jo=1232,$d=127,Qs=64,ta=class extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}};Object.defineProperty(ta.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});var ea=class extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}};Object.defineProperty(ea.prototype,"name",{value:"TransactionExpiredTimeoutError"});var ra=class extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}};Object.defineProperty(ra.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});var Xo=class{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){let t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(let e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");let n=new Map;this.keySegments().flat().forEach((i,s)=>{n.set(i.toBase58(),s)});let o=i=>{let s=n.get(i.toBase58());if(s===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return s};return t.map(i=>({programIdIndex:o(i.programId),accountKeyIndexes:i.keys.map(s=>o(s.pubkey)),data:i.data}))}},st=(r="publicKey")=>S.blob(32,r);var Zr=(r="string")=>{let t=S.struct([S.u32("length"),S.u32("lengthPadding"),S.blob(S.offset(S.u32(),-8),"chars")],r),e=t.decode.bind(t),n=t.encode.bind(t),o=t;return o.decode=(i,s)=>e(i,s).chars.toString(),o.encode=(i,s,h)=>{let l={chars:X.Buffer.from(i,"utf8")};return n(l,s,h)},o.alloc=i=>S.u32().span+S.u32().span+X.Buffer.from(i,"utf8").length,o},jd=(r="authorized")=>S.struct([st("staker"),st("withdrawer")],r),Gd=(r="lockup")=>S.struct([S.ns64("unixTimestamp"),S.ns64("epoch"),st("custodian")],r),Yd=(r="voteInit")=>S.struct([st("nodePubkey"),st("authorizedVoter"),st("authorizedWithdrawer"),S.u8("commission")],r),Zd=(r="voteAuthorizeWithSeedArgs")=>S.struct([S.u32("voteAuthorizationType"),st("currentAuthorityDerivedKeyOwnerPubkey"),Zr("currentAuthorityDerivedKeySeed"),st("newAuthorized")],r);function ju(r,t){let e=o=>{if(o.span>=0)return o.span;if(typeof o.alloc=="function")return o.alloc(t[o.property]);if("count"in o&&"elementLayout"in o){let i=t[o.property];if(Array.isArray(i))return i.length*e(o.elementLayout)}else if("fields"in o)return ju({layout:o},t[o.property]);return 0},n=0;return r.layout.fields.forEach(o=>{n+=e(o)}),n}function Cn(r){let t=0,e=0;for(;;){let n=r.shift();if(t|=(n&127)<<e*7,e+=1,(n&128)===0)break}return t}function On(r,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){r.push(n);break}else n|=128,r.push(n)}}function oe(r,t){if(!r)throw new Error(t||"Assertion failed")}var na=class r{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){let n=new Map,o=s=>{let h=s.toBase58(),l=n.get(h);return l===void 0&&(l={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(h,l)),l},i=o(e);i.isSigner=!0,i.isWritable=!0;for(let s of t){o(s.programId).isInvoked=!0;for(let h of s.keys){let l=o(h.pubkey);l.isSigner||=h.isSigner,l.isWritable||=h.isWritable}}return new r(e,n)}getMessageComponents(){let t=[...this.keyMetaMap.entries()];oe(t.length<=256,"Max static account keys length exceeded");let e=t.filter(([,l])=>l.isSigner&&l.isWritable),n=t.filter(([,l])=>l.isSigner&&!l.isWritable),o=t.filter(([,l])=>!l.isSigner&&l.isWritable),i=t.filter(([,l])=>!l.isSigner&&!l.isWritable),s={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{oe(e.length>0,"Expected at least one writable signer key");let[l]=e[0];oe(l===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let h=[...e.map(([l])=>new rt(l)),...n.map(([l])=>new rt(l)),...o.map(([l])=>new rt(l)),...i.map(([l])=>new rt(l))];return[s,h]}extractTableLookup(t){let[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,s=>!s.isSigner&&!s.isInvoked&&s.isWritable),[o,i]=this.drainKeysFoundInLookupTable(t.state.addresses,s=>!s.isSigner&&!s.isInvoked&&!s.isWritable);if(!(e.length===0&&o.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:o},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(t,e){let n=new Array,o=new Array;for(let[i,s]of this.keyMetaMap.entries())if(e(s)){let h=new rt(i),l=t.findIndex(b=>b.equals(h));l>=0&&(oe(l<256,"Max lookup table index exceeded"),n.push(l),o.push(h),this.keyMetaMap.delete(i))}return[n,o]}},Qo=class r{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new rt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:ve.default.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Xo(this.staticAccountKeys)}static compile(t){let e=na.compile(t.instructions,t.payerKey),[n,o]=e.getMessageComponents(),s=new Xo(o).compileInstructions(t.instructions).map(h=>({programIdIndex:h.programIdIndex,accounts:h.accountKeyIndexes,data:ve.default.encode(h.data)}));return new r({header:n,accountKeys:o,recentBlockhash:t.recentBlockhash,instructions:s})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){let e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){let n=t-e,i=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<i}else{let n=e-this.header.numReadonlySignedAccounts;return t<n}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){let t=this.accountKeys.length,e=[];On(e,t);let n=this.instructions.map(k=>{let{accounts:R,programIdIndex:I}=k,P=Array.from(ve.default.decode(k.data)),B=[];On(B,R.length);let A=[];return On(A,P.length),{programIdIndex:I,keyIndicesCount:X.Buffer.from(B),keyIndices:R,dataLength:X.Buffer.from(A),data:P}}),o=[];On(o,n.length);let i=X.Buffer.alloc(Jo);X.Buffer.from(o).copy(i);let s=o.length;n.forEach(k=>{let I=S.struct([S.u8("programIdIndex"),S.blob(k.keyIndicesCount.length,"keyIndicesCount"),S.seq(S.u8("keyIndex"),k.keyIndices.length,"keyIndices"),S.blob(k.dataLength.length,"dataLength"),S.seq(S.u8("userdatum"),k.data.length,"data")]).encode(k,i,s);s+=I}),i=i.slice(0,s);let h=S.struct([S.blob(1,"numRequiredSignatures"),S.blob(1,"numReadonlySignedAccounts"),S.blob(1,"numReadonlyUnsignedAccounts"),S.blob(e.length,"keyCount"),S.seq(st("key"),t,"keys"),st("recentBlockhash")]),l={numRequiredSignatures:X.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:X.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:X.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:X.Buffer.from(e),keys:this.accountKeys.map(k=>ut(k.toBytes())),recentBlockhash:ve.default.decode(this.recentBlockhash)},b=X.Buffer.alloc(2048),x=h.encode(l,b);return i.copy(b,x),b.slice(0,x+i.length)}static from(t){let e=[...t],n=e.shift();if(n!==(n&$d))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let o=e.shift(),i=e.shift(),s=Cn(e),h=[];for(let R=0;R<s;R++){let I=e.slice(0,Mr);e=e.slice(Mr),h.push(new rt(X.Buffer.from(I)))}let l=e.slice(0,Mr);e=e.slice(Mr);let b=Cn(e),x=[];for(let R=0;R<b;R++){let I=e.shift(),P=Cn(e),B=e.slice(0,P);e=e.slice(P);let A=Cn(e),T=e.slice(0,A),F=ve.default.encode(X.Buffer.from(T));e=e.slice(A),x.push({programIdIndex:I,accounts:B,data:F})}let k={header:{numRequiredSignatures:n,numReadonlySignedAccounts:o,numReadonlyUnsignedAccounts:i},recentBlockhash:ve.default.encode(X.Buffer.from(l)),accountKeys:h,instructions:x};return new r(k)}};var Jd=X.Buffer.alloc(Qs).fill(0),gt=class{constructor(t){this.keys=void 0,this.programId=void 0,this.data=X.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},bt=class r{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){let{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){let{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{let{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new gt(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let B=0;B<e.length;B++)if(e[B].programId===void 0)throw new Error(`Transaction instruction index ${B} has undefined program id`);let o=[],i=[];e.forEach(B=>{B.keys.forEach(T=>{i.push({...T})});let A=B.programId.toString();o.includes(A)||o.push(A)}),o.forEach(B=>{i.push({pubkey:new rt(B),isSigner:!1,isWritable:!1})});let s=[];i.forEach(B=>{let A=B.pubkey.toString(),T=s.findIndex(F=>F.pubkey.toString()===A);T>-1?(s[T].isWritable=s[T].isWritable||B.isWritable,s[T].isSigner=s[T].isSigner||B.isSigner):s.push(B)}),s.sort(function(B,A){if(B.isSigner!==A.isSigner)return B.isSigner?-1:1;if(B.isWritable!==A.isWritable)return B.isWritable?-1:1;let T={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return B.pubkey.toBase58().localeCompare(A.pubkey.toBase58(),"en",T)});let h=s.findIndex(B=>B.pubkey.equals(n));if(h>-1){let[B]=s.splice(h,1);B.isSigner=!0,B.isWritable=!0,s.unshift(B)}else s.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let B of this.signatures){let A=s.findIndex(T=>T.pubkey.equals(B.publicKey));if(A>-1)s[A].isSigner||(s[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: ${B.publicKey.toString()}`)}let l=0,b=0,x=0,k=[],R=[];s.forEach(({pubkey:B,isSigner:A,isWritable:T})=>{A?(k.push(B.toString()),l+=1,T||(b+=1)):(R.push(B.toString()),T||(x+=1))});let I=k.concat(R),P=e.map(B=>{let{data:A,programId:T}=B;return{programIdIndex:I.indexOf(T.toString()),accounts:B.keys.map(F=>I.indexOf(F.pubkey.toString())),data:ve.default.encode(A)}});return P.forEach(B=>{oe(B.programIdIndex>=0),B.accounts.forEach(A=>oe(A>=0))}),new Qo({header:{numRequiredSignatures:l,numReadonlySignedAccounts:b,numReadonlyUnsignedAccounts:x},accountKeys:I,recentBlockhash:t,instructions:P})}_compile(){let t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((o,i)=>e[i].equals(o.publicKey))||(this.signatures=e.map(n=>({signature:null,publicKey:n}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");let e=new Set;this.signatures=t.filter(n=>{let o=n.toString();return e.has(o)?!1:(e.add(o),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...t){if(t.length===0)throw new Error("No signers");let e=new Set,n=[];for(let i of t){let s=i.publicKey.toString();e.has(s)||(e.add(s),n.push(i))}this.signatures=n.map(i=>({signature:null,publicKey:i.publicKey}));let o=this._compile();this._partialSign(o,...n)}partialSign(...t){if(t.length===0)throw new Error("No signers");let e=new Set,n=[];for(let i of t){let s=i.publicKey.toString();e.has(s)||(e.add(s),n.push(i))}let o=this._compile();this._partialSign(o,...n)}_partialSign(t,...e){let n=t.serialize();e.forEach(o=>{let i=Hu(n,o.secretKey);this._addSignature(o.publicKey,ut(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){oe(e.length===64);let n=this.signatures.findIndex(o=>t.equals(o.publicKey));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=X.Buffer.from(e)}verifySignatures(t){return this._verifySignatures(this.serializeMessage(),t===void 0?!0:t)}_verifySignatures(t,e){for(let{signature:n,publicKey:o}of this.signatures)if(n===null){if(e)return!1}else if(!Wd(n,t,o.toBytes()))return!1;return!0}serialize(t){let{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),o=this.serializeMessage();if(n&&!this._verifySignatures(o,e))throw new Error("Signature verification failed");return this._serialize(o)}_serialize(t){let{signatures:e}=this,n=[];On(n,e.length);let o=n.length+e.length*64+t.length,i=X.Buffer.alloc(o);return oe(e.length<256),X.Buffer.from(n).copy(i,0),e.forEach(({signature:s},h)=>{s!==null&&(oe(s.length===64,"signature has invalid length"),X.Buffer.from(s).copy(i,n.length+h*64))}),t.copy(i,n.length+e.length*64),oe(i.length<=Jo,`Transaction too large: ${i.length} > ${Jo}`),i}get keys(){return oe(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return oe(this.instructions.length===1),this.instructions[0].programId}get data(){return oe(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t],n=Cn(e),o=[];for(let i=0;i<n;i++){let s=e.slice(0,Qs);e=e.slice(Qs),o.push(ve.default.encode(X.Buffer.from(s)))}return r.populate(Qo.from(e),o)}static populate(t,e=[]){let n=new r;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((o,i)=>{let s={signature:o==ve.default.encode(Jd)?null:ve.default.decode(o),publicKey:t.accountKeys[i]};n.signatures.push(s)}),t.instructions.forEach(o=>{let i=o.accounts.map(s=>{let h=t.accountKeys[s];return{pubkey:h,isSigner:n.signatures.some(l=>l.publicKey.toString()===h.toString())||t.isAccountSigner(s),isWritable:t.isAccountWritable(s)}});n.instructions.push(new gt({keys:i,programId:t.accountKeys[o.programIdIndex],data:ve.default.decode(o.data)}))}),n._message=t,n._json=n.toJSON(),n}};var Xd=160,Qd=64,t0=Xd/Qd,e0=1e3/t0,tr=new rt("SysvarC1ock11111111111111111111111111111111"),Eg=new rt("SysvarEpochSchedu1e111111111111111111111111"),_g=new rt("Sysvar1nstructions1111111111111111111111111"),$s=new rt("SysvarRecentB1ockHashes11111111111111111111"),Un=new rt("SysvarRent111111111111111111111111111111111"),Ig=new rt("SysvarRewards111111111111111111111111111111"),Ag=new rt("SysvarS1otHashes111111111111111111111111111"),Lg=new rt("SysvarS1otHistory11111111111111111111111111"),js=new rt("SysvarStakeHistory1111111111111111111111111");async function Cu(r,t,e,n){let o=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},i=await r.sendTransaction(t,e,o),s;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)s=(await r.confirmTransaction({abortSignal:n?.abortSignal,signature:i,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},n&&n.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:h}=t.nonceInfo,l=h.keys[0].pubkey;s=(await r.confirmTransaction({abortSignal:n?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:l,nonceValue:t.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."),s=(await r.confirmTransaction(i,n&&n.commitment)).value;if(s.err)throw new Error(`Transaction ${i} failed (${JSON.stringify(s)})`);return i}function r0(r){return new Promise(t=>setTimeout(t,r))}function it(r,t){let e=r.layout.span>=0?r.layout.span:ju(r,t),n=X.Buffer.alloc(e),o=Object.assign({instruction:r.index},t);return r.layout.encode(o,n),n}var n0=S.nu64("lamportsPerSignature"),o0=S.struct([S.u32("version"),S.u32("state"),st("authorizedPubkey"),st("nonce"),S.struct([n0],"feeCalculator")]),Ou=o0.span;var i0=r=>{let t=r.decode.bind(r),e=r.encode.bind(r);return{decode:t,encode:e}},s0=r=>t=>{let e=(0,Wu.blob)(r,t),{encode:n,decode:o}=i0(e),i=e;return i.decode=(s,h)=>{let l=o(s,h);return(0,zn.toBigIntLE)(X.Buffer.from(l))},i.encode=(s,h,l)=>{let b=(0,zn.toBufferLE)(s,r);return n(b,h,l)},i},Jr=s0(8);var Ae=Object.freeze({Create:{index:0,layout:S.struct([S.u32("instruction"),S.ns64("lamports"),S.ns64("space"),st("programId")])},Assign:{index:1,layout:S.struct([S.u32("instruction"),st("programId")])},Transfer:{index:2,layout:S.struct([S.u32("instruction"),Jr("lamports")])},CreateWithSeed:{index:3,layout:S.struct([S.u32("instruction"),st("base"),Zr("seed"),S.ns64("lamports"),S.ns64("space"),st("programId")])},AdvanceNonceAccount:{index:4,layout:S.struct([S.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:S.struct([S.u32("instruction"),st("authorized")])},AuthorizeNonceAccount:{index:7,layout:S.struct([S.u32("instruction"),st("authorized")])},Allocate:{index:8,layout:S.struct([S.u32("instruction"),S.ns64("space")])},AllocateWithSeed:{index:9,layout:S.struct([S.u32("instruction"),st("base"),Zr("seed"),S.ns64("space"),st("programId")])},AssignWithSeed:{index:10,layout:S.struct([S.u32("instruction"),st("base"),Zr("seed"),st("programId")])},TransferWithSeed:{index:11,layout:S.struct([S.u32("instruction"),Jr("lamports"),Zr("seed"),st("programId")])},UpgradeNonceAccount:{index:12,layout:S.struct([S.u32("instruction")])}}),ke=class r{constructor(){}static createAccount(t){let e=Ae.Create,n=it(e,{lamports:t.lamports,space:t.space,programId:ut(t.programId.toBuffer())});return new gt({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(t){let e,n;if("basePubkey"in t){let o=Ae.TransferWithSeed;e=it(o,{lamports:BigInt(t.lamports),seed:t.seed,programId:ut(t.programId.toBuffer())}),n=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{let o=Ae.Transfer;e=it(o,{lamports:BigInt(t.lamports)}),n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new gt({keys:n,programId:this.programId,data:e})}static assign(t){let e,n;if("basePubkey"in t){let o=Ae.AssignWithSeed;e=it(o,{base:ut(t.basePubkey.toBuffer()),seed:t.seed,programId:ut(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{let o=Ae.Assign;e=it(o,{programId:ut(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new gt({keys:n,programId:this.programId,data:e})}static createAccountWithSeed(t){let e=Ae.CreateWithSeed,n=it(e,{base:ut(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:ut(t.programId.toBuffer())}),o=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey!=t.fromPubkey&&o.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new gt({keys:o,programId:this.programId,data:n})}static createNonceAccount(t){let e=new bt;"basePubkey"in t&&"seed"in t?e.add(r.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Ou,programId:this.programId})):e.add(r.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Ou,programId:this.programId}));let n={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(n)),e}static nonceInitialize(t){let e=Ae.InitializeNonceAccount,n=it(e,{authorized:ut(t.authorizedPubkey.toBuffer())}),o={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$s,isSigner:!1,isWritable:!1},{pubkey:Un,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new gt(o)}static nonceAdvance(t){let e=Ae.AdvanceNonceAccount,n=it(e),o={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$s,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new gt(o)}static nonceWithdraw(t){let e=Ae.WithdrawNonceAccount,n=it(e,{lamports:t.lamports});return new gt({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:$s,isSigner:!1,isWritable:!1},{pubkey:Un,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(t){let e=Ae.AuthorizeNonceAccount,n=it(e,{authorized:ut(t.newAuthorizedPubkey.toBuffer())});return new gt({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(t){let e,n;if("basePubkey"in t){let o=Ae.AllocateWithSeed;e=it(o,{base:ut(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:ut(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{let o=Ae.Allocate;e=it(o,{space:t.space}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new gt({keys:n,programId:this.programId,data:e})}};ke.programId=new rt("11111111111111111111111111111111");var a0=Jo-300,oa=class r{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/r.chunkSize)+1+1)}static async load(t,e,n,o,i){{let k=await t.getMinimumBalanceForRentExemption(i.length),R=await t.getAccountInfo(n.publicKey,"confirmed"),I=null;if(R!==null){if(R.executable)return console.error("Program load failed, account is already executable"),!1;R.data.length!==i.length&&(I=I||new bt,I.add(ke.allocate({accountPubkey:n.publicKey,space:i.length}))),R.owner.equals(o)||(I=I||new bt,I.add(ke.assign({accountPubkey:n.publicKey,programId:o}))),R.lamports<k&&(I=I||new bt,I.add(ke.transfer({fromPubkey:e.publicKey,toPubkey:n.publicKey,lamports:k-R.lamports})))}else I=new bt().add(ke.createAccount({fromPubkey:e.publicKey,newAccountPubkey:n.publicKey,lamports:k>0?k:1,space:i.length,programId:o}));I!==null&&await Cu(t,I,[e,n],{commitment:"confirmed"})}let s=S.struct([S.u32("instruction"),S.u32("offset"),S.u32("bytesLength"),S.u32("bytesLengthPadding"),S.seq(S.u8("byte"),S.offset(S.u32(),-8),"bytes")]),h=r.chunkSize,l=0,b=i,x=[];for(;b.length>0;){let k=b.slice(0,h),R=X.Buffer.alloc(h+16);s.encode({instruction:0,offset:l,bytes:k,bytesLength:0,bytesLengthPadding:0},R);let I=new bt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:o,data:R});x.push(Cu(t,I,[e,n],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await r0(1e3/4),l+=h,b=b.slice(h)}await Promise.all(x);{let k=S.struct([S.u32("instruction")]),R=X.Buffer.alloc(k.span);k.encode({instruction:1},R);let I=new bt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Un,isSigner:!1,isWritable:!1}],programId:o,data:R}),P="processed",B=await t.sendTransaction(I,[e,n],{preflightCommitment:P}),{context:A,value:T}=await t.confirmTransaction({signature:B,lastValidBlockHeight:I.lastValidBlockHeight,blockhash:I.recentBlockhash},P);if(T.err)throw new Error(`Transaction ${B} failed (${JSON.stringify(T)})`);for(;;){try{if(await t.getSlot({commitment:P})>A.slot)break}catch{}await new Promise(F=>setTimeout(F,Math.round(e0/2)))}}return!0}};oa.chunkSize=a0;var Rg=new rt("BPFLoader2111111111111111111111111111111111");var Tg=globalThis.fetch;var Mg={index:1,layout:S.struct([S.u32("typeIndex"),Jr("deactivationSlot"),S.nu64("lastExtendedSlot"),S.u8("lastExtendedStartIndex"),S.u8(),S.seq(st(),S.offset(S.u8(),-1),"authority")])};var ie=Gr(Oo(rt),K(),r=>new rt(r)),Gu=Uo([K(),St("base64")]),la=Gr(Oo(X.Buffer),Gu,r=>X.Buffer.from(r[0],"base64")),Pg=30*1e3;function Yu(r){return me([C({jsonrpc:St("2.0"),id:K(),result:r}),C({jsonrpc:St("2.0"),id:K(),error:C({code:jr(),message:K(),data:Z(Rc())})})])}var c0=Yu(jr());function wt(r){return Gr(Yu(r),c0,t=>"error"in t?t:{...t,result:$r(t.result,r)})}function Le(r){return wt(C({context:C({slot:E()}),value:r}))}function ni(r){return C({context:C({slot:E()}),value:r})}var u0=C({foundation:E(),foundationTerm:E(),initial:E(),taper:E(),terminal:E()}),Cg=wt($(V(C({epoch:E(),effectiveSlot:E(),amount:E(),postBalance:E(),commission:Z(V(E()))})))),f0=$(C({slot:E(),prioritizationFee:E()})),l0=C({total:E(),validator:E(),foundation:E(),epoch:E()}),h0=C({epoch:E(),slotIndex:E(),slotsInEpoch:E(),absoluteSlot:E(),blockHeight:Z(E()),transactionCount:Z(E())}),d0=C({slotsPerEpoch:E(),leaderScheduleSlotOffset:E(),warmup:Ce(),firstNormalEpoch:E(),firstNormalSlot:E()}),p0=xs(K(),$(E())),Pr=V(me([C({}),K()])),y0=C({err:Pr}),g0=St("receivedSignature"),Og=C({"solana-core":K(),"feature-set":Z(E())}),Ug=Le(C({err:V(me([C({}),K()])),logs:V($(K())),accounts:Z(V($(V(C({executable:Ce(),owner:K(),lamports:E(),data:$(K()),rentEpoch:Z(E())}))))),unitsConsumed:Z(E()),returnData:Z(V(C({programId:K(),data:Uo([K(),St("base64")])})))})),Ng=Le(C({byIdentity:xs(K(),$(E())),range:C({firstSlot:E(),lastSlot:E()})}));var zg=wt(u0),qg=wt(l0),Fg=wt(f0),Dg=wt(h0),Kg=wt(d0),Wg=wt(p0),Hg=wt(E()),Vg=Le(C({total:E(),circulating:E(),nonCirculating:E(),nonCirculatingAccounts:$(ie)})),m0=C({amount:K(),uiAmount:V(E()),decimals:E(),uiAmountString:Z(K())}),$g=Le($(C({address:ie,amount:K(),uiAmount:V(E()),decimals:E(),uiAmountString:Z(K())}))),jg=Le($(C({pubkey:ie,account:C({executable:Ce(),owner:ie,lamports:E(),data:la,rentEpoch:E()})}))),ia=C({program:K(),parsed:jr(),space:E()}),Gg=Le($(C({pubkey:ie,account:C({executable:Ce(),owner:ie,lamports:E(),data:ia,rentEpoch:E()})}))),Yg=Le($(C({lamports:E(),address:ie}))),ha=C({executable:Ce(),owner:ie,lamports:E(),data:la,rentEpoch:E()}),Zg=C({pubkey:ie,account:ha}),b0=Gr(me([Oo(X.Buffer),ia]),me([Gu,ia]),r=>Array.isArray(r)?$r(r,la):r),w0=C({executable:Ce(),owner:ie,lamports:E(),data:b0,rentEpoch:E()}),Jg=C({pubkey:ie,account:w0}),Xg=C({state:me([St("active"),St("inactive"),St("activating"),St("deactivating")]),active:E(),inactive:E()}),Qg=wt($(C({signature:K(),slot:E(),err:Pr,memo:V(K()),blockTime:Z(V(E()))}))),tm=wt($(C({signature:K(),slot:E(),err:Pr,memo:V(K()),blockTime:Z(V(E()))}))),em=C({subscription:E(),result:ni(ha)}),x0=C({pubkey:ie,account:ha}),rm=C({subscription:E(),result:ni(x0)}),v0=C({parent:E(),slot:E(),root:E()}),nm=C({subscription:E(),result:v0}),k0=me([C({type:me([St("firstShredReceived"),St("completed"),St("optimisticConfirmation"),St("root")]),slot:E(),timestamp:E()}),C({type:St("createdBank"),parent:E(),slot:E(),timestamp:E()}),C({type:St("frozen"),slot:E(),timestamp:E(),stats:C({numTransactionEntries:E(),numSuccessfulTransactions:E(),numFailedTransactions:E(),maxTransactionsPerEntry:E()})}),C({type:St("dead"),slot:E(),timestamp:E(),err:K()})]),om=C({subscription:E(),result:k0}),im=C({subscription:E(),result:ni(me([y0,g0]))}),sm=C({subscription:E(),result:E()}),am=C({pubkey:K(),gossip:V(K()),tpu:V(K()),rpc:V(K()),version:V(K())}),Uu=C({votePubkey:K(),nodePubkey:K(),activatedStake:E(),epochVoteAccount:Ce(),epochCredits:$(Uo([E(),E(),E()])),commission:E(),lastVote:E(),rootSlot:V(E())}),cm=wt(C({current:$(Uu),delinquent:$(Uu)})),S0=me([St("processed"),St("confirmed"),St("finalized")]),B0=C({slot:E(),confirmations:V(E()),err:Pr,confirmationStatus:Z(S0)}),um=Le($(V(B0))),fm=wt(E()),Zu=C({accountKey:ie,writableIndexes:$(E()),readonlyIndexes:$(E())}),da=C({signatures:$(K()),message:C({accountKeys:$(K()),header:C({numRequiredSignatures:E(),numReadonlySignedAccounts:E(),numReadonlyUnsignedAccounts:E()}),instructions:$(C({accounts:$(E()),data:K(),programIdIndex:E()})),recentBlockhash:K(),addressTableLookups:Z($(Zu))})}),Ju=C({pubkey:ie,signer:Ce(),writable:Ce(),source:Z(me([St("transaction"),St("lookupTable")]))}),Xu=C({accountKeys:$(Ju),signatures:$(K())}),Qu=C({parsed:jr(),program:K(),programId:ie}),tf=C({accounts:$(ie),data:K(),programId:ie}),E0=me([tf,Qu]),_0=me([C({parsed:jr(),program:K(),programId:K()}),C({accounts:$(K()),data:K(),programId:K()})]),ef=Gr(E0,_0,r=>"accounts"in r?$r(r,tf):$r(r,Qu)),rf=C({signatures:$(K()),message:C({accountKeys:$(Ju),instructions:$(ef),recentBlockhash:K(),addressTableLookups:Z(V($(Zu)))})}),ti=C({accountIndex:E(),mint:K(),owner:Z(K()),uiTokenAmount:m0}),nf=C({writable:$(ie),readonly:$(ie)}),oi=C({err:Pr,fee:E(),innerInstructions:Z(V($(C({index:E(),instructions:$(C({accounts:$(E()),data:K(),programIdIndex:E()}))})))),preBalances:$(E()),postBalances:$(E()),logMessages:Z(V($(K()))),preTokenBalances:Z(V($(ti))),postTokenBalances:Z(V($(ti))),loadedAddresses:Z(nf),computeUnitsConsumed:Z(E())}),pa=C({err:Pr,fee:E(),innerInstructions:Z(V($(C({index:E(),instructions:$(ef)})))),preBalances:$(E()),postBalances:$(E()),logMessages:Z(V($(K()))),preTokenBalances:Z(V($(ti))),postTokenBalances:Z(V($(ti))),loadedAddresses:Z(nf),computeUnitsConsumed:Z(E())}),Qr=me([St(0),St("legacy")]),Cr=C({pubkey:K(),lamports:E(),postBalance:V(E()),rewardType:V(K()),commission:Z(V(E()))}),lm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:da,meta:V(oi),version:Z(Qr)})),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),hm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),dm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:Xu,meta:V(oi),version:Z(Qr)})),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),pm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:rf,meta:V(pa),version:Z(Qr)})),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),ym=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:Xu,meta:V(pa),version:Z(Qr)})),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),gm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),mm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:da,meta:V(oi)})),rewards:Z($(Cr)),blockTime:V(E())}))),bm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),signatures:$(K()),blockTime:V(E())}))),wm=wt(V(C({slot:E(),meta:oi,blockTime:Z(V(E())),transaction:da,version:Z(Qr)}))),xm=wt(V(C({slot:E(),transaction:rf,meta:V(pa),blockTime:Z(V(E())),version:Z(Qr)}))),vm=Le(C({blockhash:K(),feeCalculator:C({lamportsPerSignature:E()})})),km=Le(C({blockhash:K(),lastValidBlockHeight:E()})),Sm=Le(Ce()),I0=C({slot:E(),numTransactions:E(),numSlots:E(),samplePeriodSecs:E()}),Bm=wt($(I0)),Em=Le(V(C({feeCalculator:C({lamportsPerSignature:E()})}))),_m=wt(K()),Im=wt(K()),A0=C({err:Pr,logs:$(K()),signature:K()}),Am=C({result:ni(A0),subscription:E()});var sa=class r{constructor(t){this._keypair=void 0,this._keypair=t??Tu()}static generate(){return new r(Tu())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");let n=t.slice(32,64);if(!e||!e.skipValidation){let o=t.slice(0,32),i=Js(o);for(let s=0;s<32;s++)if(n[s]!==i[s])throw new Error("provided secretKey is invalid")}return new r({publicKey:n,secretKey:t})}static fromSeed(t){let e=Js(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new r({publicKey:e,secretKey:n})}get publicKey(){return new rt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},Pn=Object.freeze({CreateLookupTable:{index:0,layout:S.struct([S.u32("instruction"),Jr("recentSlot"),S.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:S.struct([S.u32("instruction")])},ExtendLookupTable:{index:2,layout:S.struct([S.u32("instruction"),Jr(),S.seq(st(),S.offset(S.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:S.struct([S.u32("instruction")])},CloseLookupTable:{index:4,layout:S.struct([S.u32("instruction")])}});var aa=class{constructor(){}static createLookupTable(t){let[e,n]=rt.findProgramAddressSync([t.authority.toBuffer(),(0,zn.toBufferLE)(BigInt(t.recentSlot),8)],this.programId),o=Pn.CreateLookupTable,i=it(o,{recentSlot:BigInt(t.recentSlot),bumpSeed:n}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ke.programId,isSigner:!1,isWritable:!1}];return[new gt({programId:this.programId,keys:s,data:i}),e]}static freezeLookupTable(t){let e=Pn.FreezeLookupTable,n=it(e),o=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new gt({programId:this.programId,keys:o,data:n})}static extendLookupTable(t){let e=Pn.ExtendLookupTable,n=it(e,{addresses:t.addresses.map(i=>i.toBytes())}),o=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&o.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ke.programId,isSigner:!1,isWritable:!1}),new gt({programId:this.programId,keys:o,data:n})}static deactivateLookupTable(t){let e=Pn.DeactivateLookupTable,n=it(e),o=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new gt({programId:this.programId,keys:o,data:n})}static closeLookupTable(t){let e=Pn.CloseLookupTable,n=it(e),o=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new gt({programId:this.programId,keys:o,data:n})}};aa.programId=new rt("AddressLookupTab1e1111111111111111111111111");var Go=Object.freeze({RequestUnits:{index:0,layout:S.struct([S.u8("instruction"),S.u32("units"),S.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:S.struct([S.u8("instruction"),S.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:S.struct([S.u8("instruction"),S.u32("units")])},SetComputeUnitPrice:{index:3,layout:S.struct([S.u8("instruction"),Jr("microLamports")])}}),ca=class{constructor(){}static requestUnits(t){let e=Go.RequestUnits,n=it(e,t);return new gt({keys:[],programId:this.programId,data:n})}static requestHeapFrame(t){let e=Go.RequestHeapFrame,n=it(e,t);return new gt({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(t){let e=Go.SetComputeUnitLimit,n=it(e,t);return new gt({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(t){let e=Go.SetComputeUnitPrice,n=it(e,{microLamports:BigInt(t.microLamports)});return new gt({keys:[],programId:this.programId,data:n})}};ca.programId=new rt("ComputeBudget111111111111111111111111111111");var Nu=64,zu=32,qu=64,Fu=S.struct([S.u8("numSignatures"),S.u8("padding"),S.u16("signatureOffset"),S.u16("signatureInstructionIndex"),S.u16("publicKeyOffset"),S.u16("publicKeyInstructionIndex"),S.u16("messageDataOffset"),S.u16("messageDataSize"),S.u16("messageInstructionIndex")]),ua=class r{constructor(){}static createInstructionWithPublicKey(t){let{publicKey:e,message:n,signature:o,instructionIndex:i}=t;oe(e.length===zu,`Public Key must be ${zu} bytes but received ${e.length} bytes`),oe(o.length===qu,`Signature must be ${qu} bytes but received ${o.length} bytes`);let s=Fu.span,h=s+e.length,l=h+o.length,b=1,x=X.Buffer.alloc(l+n.length),k=i??65535;return Fu.encode({numSignatures:b,padding:0,signatureOffset:h,signatureInstructionIndex:k,publicKeyOffset:s,publicKeyInstructionIndex:k,messageDataOffset:l,messageDataSize:n.length,messageInstructionIndex:k},x),x.fill(e,s),x.fill(o,h),x.fill(n,l),new gt({keys:[],programId:r.programId,data:x})}static createInstructionWithPrivateKey(t){let{privateKey:e,message:n,instructionIndex:o}=t;oe(e.length===Nu,`Private key must be ${Nu} bytes but received ${e.length} bytes`);try{let i=sa.fromSecretKey(e),s=i.publicKey.toBytes(),h=Hu(n,i.secretKey);return this.createInstructionWithPublicKey({publicKey:s,message:n,signature:h,instructionIndex:o})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}};ua.programId=new rt("Ed25519SigVerify111111111111111111111111111");var L0=(r,t)=>{let e=Mn.sign(r,t);return[e.toCompactRawBytes(),e.recovery]};Mn.utils.isValidPrivateKey;var R0=Mn.getPublicKey,Du=32,Gs=20,Ku=64,T0=11,Ys=S.struct([S.u8("numSignatures"),S.u16("signatureOffset"),S.u8("signatureInstructionIndex"),S.u16("ethAddressOffset"),S.u8("ethAddressInstructionIndex"),S.u16("messageDataOffset"),S.u16("messageDataSize"),S.u8("messageInstructionIndex"),S.blob(20,"ethAddress"),S.blob(64,"signature"),S.u8("recoveryId")]),fa=class r{constructor(){}static publicKeyToEthAddress(t){oe(t.length===Ku,`Public key must be ${Ku} bytes but received ${t.length} bytes`);try{return X.Buffer.from(Ks(ut(t))).slice(-Gs)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){let{publicKey:e,message:n,signature:o,recoveryId:i,instructionIndex:s}=t;return r.createInstructionWithEthAddress({ethAddress:r.publicKeyToEthAddress(e),message:n,signature:o,recoveryId:i,instructionIndex:s})}static createInstructionWithEthAddress(t){let{ethAddress:e,message:n,signature:o,recoveryId:i,instructionIndex:s=0}=t,h;typeof e=="string"?e.startsWith("0x")?h=X.Buffer.from(e.substr(2),"hex"):h=X.Buffer.from(e,"hex"):h=e,oe(h.length===Gs,`Address must be ${Gs} bytes but received ${h.length} bytes`);let l=1+T0,b=l,x=l+h.length,k=x+o.length+1,R=1,I=X.Buffer.alloc(Ys.span+n.length);return Ys.encode({numSignatures:R,signatureOffset:x,signatureInstructionIndex:s,ethAddressOffset:b,ethAddressInstructionIndex:s,messageDataOffset:k,messageDataSize:n.length,messageInstructionIndex:s,signature:ut(o),ethAddress:ut(h),recoveryId:i},I),I.fill(ut(n),Ys.span),new gt({keys:[],programId:r.programId,data:I})}static createInstructionWithPrivateKey(t){let{privateKey:e,message:n,instructionIndex:o}=t;oe(e.length===Du,`Private key must be ${Du} bytes but received ${e.length} bytes`);try{let i=ut(e),s=R0(i,!1).slice(1),h=X.Buffer.from(Ks(ut(n))),[l,b]=L0(h,i);return this.createInstructionWithPublicKey({publicKey:s,message:n,signature:l,recoveryId:b,instructionIndex:o})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}};fa.programId=new rt("KeccakSecp256k11111111111111111111111111111");var of,M0=new rt("StakeConfig11111111111111111111111111111111");var Nn=class{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}};of=Nn;Nn.default=new of(0,0,rt.default);var xr=Object.freeze({Initialize:{index:0,layout:S.struct([S.u32("instruction"),jd(),Gd()])},Authorize:{index:1,layout:S.struct([S.u32("instruction"),st("newAuthorized"),S.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:S.struct([S.u32("instruction")])},Split:{index:3,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},Withdraw:{index:4,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},Deactivate:{index:5,layout:S.struct([S.u32("instruction")])},Merge:{index:7,layout:S.struct([S.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:S.struct([S.u32("instruction"),st("newAuthorized"),S.u32("stakeAuthorizationType"),Zr("authoritySeed"),st("authorityOwner")])}}),Lm=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),ei=class{constructor(){}static initialize(t){let{stakePubkey:e,authorized:n,lockup:o}=t,i=o||Nn.default,s=xr.Initialize,h=it(s,{authorized:{staker:ut(n.staker.toBuffer()),withdrawer:ut(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:ut(i.custodian.toBuffer())}}),l={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Un,isSigner:!1,isWritable:!1}],programId:this.programId,data:h};return new gt(l)}static createAccountWithSeed(t){let e=new bt;e.add(ke.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:o,lockup:i}=t;return e.add(this.initialize({stakePubkey:n,authorized:o,lockup:i}))}static createAccount(t){let e=new bt;e.add(ke.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:o,lockup:i}=t;return e.add(this.initialize({stakePubkey:n,authorized:o,lockup:i}))}static delegate(t){let{stakePubkey:e,authorizedPubkey:n,votePubkey:o}=t,i=xr.Delegate,s=it(i);return new bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:js,isSigner:!1,isWritable:!1},{pubkey:M0,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static authorize(t){let{stakePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:o,stakeAuthorizationType:i,custodianPubkey:s}=t,h=xr.Authorize,l=it(h,{newAuthorized:ut(o.toBuffer()),stakeAuthorizationType:i.index}),b=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return s&&b.push({pubkey:s,isSigner:!1,isWritable:!1}),new bt().add({keys:b,programId:this.programId,data:l})}static authorizeWithSeed(t){let{stakePubkey:e,authorityBase:n,authoritySeed:o,authorityOwner:i,newAuthorizedPubkey:s,stakeAuthorizationType:h,custodianPubkey:l}=t,b=xr.AuthorizeWithSeed,x=it(b,{newAuthorized:ut(s.toBuffer()),stakeAuthorizationType:h.index,authoritySeed:o,authorityOwner:ut(i.toBuffer())}),k=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:tr,isSigner:!1,isWritable:!1}];return l&&k.push({pubkey:l,isSigner:!1,isWritable:!1}),new bt().add({keys:k,programId:this.programId,data:x})}static splitInstruction(t){let{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:o,lamports:i}=t,s=xr.Split,h=it(s,{lamports:i});return new gt({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:h})}static split(t){let e=new bt;return e.add(ke.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:0,space:this.space,programId:this.programId})),e.add(this.splitInstruction(t))}static splitWithSeed(t){let{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:o,basePubkey:i,seed:s,lamports:h}=t,l=new bt;return l.add(ke.allocate({accountPubkey:o,basePubkey:i,seed:s,space:this.space,programId:this.programId})),l.add(this.splitInstruction({stakePubkey:e,authorizedPubkey:n,splitStakePubkey:o,lamports:h}))}static merge(t){let{stakePubkey:e,sourceStakePubKey:n,authorizedPubkey:o}=t,i=xr.Merge,s=it(i);return new bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:js,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static withdraw(t){let{stakePubkey:e,authorizedPubkey:n,toPubkey:o,lamports:i,custodianPubkey:s}=t,h=xr.Withdraw,l=it(h,{lamports:i}),b=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:js,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return s&&b.push({pubkey:s,isSigner:!1,isWritable:!1}),new bt().add({keys:b,programId:this.programId,data:l})}static deactivate(t){let{stakePubkey:e,authorizedPubkey:n}=t,o=xr.Deactivate,i=it(o);return new bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}};ei.programId=new rt("Stake11111111111111111111111111111111111111");ei.space=200;var Yo=Object.freeze({InitializeAccount:{index:0,layout:S.struct([S.u32("instruction"),Yd()])},Authorize:{index:1,layout:S.struct([S.u32("instruction"),st("newAuthorized"),S.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},AuthorizeWithSeed:{index:10,layout:S.struct([S.u32("instruction"),Zd()])}}),Rm=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),ri=class r{constructor(){}static initializeAccount(t){let{votePubkey:e,nodePubkey:n,voteInit:o}=t,i=Yo.InitializeAccount,s=it(i,{voteInit:{nodePubkey:ut(o.nodePubkey.toBuffer()),authorizedVoter:ut(o.authorizedVoter.toBuffer()),authorizedWithdrawer:ut(o.authorizedWithdrawer.toBuffer()),commission:o.commission}}),h={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Un,isSigner:!1,isWritable:!1},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s};return new gt(h)}static createAccount(t){let e=new bt;return e.add(ke.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){let{votePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:o,voteAuthorizationType:i}=t,s=Yo.Authorize,h=it(s,{newAuthorized:ut(o.toBuffer()),voteAuthorizationType:i.index}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new bt().add({keys:l,programId:this.programId,data:h})}static authorizeWithSeed(t){let{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:o,newAuthorizedPubkey:i,voteAuthorizationType:s,votePubkey:h}=t,l=Yo.AuthorizeWithSeed,b=it(l,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:ut(n.toBuffer()),currentAuthorityDerivedKeySeed:o,newAuthorized:ut(i.toBuffer()),voteAuthorizationType:s.index}}),x=[{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new bt().add({keys:x,programId:this.programId,data:b})}static withdraw(t){let{votePubkey:e,authorizedWithdrawerPubkey:n,lamports:o,toPubkey:i}=t,s=Yo.Withdraw,h=it(s,{lamports:o}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new bt().add({keys:l,programId:this.programId,data:h})}static safeWithdraw(t,e,n){if(t.lamports>e-n)throw new Error("Withdraw will leave vote account with insuffcient funds.");return r.withdraw(t)}};ri.programId=new rt("Vote111111111111111111111111111111111111111");ri.space=3731;var Tm=new rt("Va1idator1nfo111111111111111111111111111111"),Mm=C({name:K(),website:Z(K()),details:Z(K()),keybaseUsername:Z(K())});var Pm=new rt("Vote111111111111111111111111111111111111111"),Cm=S.struct([st("nodePubkey"),st("authorizedWithdrawer"),S.u8("commission"),S.nu64(),S.seq(S.struct([S.nu64("slot"),S.u32("confirmationCount")]),S.offset(S.u32(),-8),"votes"),S.u8("rootSlotValid"),S.nu64("rootSlot"),S.nu64(),S.seq(S.struct([S.nu64("epoch"),st("authorizedVoter")]),S.offset(S.u32(),-8),"authorizedVoters"),S.struct([S.seq(S.struct([st("authorizedPubkey"),S.nu64("epochOfLastAuthorizedSwitch"),S.nu64("targetEpoch")]),32,"buf"),S.nu64("idx"),S.u8("isEmpty")],"priorVoters"),S.nu64(),S.seq(S.struct([S.nu64("epoch"),S.nu64("credits"),S.nu64("prevCredits")]),S.offset(S.u32(),-8),"epochCredits"),S.struct([S.nu64("slot"),S.nu64("timestamp")],"lastTimestamp")]);var ii={SIGN_TRANSACTION:"sol_signTransaction",SIGN_MESSAGE:"sol_signMessage",PARTIAL_SIGN_TRANSACTION:"sol_partialSignTransaction"};var si=class extends sf.Extension.Internal{constructor(e){super();this.solanaConfig=e;this.config={rpcUrl:e.rpcUrl,chainType:"SOLANA"}}name="solana";config={};signTransaction=(e,n)=>this.request({id:42,jsonrpc:"2.0",method:ii.SIGN_TRANSACTION,params:{type:e instanceof bt?"legacy":0,serialized:e.serialize(n),serializeConfig:n}});signMessage=e=>this.request({id:42,jsonrpc:"2.0",method:ii.SIGN_MESSAGE,params:{message:e}});partialSignTransaction=(e,n)=>this.request({id:42,jsonrpc:"2.0",method:ii.PARTIAL_SIGN_TRANSACTION,params:{type:e instanceof bt?"legacy":0,serialized:e.serialize(n),serializeConfig:n}})};var P0=si;return Ii(C0);})();
|
|
1
|
+
"use strict";var MagicSolanaExtension=(()=>{var af=Object.create;var Dn=Object.defineProperty;var cf=Object.getOwnPropertyDescriptor;var uf=Object.getOwnPropertyNames;var ff=Object.getPrototypeOf,lf=Object.prototype.hasOwnProperty;var ye=(r,t)=>()=>(r&&(t=r(r=0)),t);var at=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),_i=(r,t)=>{for(var e in t)Dn(r,e,{get:t[e],enumerable:!0})},Ea=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of uf(t))!lf.call(r,o)&&o!==e&&Dn(r,o,{get:()=>t[o],enumerable:!(n=cf(t,o))||n.enumerable});return r};var Re=(r,t,e)=>(e=r!=null?af(ff(r)):{},Ea(t||!r||!r.__esModule?Dn(e,"default",{value:r,enumerable:!0}):e,r)),Ii=r=>Ea(Dn({},"__esModule",{value:!0}),r);var Ia=at((U0,_a)=>{"use strict";_a.exports=Magic});var Ra=at(Kn=>{"use strict";Kn.byteLength=df;Kn.toByteArray=yf;Kn.fromByteArray=bf;var Oe=[],Ee=[],hf=typeof Uint8Array<"u"?Uint8Array:Array,Ai="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(vr=0,Aa=Ai.length;vr<Aa;++vr)Oe[vr]=Ai[vr],Ee[Ai.charCodeAt(vr)]=vr;var vr,Aa;Ee[45]=62;Ee[95]=63;function La(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function df(r){var t=La(r),e=t[0],n=t[1];return(e+n)*3/4-n}function pf(r,t,e){return(t+e)*3/4-e}function yf(r){var t,e=La(r),n=e[0],o=e[1],i=new hf(pf(r,n,o)),s=0,h=o>0?n-4:n,l;for(l=0;l<h;l+=4)t=Ee[r.charCodeAt(l)]<<18|Ee[r.charCodeAt(l+1)]<<12|Ee[r.charCodeAt(l+2)]<<6|Ee[r.charCodeAt(l+3)],i[s++]=t>>16&255,i[s++]=t>>8&255,i[s++]=t&255;return o===2&&(t=Ee[r.charCodeAt(l)]<<2|Ee[r.charCodeAt(l+1)]>>4,i[s++]=t&255),o===1&&(t=Ee[r.charCodeAt(l)]<<10|Ee[r.charCodeAt(l+1)]<<4|Ee[r.charCodeAt(l+2)]>>2,i[s++]=t>>8&255,i[s++]=t&255),i}function gf(r){return Oe[r>>18&63]+Oe[r>>12&63]+Oe[r>>6&63]+Oe[r&63]}function mf(r,t,e){for(var n,o=[],i=t;i<e;i+=3)n=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(r[i+2]&255),o.push(gf(n));return o.join("")}function bf(r){for(var t,e=r.length,n=e%3,o=[],i=16383,s=0,h=e-n;s<h;s+=i)o.push(mf(r,s,s+i>h?h:s+i));return n===1?(t=r[e-1],o.push(Oe[t>>2]+Oe[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],o.push(Oe[t>>10]+Oe[t>>4&63]+Oe[t<<2&63]+"=")),o.join("")}});var Ta=at(Li=>{"use strict";Li.read=function(r,t,e,n,o){var i,s,h=o*8-n-1,l=(1<<h)-1,b=l>>1,x=-7,k=e?o-1:0,R=e?-1:1,I=r[t+k];for(k+=R,i=I&(1<<-x)-1,I>>=-x,x+=h;x>0;i=i*256+r[t+k],k+=R,x-=8);for(s=i&(1<<-x)-1,i>>=-x,x+=n;x>0;s=s*256+r[t+k],k+=R,x-=8);if(i===0)i=1-b;else{if(i===l)return s?NaN:(I?-1:1)*(1/0);s=s+Math.pow(2,n),i=i-b}return(I?-1:1)*s*Math.pow(2,i-n)};Li.write=function(r,t,e,n,o,i){var s,h,l,b=i*8-o-1,x=(1<<b)-1,k=x>>1,R=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=n?0:i-1,P=n?1:-1,B=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(h=isNaN(t)?1:0,s=x):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+k>=1?t+=R/l:t+=R*Math.pow(2,1-k),t*l>=2&&(s++,l/=2),s+k>=x?(h=0,s=x):s+k>=1?(h=(t*l-1)*Math.pow(2,o),s=s+k):(h=t*Math.pow(2,k-1)*Math.pow(2,o),s=0));o>=8;r[e+I]=h&255,I+=P,h/=256,o-=8);for(s=s<<o|h,b+=o;b>0;r[e+I]=s&255,I+=P,s/=256,b-=8);r[e+I-P]|=B*128}});var Vn=at(zr=>{"use strict";var Ri=Ra(),Ur=Ta(),Ma=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;zr.Buffer=L;zr.SlowBuffer=Bf;zr.INSPECT_MAX_BYTES=50;var Wn=2147483647;zr.kMaxLength=Wn;L.TYPED_ARRAY_SUPPORT=wf();!L.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 wf(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(L.prototype,"parent",{enumerable:!0,get:function(){if(L.isBuffer(this))return this.buffer}});Object.defineProperty(L.prototype,"offset",{enumerable:!0,get:function(){if(L.isBuffer(this))return this.byteOffset}});function De(r){if(r>Wn)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,L.prototype),t}function L(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ci(r)}return Ua(r,t,e)}L.poolSize=8192;function Ua(r,t,e){if(typeof r=="string")return vf(r,t);if(ArrayBuffer.isView(r))return kf(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(Ue(r,ArrayBuffer)||r&&Ue(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ue(r,SharedArrayBuffer)||r&&Ue(r.buffer,SharedArrayBuffer)))return Mi(r,t,e);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 L.from(n,t,e);let o=Sf(r);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return L.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}L.from=function(r,t,e){return Ua(r,t,e)};Object.setPrototypeOf(L.prototype,Uint8Array.prototype);Object.setPrototypeOf(L,Uint8Array);function Na(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 xf(r,t,e){return Na(r),r<=0?De(r):t!==void 0?typeof e=="string"?De(r).fill(t,e):De(r).fill(t):De(r)}L.alloc=function(r,t,e){return xf(r,t,e)};function Ci(r){return Na(r),De(r<0?0:Oi(r)|0)}L.allocUnsafe=function(r){return Ci(r)};L.allocUnsafeSlow=function(r){return Ci(r)};function vf(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!L.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=za(r,t)|0,n=De(e),o=n.write(r,t);return o!==e&&(n=n.slice(0,o)),n}function Ti(r){let t=r.length<0?0:Oi(r.length)|0,e=De(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function kf(r){if(Ue(r,Uint8Array)){let t=new Uint8Array(r);return Mi(t.buffer,t.byteOffset,t.byteLength)}return Ti(r)}function Mi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,L.prototype),n}function Sf(r){if(L.isBuffer(r)){let t=Oi(r.length)|0,e=De(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Ni(r.length)?De(0):Ti(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Ti(r.data)}function Oi(r){if(r>=Wn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Wn.toString(16)+" bytes");return r|0}function Bf(r){return+r!=r&&(r=0),L.alloc(+r)}L.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==L.prototype};L.compare=function(t,e){if(Ue(t,Uint8Array)&&(t=L.from(t,t.offset,t.byteLength)),Ue(e,Uint8Array)&&(e=L.from(e,e.offset,e.byteLength)),!L.isBuffer(t)||!L.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,o=e.length;for(let i=0,s=Math.min(n,o);i<s;++i)if(t[i]!==e[i]){n=t[i],o=e[i];break}return n<o?-1:o<n?1:0};L.isEncoding=function(t){switch(String(t).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}};L.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return L.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let o=L.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){let s=t[n];if(Ue(s,Uint8Array))i+s.length>o.length?(L.isBuffer(s)||(s=L.from(s)),s.copy(o,i)):Uint8Array.prototype.set.call(o,s,i);else if(L.isBuffer(s))s.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return o};function za(r,t){if(L.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Ue(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 e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Pi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ja(r).length;default:if(o)return n?-1:Pi(r).length;t=(""+t).toLowerCase(),o=!0}}L.byteLength=za;function Ef(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Of(this,t,e);case"utf8":case"utf-8":return Fa(this,t,e);case"ascii":return Pf(this,t,e);case"latin1":case"binary":return Cf(this,t,e);case"base64":return Tf(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Uf(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}L.prototype._isBuffer=!0;function kr(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}L.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)kr(this,e,e+1);return this};L.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)kr(this,e,e+3),kr(this,e+1,e+2);return this};L.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)kr(this,e,e+7),kr(this,e+1,e+6),kr(this,e+2,e+5),kr(this,e+3,e+4);return this};L.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Fa(this,0,t):Ef.apply(this,arguments)};L.prototype.toLocaleString=L.prototype.toString;L.prototype.equals=function(t){if(!L.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:L.compare(this,t)===0};L.prototype.inspect=function(){let t="",e=zr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};Ma&&(L.prototype[Ma]=L.prototype.inspect);L.prototype.compare=function(t,e,n,o,i){if(Ue(t,Uint8Array)&&(t=L.from(t,t.offset,t.byteLength)),!L.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),e<0||n>t.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=n)return 0;if(o>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,i>>>=0,this===t)return 0;let s=i-o,h=n-e,l=Math.min(s,h),b=this.slice(o,i),x=t.slice(e,n);for(let k=0;k<l;++k)if(b[k]!==x[k]){s=b[k],h=x[k];break}return s<h?-1:h<s?1:0};function qa(r,t,e,n,o){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Ni(e)&&(e=o?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(o)return-1;e=r.length-1}else if(e<0)if(o)e=0;else return-1;if(typeof t=="string"&&(t=L.from(t,n)),L.isBuffer(t))return t.length===0?-1:Pa(r,t,e,n,o);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Pa(r,[t],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Pa(r,t,e,n,o){let i=1,s=r.length,h=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;i=2,s/=2,h/=2,e/=2}function l(x,k){return i===1?x[k]:x.readUInt16BE(k*i)}let b;if(o){let x=-1;for(b=e;b<s;b++)if(l(r,b)===l(t,x===-1?0:b-x)){if(x===-1&&(x=b),b-x+1===h)return x*i}else x!==-1&&(b-=b-x),x=-1}else for(e+h>s&&(e=s-h),b=e;b>=0;b--){let x=!0;for(let k=0;k<h;k++)if(l(r,b+k)!==l(t,k)){x=!1;break}if(x)return b}return-1}L.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};L.prototype.indexOf=function(t,e,n){return qa(this,t,e,n,!0)};L.prototype.lastIndexOf=function(t,e,n){return qa(this,t,e,n,!1)};function _f(r,t,e,n){e=Number(e)||0;let o=r.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;let i=t.length;n>i/2&&(n=i/2);let s;for(s=0;s<n;++s){let h=parseInt(t.substr(s*2,2),16);if(Ni(h))return s;r[e+s]=h}return s}function If(r,t,e,n){return Hn(Pi(t,r.length-e),r,e,n)}function Af(r,t,e,n){return Hn(Ff(t),r,e,n)}function Lf(r,t,e,n){return Hn(ja(t),r,e,n)}function Rf(r,t,e,n){return Hn(Df(t,r.length-e),r,e,n)}L.prototype.write=function(t,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-e;if((n===void 0||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return _f(this,t,e,n);case"utf8":case"utf-8":return If(this,t,e,n);case"ascii":case"latin1":case"binary":return Af(this,t,e,n);case"base64":return Lf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rf(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};L.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tf(r,t,e){return t===0&&e===r.length?Ri.fromByteArray(r):Ri.fromByteArray(r.slice(t,e))}function Fa(r,t,e){e=Math.min(r.length,e);let n=[],o=t;for(;o<e;){let i=r[o],s=null,h=i>239?4:i>223?3:i>191?2:1;if(o+h<=e){let l,b,x,k;switch(h){case 1:i<128&&(s=i);break;case 2:l=r[o+1],(l&192)===128&&(k=(i&31)<<6|l&63,k>127&&(s=k));break;case 3:l=r[o+1],b=r[o+2],(l&192)===128&&(b&192)===128&&(k=(i&15)<<12|(l&63)<<6|b&63,k>2047&&(k<55296||k>57343)&&(s=k));break;case 4:l=r[o+1],b=r[o+2],x=r[o+3],(l&192)===128&&(b&192)===128&&(x&192)===128&&(k=(i&15)<<18|(l&63)<<12|(b&63)<<6|x&63,k>65535&&k<1114112&&(s=k))}}s===null?(s=65533,h=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),o+=h}return Mf(n)}var Ca=4096;function Mf(r){let t=r.length;if(t<=Ca)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Ca));return e}function Pf(r,t,e){let n="";e=Math.min(r.length,e);for(let o=t;o<e;++o)n+=String.fromCharCode(r[o]&127);return n}function Cf(r,t,e){let n="";e=Math.min(r.length,e);for(let o=t;o<e;++o)n+=String.fromCharCode(r[o]);return n}function Of(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let o="";for(let i=t;i<e;++i)o+=Kf[r[i]];return o}function Uf(r,t,e){let n=r.slice(t,e),o="";for(let i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}L.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let o=this.subarray(t,e);return Object.setPrototypeOf(o,L.prototype),o};function se(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}L.prototype.readUintLE=L.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||se(t,e,this.length);let o=this[t],i=1,s=0;for(;++s<e&&(i*=256);)o+=this[t+s]*i;return o};L.prototype.readUintBE=L.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||se(t,e,this.length);let o=this[t+--e],i=1;for(;e>0&&(i*=256);)o+=this[t+--e]*i;return o};L.prototype.readUint8=L.prototype.readUInt8=function(t,e){return t=t>>>0,e||se(t,1,this.length),this[t]};L.prototype.readUint16LE=L.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||se(t,2,this.length),this[t]|this[t+1]<<8};L.prototype.readUint16BE=L.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||se(t,2,this.length),this[t]<<8|this[t+1]};L.prototype.readUint32LE=L.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||se(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};L.prototype.readUint32BE=L.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||se(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};L.prototype.readBigUInt64LE=rr(function(t){t=t>>>0,Nr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nn(t,this.length-8);let o=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,i=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(o)+(BigInt(i)<<BigInt(32))});L.prototype.readBigUInt64BE=rr(function(t){t=t>>>0,Nr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nn(t,this.length-8);let o=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],i=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(o)<<BigInt(32))+BigInt(i)});L.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||se(t,e,this.length);let o=this[t],i=1,s=0;for(;++s<e&&(i*=256);)o+=this[t+s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o};L.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||se(t,e,this.length);let o=e,i=1,s=this[t+--o];for(;o>0&&(i*=256);)s+=this[t+--o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*e)),s};L.prototype.readInt8=function(t,e){return t=t>>>0,e||se(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};L.prototype.readInt16LE=function(t,e){t=t>>>0,e||se(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};L.prototype.readInt16BE=function(t,e){t=t>>>0,e||se(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};L.prototype.readInt32LE=function(t,e){return t=t>>>0,e||se(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};L.prototype.readInt32BE=function(t,e){return t=t>>>0,e||se(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};L.prototype.readBigInt64LE=rr(function(t){t=t>>>0,Nr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nn(t,this.length-8);let o=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(o)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});L.prototype.readBigInt64BE=rr(function(t){t=t>>>0,Nr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nn(t,this.length-8);let o=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(o)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});L.prototype.readFloatLE=function(t,e){return t=t>>>0,e||se(t,4,this.length),Ur.read(this,t,!0,23,4)};L.prototype.readFloatBE=function(t,e){return t=t>>>0,e||se(t,4,this.length),Ur.read(this,t,!1,23,4)};L.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||se(t,8,this.length),Ur.read(this,t,!0,52,8)};L.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||se(t,8,this.length),Ur.read(this,t,!1,52,8)};function we(r,t,e,n,o,i){if(!L.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}L.prototype.writeUintLE=L.prototype.writeUIntLE=function(t,e,n,o){if(t=+t,e=e>>>0,n=n>>>0,!o){let h=Math.pow(2,8*n)-1;we(this,t,e,n,h,0)}let i=1,s=0;for(this[e]=t&255;++s<n&&(i*=256);)this[e+s]=t/i&255;return e+n};L.prototype.writeUintBE=L.prototype.writeUIntBE=function(t,e,n,o){if(t=+t,e=e>>>0,n=n>>>0,!o){let h=Math.pow(2,8*n)-1;we(this,t,e,n,h,0)}let i=n-1,s=1;for(this[e+i]=t&255;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+n};L.prototype.writeUint8=L.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,1,255,0),this[e]=t&255,e+1};L.prototype.writeUint16LE=L.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};L.prototype.writeUint16BE=L.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};L.prototype.writeUint32LE=L.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};L.prototype.writeUint32BE=L.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Da(r,t,e,n,o){$a(t,n,o,r,e,7);let i=Number(t&BigInt(4294967295));r[e++]=i,i=i>>8,r[e++]=i,i=i>>8,r[e++]=i,i=i>>8,r[e++]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,e}function Ka(r,t,e,n,o){$a(t,n,o,r,e,7);let i=Number(t&BigInt(4294967295));r[e+7]=i,i=i>>8,r[e+6]=i,i=i>>8,r[e+5]=i,i=i>>8,r[e+4]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=s,s=s>>8,r[e+2]=s,s=s>>8,r[e+1]=s,s=s>>8,r[e]=s,e+8}L.prototype.writeBigUInt64LE=rr(function(t,e=0){return Da(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});L.prototype.writeBigUInt64BE=rr(function(t,e=0){return Ka(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});L.prototype.writeIntLE=function(t,e,n,o){if(t=+t,e=e>>>0,!o){let l=Math.pow(2,8*n-1);we(this,t,e,n,l-1,-l)}let i=0,s=1,h=0;for(this[e]=t&255;++i<n&&(s*=256);)t<0&&h===0&&this[e+i-1]!==0&&(h=1),this[e+i]=(t/s>>0)-h&255;return e+n};L.prototype.writeIntBE=function(t,e,n,o){if(t=+t,e=e>>>0,!o){let l=Math.pow(2,8*n-1);we(this,t,e,n,l-1,-l)}let i=n-1,s=1,h=0;for(this[e+i]=t&255;--i>=0&&(s*=256);)t<0&&h===0&&this[e+i+1]!==0&&(h=1),this[e+i]=(t/s>>0)-h&255;return e+n};L.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};L.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};L.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};L.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};L.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||we(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};L.prototype.writeBigInt64LE=rr(function(t,e=0){return Da(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});L.prototype.writeBigInt64BE=rr(function(t,e=0){return Ka(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Wa(r,t,e,n,o,i){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ha(r,t,e,n,o){return t=+t,e=e>>>0,o||Wa(r,t,e,4,34028234663852886e22,-34028234663852886e22),Ur.write(r,t,e,n,23,4),e+4}L.prototype.writeFloatLE=function(t,e,n){return Ha(this,t,e,!0,n)};L.prototype.writeFloatBE=function(t,e,n){return Ha(this,t,e,!1,n)};function Va(r,t,e,n,o){return t=+t,e=e>>>0,o||Wa(r,t,e,8,17976931348623157e292,-17976931348623157e292),Ur.write(r,t,e,n,52,8),e+8}L.prototype.writeDoubleLE=function(t,e,n){return Va(this,t,e,!0,n)};L.prototype.writeDoubleBE=function(t,e,n){return Va(this,t,e,!1,n)};L.prototype.copy=function(t,e,n,o){if(!L.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),e>=t.length&&(e=t.length),e||(e=0),o>0&&o<n&&(o=n),o===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-e<o-n&&(o=t.length-e+n);let i=o-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,o):Uint8Array.prototype.set.call(t,this.subarray(n,o),e),i};L.prototype.fill=function(t,e,n,o){if(typeof t=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!L.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(t.length===1){let s=t.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let i;if(typeof t=="number")for(i=e;i<n;++i)this[i]=t;else{let s=L.isBuffer(t)?t:L.from(t,o),h=s.length;if(h===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=s[i%h]}return this};var Or={};function Ui(r,t,e){Or[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Ui("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ui("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);Ui("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,o=e;return Number.isInteger(e)&&Math.abs(e)>2**32?o=Oa(String(e)):typeof e=="bigint"&&(o=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(o=Oa(o)),o+="n"),n+=` It must be ${t}. Received ${o}`,n},RangeError);function Oa(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function Nf(r,t,e){Nr(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&nn(t,r.length-(e+1))}function $a(r,t,e,n,o,i){if(r>e||r<t){let s=typeof t=="bigint"?"n":"",h;throw i>3?t===0||t===BigInt(0)?h=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:h=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:h=`>= ${t}${s} and <= ${e}${s}`,new Or.ERR_OUT_OF_RANGE("value",h,r)}Nf(n,o,i)}function Nr(r,t){if(typeof r!="number")throw new Or.ERR_INVALID_ARG_TYPE(t,"number",r)}function nn(r,t,e){throw Math.floor(r)!==r?(Nr(r,e),new Or.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new Or.ERR_BUFFER_OUT_OF_BOUNDS:new Or.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var zf=/[^+/0-9A-Za-z-_]/g;function qf(r){if(r=r.split("=")[0],r=r.trim().replace(zf,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Pi(r,t){t=t||1/0;let e,n=r.length,o=null,i=[];for(let s=0;s<n;++s){if(e=r.charCodeAt(s),e>55295&&e<57344){if(!o){if(e>56319){(t-=3)>-1&&i.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(t-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((t-=1)<0)break;i.push(e)}else if(e<2048){if((t-=2)<0)break;i.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;i.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return i}function Ff(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Df(r,t){let e,n,o,i=[];for(let s=0;s<r.length&&!((t-=2)<0);++s)e=r.charCodeAt(s),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function ja(r){return Ri.toByteArray(qf(r))}function Hn(r,t,e,n){let o;for(o=0;o<n&&!(o+e>=t.length||o>=r.length);++o)t[o+e]=r[o];return o}function Ue(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Ni(r){return r!==r}var Kf=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let o=0;o<16;++o)t[n+o]=r[e]+r[o]}return t}();function rr(r){return typeof BigInt>"u"?Wf:r}function Wf(){throw new Error("BigInt not supported")}});var hc=at(()=>{"use strict"});var is=at((dc,os)=>{"use strict";(function(r,t){"use strict";function e(v,a){if(!v)throw new Error(a||"Assertion failed")}function n(v,a){v.super_=a;var u=function(){};u.prototype=a.prototype,v.prototype=new u,v.prototype.constructor=v}function o(v,a,u){if(o.isBN(v))return v;this.negative=0,this.words=null,this.length=0,this.red=null,v!==null&&((a==="le"||a==="be")&&(u=a,a=10),this._init(v||0,a||10,u||"be"))}typeof r=="object"?r.exports=o:t.BN=o,o.BN=o,o.wordSize=26;var i;try{typeof window<"u"&&typeof window.Buffer<"u"?i=window.Buffer:i=hc().Buffer}catch{}o.isBN=function(a){return a instanceof o?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===o.wordSize&&Array.isArray(a.words)},o.max=function(a,u){return a.cmp(u)>0?a:u},o.min=function(a,u){return a.cmp(u)<0?a:u},o.prototype._init=function(a,u,f){if(typeof a=="number")return this._initNumber(a,u,f);if(typeof a=="object")return this._initArray(a,u,f);u==="hex"&&(u=16),e(u===(u|0)&&u>=2&&u<=36),a=a.toString().replace(/\s+/g,"");var d=0;a[0]==="-"&&(d++,this.negative=1),d<a.length&&(u===16?this._parseHex(a,d,f):(this._parseBase(a,u,d),f==="le"&&this._initArray(this.toArray(),u,f)))},o.prototype._initNumber=function(a,u,f){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):(e(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),f==="le"&&this._initArray(this.toArray(),u,f)},o.prototype._initArray=function(a,u,f){if(e(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 d=0;d<this.length;d++)this.words[d]=0;var p,g,w=0;if(f==="be")for(d=a.length-1,p=0;d>=0;d-=3)g=a[d]|a[d-1]<<8|a[d-2]<<16,this.words[p]|=g<<w&67108863,this.words[p+1]=g>>>26-w&67108863,w+=24,w>=26&&(w-=26,p++);else if(f==="le")for(d=0,p=0;d<a.length;d+=3)g=a[d]|a[d+1]<<8|a[d+2]<<16,this.words[p]|=g<<w&67108863,this.words[p+1]=g>>>26-w&67108863,w+=24,w>=26&&(w-=26,p++);return this._strip()};function s(v,a){var u=v.charCodeAt(a);if(u>=48&&u<=57)return u-48;if(u>=65&&u<=70)return u-55;if(u>=97&&u<=102)return u-87;e(!1,"Invalid character in "+v)}function h(v,a,u){var f=s(v,u);return u-1>=a&&(f|=s(v,u-1)<<4),f}o.prototype._parseHex=function(a,u,f){this.length=Math.ceil((a.length-u)/6),this.words=new Array(this.length);for(var d=0;d<this.length;d++)this.words[d]=0;var p=0,g=0,w;if(f==="be")for(d=a.length-1;d>=u;d-=2)w=h(a,u,d)<<p,this.words[g]|=w&67108863,p>=18?(p-=18,g+=1,this.words[g]|=w>>>26):p+=8;else{var y=a.length-u;for(d=y%2===0?u+1:u;d<a.length;d+=2)w=h(a,u,d)<<p,this.words[g]|=w&67108863,p>=18?(p-=18,g+=1,this.words[g]|=w>>>26):p+=8}this._strip()};function l(v,a,u,f){for(var d=0,p=0,g=Math.min(v.length,u),w=a;w<g;w++){var y=v.charCodeAt(w)-48;d*=f,y>=49?p=y-49+10:y>=17?p=y-17+10:p=y,e(y>=0&&p<f,"Invalid character"),d+=p}return d}o.prototype._parseBase=function(a,u,f){this.words=[0],this.length=1;for(var d=0,p=1;p<=67108863;p*=u)d++;d--,p=p/u|0;for(var g=a.length-f,w=g%d,y=Math.min(g,g-w)+f,c=0,m=f;m<y;m+=d)c=l(a,m,m+d,u),this.imuln(p),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(w!==0){var M=1;for(c=l(a,m,a.length,u),m=0;m<w;m++)M*=u;this.imuln(M),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},o.prototype.copy=function(a){a.words=new Array(this.length);for(var u=0;u<this.length;u++)a.words[u]=this.words[u];a.length=this.length,a.negative=this.negative,a.red=this.red};function b(v,a){v.words=a.words,v.length=a.length,v.negative=a.negative,v.red=a.red}if(o.prototype._move=function(a){b(a,this)},o.prototype.clone=function(){var a=new o(null);return this.copy(a),a},o.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=x}catch{o.prototype.inspect=x}else o.prototype.inspect=x;function x(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var k=["","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"],R=[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],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(a,u){a=a||10,u=u|0||1;var f;if(a===16||a==="hex"){f="";for(var d=0,p=0,g=0;g<this.length;g++){var w=this.words[g],y=((w<<d|p)&16777215).toString(16);p=w>>>24-d&16777215,d+=2,d>=26&&(d-=26,g--),p!==0||g!==this.length-1?f=k[6-y.length]+y+f:f=y+f}for(p!==0&&(f=p.toString(16)+f);f.length%u!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(a===(a|0)&&a>=2&&a<=36){var c=R[a],m=I[a];f="";var M=this.clone();for(M.negative=0;!M.isZero();){var U=M.modrn(m).toString(a);M=M.idivn(m),M.isZero()?f=U+f:f=k[c-U.length]+U+f}for(this.isZero()&&(f="0"+f);f.length%u!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}e(!1,"Base should be between 2 and 36")},o.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&&e(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},o.prototype.toJSON=function(){return this.toString(16,2)},i&&(o.prototype.toBuffer=function(a,u){return this.toArrayLike(i,a,u)}),o.prototype.toArray=function(a,u){return this.toArrayLike(Array,a,u)};var P=function(a,u){return a.allocUnsafe?a.allocUnsafe(u):new a(u)};o.prototype.toArrayLike=function(a,u,f){this._strip();var d=this.byteLength(),p=f||Math.max(1,d);e(d<=p,"byte array longer than desired length"),e(p>0,"Requested array length <= 0");var g=P(a,p),w=u==="le"?"LE":"BE";return this["_toArrayLike"+w](g,d),g},o.prototype._toArrayLikeLE=function(a,u){for(var f=0,d=0,p=0,g=0;p<this.length;p++){var w=this.words[p]<<g|d;a[f++]=w&255,f<a.length&&(a[f++]=w>>8&255),f<a.length&&(a[f++]=w>>16&255),g===6?(f<a.length&&(a[f++]=w>>24&255),d=0,g=0):(d=w>>>24,g+=2)}if(f<a.length)for(a[f++]=d;f<a.length;)a[f++]=0},o.prototype._toArrayLikeBE=function(a,u){for(var f=a.length-1,d=0,p=0,g=0;p<this.length;p++){var w=this.words[p]<<g|d;a[f--]=w&255,f>=0&&(a[f--]=w>>8&255),f>=0&&(a[f--]=w>>16&255),g===6?(f>=0&&(a[f--]=w>>24&255),d=0,g=0):(d=w>>>24,g+=2)}if(f>=0)for(a[f--]=d;f>=0;)a[f--]=0},Math.clz32?o.prototype._countBits=function(a){return 32-Math.clz32(a)}:o.prototype._countBits=function(a){var u=a,f=0;return u>=4096&&(f+=13,u>>>=13),u>=64&&(f+=7,u>>>=7),u>=8&&(f+=4,u>>>=4),u>=2&&(f+=2,u>>>=2),f+u},o.prototype._zeroBits=function(a){if(a===0)return 26;var u=a,f=0;return(u&8191)===0&&(f+=13,u>>>=13),(u&127)===0&&(f+=7,u>>>=7),(u&15)===0&&(f+=4,u>>>=4),(u&3)===0&&(f+=2,u>>>=2),(u&1)===0&&f++,f},o.prototype.bitLength=function(){var a=this.words[this.length-1],u=this._countBits(a);return(this.length-1)*26+u};function B(v){for(var a=new Array(v.bitLength()),u=0;u<a.length;u++){var f=u/26|0,d=u%26;a[u]=v.words[f]>>>d&1}return a}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,u=0;u<this.length;u++){var f=this._zeroBits(this.words[u]);if(a+=f,f!==26)break}return a},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},o.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var u=0;u<a.length;u++)this.words[u]=this.words[u]|a.words[u];return this._strip()},o.prototype.ior=function(a){return e((this.negative|a.negative)===0),this.iuor(a)},o.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},o.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},o.prototype.iuand=function(a){var u;this.length>a.length?u=a:u=this;for(var f=0;f<u.length;f++)this.words[f]=this.words[f]&a.words[f];return this.length=u.length,this._strip()},o.prototype.iand=function(a){return e((this.negative|a.negative)===0),this.iuand(a)},o.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},o.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},o.prototype.iuxor=function(a){var u,f;this.length>a.length?(u=this,f=a):(u=a,f=this);for(var d=0;d<f.length;d++)this.words[d]=u.words[d]^f.words[d];if(this!==u)for(;d<u.length;d++)this.words[d]=u.words[d];return this.length=u.length,this._strip()},o.prototype.ixor=function(a){return e((this.negative|a.negative)===0),this.iuxor(a)},o.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},o.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},o.prototype.inotn=function(a){e(typeof a=="number"&&a>=0);var u=Math.ceil(a/26)|0,f=a%26;this._expand(u),f>0&&u--;for(var d=0;d<u;d++)this.words[d]=~this.words[d]&67108863;return f>0&&(this.words[d]=~this.words[d]&67108863>>26-f),this._strip()},o.prototype.notn=function(a){return this.clone().inotn(a)},o.prototype.setn=function(a,u){e(typeof a=="number"&&a>=0);var f=a/26|0,d=a%26;return this._expand(f+1),u?this.words[f]=this.words[f]|1<<d:this.words[f]=this.words[f]&~(1<<d),this._strip()},o.prototype.iadd=function(a){var u;if(this.negative!==0&&a.negative===0)return this.negative=0,u=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,u=this.isub(a),a.negative=1,u._normSign();var f,d;this.length>a.length?(f=this,d=a):(f=a,d=this);for(var p=0,g=0;g<d.length;g++)u=(f.words[g]|0)+(d.words[g]|0)+p,this.words[g]=u&67108863,p=u>>>26;for(;p!==0&&g<f.length;g++)u=(f.words[g]|0)+p,this.words[g]=u&67108863,p=u>>>26;if(this.length=f.length,p!==0)this.words[this.length]=p,this.length++;else if(f!==this)for(;g<f.length;g++)this.words[g]=f.words[g];return this},o.prototype.add=function(a){var u;return a.negative!==0&&this.negative===0?(a.negative=0,u=this.sub(a),a.negative^=1,u):a.negative===0&&this.negative!==0?(this.negative=0,u=a.sub(this),this.negative=1,u):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},o.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var u=this.iadd(a);return a.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var f=this.cmp(a);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var d,p;f>0?(d=this,p=a):(d=a,p=this);for(var g=0,w=0;w<p.length;w++)u=(d.words[w]|0)-(p.words[w]|0)+g,g=u>>26,this.words[w]=u&67108863;for(;g!==0&&w<d.length;w++)u=(d.words[w]|0)+g,g=u>>26,this.words[w]=u&67108863;if(g===0&&w<d.length&&d!==this)for(;w<d.length;w++)this.words[w]=d.words[w];return this.length=Math.max(this.length,w),d!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(a){return this.clone().isub(a)};function A(v,a,u){u.negative=a.negative^v.negative;var f=v.length+a.length|0;u.length=f,f=f-1|0;var d=v.words[0]|0,p=a.words[0]|0,g=d*p,w=g&67108863,y=g/67108864|0;u.words[0]=w;for(var c=1;c<f;c++){for(var m=y>>>26,M=y&67108863,U=Math.min(c,a.length-1),O=Math.max(0,c-v.length+1);O<=U;O++){var D=c-O|0;d=v.words[D]|0,p=a.words[O]|0,g=d*p+M,m+=g/67108864|0,M=g&67108863}u.words[c]=M|0,y=m|0}return y!==0?u.words[c]=y|0:u.length--,u._strip()}var T=function(a,u,f){var d=a.words,p=u.words,g=f.words,w=0,y,c,m,M=d[0]|0,U=M&8191,O=M>>>13,D=d[1]|0,Y=D&8191,J=D>>>13,mt=d[2]|0,Q=mt&8191,tt=mt>>>13,re=d[3]|0,ht=re&8191,dt=re>>>13,er=d[4]|0,Bt=er&8191,Lt=er>>>13,qn=d[5]|0,Rt=qn&8191,Tt=qn>>>13,tn=d[6]|0,Et=tn&8191,xt=tn>>>13,en=d[7]|0,_t=en&8191,It=en>>>13,rn=d[8]|0,At=rn&8191,Mt=rn>>>13,Fn=d[9]|0,Pt=Fn&8191,Ct=Fn>>>13,ya=p[0]|0,Ut=ya&8191,Nt=ya>>>13,ga=p[1]|0,zt=ga&8191,qt=ga>>>13,ma=p[2]|0,Ft=ma&8191,Dt=ma>>>13,ba=p[3]|0,Kt=ba&8191,Wt=ba>>>13,wa=p[4]|0,Ht=wa&8191,Vt=wa>>>13,xa=p[5]|0,$t=xa&8191,jt=xa>>>13,va=p[6]|0,Gt=va&8191,Yt=va>>>13,ka=p[7]|0,Zt=ka&8191,Jt=ka>>>13,Sa=p[8]|0,Xt=Sa&8191,Qt=Sa>>>13,Ba=p[9]|0,te=Ba&8191,ee=Ba>>>13;f.negative=a.negative^u.negative,f.length=19,y=Math.imul(U,Ut),c=Math.imul(U,Nt),c=c+Math.imul(O,Ut)|0,m=Math.imul(O,Nt);var ai=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(ai>>>26)|0,ai&=67108863,y=Math.imul(Y,Ut),c=Math.imul(Y,Nt),c=c+Math.imul(J,Ut)|0,m=Math.imul(J,Nt),y=y+Math.imul(U,zt)|0,c=c+Math.imul(U,qt)|0,c=c+Math.imul(O,zt)|0,m=m+Math.imul(O,qt)|0;var ci=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(ci>>>26)|0,ci&=67108863,y=Math.imul(Q,Ut),c=Math.imul(Q,Nt),c=c+Math.imul(tt,Ut)|0,m=Math.imul(tt,Nt),y=y+Math.imul(Y,zt)|0,c=c+Math.imul(Y,qt)|0,c=c+Math.imul(J,zt)|0,m=m+Math.imul(J,qt)|0,y=y+Math.imul(U,Ft)|0,c=c+Math.imul(U,Dt)|0,c=c+Math.imul(O,Ft)|0,m=m+Math.imul(O,Dt)|0;var ui=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(ui>>>26)|0,ui&=67108863,y=Math.imul(ht,Ut),c=Math.imul(ht,Nt),c=c+Math.imul(dt,Ut)|0,m=Math.imul(dt,Nt),y=y+Math.imul(Q,zt)|0,c=c+Math.imul(Q,qt)|0,c=c+Math.imul(tt,zt)|0,m=m+Math.imul(tt,qt)|0,y=y+Math.imul(Y,Ft)|0,c=c+Math.imul(Y,Dt)|0,c=c+Math.imul(J,Ft)|0,m=m+Math.imul(J,Dt)|0,y=y+Math.imul(U,Kt)|0,c=c+Math.imul(U,Wt)|0,c=c+Math.imul(O,Kt)|0,m=m+Math.imul(O,Wt)|0;var fi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(fi>>>26)|0,fi&=67108863,y=Math.imul(Bt,Ut),c=Math.imul(Bt,Nt),c=c+Math.imul(Lt,Ut)|0,m=Math.imul(Lt,Nt),y=y+Math.imul(ht,zt)|0,c=c+Math.imul(ht,qt)|0,c=c+Math.imul(dt,zt)|0,m=m+Math.imul(dt,qt)|0,y=y+Math.imul(Q,Ft)|0,c=c+Math.imul(Q,Dt)|0,c=c+Math.imul(tt,Ft)|0,m=m+Math.imul(tt,Dt)|0,y=y+Math.imul(Y,Kt)|0,c=c+Math.imul(Y,Wt)|0,c=c+Math.imul(J,Kt)|0,m=m+Math.imul(J,Wt)|0,y=y+Math.imul(U,Ht)|0,c=c+Math.imul(U,Vt)|0,c=c+Math.imul(O,Ht)|0,m=m+Math.imul(O,Vt)|0;var li=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(li>>>26)|0,li&=67108863,y=Math.imul(Rt,Ut),c=Math.imul(Rt,Nt),c=c+Math.imul(Tt,Ut)|0,m=Math.imul(Tt,Nt),y=y+Math.imul(Bt,zt)|0,c=c+Math.imul(Bt,qt)|0,c=c+Math.imul(Lt,zt)|0,m=m+Math.imul(Lt,qt)|0,y=y+Math.imul(ht,Ft)|0,c=c+Math.imul(ht,Dt)|0,c=c+Math.imul(dt,Ft)|0,m=m+Math.imul(dt,Dt)|0,y=y+Math.imul(Q,Kt)|0,c=c+Math.imul(Q,Wt)|0,c=c+Math.imul(tt,Kt)|0,m=m+Math.imul(tt,Wt)|0,y=y+Math.imul(Y,Ht)|0,c=c+Math.imul(Y,Vt)|0,c=c+Math.imul(J,Ht)|0,m=m+Math.imul(J,Vt)|0,y=y+Math.imul(U,$t)|0,c=c+Math.imul(U,jt)|0,c=c+Math.imul(O,$t)|0,m=m+Math.imul(O,jt)|0;var hi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(hi>>>26)|0,hi&=67108863,y=Math.imul(Et,Ut),c=Math.imul(Et,Nt),c=c+Math.imul(xt,Ut)|0,m=Math.imul(xt,Nt),y=y+Math.imul(Rt,zt)|0,c=c+Math.imul(Rt,qt)|0,c=c+Math.imul(Tt,zt)|0,m=m+Math.imul(Tt,qt)|0,y=y+Math.imul(Bt,Ft)|0,c=c+Math.imul(Bt,Dt)|0,c=c+Math.imul(Lt,Ft)|0,m=m+Math.imul(Lt,Dt)|0,y=y+Math.imul(ht,Kt)|0,c=c+Math.imul(ht,Wt)|0,c=c+Math.imul(dt,Kt)|0,m=m+Math.imul(dt,Wt)|0,y=y+Math.imul(Q,Ht)|0,c=c+Math.imul(Q,Vt)|0,c=c+Math.imul(tt,Ht)|0,m=m+Math.imul(tt,Vt)|0,y=y+Math.imul(Y,$t)|0,c=c+Math.imul(Y,jt)|0,c=c+Math.imul(J,$t)|0,m=m+Math.imul(J,jt)|0,y=y+Math.imul(U,Gt)|0,c=c+Math.imul(U,Yt)|0,c=c+Math.imul(O,Gt)|0,m=m+Math.imul(O,Yt)|0;var di=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(di>>>26)|0,di&=67108863,y=Math.imul(_t,Ut),c=Math.imul(_t,Nt),c=c+Math.imul(It,Ut)|0,m=Math.imul(It,Nt),y=y+Math.imul(Et,zt)|0,c=c+Math.imul(Et,qt)|0,c=c+Math.imul(xt,zt)|0,m=m+Math.imul(xt,qt)|0,y=y+Math.imul(Rt,Ft)|0,c=c+Math.imul(Rt,Dt)|0,c=c+Math.imul(Tt,Ft)|0,m=m+Math.imul(Tt,Dt)|0,y=y+Math.imul(Bt,Kt)|0,c=c+Math.imul(Bt,Wt)|0,c=c+Math.imul(Lt,Kt)|0,m=m+Math.imul(Lt,Wt)|0,y=y+Math.imul(ht,Ht)|0,c=c+Math.imul(ht,Vt)|0,c=c+Math.imul(dt,Ht)|0,m=m+Math.imul(dt,Vt)|0,y=y+Math.imul(Q,$t)|0,c=c+Math.imul(Q,jt)|0,c=c+Math.imul(tt,$t)|0,m=m+Math.imul(tt,jt)|0,y=y+Math.imul(Y,Gt)|0,c=c+Math.imul(Y,Yt)|0,c=c+Math.imul(J,Gt)|0,m=m+Math.imul(J,Yt)|0,y=y+Math.imul(U,Zt)|0,c=c+Math.imul(U,Jt)|0,c=c+Math.imul(O,Zt)|0,m=m+Math.imul(O,Jt)|0;var pi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(pi>>>26)|0,pi&=67108863,y=Math.imul(At,Ut),c=Math.imul(At,Nt),c=c+Math.imul(Mt,Ut)|0,m=Math.imul(Mt,Nt),y=y+Math.imul(_t,zt)|0,c=c+Math.imul(_t,qt)|0,c=c+Math.imul(It,zt)|0,m=m+Math.imul(It,qt)|0,y=y+Math.imul(Et,Ft)|0,c=c+Math.imul(Et,Dt)|0,c=c+Math.imul(xt,Ft)|0,m=m+Math.imul(xt,Dt)|0,y=y+Math.imul(Rt,Kt)|0,c=c+Math.imul(Rt,Wt)|0,c=c+Math.imul(Tt,Kt)|0,m=m+Math.imul(Tt,Wt)|0,y=y+Math.imul(Bt,Ht)|0,c=c+Math.imul(Bt,Vt)|0,c=c+Math.imul(Lt,Ht)|0,m=m+Math.imul(Lt,Vt)|0,y=y+Math.imul(ht,$t)|0,c=c+Math.imul(ht,jt)|0,c=c+Math.imul(dt,$t)|0,m=m+Math.imul(dt,jt)|0,y=y+Math.imul(Q,Gt)|0,c=c+Math.imul(Q,Yt)|0,c=c+Math.imul(tt,Gt)|0,m=m+Math.imul(tt,Yt)|0,y=y+Math.imul(Y,Zt)|0,c=c+Math.imul(Y,Jt)|0,c=c+Math.imul(J,Zt)|0,m=m+Math.imul(J,Jt)|0,y=y+Math.imul(U,Xt)|0,c=c+Math.imul(U,Qt)|0,c=c+Math.imul(O,Xt)|0,m=m+Math.imul(O,Qt)|0;var yi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(yi>>>26)|0,yi&=67108863,y=Math.imul(Pt,Ut),c=Math.imul(Pt,Nt),c=c+Math.imul(Ct,Ut)|0,m=Math.imul(Ct,Nt),y=y+Math.imul(At,zt)|0,c=c+Math.imul(At,qt)|0,c=c+Math.imul(Mt,zt)|0,m=m+Math.imul(Mt,qt)|0,y=y+Math.imul(_t,Ft)|0,c=c+Math.imul(_t,Dt)|0,c=c+Math.imul(It,Ft)|0,m=m+Math.imul(It,Dt)|0,y=y+Math.imul(Et,Kt)|0,c=c+Math.imul(Et,Wt)|0,c=c+Math.imul(xt,Kt)|0,m=m+Math.imul(xt,Wt)|0,y=y+Math.imul(Rt,Ht)|0,c=c+Math.imul(Rt,Vt)|0,c=c+Math.imul(Tt,Ht)|0,m=m+Math.imul(Tt,Vt)|0,y=y+Math.imul(Bt,$t)|0,c=c+Math.imul(Bt,jt)|0,c=c+Math.imul(Lt,$t)|0,m=m+Math.imul(Lt,jt)|0,y=y+Math.imul(ht,Gt)|0,c=c+Math.imul(ht,Yt)|0,c=c+Math.imul(dt,Gt)|0,m=m+Math.imul(dt,Yt)|0,y=y+Math.imul(Q,Zt)|0,c=c+Math.imul(Q,Jt)|0,c=c+Math.imul(tt,Zt)|0,m=m+Math.imul(tt,Jt)|0,y=y+Math.imul(Y,Xt)|0,c=c+Math.imul(Y,Qt)|0,c=c+Math.imul(J,Xt)|0,m=m+Math.imul(J,Qt)|0,y=y+Math.imul(U,te)|0,c=c+Math.imul(U,ee)|0,c=c+Math.imul(O,te)|0,m=m+Math.imul(O,ee)|0;var gi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(gi>>>26)|0,gi&=67108863,y=Math.imul(Pt,zt),c=Math.imul(Pt,qt),c=c+Math.imul(Ct,zt)|0,m=Math.imul(Ct,qt),y=y+Math.imul(At,Ft)|0,c=c+Math.imul(At,Dt)|0,c=c+Math.imul(Mt,Ft)|0,m=m+Math.imul(Mt,Dt)|0,y=y+Math.imul(_t,Kt)|0,c=c+Math.imul(_t,Wt)|0,c=c+Math.imul(It,Kt)|0,m=m+Math.imul(It,Wt)|0,y=y+Math.imul(Et,Ht)|0,c=c+Math.imul(Et,Vt)|0,c=c+Math.imul(xt,Ht)|0,m=m+Math.imul(xt,Vt)|0,y=y+Math.imul(Rt,$t)|0,c=c+Math.imul(Rt,jt)|0,c=c+Math.imul(Tt,$t)|0,m=m+Math.imul(Tt,jt)|0,y=y+Math.imul(Bt,Gt)|0,c=c+Math.imul(Bt,Yt)|0,c=c+Math.imul(Lt,Gt)|0,m=m+Math.imul(Lt,Yt)|0,y=y+Math.imul(ht,Zt)|0,c=c+Math.imul(ht,Jt)|0,c=c+Math.imul(dt,Zt)|0,m=m+Math.imul(dt,Jt)|0,y=y+Math.imul(Q,Xt)|0,c=c+Math.imul(Q,Qt)|0,c=c+Math.imul(tt,Xt)|0,m=m+Math.imul(tt,Qt)|0,y=y+Math.imul(Y,te)|0,c=c+Math.imul(Y,ee)|0,c=c+Math.imul(J,te)|0,m=m+Math.imul(J,ee)|0;var mi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(mi>>>26)|0,mi&=67108863,y=Math.imul(Pt,Ft),c=Math.imul(Pt,Dt),c=c+Math.imul(Ct,Ft)|0,m=Math.imul(Ct,Dt),y=y+Math.imul(At,Kt)|0,c=c+Math.imul(At,Wt)|0,c=c+Math.imul(Mt,Kt)|0,m=m+Math.imul(Mt,Wt)|0,y=y+Math.imul(_t,Ht)|0,c=c+Math.imul(_t,Vt)|0,c=c+Math.imul(It,Ht)|0,m=m+Math.imul(It,Vt)|0,y=y+Math.imul(Et,$t)|0,c=c+Math.imul(Et,jt)|0,c=c+Math.imul(xt,$t)|0,m=m+Math.imul(xt,jt)|0,y=y+Math.imul(Rt,Gt)|0,c=c+Math.imul(Rt,Yt)|0,c=c+Math.imul(Tt,Gt)|0,m=m+Math.imul(Tt,Yt)|0,y=y+Math.imul(Bt,Zt)|0,c=c+Math.imul(Bt,Jt)|0,c=c+Math.imul(Lt,Zt)|0,m=m+Math.imul(Lt,Jt)|0,y=y+Math.imul(ht,Xt)|0,c=c+Math.imul(ht,Qt)|0,c=c+Math.imul(dt,Xt)|0,m=m+Math.imul(dt,Qt)|0,y=y+Math.imul(Q,te)|0,c=c+Math.imul(Q,ee)|0,c=c+Math.imul(tt,te)|0,m=m+Math.imul(tt,ee)|0;var bi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(bi>>>26)|0,bi&=67108863,y=Math.imul(Pt,Kt),c=Math.imul(Pt,Wt),c=c+Math.imul(Ct,Kt)|0,m=Math.imul(Ct,Wt),y=y+Math.imul(At,Ht)|0,c=c+Math.imul(At,Vt)|0,c=c+Math.imul(Mt,Ht)|0,m=m+Math.imul(Mt,Vt)|0,y=y+Math.imul(_t,$t)|0,c=c+Math.imul(_t,jt)|0,c=c+Math.imul(It,$t)|0,m=m+Math.imul(It,jt)|0,y=y+Math.imul(Et,Gt)|0,c=c+Math.imul(Et,Yt)|0,c=c+Math.imul(xt,Gt)|0,m=m+Math.imul(xt,Yt)|0,y=y+Math.imul(Rt,Zt)|0,c=c+Math.imul(Rt,Jt)|0,c=c+Math.imul(Tt,Zt)|0,m=m+Math.imul(Tt,Jt)|0,y=y+Math.imul(Bt,Xt)|0,c=c+Math.imul(Bt,Qt)|0,c=c+Math.imul(Lt,Xt)|0,m=m+Math.imul(Lt,Qt)|0,y=y+Math.imul(ht,te)|0,c=c+Math.imul(ht,ee)|0,c=c+Math.imul(dt,te)|0,m=m+Math.imul(dt,ee)|0;var wi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(wi>>>26)|0,wi&=67108863,y=Math.imul(Pt,Ht),c=Math.imul(Pt,Vt),c=c+Math.imul(Ct,Ht)|0,m=Math.imul(Ct,Vt),y=y+Math.imul(At,$t)|0,c=c+Math.imul(At,jt)|0,c=c+Math.imul(Mt,$t)|0,m=m+Math.imul(Mt,jt)|0,y=y+Math.imul(_t,Gt)|0,c=c+Math.imul(_t,Yt)|0,c=c+Math.imul(It,Gt)|0,m=m+Math.imul(It,Yt)|0,y=y+Math.imul(Et,Zt)|0,c=c+Math.imul(Et,Jt)|0,c=c+Math.imul(xt,Zt)|0,m=m+Math.imul(xt,Jt)|0,y=y+Math.imul(Rt,Xt)|0,c=c+Math.imul(Rt,Qt)|0,c=c+Math.imul(Tt,Xt)|0,m=m+Math.imul(Tt,Qt)|0,y=y+Math.imul(Bt,te)|0,c=c+Math.imul(Bt,ee)|0,c=c+Math.imul(Lt,te)|0,m=m+Math.imul(Lt,ee)|0;var xi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(xi>>>26)|0,xi&=67108863,y=Math.imul(Pt,$t),c=Math.imul(Pt,jt),c=c+Math.imul(Ct,$t)|0,m=Math.imul(Ct,jt),y=y+Math.imul(At,Gt)|0,c=c+Math.imul(At,Yt)|0,c=c+Math.imul(Mt,Gt)|0,m=m+Math.imul(Mt,Yt)|0,y=y+Math.imul(_t,Zt)|0,c=c+Math.imul(_t,Jt)|0,c=c+Math.imul(It,Zt)|0,m=m+Math.imul(It,Jt)|0,y=y+Math.imul(Et,Xt)|0,c=c+Math.imul(Et,Qt)|0,c=c+Math.imul(xt,Xt)|0,m=m+Math.imul(xt,Qt)|0,y=y+Math.imul(Rt,te)|0,c=c+Math.imul(Rt,ee)|0,c=c+Math.imul(Tt,te)|0,m=m+Math.imul(Tt,ee)|0;var vi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(vi>>>26)|0,vi&=67108863,y=Math.imul(Pt,Gt),c=Math.imul(Pt,Yt),c=c+Math.imul(Ct,Gt)|0,m=Math.imul(Ct,Yt),y=y+Math.imul(At,Zt)|0,c=c+Math.imul(At,Jt)|0,c=c+Math.imul(Mt,Zt)|0,m=m+Math.imul(Mt,Jt)|0,y=y+Math.imul(_t,Xt)|0,c=c+Math.imul(_t,Qt)|0,c=c+Math.imul(It,Xt)|0,m=m+Math.imul(It,Qt)|0,y=y+Math.imul(Et,te)|0,c=c+Math.imul(Et,ee)|0,c=c+Math.imul(xt,te)|0,m=m+Math.imul(xt,ee)|0;var ki=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(ki>>>26)|0,ki&=67108863,y=Math.imul(Pt,Zt),c=Math.imul(Pt,Jt),c=c+Math.imul(Ct,Zt)|0,m=Math.imul(Ct,Jt),y=y+Math.imul(At,Xt)|0,c=c+Math.imul(At,Qt)|0,c=c+Math.imul(Mt,Xt)|0,m=m+Math.imul(Mt,Qt)|0,y=y+Math.imul(_t,te)|0,c=c+Math.imul(_t,ee)|0,c=c+Math.imul(It,te)|0,m=m+Math.imul(It,ee)|0;var Si=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(Si>>>26)|0,Si&=67108863,y=Math.imul(Pt,Xt),c=Math.imul(Pt,Qt),c=c+Math.imul(Ct,Xt)|0,m=Math.imul(Ct,Qt),y=y+Math.imul(At,te)|0,c=c+Math.imul(At,ee)|0,c=c+Math.imul(Mt,te)|0,m=m+Math.imul(Mt,ee)|0;var Bi=(w+y|0)+((c&8191)<<13)|0;w=(m+(c>>>13)|0)+(Bi>>>26)|0,Bi&=67108863,y=Math.imul(Pt,te),c=Math.imul(Pt,ee),c=c+Math.imul(Ct,te)|0,m=Math.imul(Ct,ee);var Ei=(w+y|0)+((c&8191)<<13)|0;return w=(m+(c>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,g[0]=ai,g[1]=ci,g[2]=ui,g[3]=fi,g[4]=li,g[5]=hi,g[6]=di,g[7]=pi,g[8]=yi,g[9]=gi,g[10]=mi,g[11]=bi,g[12]=wi,g[13]=xi,g[14]=vi,g[15]=ki,g[16]=Si,g[17]=Bi,g[18]=Ei,w!==0&&(g[19]=w,f.length++),f};Math.imul||(T=A);function F(v,a,u){u.negative=a.negative^v.negative,u.length=v.length+a.length;for(var f=0,d=0,p=0;p<u.length-1;p++){var g=d;d=0;for(var w=f&67108863,y=Math.min(p,a.length-1),c=Math.max(0,p-v.length+1);c<=y;c++){var m=p-c,M=v.words[m]|0,U=a.words[c]|0,O=M*U,D=O&67108863;g=g+(O/67108864|0)|0,D=D+w|0,w=D&67108863,g=g+(D>>>26)|0,d+=g>>>26,g&=67108863}u.words[p]=w,f=g,g=d}return f!==0?u.words[p]=f:u.length--,u._strip()}function N(v,a,u){return F(v,a,u)}o.prototype.mulTo=function(a,u){var f,d=this.length+a.length;return this.length===10&&a.length===10?f=T(this,a,u):d<63?f=A(this,a,u):d<1024?f=F(this,a,u):f=N(this,a,u),f};function W(v,a){this.x=v,this.y=a}W.prototype.makeRBT=function(a){for(var u=new Array(a),f=o.prototype._countBits(a)-1,d=0;d<a;d++)u[d]=this.revBin(d,f,a);return u},W.prototype.revBin=function(a,u,f){if(a===0||a===f-1)return a;for(var d=0,p=0;p<u;p++)d|=(a&1)<<u-p-1,a>>=1;return d},W.prototype.permute=function(a,u,f,d,p,g){for(var w=0;w<g;w++)d[w]=u[a[w]],p[w]=f[a[w]]},W.prototype.transform=function(a,u,f,d,p,g){this.permute(g,a,u,f,d,p);for(var w=1;w<p;w<<=1)for(var y=w<<1,c=Math.cos(2*Math.PI/y),m=Math.sin(2*Math.PI/y),M=0;M<p;M+=y)for(var U=c,O=m,D=0;D<w;D++){var Y=f[M+D],J=d[M+D],mt=f[M+D+w],Q=d[M+D+w],tt=U*mt-O*Q;Q=U*Q+O*mt,mt=tt,f[M+D]=Y+mt,d[M+D]=J+Q,f[M+D+w]=Y-mt,d[M+D+w]=J-Q,D!==y&&(tt=c*U-m*O,O=c*O+m*U,U=tt)}},W.prototype.guessLen13b=function(a,u){var f=Math.max(u,a)|1,d=f&1,p=0;for(f=f/2|0;f;f=f>>>1)p++;return 1<<p+1+d},W.prototype.conjugate=function(a,u,f){if(!(f<=1))for(var d=0;d<f/2;d++){var p=a[d];a[d]=a[f-d-1],a[f-d-1]=p,p=u[d],u[d]=-u[f-d-1],u[f-d-1]=-p}},W.prototype.normalize13b=function(a,u){for(var f=0,d=0;d<u/2;d++){var p=Math.round(a[2*d+1]/u)*8192+Math.round(a[2*d]/u)+f;a[d]=p&67108863,p<67108864?f=0:f=p/67108864|0}return a},W.prototype.convert13b=function(a,u,f,d){for(var p=0,g=0;g<u;g++)p=p+(a[g]|0),f[2*g]=p&8191,p=p>>>13,f[2*g+1]=p&8191,p=p>>>13;for(g=2*u;g<d;++g)f[g]=0;e(p===0),e((p&-8192)===0)},W.prototype.stub=function(a){for(var u=new Array(a),f=0;f<a;f++)u[f]=0;return u},W.prototype.mulp=function(a,u,f){var d=2*this.guessLen13b(a.length,u.length),p=this.makeRBT(d),g=this.stub(d),w=new Array(d),y=new Array(d),c=new Array(d),m=new Array(d),M=new Array(d),U=new Array(d),O=f.words;O.length=d,this.convert13b(a.words,a.length,w,d),this.convert13b(u.words,u.length,m,d),this.transform(w,g,y,c,d,p),this.transform(m,g,M,U,d,p);for(var D=0;D<d;D++){var Y=y[D]*M[D]-c[D]*U[D];c[D]=y[D]*U[D]+c[D]*M[D],y[D]=Y}return this.conjugate(y,c,d),this.transform(y,c,O,g,d,p),this.conjugate(O,g,d),this.normalize13b(O,d),f.negative=a.negative^u.negative,f.length=a.length+u.length,f._strip()},o.prototype.mul=function(a){var u=new o(null);return u.words=new Array(this.length+a.length),this.mulTo(a,u)},o.prototype.mulf=function(a){var u=new o(null);return u.words=new Array(this.length+a.length),N(this,a,u)},o.prototype.imul=function(a){return this.clone().mulTo(a,this)},o.prototype.imuln=function(a){var u=a<0;u&&(a=-a),e(typeof a=="number"),e(a<67108864);for(var f=0,d=0;d<this.length;d++){var p=(this.words[d]|0)*a,g=(p&67108863)+(f&67108863);f>>=26,f+=p/67108864|0,f+=g>>>26,this.words[d]=g&67108863}return f!==0&&(this.words[d]=f,this.length++),u?this.ineg():this},o.prototype.muln=function(a){return this.clone().imuln(a)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(a){var u=B(a);if(u.length===0)return new o(1);for(var f=this,d=0;d<u.length&&u[d]===0;d++,f=f.sqr());if(++d<u.length)for(var p=f.sqr();d<u.length;d++,p=p.sqr())u[d]!==0&&(f=f.mul(p));return f},o.prototype.iushln=function(a){e(typeof a=="number"&&a>=0);var u=a%26,f=(a-u)/26,d=67108863>>>26-u<<26-u,p;if(u!==0){var g=0;for(p=0;p<this.length;p++){var w=this.words[p]&d,y=(this.words[p]|0)-w<<u;this.words[p]=y|g,g=w>>>26-u}g&&(this.words[p]=g,this.length++)}if(f!==0){for(p=this.length-1;p>=0;p--)this.words[p+f]=this.words[p];for(p=0;p<f;p++)this.words[p]=0;this.length+=f}return this._strip()},o.prototype.ishln=function(a){return e(this.negative===0),this.iushln(a)},o.prototype.iushrn=function(a,u,f){e(typeof a=="number"&&a>=0);var d;u?d=(u-u%26)/26:d=0;var p=a%26,g=Math.min((a-p)/26,this.length),w=67108863^67108863>>>p<<p,y=f;if(d-=g,d=Math.max(0,d),y){for(var c=0;c<g;c++)y.words[c]=this.words[c];y.length=g}if(g!==0)if(this.length>g)for(this.length-=g,c=0;c<this.length;c++)this.words[c]=this.words[c+g];else this.words[0]=0,this.length=1;var m=0;for(c=this.length-1;c>=0&&(m!==0||c>=d);c--){var M=this.words[c]|0;this.words[c]=m<<26-p|M>>>p,m=M&w}return y&&m!==0&&(y.words[y.length++]=m),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(a,u,f){return e(this.negative===0),this.iushrn(a,u,f)},o.prototype.shln=function(a){return this.clone().ishln(a)},o.prototype.ushln=function(a){return this.clone().iushln(a)},o.prototype.shrn=function(a){return this.clone().ishrn(a)},o.prototype.ushrn=function(a){return this.clone().iushrn(a)},o.prototype.testn=function(a){e(typeof a=="number"&&a>=0);var u=a%26,f=(a-u)/26,d=1<<u;if(this.length<=f)return!1;var p=this.words[f];return!!(p&d)},o.prototype.imaskn=function(a){e(typeof a=="number"&&a>=0);var u=a%26,f=(a-u)/26;if(e(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(u!==0&&f++,this.length=Math.min(f,this.length),u!==0){var d=67108863^67108863>>>u<<u;this.words[this.length-1]&=d}return this._strip()},o.prototype.maskn=function(a){return this.clone().imaskn(a)},o.prototype.iaddn=function(a){return e(typeof a=="number"),e(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)},o.prototype._iaddn=function(a){this.words[0]+=a;for(var u=0;u<this.length&&this.words[u]>=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},o.prototype.isubn=function(a){if(e(typeof a=="number"),e(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 u=0;u<this.length&&this.words[u]<0;u++)this.words[u]+=67108864,this.words[u+1]-=1;return this._strip()},o.prototype.addn=function(a){return this.clone().iaddn(a)},o.prototype.subn=function(a){return this.clone().isubn(a)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(a,u,f){var d=a.length+f,p;this._expand(d);var g,w=0;for(p=0;p<a.length;p++){g=(this.words[p+f]|0)+w;var y=(a.words[p]|0)*u;g-=y&67108863,w=(g>>26)-(y/67108864|0),this.words[p+f]=g&67108863}for(;p<this.length-f;p++)g=(this.words[p+f]|0)+w,w=g>>26,this.words[p+f]=g&67108863;if(w===0)return this._strip();for(e(w===-1),w=0,p=0;p<this.length;p++)g=-(this.words[p]|0)+w,w=g>>26,this.words[p]=g&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(a,u){var f=this.length-a.length,d=this.clone(),p=a,g=p.words[p.length-1]|0,w=this._countBits(g);f=26-w,f!==0&&(p=p.ushln(f),d.iushln(f),g=p.words[p.length-1]|0);var y=d.length-p.length,c;if(u!=="mod"){c=new o(null),c.length=y+1,c.words=new Array(c.length);for(var m=0;m<c.length;m++)c.words[m]=0}var M=d.clone()._ishlnsubmul(p,1,y);M.negative===0&&(d=M,c&&(c.words[y]=1));for(var U=y-1;U>=0;U--){var O=(d.words[p.length+U]|0)*67108864+(d.words[p.length+U-1]|0);for(O=Math.min(O/g|0,67108863),d._ishlnsubmul(p,O,U);d.negative!==0;)O--,d.negative=0,d._ishlnsubmul(p,1,U),d.isZero()||(d.negative^=1);c&&(c.words[U]=O)}return c&&c._strip(),d._strip(),u!=="div"&&f!==0&&d.iushrn(f),{div:c||null,mod:d}},o.prototype.divmod=function(a,u,f){if(e(!a.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var d,p,g;return this.negative!==0&&a.negative===0?(g=this.neg().divmod(a,u),u!=="mod"&&(d=g.div.neg()),u!=="div"&&(p=g.mod.neg(),f&&p.negative!==0&&p.iadd(a)),{div:d,mod:p}):this.negative===0&&a.negative!==0?(g=this.divmod(a.neg(),u),u!=="mod"&&(d=g.div.neg()),{div:d,mod:g.mod}):(this.negative&a.negative)!==0?(g=this.neg().divmod(a.neg(),u),u!=="div"&&(p=g.mod.neg(),f&&p.negative!==0&&p.isub(a)),{div:g.div,mod:p}):a.length>this.length||this.cmp(a)<0?{div:new o(0),mod:this}:a.length===1?u==="div"?{div:this.divn(a.words[0]),mod:null}:u==="mod"?{div:null,mod:new o(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new o(this.modrn(a.words[0]))}:this._wordDiv(a,u)},o.prototype.div=function(a){return this.divmod(a,"div",!1).div},o.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},o.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},o.prototype.divRound=function(a){var u=this.divmod(a);if(u.mod.isZero())return u.div;var f=u.div.negative!==0?u.mod.isub(a):u.mod,d=a.ushrn(1),p=a.andln(1),g=f.cmp(d);return g<0||p===1&&g===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},o.prototype.modrn=function(a){var u=a<0;u&&(a=-a),e(a<=67108863);for(var f=(1<<26)%a,d=0,p=this.length-1;p>=0;p--)d=(f*d+(this.words[p]|0))%a;return u?-d:d},o.prototype.modn=function(a){return this.modrn(a)},o.prototype.idivn=function(a){var u=a<0;u&&(a=-a),e(a<=67108863);for(var f=0,d=this.length-1;d>=0;d--){var p=(this.words[d]|0)+f*67108864;this.words[d]=p/a|0,f=p%a}return this._strip(),u?this.ineg():this},o.prototype.divn=function(a){return this.clone().idivn(a)},o.prototype.egcd=function(a){e(a.negative===0),e(!a.isZero());var u=this,f=a.clone();u.negative!==0?u=u.umod(a):u=u.clone();for(var d=new o(1),p=new o(0),g=new o(0),w=new o(1),y=0;u.isEven()&&f.isEven();)u.iushrn(1),f.iushrn(1),++y;for(var c=f.clone(),m=u.clone();!u.isZero();){for(var M=0,U=1;(u.words[0]&U)===0&&M<26;++M,U<<=1);if(M>0)for(u.iushrn(M);M-- >0;)(d.isOdd()||p.isOdd())&&(d.iadd(c),p.isub(m)),d.iushrn(1),p.iushrn(1);for(var O=0,D=1;(f.words[0]&D)===0&&O<26;++O,D<<=1);if(O>0)for(f.iushrn(O);O-- >0;)(g.isOdd()||w.isOdd())&&(g.iadd(c),w.isub(m)),g.iushrn(1),w.iushrn(1);u.cmp(f)>=0?(u.isub(f),d.isub(g),p.isub(w)):(f.isub(u),g.isub(d),w.isub(p))}return{a:g,b:w,gcd:f.iushln(y)}},o.prototype._invmp=function(a){e(a.negative===0),e(!a.isZero());var u=this,f=a.clone();u.negative!==0?u=u.umod(a):u=u.clone();for(var d=new o(1),p=new o(0),g=f.clone();u.cmpn(1)>0&&f.cmpn(1)>0;){for(var w=0,y=1;(u.words[0]&y)===0&&w<26;++w,y<<=1);if(w>0)for(u.iushrn(w);w-- >0;)d.isOdd()&&d.iadd(g),d.iushrn(1);for(var c=0,m=1;(f.words[0]&m)===0&&c<26;++c,m<<=1);if(c>0)for(f.iushrn(c);c-- >0;)p.isOdd()&&p.iadd(g),p.iushrn(1);u.cmp(f)>=0?(u.isub(f),d.isub(p)):(f.isub(u),p.isub(d))}var M;return u.cmpn(1)===0?M=d:M=p,M.cmpn(0)<0&&M.iadd(a),M},o.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var u=this.clone(),f=a.clone();u.negative=0,f.negative=0;for(var d=0;u.isEven()&&f.isEven();d++)u.iushrn(1),f.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;f.isEven();)f.iushrn(1);var p=u.cmp(f);if(p<0){var g=u;u=f,f=g}else if(p===0||f.cmpn(1)===0)break;u.isub(f)}while(!0);return f.iushln(d)},o.prototype.invm=function(a){return this.egcd(a).a.umod(a)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(a){return this.words[0]&a},o.prototype.bincn=function(a){e(typeof a=="number");var u=a%26,f=(a-u)/26,d=1<<u;if(this.length<=f)return this._expand(f+1),this.words[f]|=d,this;for(var p=d,g=f;p!==0&&g<this.length;g++){var w=this.words[g]|0;w+=p,p=w>>>26,w&=67108863,this.words[g]=w}return p!==0&&(this.words[g]=p,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(a){var u=a<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this._strip();var f;if(this.length>1)f=1;else{u&&(a=-a),e(a<=67108863,"Number is too big");var d=this.words[0]|0;f=d===a?0:d<a?-1:1}return this.negative!==0?-f|0:f},o.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var u=this.ucmp(a);return this.negative!==0?-u|0:u},o.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var u=0,f=this.length-1;f>=0;f--){var d=this.words[f]|0,p=a.words[f]|0;if(d!==p){d<p?u=-1:d>p&&(u=1);break}}return u},o.prototype.gtn=function(a){return this.cmpn(a)===1},o.prototype.gt=function(a){return this.cmp(a)===1},o.prototype.gten=function(a){return this.cmpn(a)>=0},o.prototype.gte=function(a){return this.cmp(a)>=0},o.prototype.ltn=function(a){return this.cmpn(a)===-1},o.prototype.lt=function(a){return this.cmp(a)===-1},o.prototype.lten=function(a){return this.cmpn(a)<=0},o.prototype.lte=function(a){return this.cmp(a)<=0},o.prototype.eqn=function(a){return this.cmpn(a)===0},o.prototype.eq=function(a){return this.cmp(a)===0},o.red=function(a){return new G(a)},o.prototype.toRed=function(a){return e(!this.red,"Already a number in reduction context"),e(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},o.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(a){return this.red=a,this},o.prototype.forceRed=function(a){return e(!this.red,"Already a number in reduction context"),this._forceRed(a)},o.prototype.redAdd=function(a){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},o.prototype.redIAdd=function(a){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},o.prototype.redSub=function(a){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},o.prototype.redISub=function(a){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},o.prototype.redShl=function(a){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},o.prototype.redMul=function(a){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},o.prototype.redIMul=function(a){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},o.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(a){return e(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var q={k256:null,p224:null,p192:null,p25519:null};function z(v,a){this.name=v,this.p=new o(a,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var a=new o(null);return a.words=new Array(Math.ceil(this.n/13)),a},z.prototype.ireduce=function(a){var u=a,f;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),f=u.bitLength();while(f>this.n);var d=f<this.n?-1:u.ucmp(this.p);return d===0?(u.words[0]=0,u.length=1):d>0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},z.prototype.split=function(a,u){a.iushrn(this.n,0,u)},z.prototype.imulK=function(a){return a.imul(this.k)};function H(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(H,z),H.prototype.split=function(a,u){for(var f=4194303,d=Math.min(a.length,9),p=0;p<d;p++)u.words[p]=a.words[p];if(u.length=d,a.length<=9){a.words[0]=0,a.length=1;return}var g=a.words[9];for(u.words[u.length++]=g&f,p=10;p<a.length;p++){var w=a.words[p]|0;a.words[p-10]=(w&f)<<4|g>>>22,g=w}g>>>=22,a.words[p-10]=g,g===0&&a.length>10?a.length-=10:a.length-=9},H.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var u=0,f=0;f<a.length;f++){var d=a.words[f]|0;u+=d*977,a.words[f]=u&67108863,u=d*64+(u/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function j(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(j,z);function ot(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(ot,z);function nt(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(nt,z),nt.prototype.imulK=function(a){for(var u=0,f=0;f<a.length;f++){var d=(a.words[f]|0)*19+u,p=d&67108863;d>>>=26,a.words[f]=p,u=d}return u!==0&&(a.words[a.length++]=u),a},o._prime=function(a){if(q[a])return q[a];var u;if(a==="k256")u=new H;else if(a==="p224")u=new j;else if(a==="p192")u=new ot;else if(a==="p25519")u=new nt;else throw new Error("Unknown prime "+a);return q[a]=u,u};function G(v){if(typeof v=="string"){var a=o._prime(v);this.m=a.p,this.prime=a}else e(v.gtn(1),"modulus must be greater than 1"),this.m=v,this.prime=null}G.prototype._verify1=function(a){e(a.negative===0,"red works only with positives"),e(a.red,"red works only with red numbers")},G.prototype._verify2=function(a,u){e((a.negative|u.negative)===0,"red works only with positives"),e(a.red&&a.red===u.red,"red works only with red numbers")},G.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(b(a,a.umod(this.m)._forceRed(this)),a)},G.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},G.prototype.add=function(a,u){this._verify2(a,u);var f=a.add(u);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},G.prototype.iadd=function(a,u){this._verify2(a,u);var f=a.iadd(u);return f.cmp(this.m)>=0&&f.isub(this.m),f},G.prototype.sub=function(a,u){this._verify2(a,u);var f=a.sub(u);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},G.prototype.isub=function(a,u){this._verify2(a,u);var f=a.isub(u);return f.cmpn(0)<0&&f.iadd(this.m),f},G.prototype.shl=function(a,u){return this._verify1(a),this.imod(a.ushln(u))},G.prototype.imul=function(a,u){return this._verify2(a,u),this.imod(a.imul(u))},G.prototype.mul=function(a,u){return this._verify2(a,u),this.imod(a.mul(u))},G.prototype.isqr=function(a){return this.imul(a,a.clone())},G.prototype.sqr=function(a){return this.mul(a,a)},G.prototype.sqrt=function(a){if(a.isZero())return a.clone();var u=this.m.andln(3);if(e(u%2===1),u===3){var f=this.m.add(new o(1)).iushrn(2);return this.pow(a,f)}for(var d=this.m.subn(1),p=0;!d.isZero()&&d.andln(1)===0;)p++,d.iushrn(1);e(!d.isZero());var g=new o(1).toRed(this),w=g.redNeg(),y=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);this.pow(c,y).cmp(w)!==0;)c.redIAdd(w);for(var m=this.pow(c,d),M=this.pow(a,d.addn(1).iushrn(1)),U=this.pow(a,d),O=p;U.cmp(g)!==0;){for(var D=U,Y=0;D.cmp(g)!==0;Y++)D=D.redSqr();e(Y<O);var J=this.pow(m,new o(1).iushln(O-Y-1));M=M.redMul(J),m=J.redSqr(),U=U.redMul(m),O=Y}return M},G.prototype.invm=function(a){var u=a._invmp(this.m);return u.negative!==0?(u.negative=0,this.imod(u).redNeg()):this.imod(u)},G.prototype.pow=function(a,u){if(u.isZero())return new o(1).toRed(this);if(u.cmpn(1)===0)return a.clone();var f=4,d=new Array(1<<f);d[0]=new o(1).toRed(this),d[1]=a;for(var p=2;p<d.length;p++)d[p]=this.mul(d[p-1],a);var g=d[0],w=0,y=0,c=u.bitLength()%26;for(c===0&&(c=26),p=u.length-1;p>=0;p--){for(var m=u.words[p],M=c-1;M>=0;M--){var U=m>>M&1;if(g!==d[0]&&(g=this.sqr(g)),U===0&&w===0){y=0;continue}w<<=1,w|=U,y++,!(y!==f&&(p!==0||M!==0))&&(g=this.mul(g,d[w]),y=0,w=0)}c=26}return g},G.prototype.convertTo=function(a){var u=a.umod(this.m);return u===a?u.clone():u},G.prototype.convertFrom=function(a){var u=a.clone();return u.red=null,u},o.mont=function(a){return new lt(a)};function lt(v){G.call(this,v),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(lt,G),lt.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},lt.prototype.convertFrom=function(a){var u=this.imod(a.mul(this.rinv));return u.red=null,u},lt.prototype.imul=function(a,u){if(a.isZero()||u.isZero())return a.words[0]=0,a.length=1,a;var f=a.imul(u),d=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),p=f.isub(d).iushrn(this.shift),g=p;return p.cmp(this.m)>=0?g=p.isub(this.m):p.cmpn(0)<0&&(g=p.iadd(this.m)),g._forceRed(this)},lt.prototype.mul=function(a,u){if(a.isZero()||u.isZero())return new o(0)._forceRed(this);var f=a.mul(u),d=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),p=f.isub(d).iushrn(this.shift),g=p;return p.cmp(this.m)>=0?g=p.isub(this.m):p.cmpn(0)<0&&(g=p.iadd(this.m)),g._forceRed(this)},lt.prototype.invm=function(a){var u=this.imod(a._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(typeof os>"u"||os,dc)});var gc=at((ss,yc)=>{"use strict";var so=Vn(),ze=so.Buffer;function pc(r,t){for(var e in r)t[e]=r[e]}ze.from&&ze.alloc&&ze.allocUnsafe&&ze.allocUnsafeSlow?yc.exports=so:(pc(so,ss),ss.Buffer=Ir);function Ir(r,t,e){return ze(r,t,e)}Ir.prototype=Object.create(ze.prototype);pc(ze,Ir);Ir.from=function(r,t,e){if(typeof r=="number")throw new TypeError("Argument must not be a number");return ze(r,t,e)};Ir.alloc=function(r,t,e){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=ze(r);return t!==void 0?typeof e=="string"?n.fill(t,e):n.fill(t):n.fill(0),n};Ir.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return ze(r)};Ir.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return so.SlowBuffer(r)}});var bc=at((Ap,mc)=>{"use strict";var ao=gc().Buffer;function Kl(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var n=0;n<r.length;n++){var o=r.charAt(n),i=o.charCodeAt(0);if(t[i]!==255)throw new TypeError(o+" is ambiguous");t[i]=n}var s=r.length,h=r.charAt(0),l=Math.log(s)/Math.log(256),b=Math.log(256)/Math.log(s);function x(I){if((Array.isArray(I)||I instanceof Uint8Array)&&(I=ao.from(I)),!ao.isBuffer(I))throw new TypeError("Expected Buffer");if(I.length===0)return"";for(var P=0,B=0,A=0,T=I.length;A!==T&&I[A]===0;)A++,P++;for(var F=(T-A)*b+1>>>0,N=new Uint8Array(F);A!==T;){for(var W=I[A],q=0,z=F-1;(W!==0||q<B)&&z!==-1;z--,q++)W+=256*N[z]>>>0,N[z]=W%s>>>0,W=W/s>>>0;if(W!==0)throw new Error("Non-zero carry");B=q,A++}for(var H=F-B;H!==F&&N[H]===0;)H++;for(var j=h.repeat(P);H<F;++H)j+=r.charAt(N[H]);return j}function k(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return ao.alloc(0);for(var P=0,B=0,A=0;I[P]===h;)B++,P++;for(var T=(I.length-P)*l+1>>>0,F=new Uint8Array(T);P<I.length;){var N=I.charCodeAt(P);if(N>255)return;var W=t[N];if(W===255)return;for(var q=0,z=T-1;(W!==0||q<A)&&z!==-1;z--,q++)W+=s*F[z]>>>0,F[z]=W%256>>>0,W=W/256>>>0;if(W!==0)throw new Error("Non-zero carry");A=q,P++}for(var H=T-A;H!==T&&F[H]===0;)H++;var j=ao.allocUnsafe(B+(T-H));j.fill(0,0,B);for(var ot=B;H!==T;)j[ot++]=F[H++];return j}function R(I){var P=k(I);if(P)return P;throw new Error("Non-base"+s+" character")}return{encode:x,decodeUnsafe:k,decode:R}}mc.exports=Kl});var as=at((Lp,wc)=>{"use strict";var Wl=bc(),Hl="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";wc.exports=Wl(Hl)});var xc=at(ls=>{"use strict";function je(r,t,e){return t<=r&&r<=e}function ho(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function Gl(r){for(var t=String(r),e=t.length,n=0,o=[];n<e;){var i=t.charCodeAt(n);if(i<55296||i>57343)o.push(i);else if(56320<=i&&i<=57343)o.push(65533);else if(55296<=i&&i<=56319)if(n===e-1)o.push(65533);else{var s=r.charCodeAt(n+1);if(56320<=s&&s<=57343){var h=i&1023,l=s&1023;o.push(65536+(h<<10)+l),n+=1}else o.push(65533)}n+=1}return o}function Yl(r){for(var t="",e=0;e<r.length;++e){var n=r[e];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return t}var co=-1;function fs(r){this.tokens=[].slice.call(r)}fs.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():co},prepend:function(r){if(Array.isArray(r))for(var t=r;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var t=r;t.length;)this.tokens.push(t.shift());else this.tokens.push(r)}};var Dr=-1;function us(r,t){if(r)throw TypeError("Decoder error");return t||65533}var uo="utf-8";function fo(r,t){if(!(this instanceof fo))return new fo(r,t);if(r=r!==void 0?String(r).toLowerCase():uo,r!==uo)throw new Error("Encoding not supported. Only utf-8 is supported");t=ho(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}fo.prototype={decode:function(t,e){var n;typeof t=="object"&&t instanceof ArrayBuffer?n=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):n=new Uint8Array(0),e=ho(e),this._streaming||(this._decoder=new Zl({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var o=new fs(n),i=[],s;!o.endOfStream()&&(s=this._decoder.handler(o,o.read()),s!==Dr);)s!==null&&(Array.isArray(s)?i.push.apply(i,s):i.push(s));if(!this._streaming){do{if(s=this._decoder.handler(o,o.read()),s===Dr)break;s!==null&&(Array.isArray(s)?i.push.apply(i,s):i.push(s))}while(!o.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),Yl(i)}};function lo(r,t){if(!(this instanceof lo))return new lo(r,t);if(r=r!==void 0?String(r).toLowerCase():uo,r!==uo)throw new Error("Encoding not supported. Only utf-8 is supported");t=ho(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}lo.prototype={encode:function(t,e){t=t?String(t):"",e=ho(e),this._streaming||(this._encoder=new Jl(this._options)),this._streaming=!!e.stream;for(var n=[],o=new fs(Gl(t)),i;!o.endOfStream()&&(i=this._encoder.handler(o,o.read()),i!==Dr);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(o,o.read()),i!==Dr;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}};function Zl(r){var t=r.fatal,e=0,n=0,o=0,i=128,s=191;this.handler=function(h,l){if(l===co&&o!==0)return o=0,us(t);if(l===co)return Dr;if(o===0){if(je(l,0,127))return l;if(je(l,194,223))o=1,e=l-192;else if(je(l,224,239))l===224&&(i=160),l===237&&(s=159),o=2,e=l-224;else if(je(l,240,244))l===240&&(i=144),l===244&&(s=143),o=3,e=l-240;else return us(t);return e=e<<6*o,null}if(!je(l,i,s))return e=o=n=0,i=128,s=191,h.prepend(l),us(t);if(i=128,s=191,n+=1,e+=l-128<<6*(o-n),n!==o)return null;var b=e;return e=o=n=0,b}}function Jl(r){var t=r.fatal;this.handler=function(e,n){if(n===co)return Dr;if(je(n,0,127))return n;var o,i;je(n,128,2047)?(o=1,i=192):je(n,2048,65535)?(o=2,i=224):je(n,65536,1114111)&&(o=3,i=240);for(var s=[(n>>6*o)+i];o>0;){var h=n>>6*(o-1);s.push(128|h&63),o-=1}return s}}ls.TextEncoder=lo;ls.TextDecoder=fo});var Ec=at(yt=>{"use strict";var Xl=yt&&yt.__createBinding||(Object.create?function(r,t,e,n){n===void 0&&(n=e),Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[e]}})}:function(r,t,e,n){n===void 0&&(n=e),r[n]=t[e]}),Ql=yt&&yt.__setModuleDefault||(Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t}),qe=yt&&yt.__decorate||function(r,t,e,n){var o=arguments.length,i=o<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,t,e,n);else for(var h=r.length-1;h>=0;h--)(s=r[h])&&(i=(o<3?s(i):o>3?s(t,e,i):s(t,e))||i);return o>3&&i&&Object.defineProperty(t,e,i),i},th=yt&&yt.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)e!=="default"&&Object.hasOwnProperty.call(r,e)&&Xl(t,r,e);return Ql(t,r),t},vc=yt&&yt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(yt,"__esModule",{value:!0});yt.deserializeUnchecked=yt.deserialize=yt.serialize=yt.BinaryReader=yt.BinaryWriter=yt.BorshError=yt.baseDecode=yt.baseEncode=void 0;var lr=vc(is()),kc=vc(as()),eh=th(xc()),rh=typeof TextDecoder!="function"?eh.TextDecoder:TextDecoder,nh=new rh("utf-8",{fatal:!0});function oh(r){return typeof r=="string"&&(r=Buffer.from(r,"utf8")),kc.default.encode(Buffer.from(r))}yt.baseEncode=oh;function ih(r){return Buffer.from(kc.default.decode(r))}yt.baseDecode=ih;var hs=1024,ae=class extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}};yt.BorshError=ae;var po=class{constructor(){this.buf=Buffer.alloc(hs),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(hs)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new lr.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new lr.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new lr.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new lr.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(hs)]),this.length+=t.length}writeString(t){this.maybeResize();let e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(let n of t)this.maybeResize(),e(n)}toArray(){return this.buf.subarray(0,this.length)}};yt.BinaryWriter=po;function Fe(r,t,e){let n=e.value;e.value=function(...o){try{return n.apply(this,o)}catch(i){if(i instanceof RangeError){let s=i.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(s)>=0)throw new ae("Reached the end of buffer when deserializing")}throw i}}}var ge=class{constructor(t){this.buf=t,this.offset=0}readU8(){let t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){let t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){let t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){let t=this.readBuffer(8);return new lr.default(t,"le")}readU128(){let t=this.readBuffer(16);return new lr.default(t,"le")}readU256(){let t=this.readBuffer(32);return new lr.default(t,"le")}readU512(){let t=this.readBuffer(64);return new lr.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new ae(`Expected buffer length ${t} isn't within bounds`);let e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){let t=this.readU32(),e=this.readBuffer(t);try{return nh.decode(e)}catch(n){throw new ae(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){let e=this.readU32(),n=Array();for(let o=0;o<e;++o)n.push(t());return n}};qe([Fe],ge.prototype,"readU8",null);qe([Fe],ge.prototype,"readU16",null);qe([Fe],ge.prototype,"readU32",null);qe([Fe],ge.prototype,"readU64",null);qe([Fe],ge.prototype,"readU128",null);qe([Fe],ge.prototype,"readU256",null);qe([Fe],ge.prototype,"readU512",null);qe([Fe],ge.prototype,"readString",null);qe([Fe],ge.prototype,"readFixedArray",null);qe([Fe],ge.prototype,"readArray",null);yt.BinaryReader=ge;function Sc(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Ar(r,t,e,n,o){try{if(typeof n=="string")o[`write${Sc(n)}`](e);else if(n instanceof Array)if(typeof n[0]=="number"){if(e.length!==n[0])throw new ae(`Expecting byte array of length ${n[0]}, but got ${e.length} bytes`);o.writeFixedArray(e)}else if(n.length===2&&typeof n[1]=="number"){if(e.length!==n[1])throw new ae(`Expecting byte array of length ${n[1]}, but got ${e.length} bytes`);for(let i=0;i<n[1];i++)Ar(r,null,e[i],n[0],o)}else o.writeArray(e,i=>{Ar(r,t,i,n[0],o)});else if(n.kind!==void 0)switch(n.kind){case"option":{e==null?o.writeU8(0):(o.writeU8(1),Ar(r,t,e,n.type,o));break}case"map":{o.writeU32(e.size),e.forEach((i,s)=>{Ar(r,t,s,n.key,o),Ar(r,t,i,n.value,o)});break}default:throw new ae(`FieldType ${n} unrecognized`)}else Bc(r,e,o)}catch(i){throw i instanceof ae&&i.addToFieldPath(t),i}}function Bc(r,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}let n=r.get(t.constructor);if(!n)throw new ae(`Class ${t.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([o,i])=>{Ar(r,o,t[o],i,e)});else if(n.kind==="enum"){let o=t[n.field];for(let i=0;i<n.values.length;++i){let[s,h]=n.values[i];if(s===o){e.writeU8(i),Ar(r,s,t[s],h,e);break}}}else throw new ae(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function sh(r,t,e=po){let n=new e;return Bc(r,t,n),n.toArray()}yt.serialize=sh;function Lr(r,t,e,n){try{if(typeof e=="string")return n[`read${Sc(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return n.readFixedArray(e[0]);if(typeof e[1]=="number"){let o=[];for(let i=0;i<e[1];i++)o.push(Lr(r,null,e[0],n));return o}else return n.readArray(()=>Lr(r,t,e[0],n))}if(e.kind==="option")return n.readU8()?Lr(r,t,e.type,n):void 0;if(e.kind==="map"){let o=new Map,i=n.readU32();for(let s=0;s<i;s++){let h=Lr(r,t,e.key,n),l=Lr(r,t,e.value,n);o.set(h,l)}return o}return ds(r,e,n)}catch(o){throw o instanceof ae&&o.addToFieldPath(t),o}}function ds(r,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);let n=r.get(t);if(!n)throw new ae(`Class ${t.name} is missing in schema`);if(n.kind==="struct"){let o={};for(let[i,s]of r.get(t).fields)o[i]=Lr(r,i,s,e);return new t(o)}if(n.kind==="enum"){let o=e.readU8();if(o>=n.values.length)throw new ae(`Enum index: ${o} is out of range`);let[i,s]=n.values[o],h=Lr(r,i,s,e);return new t({[i]:h})}throw new ae(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function ah(r,t,e,n=ge){let o=new n(e),i=ds(r,t,o);if(o.offset<e.length)throw new ae(`Unexpected ${e.length-o.offset} bytes after deserialized data`);return i}yt.deserialize=ah;function ch(r,t,e,n=ge){let o=new n(e);return ds(r,t,o)}yt.deserializeUnchecked=ch});var ms=at(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.s16=_.s8=_.nu64be=_.u48be=_.u40be=_.u32be=_.u24be=_.u16be=_.nu64=_.u48=_.u40=_.u32=_.u24=_.u16=_.u8=_.offset=_.greedy=_.Constant=_.UTF8=_.CString=_.Blob=_.Boolean=_.BitField=_.BitStructure=_.VariantLayout=_.Union=_.UnionLayoutDiscriminator=_.UnionDiscriminator=_.Structure=_.Sequence=_.DoubleBE=_.Double=_.FloatBE=_.Float=_.NearInt64BE=_.NearInt64=_.NearUInt64BE=_.NearUInt64=_.IntBE=_.Int=_.UIntBE=_.UInt=_.OffsetLayout=_.GreedyCount=_.ExternalLayout=_.bindConstructorLayout=_.nameWithProperty=_.Layout=_.uint8ArrayToBuffer=_.checkUint8Array=void 0;_.constant=_.utf8=_.cstr=_.blob=_.unionLayoutDiscriminator=_.union=_.seq=_.bits=_.struct=_.f64be=_.f64=_.f32be=_.f32=_.ns64be=_.s48be=_.s40be=_.s32be=_.s24be=_.s16be=_.ns64=_.s48=_.s40=_.s32=_.s24=void 0;var ys=Vn();function Hr(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}_.checkUint8Array=Hr;function ct(r){return Hr(r),ys.Buffer.from(r.buffer,r.byteOffset,r.length)}_.uint8ArrayToBuffer=ct;var ft=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){let e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};_.Layout=ft;function gs(r,t){return t.property?r+"["+t.property+"]":r}_.nameWithProperty=gs;function uh(r,t){if(typeof r!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(r,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof ft))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=t,t.boundConstructor_=r,t.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(r,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}_.bindConstructorLayout=uh;var ue=class extends ft{isCount(){throw new Error("ExternalLayout is abstract")}};_.ExternalLayout=ue;var yo=class extends ue{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){Hr(t);let n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}};_.GreedyCount=yo;var fn=class extends ue{constructor(t,e=0,n){if(!(t instanceof ft))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof xe||this.layout instanceof Be}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,n=0){return this.layout.encode(t,e,n+this.offset)}};_.OffsetLayout=fn;var xe=class extends ft{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return ct(t).readUIntLE(e,this.span)}encode(t,e,n=0){return ct(e).writeUIntLE(t,n,this.span),this.span}};_.UInt=xe;var Be=class extends ft{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return ct(t).readUIntBE(e,this.span)}encode(t,e,n=0){return ct(e).writeUIntBE(t,n,this.span),this.span}};_.UIntBE=Be;var Ge=class extends ft{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return ct(t).readIntLE(e,this.span)}encode(t,e,n=0){return ct(e).writeIntLE(t,n,this.span),this.span}};_.Int=Ge;var hr=class extends ft{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return ct(t).readIntBE(e,this.span)}encode(t,e,n=0){return ct(e).writeIntBE(t,n,this.span),this.span}};_.IntBE=hr;var ps=Math.pow(2,32);function Mo(r){let t=Math.floor(r/ps),e=r-t*ps;return{hi32:t,lo32:e}}function Po(r,t){return r*ps+t}var go=class extends ft{constructor(t){super(8,t)}decode(t,e=0){let n=ct(t),o=n.readUInt32LE(e),i=n.readUInt32LE(e+4);return Po(i,o)}encode(t,e,n=0){let o=Mo(t),i=ct(e);return i.writeUInt32LE(o.lo32,n),i.writeUInt32LE(o.hi32,n+4),8}};_.NearUInt64=go;var mo=class extends ft{constructor(t){super(8,t)}decode(t,e=0){let n=ct(t),o=n.readUInt32BE(e),i=n.readUInt32BE(e+4);return Po(o,i)}encode(t,e,n=0){let o=Mo(t),i=ct(e);return i.writeUInt32BE(o.hi32,n),i.writeUInt32BE(o.lo32,n+4),8}};_.NearUInt64BE=mo;var bo=class extends ft{constructor(t){super(8,t)}decode(t,e=0){let n=ct(t),o=n.readUInt32LE(e),i=n.readInt32LE(e+4);return Po(i,o)}encode(t,e,n=0){let o=Mo(t),i=ct(e);return i.writeUInt32LE(o.lo32,n),i.writeInt32LE(o.hi32,n+4),8}};_.NearInt64=bo;var wo=class extends ft{constructor(t){super(8,t)}decode(t,e=0){let n=ct(t),o=n.readInt32BE(e),i=n.readUInt32BE(e+4);return Po(o,i)}encode(t,e,n=0){let o=Mo(t),i=ct(e);return i.writeInt32BE(o.hi32,n),i.writeUInt32BE(o.lo32,n+4),8}};_.NearInt64BE=wo;var xo=class extends ft{constructor(t){super(4,t)}decode(t,e=0){return ct(t).readFloatLE(e)}encode(t,e,n=0){return ct(e).writeFloatLE(t,n),4}};_.Float=xo;var vo=class extends ft{constructor(t){super(4,t)}decode(t,e=0){return ct(t).readFloatBE(e)}encode(t,e,n=0){return ct(e).writeFloatBE(t,n),4}};_.FloatBE=vo;var ko=class extends ft{constructor(t){super(8,t)}decode(t,e=0){return ct(t).readDoubleLE(e)}encode(t,e,n=0){return ct(e).writeDoubleLE(t,n),8}};_.Double=ko;var So=class extends ft{constructor(t){super(8,t)}decode(t,e=0){return ct(t).readDoubleBE(e)}encode(t,e,n=0){return ct(e).writeDoubleBE(t,n),8}};_.DoubleBE=So;var Bo=class extends ft{constructor(t,e,n){if(!(t instanceof ft))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof ue&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let o=-1;!(e instanceof ue)&&0<t.span&&(o=e*t.span),super(o,n),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0,o=this.count;if(o instanceof ue&&(o=o.decode(t,e)),0<this.elementLayout.span)n=o*this.elementLayout.span;else{let i=0;for(;i<o;)n+=this.elementLayout.getSpan(t,e+n),++i}return n}decode(t,e=0){let n=[],o=0,i=this.count;for(i instanceof ue&&(i=i.decode(t,e));o<i;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),o+=1;return n}encode(t,e,n=0){let o=this.elementLayout,i=t.reduce((s,h)=>s+o.encode(h,e,n+s),0);return this.count instanceof ue&&this.count.encode(t.length,e,n),i}};_.Sequence=Bo;var Eo=class extends ft{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((i,s)=>i&&s instanceof ft,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(let i of t)if(0>i.span&&i.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let o=-1;try{o=t.reduce((i,s)=>i+s.getSpan(),0)}catch{}super(o,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((o,i)=>{let s=i.getSpan(t,e);return e+=s,o+s},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e=0){Hr(t);let n=this.makeDestinationObject();for(let o of this.fields)if(o.property!==void 0&&(n[o.property]=o.decode(t,e)),e+=o.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n=0){let o=n,i=0,s=0;for(let h of this.fields){let l=h.span;if(s=0<l?l:0,h.property!==void 0){let b=t[h.property];b!==void 0&&(s=h.encode(b,e,n),0>l&&(l=h.getSpan(e,n)))}i=n,n+=l}return i+s-o}fromArray(t){let e=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(let e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(let n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}};_.Structure=Eo;var ln=class{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}};_.UnionDiscriminator=ln;var Wr=class extends ln{constructor(t,e){if(!(t instanceof ue&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}};_.UnionLayoutDiscriminator=Wr;var hn=class extends ft{constructor(t,e,n){let o;if(t instanceof xe||t instanceof Be)o=new Wr(new fn(t));else if(t instanceof ue&&t.isCount())o=new Wr(t);else if(t instanceof ln)o=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof ft))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&(t instanceof xe||t instanceof Be)&&(i+=o.layout.span)),super(i,n),this.discriminator=o,this.usesPrefixDiscriminator=t instanceof xe||t instanceof Be,this.defaultLayout=e,this.registry={};let s=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(h){return s(h)},this.configGetSourceVariant=function(h){s=h.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;let n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;let e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(let e in this.registry){let n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n,o=this.discriminator,i=o.decode(t,e),s=this.registry[i];if(s===void 0){let h=this.defaultLayout,l=0;this.usesPrefixDiscriminator&&(l=o.layout.span),n=this.makeDestinationObject(),n[o.property]=i,n[h.property]=h.decode(t,e+l)}else n=s.decode(t,e);return n}encode(t,e,n=0){let o=this.getSourceVariant(t);if(o===void 0){let i=this.discriminator,s=this.defaultLayout,h=0;return this.usesPrefixDiscriminator&&(h=i.layout.span),i.encode(t[i.property],e,n),h+s.encode(t[s.property],e,n+h)}return o.encode(t,e,n)}addVariant(t,e,n){let o=new _o(this,t,e,n);return this.registry[t]=o,o}getVariant(t,e=0){let n;return t instanceof Uint8Array?n=this.discriminator.decode(t,e):n=t,this.registry[n]}};_.Union=hn;var _o=class extends ft{constructor(t,e,n,o){if(!(t instanceof hn))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&o===void 0&&(o=n,n=null),n){if(!(n instanceof ft))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof o!="string")throw new TypeError("variant must have a String property")}let i=t.span;0>t.span&&(i=n?n.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,o),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let o=0;return this.layout&&(o=this.layout.getSpan(t,e+n)),n+o}decode(t,e=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let o=0;return this.union.usesPrefixDiscriminator&&(o=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+o):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n=0){let o=0;if(this.union.usesPrefixDiscriminator&&(o=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let i=o;if(this.layout&&(this.layout.encode(t[this.property],e,n+o),i+=this.layout.getSpan(e,n+o),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};_.VariantLayout=_o;function Kr(r){return 0>r&&(r+=4294967296),r}var dn=class extends ft{constructor(t,e,n){if(!(t instanceof xe||t instanceof Be))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&n===void 0&&(n=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let o=0;this._packedSetValue=function(i){return o=Kr(i),this},this._packedGetValue=function(){return o}}decode(t,e=0){let n=this.makeDestinationObject(),o=this.word.decode(t,e);this._packedSetValue(o);for(let i of this.fields)i.property!==void 0&&(n[i.property]=i.decode(t));return n}encode(t,e,n=0){let o=this.word.decode(e,n);this._packedSetValue(o);for(let i of this.fields)if(i.property!==void 0){let s=t[i.property];s!==void 0&&i.encode(s)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){let n=new pn(this,t,e);return this.fields.push(n),n}addBoolean(t){let e=new Io(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(let e of this.fields)if(e.property===t)return e}};_.BitStructure=dn;var pn=class{constructor(t,e,n){if(!(t instanceof dn))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");let o=8*t.span,i=t.fields.reduce((s,h)=>s+h.bits,0);if(e+i>o)throw new Error("bits too long for span remainder ("+(o-i)+" of "+o+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=o-i-e),this.wordMask=Kr(this.valueMask<<this.start),this.property=n}decode(t,e){let n=this.container._packedGetValue();return Kr(n&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==Kr(t&this.valueMask))throw new TypeError(gs("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let e=this.container._packedGetValue(),n=Kr(t<<this.start);this.container._packedSetValue(Kr(e&~this.wordMask)|n)}};_.BitField=pn;var Io=class extends pn{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};_.Boolean=Io;var Ao=class extends ft{constructor(t,e){if(!(t instanceof ue&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof ue||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e=0){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),ct(t).slice(e,e+n)}encode(t,e,n){let o=this.length;if(this.length instanceof ue&&(o=t.length),!(t instanceof Uint8Array&&o===t.length))throw new TypeError(gs("Blob.encode",this)+" requires (length "+o+") Uint8Array as src");if(n+o>e.length)throw new RangeError("encoding overruns Uint8Array");let i=ct(t);return ct(e).write(i.toString("hex"),n,o,"hex"),this.length instanceof ue&&this.length.encode(o,e,n),o}};_.Blob=Ao;var Lo=class extends ft{constructor(t){super(-1,t)}getSpan(t,e=0){Hr(t);let n=e;for(;n<t.length&&t[n]!==0;)n+=1;return 1+n-e}decode(t,e=0){let n=this.getSpan(t,e);return ct(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));let o=ys.Buffer.from(t,"utf8"),i=o.length;if(n+i>e.length)throw new RangeError("encoding overruns Buffer");let s=ct(e);return o.copy(s,n),s[n+i]=0,i+1}};_.CString=Lo;var Ro=class extends ft{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Hr(t),t.length-e}decode(t,e=0){let n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return ct(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));let o=ys.Buffer.from(t,"utf8"),i=o.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(n+i>e.length)throw new RangeError("encoding overruns Buffer");return o.copy(ct(e),n),i}};_.UTF8=Ro;var To=class extends ft{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}};_.Constant=To;_.greedy=(r,t)=>new yo(r,t);_.offset=(r,t,e)=>new fn(r,t,e);_.u8=r=>new xe(1,r);_.u16=r=>new xe(2,r);_.u24=r=>new xe(3,r);_.u32=r=>new xe(4,r);_.u40=r=>new xe(5,r);_.u48=r=>new xe(6,r);_.nu64=r=>new go(r);_.u16be=r=>new Be(2,r);_.u24be=r=>new Be(3,r);_.u32be=r=>new Be(4,r);_.u40be=r=>new Be(5,r);_.u48be=r=>new Be(6,r);_.nu64be=r=>new mo(r);_.s8=r=>new Ge(1,r);_.s16=r=>new Ge(2,r);_.s24=r=>new Ge(3,r);_.s32=r=>new Ge(4,r);_.s40=r=>new Ge(5,r);_.s48=r=>new Ge(6,r);_.ns64=r=>new bo(r);_.s16be=r=>new hr(2,r);_.s24be=r=>new hr(3,r);_.s32be=r=>new hr(4,r);_.s40be=r=>new hr(5,r);_.s48be=r=>new hr(6,r);_.ns64be=r=>new wo(r);_.f32=r=>new xo(r);_.f32be=r=>new vo(r);_.f64=r=>new ko(r);_.f64be=r=>new So(r);_.struct=(r,t,e)=>new Eo(r,t,e);_.bits=(r,t,e)=>new dn(r,t,e);_.seq=(r,t,e)=>new Bo(r,t,e);_.union=(r,t,e)=>new hn(r,t,e);_.unionLayoutDiscriminator=(r,t)=>new Wr(r,t);_.blob=(r,t)=>new Ao(r,t);_.cstr=r=>new Lo(r);_.utf8=(r,t)=>new Ro(r,t);_.constant=(r,t)=>new To(r,t)});var _c=at(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});var Co;function fh(r){{let t=Buffer.from(r);t.reverse();let e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}return Co.toBigInt(r,!1)}Vr.toBigIntLE=fh;function lh(r){{let t=r.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}return Co.toBigInt(r,!0)}Vr.toBigIntBE=lh;function hh(r,t){{let e=r.toString(16),n=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return n.reverse(),n}return Co.fromBigInt(r,Buffer.allocUnsafe(t),!1)}Vr.toBufferLE=hh;function dh(r,t){{let e=r.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}return Co.fromBigInt(r,Buffer.allocUnsafe(t),!0)}Vr.toBufferBE=dh});function gn(){if(!No&&(No=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!No))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return No(wh)}var No,wh,vs=ye(()=>{"use strict";wh=new Uint8Array(16)});var Tc,Mc=ye(()=>{"use strict";Tc=/^(?:[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 xh(r){return typeof r=="string"&&Tc.test(r)}var pr,mn=ye(()=>{"use strict";Mc();pr=xh});function vh(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(ce[r[t+0]]+ce[r[t+1]]+ce[r[t+2]]+ce[r[t+3]]+"-"+ce[r[t+4]]+ce[r[t+5]]+"-"+ce[r[t+6]]+ce[r[t+7]]+"-"+ce[r[t+8]]+ce[r[t+9]]+"-"+ce[r[t+10]]+ce[r[t+11]]+ce[r[t+12]]+ce[r[t+13]]+ce[r[t+14]]+ce[r[t+15]]).toLowerCase();if(!pr(e))throw TypeError("Stringified UUID is invalid");return e}var ce,zo,yr,bn=ye(()=>{"use strict";mn();ce=[];for(zo=0;zo<256;++zo)ce.push((zo+256).toString(16).substr(1));yr=vh});function kh(r,t,e){var n=t&&e||0,o=t||new Array(16);r=r||{};var i=r.node||Pc,s=r.clockseq!==void 0?r.clockseq:ks;if(i==null||s==null){var h=r.random||(r.rng||gn)();i==null&&(i=Pc=[h[0]|1,h[1],h[2],h[3],h[4],h[5]]),s==null&&(s=ks=(h[6]<<8|h[7])&16383)}var l=r.msecs!==void 0?r.msecs:Date.now(),b=r.nsecs!==void 0?r.nsecs:Bs+1,x=l-Ss+(b-Bs)/1e4;if(x<0&&r.clockseq===void 0&&(s=s+1&16383),(x<0||l>Ss)&&r.nsecs===void 0&&(b=0),b>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ss=l,Bs=b,ks=s,l+=122192928e5;var k=((l&268435455)*1e4+b)%4294967296;o[n++]=k>>>24&255,o[n++]=k>>>16&255,o[n++]=k>>>8&255,o[n++]=k&255;var R=l/4294967296*1e4&268435455;o[n++]=R>>>8&255,o[n++]=R&255,o[n++]=R>>>24&15|16,o[n++]=R>>>16&255,o[n++]=s>>>8|128,o[n++]=s&255;for(var I=0;I<6;++I)o[n+I]=i[I];return t||yr(o)}var Pc,ks,Ss,Bs,Cc,Oc=ye(()=>{"use strict";vs();bn();Ss=0,Bs=0;Cc=kh});function Sh(r){if(!pr(r))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(r.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(r.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(r.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(r.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(r.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}var qo,Es=ye(()=>{"use strict";mn();qo=Sh});function Bh(r){r=unescape(encodeURIComponent(r));for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e));return t}function Fo(r,t,e){function n(o,i,s,h){if(typeof o=="string"&&(o=Bh(o)),typeof i=="string"&&(i=qo(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var l=new Uint8Array(16+o.length);if(l.set(i),l.set(o,i.length),l=e(l),l[6]=l[6]&15|t,l[8]=l[8]&63|128,s){h=h||0;for(var b=0;b<16;++b)s[h+b]=l[b];return s}return yr(l)}try{n.name=r}catch{}return n.DNS=Eh,n.URL=_h,n}var Eh,_h,_s=ye(()=>{"use strict";bn();Es();Eh="6ba7b810-9dad-11d1-80b4-00c04fd430c8",_h="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function Ih(r){if(typeof r=="string"){var t=unescape(encodeURIComponent(r));r=new Uint8Array(t.length);for(var e=0;e<t.length;++e)r[e]=t.charCodeAt(e)}return Ah(Lh(Rh(r),r.length*8))}function Ah(r){for(var t=[],e=r.length*32,n="0123456789abcdef",o=0;o<e;o+=8){var i=r[o>>5]>>>o%32&255,s=parseInt(n.charAt(i>>>4&15)+n.charAt(i&15),16);t.push(s)}return t}function Uc(r){return(r+64>>>9<<4)+14+1}function Lh(r,t){r[t>>5]|=128<<t%32,r[Uc(t)-1]=t;for(var e=1732584193,n=-271733879,o=-1732584194,i=271733878,s=0;s<r.length;s+=16){var h=e,l=n,b=o,x=i;e=fe(e,n,o,i,r[s],7,-680876936),i=fe(i,e,n,o,r[s+1],12,-389564586),o=fe(o,i,e,n,r[s+2],17,606105819),n=fe(n,o,i,e,r[s+3],22,-1044525330),e=fe(e,n,o,i,r[s+4],7,-176418897),i=fe(i,e,n,o,r[s+5],12,1200080426),o=fe(o,i,e,n,r[s+6],17,-1473231341),n=fe(n,o,i,e,r[s+7],22,-45705983),e=fe(e,n,o,i,r[s+8],7,1770035416),i=fe(i,e,n,o,r[s+9],12,-1958414417),o=fe(o,i,e,n,r[s+10],17,-42063),n=fe(n,o,i,e,r[s+11],22,-1990404162),e=fe(e,n,o,i,r[s+12],7,1804603682),i=fe(i,e,n,o,r[s+13],12,-40341101),o=fe(o,i,e,n,r[s+14],17,-1502002290),n=fe(n,o,i,e,r[s+15],22,1236535329),e=le(e,n,o,i,r[s+1],5,-165796510),i=le(i,e,n,o,r[s+6],9,-1069501632),o=le(o,i,e,n,r[s+11],14,643717713),n=le(n,o,i,e,r[s],20,-373897302),e=le(e,n,o,i,r[s+5],5,-701558691),i=le(i,e,n,o,r[s+10],9,38016083),o=le(o,i,e,n,r[s+15],14,-660478335),n=le(n,o,i,e,r[s+4],20,-405537848),e=le(e,n,o,i,r[s+9],5,568446438),i=le(i,e,n,o,r[s+14],9,-1019803690),o=le(o,i,e,n,r[s+3],14,-187363961),n=le(n,o,i,e,r[s+8],20,1163531501),e=le(e,n,o,i,r[s+13],5,-1444681467),i=le(i,e,n,o,r[s+2],9,-51403784),o=le(o,i,e,n,r[s+7],14,1735328473),n=le(n,o,i,e,r[s+12],20,-1926607734),e=he(e,n,o,i,r[s+5],4,-378558),i=he(i,e,n,o,r[s+8],11,-2022574463),o=he(o,i,e,n,r[s+11],16,1839030562),n=he(n,o,i,e,r[s+14],23,-35309556),e=he(e,n,o,i,r[s+1],4,-1530992060),i=he(i,e,n,o,r[s+4],11,1272893353),o=he(o,i,e,n,r[s+7],16,-155497632),n=he(n,o,i,e,r[s+10],23,-1094730640),e=he(e,n,o,i,r[s+13],4,681279174),i=he(i,e,n,o,r[s],11,-358537222),o=he(o,i,e,n,r[s+3],16,-722521979),n=he(n,o,i,e,r[s+6],23,76029189),e=he(e,n,o,i,r[s+9],4,-640364487),i=he(i,e,n,o,r[s+12],11,-421815835),o=he(o,i,e,n,r[s+15],16,530742520),n=he(n,o,i,e,r[s+2],23,-995338651),e=de(e,n,o,i,r[s],6,-198630844),i=de(i,e,n,o,r[s+7],10,1126891415),o=de(o,i,e,n,r[s+14],15,-1416354905),n=de(n,o,i,e,r[s+5],21,-57434055),e=de(e,n,o,i,r[s+12],6,1700485571),i=de(i,e,n,o,r[s+3],10,-1894986606),o=de(o,i,e,n,r[s+10],15,-1051523),n=de(n,o,i,e,r[s+1],21,-2054922799),e=de(e,n,o,i,r[s+8],6,1873313359),i=de(i,e,n,o,r[s+15],10,-30611744),o=de(o,i,e,n,r[s+6],15,-1560198380),n=de(n,o,i,e,r[s+13],21,1309151649),e=de(e,n,o,i,r[s+4],6,-145523070),i=de(i,e,n,o,r[s+11],10,-1120210379),o=de(o,i,e,n,r[s+2],15,718787259),n=de(n,o,i,e,r[s+9],21,-343485551),e=gr(e,h),n=gr(n,l),o=gr(o,b),i=gr(i,x)}return[e,n,o,i]}function Rh(r){if(r.length===0)return[];for(var t=r.length*8,e=new Uint32Array(Uc(t)),n=0;n<t;n+=8)e[n>>5]|=(r[n/8]&255)<<n%32;return e}function gr(r,t){var e=(r&65535)+(t&65535),n=(r>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function Th(r,t){return r<<t|r>>>32-t}function Do(r,t,e,n,o,i){return gr(Th(gr(gr(t,r),gr(n,i)),o),e)}function fe(r,t,e,n,o,i,s){return Do(t&e|~t&n,r,t,o,i,s)}function le(r,t,e,n,o,i,s){return Do(t&n|e&~n,r,t,o,i,s)}function he(r,t,e,n,o,i,s){return Do(t^e^n,r,t,o,i,s)}function de(r,t,e,n,o,i,s){return Do(e^(t|~n),r,t,o,i,s)}var Nc,zc=ye(()=>{"use strict";Nc=Ih});var Mh,qc,Fc=ye(()=>{"use strict";_s();zc();Mh=Fo("v3",48,Nc),qc=Mh});function Ph(r,t,e){r=r||{};var n=r.random||(r.rng||gn)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var o=0;o<16;++o)t[e+o]=n[o];return t}return yr(n)}var Dc,Kc=ye(()=>{"use strict";vs();bn();Dc=Ph});function Ch(r,t,e,n){switch(r){case 0:return t&e^~t&n;case 1:return t^e^n;case 2:return t&e^t&n^e&n;case 3:return t^e^n}}function Is(r,t){return r<<t|r>>>32-t}function Oh(r){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var o=0;o<n.length;++o)r.push(n.charCodeAt(o))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var i=r.length/4+2,s=Math.ceil(i/16),h=new Array(s),l=0;l<s;++l){for(var b=new Uint32Array(16),x=0;x<16;++x)b[x]=r[l*64+x*4]<<24|r[l*64+x*4+1]<<16|r[l*64+x*4+2]<<8|r[l*64+x*4+3];h[l]=b}h[s-1][14]=(r.length-1)*8/Math.pow(2,32),h[s-1][14]=Math.floor(h[s-1][14]),h[s-1][15]=(r.length-1)*8&4294967295;for(var k=0;k<s;++k){for(var R=new Uint32Array(80),I=0;I<16;++I)R[I]=h[k][I];for(var P=16;P<80;++P)R[P]=Is(R[P-3]^R[P-8]^R[P-14]^R[P-16],1);for(var B=e[0],A=e[1],T=e[2],F=e[3],N=e[4],W=0;W<80;++W){var q=Math.floor(W/20),z=Is(B,5)+Ch(q,A,T,F)+N+t[q]+R[W]>>>0;N=F,F=T,T=Is(A,30)>>>0,A=B,B=z}e[0]=e[0]+B>>>0,e[1]=e[1]+A>>>0,e[2]=e[2]+T>>>0,e[3]=e[3]+F>>>0,e[4]=e[4]+N>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var Wc,Hc=ye(()=>{"use strict";Wc=Oh});var Uh,Vc,$c=ye(()=>{"use strict";_s();Hc();Uh=Fo("v5",80,Wc),Vc=Uh});var jc,Gc=ye(()=>{"use strict";jc="00000000-0000-0000-0000-000000000000"});function Nh(r){if(!pr(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}var Yc,Zc=ye(()=>{"use strict";mn();Yc=Nh});var As={};_i(As,{NIL:()=>jc,parse:()=>qo,stringify:()=>yr,v1:()=>Cc,v3:()=>qc,v4:()=>Dc,v5:()=>Vc,validate:()=>pr,version:()=>Yc});var Ls=ye(()=>{"use strict";Oc();Fc();Kc();$c();Gc();Zc();mn();bn();Es()});var Xc=at((vy,Jc)=>{"use strict";var zh=(Ls(),Ii(As)).v4,qh=function(r,t,e,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};let o=typeof n.version=="number"?n.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");let i={method:r};if(o===2&&(i.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");i.params=t}if(typeof e>"u"){let s=typeof n.generator=="function"?n.generator:function(){return zh()};i.id=s(i,n)}else o===2&&e===null?n.notificationIdNull&&(i.id=null):i.id=e;return i};Jc.exports=qh});var tu=at((ky,Qc)=>{"use strict";var Fh=(Ls(),Ii(As)).v4,Dh=Xc(),wn=function(r,t){if(!(this instanceof wn))return new wn(r,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return Fh()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=r};Qc.exports=wn;wn.prototype.request=function(r,t,e,n){let o=this,i=null,s=Array.isArray(r)&&typeof t=="function";if(this.options.version===1&&s)throw new TypeError("JSON-RPC 1.0 does not support batching");if(s||!s&&r&&typeof r=="object"&&typeof t=="function")n=t,i=r;else{typeof e=="function"&&(n=e,e=void 0);let b=typeof n=="function";try{i=Dh(r,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(x){if(b)return n(x);throw x}if(!b)return i}let l;try{l=JSON.stringify(i,this.options.replacer)}catch(b){return n(b)}return this.callServer(l,function(b,x){o._parseResponse(b,x,n)}),i};wn.prototype._parseResponse=function(r,t,e){if(r){e(r);return}if(!t)return e();let n;try{n=JSON.parse(t,this.options.reviver)}catch(o){return e(o)}if(e.length===3)if(Array.isArray(n)){let o=function(s){return typeof s.error<"u"},i=function(s){return!o(s)};return e(null,n.filter(o),n.filter(i))}else return e(null,n.error,n.result);e(null,n)}});var Rs=at((Sy,xn)=>{"use strict";function Kh(r){return r&&r.__esModule?r:{default:r}}xn.exports=Kh,xn.exports.__esModule=!0,xn.exports.default=xn.exports});var Yr=at((By,Ye)=>{"use strict";function Ts(r){"@babel/helpers - typeof";return Ye.exports=Ts=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ye.exports.__esModule=!0,Ye.exports.default=Ye.exports,Ts(r)}Ye.exports=Ts,Ye.exports.__esModule=!0,Ye.exports.default=Ye.exports});var nu=at((Ey,Ze)=>{"use strict";var eu=Yr().default;function ru(){"use strict";Ze.exports=ru=function(){return t},Ze.exports.__esModule=!0,Ze.exports.default=Ze.exports;var r,t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(f,d,p){f[d]=p.value},i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",h=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function b(f,d,p){return Object.defineProperty(f,d,{value:p,enumerable:!0,configurable:!0,writable:!0}),f[d]}try{b({},"")}catch{b=function(p,g,w){return p[g]=w}}function x(f,d,p,g){var w=d&&d.prototype instanceof T?d:T,y=Object.create(w.prototype),c=new a(g||[]);return o(y,"_invoke",{value:nt(f,p,c)}),y}function k(f,d,p){try{return{type:"normal",arg:f.call(d,p)}}catch(g){return{type:"throw",arg:g}}}t.wrap=x;var R="suspendedStart",I="suspendedYield",P="executing",B="completed",A={};function T(){}function F(){}function N(){}var W={};b(W,s,function(){return this});var q=Object.getPrototypeOf,z=q&&q(q(u([])));z&&z!==e&&n.call(z,s)&&(W=z);var H=N.prototype=T.prototype=Object.create(W);function j(f){["next","throw","return"].forEach(function(d){b(f,d,function(p){return this._invoke(d,p)})})}function ot(f,d){function p(w,y,c,m){var M=k(f[w],f,y);if(M.type!=="throw"){var U=M.arg,O=U.value;return O&&eu(O)=="object"&&n.call(O,"__await")?d.resolve(O.__await).then(function(D){p("next",D,c,m)},function(D){p("throw",D,c,m)}):d.resolve(O).then(function(D){U.value=D,c(U)},function(D){return p("throw",D,c,m)})}m(M.arg)}var g;o(this,"_invoke",{value:function(y,c){function m(){return new d(function(M,U){p(y,c,M,U)})}return g=g?g.then(m,m):m()}})}function nt(f,d,p){var g=R;return function(w,y){if(g===P)throw Error("Generator is already running");if(g===B){if(w==="throw")throw y;return{value:r,done:!0}}for(p.method=w,p.arg=y;;){var c=p.delegate;if(c){var m=G(c,p);if(m){if(m===A)continue;return m}}if(p.method==="next")p.sent=p._sent=p.arg;else if(p.method==="throw"){if(g===R)throw g=B,p.arg;p.dispatchException(p.arg)}else p.method==="return"&&p.abrupt("return",p.arg);g=P;var M=k(f,d,p);if(M.type==="normal"){if(g=p.done?B:I,M.arg===A)continue;return{value:M.arg,done:p.done}}M.type==="throw"&&(g=B,p.method="throw",p.arg=M.arg)}}}function G(f,d){var p=d.method,g=f.iterator[p];if(g===r)return d.delegate=null,p==="throw"&&f.iterator.return&&(d.method="return",d.arg=r,G(f,d),d.method==="throw")||p!=="return"&&(d.method="throw",d.arg=new TypeError("The iterator does not provide a '"+p+"' method")),A;var w=k(g,f.iterator,d.arg);if(w.type==="throw")return d.method="throw",d.arg=w.arg,d.delegate=null,A;var y=w.arg;return y?y.done?(d[f.resultName]=y.value,d.next=f.nextLoc,d.method!=="return"&&(d.method="next",d.arg=r),d.delegate=null,A):y:(d.method="throw",d.arg=new TypeError("iterator result is not an object"),d.delegate=null,A)}function lt(f){var d={tryLoc:f[0]};1 in f&&(d.catchLoc=f[1]),2 in f&&(d.finallyLoc=f[2],d.afterLoc=f[3]),this.tryEntries.push(d)}function v(f){var d=f.completion||{};d.type="normal",delete d.arg,f.completion=d}function a(f){this.tryEntries=[{tryLoc:"root"}],f.forEach(lt,this),this.reset(!0)}function u(f){if(f||f===""){var d=f[s];if(d)return d.call(f);if(typeof f.next=="function")return f;if(!isNaN(f.length)){var p=-1,g=function w(){for(;++p<f.length;)if(n.call(f,p))return w.value=f[p],w.done=!1,w;return w.value=r,w.done=!0,w};return g.next=g}}throw new TypeError(eu(f)+" is not iterable")}return F.prototype=N,o(H,"constructor",{value:N,configurable:!0}),o(N,"constructor",{value:F,configurable:!0}),F.displayName=b(N,l,"GeneratorFunction"),t.isGeneratorFunction=function(f){var d=typeof f=="function"&&f.constructor;return!!d&&(d===F||(d.displayName||d.name)==="GeneratorFunction")},t.mark=function(f){return Object.setPrototypeOf?Object.setPrototypeOf(f,N):(f.__proto__=N,b(f,l,"GeneratorFunction")),f.prototype=Object.create(H),f},t.awrap=function(f){return{__await:f}},j(ot.prototype),b(ot.prototype,h,function(){return this}),t.AsyncIterator=ot,t.async=function(f,d,p,g,w){w===void 0&&(w=Promise);var y=new ot(x(f,d,p,g),w);return t.isGeneratorFunction(d)?y:y.next().then(function(c){return c.done?c.value:y.next()})},j(H),b(H,l,"Generator"),b(H,s,function(){return this}),b(H,"toString",function(){return"[object Generator]"}),t.keys=function(f){var d=Object(f),p=[];for(var g in d)p.push(g);return p.reverse(),function w(){for(;p.length;){var y=p.pop();if(y in d)return w.value=y,w.done=!1,w}return w.done=!0,w}},t.values=u,a.prototype={constructor:a,reset:function(d){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(v),!d)for(var p in this)p.charAt(0)==="t"&&n.call(this,p)&&!isNaN(+p.slice(1))&&(this[p]=r)},stop:function(){this.done=!0;var d=this.tryEntries[0].completion;if(d.type==="throw")throw d.arg;return this.rval},dispatchException:function(d){if(this.done)throw d;var p=this;function g(U,O){return c.type="throw",c.arg=d,p.next=U,O&&(p.method="next",p.arg=r),!!O}for(var w=this.tryEntries.length-1;w>=0;--w){var y=this.tryEntries[w],c=y.completion;if(y.tryLoc==="root")return g("end");if(y.tryLoc<=this.prev){var m=n.call(y,"catchLoc"),M=n.call(y,"finallyLoc");if(m&&M){if(this.prev<y.catchLoc)return g(y.catchLoc,!0);if(this.prev<y.finallyLoc)return g(y.finallyLoc)}else if(m){if(this.prev<y.catchLoc)return g(y.catchLoc,!0)}else{if(!M)throw Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return g(y.finallyLoc)}}}},abrupt:function(d,p){for(var g=this.tryEntries.length-1;g>=0;--g){var w=this.tryEntries[g];if(w.tryLoc<=this.prev&&n.call(w,"finallyLoc")&&this.prev<w.finallyLoc){var y=w;break}}y&&(d==="break"||d==="continue")&&y.tryLoc<=p&&p<=y.finallyLoc&&(y=null);var c=y?y.completion:{};return c.type=d,c.arg=p,y?(this.method="next",this.next=y.finallyLoc,A):this.complete(c)},complete:function(d,p){if(d.type==="throw")throw d.arg;return d.type==="break"||d.type==="continue"?this.next=d.arg:d.type==="return"?(this.rval=this.arg=d.arg,this.method="return",this.next="end"):d.type==="normal"&&p&&(this.next=p),A},finish:function(d){for(var p=this.tryEntries.length-1;p>=0;--p){var g=this.tryEntries[p];if(g.finallyLoc===d)return this.complete(g.completion,g.afterLoc),v(g),A}},catch:function(d){for(var p=this.tryEntries.length-1;p>=0;--p){var g=this.tryEntries[p];if(g.tryLoc===d){var w=g.completion;if(w.type==="throw"){var y=w.arg;v(g)}return y}}throw Error("illegal catch attempt")},delegateYield:function(d,p,g){return this.delegate={iterator:u(d),resultName:p,nextLoc:g},this.method==="next"&&(this.arg=r),A}},t}Ze.exports=ru,Ze.exports.__esModule=!0,Ze.exports.default=Ze.exports});var iu=at((_y,ou)=>{"use strict";var Ko=nu()();ou.exports=Ko;try{regeneratorRuntime=Ko}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Ko:Function("r","regeneratorRuntime = r")(Ko)}});var au=at((Iy,vn)=>{"use strict";function su(r,t,e,n,o,i,s){try{var h=r[i](s),l=h.value}catch(b){return void e(b)}h.done?t(l):Promise.resolve(l).then(n,o)}function Wh(r){return function(){var t=this,e=arguments;return new Promise(function(n,o){var i=r.apply(t,e);function s(l){su(i,n,o,s,h,"next",l)}function h(l){su(i,n,o,s,h,"throw",l)}s(void 0)})}}vn.exports=Wh,vn.exports.__esModule=!0,vn.exports.default=vn.exports});var Ms=at((Ay,kn)=>{"use strict";function Hh(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}kn.exports=Hh,kn.exports.__esModule=!0,kn.exports.default=kn.exports});var uu=at((Ly,Sn)=>{"use strict";var cu=Yr().default;function Vh(r,t){if(cu(r)!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t||"default");if(cu(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}Sn.exports=Vh,Sn.exports.__esModule=!0,Sn.exports.default=Sn.exports});var fu=at((Ry,Bn)=>{"use strict";var $h=Yr().default,jh=uu();function Gh(r){var t=jh(r,"string");return $h(t)=="symbol"?t:t+""}Bn.exports=Gh,Bn.exports.__esModule=!0,Bn.exports.default=Bn.exports});var Ps=at((Ty,En)=>{"use strict";var Yh=fu();function lu(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Yh(n.key),n)}}function Zh(r,t,e){return t&&lu(r.prototype,t),e&&lu(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}En.exports=Zh,En.exports.__esModule=!0,En.exports.default=En.exports});var hu=at((My,Je)=>{"use strict";function Cs(r,t){return Je.exports=Cs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},Je.exports.__esModule=!0,Je.exports.default=Je.exports,Cs(r,t)}Je.exports=Cs,Je.exports.__esModule=!0,Je.exports.default=Je.exports});var Os=at((Py,_n)=>{"use strict";var Jh=hu();function Xh(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&Jh(r,t)}_n.exports=Xh,_n.exports.__esModule=!0,_n.exports.default=_n.exports});var du=at((Cy,In)=>{"use strict";function Qh(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}In.exports=Qh,In.exports.__esModule=!0,In.exports.default=In.exports});var Us=at((Oy,An)=>{"use strict";var td=Yr().default,ed=du();function rd(r,t){if(t&&(td(t)=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ed(r)}An.exports=rd,An.exports.__esModule=!0,An.exports.default=An.exports});var zs=at((Uy,Xe)=>{"use strict";function Ns(r){return Xe.exports=Ns=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xe.exports.__esModule=!0,Xe.exports.default=Xe.exports,Ns(r)}Xe.exports=Ns,Xe.exports.__esModule=!0,Xe.exports.default=Xe.exports});var Fs=at((Ny,qs)=>{"use strict";var nd=Object.prototype.hasOwnProperty,be="~";function Ln(){}Object.create&&(Ln.prototype=Object.create(null),new Ln().__proto__||(be=!1));function od(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function pu(r,t,e,n,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var i=new od(e,n||r,o),s=be?be+t:t;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Wo(r,t){--r._eventsCount===0?r._events=new Ln:delete r._events[t]}function pe(){this._events=new Ln,this._eventsCount=0}pe.prototype.eventNames=function(){var t=[],e,n;if(this._eventsCount===0)return t;for(n in e=this._events)nd.call(e,n)&&t.push(be?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};pe.prototype.listeners=function(t){var e=be?be+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};pe.prototype.listenerCount=function(t){var e=be?be+t:t,n=this._events[e];return n?n.fn?1:n.length:0};pe.prototype.emit=function(t,e,n,o,i,s){var h=be?be+t:t;if(!this._events[h])return!1;var l=this._events[h],b=arguments.length,x,k;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),b){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,s),!0}for(k=1,x=new Array(b-1);k<b;k++)x[k-1]=arguments[k];l.fn.apply(l.context,x)}else{var R=l.length,I;for(k=0;k<R;k++)switch(l[k].once&&this.removeListener(t,l[k].fn,void 0,!0),b){case 1:l[k].fn.call(l[k].context);break;case 2:l[k].fn.call(l[k].context,e);break;case 3:l[k].fn.call(l[k].context,e,n);break;case 4:l[k].fn.call(l[k].context,e,n,o);break;default:if(!x)for(I=1,x=new Array(b-1);I<b;I++)x[I-1]=arguments[I];l[k].fn.apply(l[k].context,x)}}return!0};pe.prototype.on=function(t,e,n){return pu(this,t,e,n,!1)};pe.prototype.once=function(t,e,n){return pu(this,t,e,n,!0)};pe.prototype.removeListener=function(t,e,n,o){var i=be?be+t:t;if(!this._events[i])return this;if(!e)return Wo(this,i),this;var s=this._events[i];if(s.fn)s.fn===e&&(!o||s.once)&&(!n||s.context===n)&&Wo(this,i);else{for(var h=0,l=[],b=s.length;h<b;h++)(s[h].fn!==e||o&&!s[h].once||n&&s[h].context!==n)&&l.push(s[h]);l.length?this._events[i]=l.length===1?l[0]:l:Wo(this,i)}return this};pe.prototype.removeAllListeners=function(t){var e;return t?(e=be?be+t:t,this._events[e]&&Wo(this,e)):(this._events=new Ln,this._eventsCount=0),this};pe.prototype.off=pe.prototype.removeListener;pe.prototype.addListener=pe.prototype.on;pe.prefixed=be;pe.EventEmitter=pe;typeof qs<"u"&&(qs.exports=pe)});var gu=at(Vo=>{"use strict";var br=Rs();Object.defineProperty(Vo,"__esModule",{value:!0});Vo.default=void 0;var mr=br(iu()),Ho=br(au()),id=br(Yr()),sd=br(Ms()),ad=br(Ps()),cd=br(Os()),ud=br(Us()),yu=br(zs()),fd=Fs();function ld(r){var t=hd();return function(){var n=(0,yu.default)(r),o;if(t){var i=(0,yu.default)(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return(0,ud.default)(this,o)}}function hd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var dd=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(r);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(r,n[o])&&(e[n[o]]=r[n[o]]);return e},pd=function(r){(0,cd.default)(e,r);var t=ld(e);function e(n){var o,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ws://localhost:8080",s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},h=arguments.length>3?arguments[3]:void 0;(0,sd.default)(this,e);var l=s.autoconnect,b=l===void 0?!0:l,x=s.reconnect,k=x===void 0?!0:x,R=s.reconnect_interval,I=R===void 0?1e3:R,P=s.max_reconnects,B=P===void 0?5:P,A=dd(s,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return o=t.call(this),o.webSocketFactory=n,o.queue={},o.rpc_id=0,o.address=i,o.autoconnect=b,o.ready=!1,o.reconnect=k,o.reconnect_timer_id=void 0,o.reconnect_interval=I,o.max_reconnects=B,o.rest_options=A,o.current_reconnects=0,o.generate_request_id=h||function(){return++o.rpc_id},o.autoconnect&&o._connect(o.address,Object.assign({autoconnect:o.autoconnect,reconnect:o.reconnect,reconnect_interval:o.reconnect_interval,max_reconnects:o.max_reconnects},o.rest_options)),o}return(0,ad.default)(e,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(o,i,s,h){var l=this;return!h&&(0,id.default)(s)==="object"&&(h=s,s=null),new Promise(function(b,x){if(!l.ready)return x(new Error("socket not ready"));var k=l.generate_request_id(o,i),R={jsonrpc:"2.0",method:o,params:i||null,id:k};l.socket.send(JSON.stringify(R),h,function(I){if(I)return x(I);l.queue[k]={promise:[b,x]},s&&(l.queue[k].timeout=setTimeout(function(){delete l.queue[k],x(new Error("reply timeout"))},s))})})}},{key:"login",value:function(){var n=(0,Ho.default)(mr.default.mark(function i(s){var h;return mr.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.call("rpc.login",s);case 2:if(h=b.sent,h){b.next=5;break}throw new Error("authentication failed");case 5:return b.abrupt("return",h);case 6:case"end":return b.stop()}},i,this)}));function o(i){return n.apply(this,arguments)}return o}()},{key:"listMethods",value:function(){var n=(0,Ho.default)(mr.default.mark(function i(){return mr.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.call("__listMethods");case 2:return h.abrupt("return",h.sent);case 3:case"end":return h.stop()}},i,this)}));function o(){return n.apply(this,arguments)}return o}()},{key:"notify",value:function(o,i){var s=this;return new Promise(function(h,l){if(!s.ready)return l(new Error("socket not ready"));var b={jsonrpc:"2.0",method:o,params:i||null};s.socket.send(JSON.stringify(b),function(x){if(x)return l(x);h()})})}},{key:"subscribe",value:function(){var n=(0,Ho.default)(mr.default.mark(function i(s){var h;return mr.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return typeof s=="string"&&(s=[s]),b.next=3,this.call("rpc.on",s);case 3:if(h=b.sent,!(typeof s=="string"&&h[s]!=="ok")){b.next=6;break}throw new Error("Failed subscribing to an event '"+s+"' with: "+h[s]);case 6:return b.abrupt("return",h);case 7:case"end":return b.stop()}},i,this)}));function o(i){return n.apply(this,arguments)}return o}()},{key:"unsubscribe",value:function(){var n=(0,Ho.default)(mr.default.mark(function i(s){var h;return mr.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return typeof s=="string"&&(s=[s]),b.next=3,this.call("rpc.off",s);case 3:if(h=b.sent,!(typeof s=="string"&&h[s]!=="ok")){b.next=6;break}throw new Error("Failed unsubscribing from an event with: "+h);case 6:return b.abrupt("return",h);case 7:case"end":return b.stop()}},i,this)}));function o(i){return n.apply(this,arguments)}return o}()},{key:"close",value:function(o,i){this.socket.close(o||1e3,i)}},{key:"_connect",value:function(o,i){var s=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(o,i),this.socket.addEventListener("open",function(){s.ready=!0,s.emit("open"),s.current_reconnects=0}),this.socket.addEventListener("message",function(h){var l=h.data;l instanceof ArrayBuffer&&(l=Buffer.from(l).toString());try{l=JSON.parse(l)}catch{return}if(l.notification&&s.listeners(l.notification).length){if(!Object.keys(l.params).length)return s.emit(l.notification);var b=[l.notification];if(l.params.constructor===Object)b.push(l.params);else for(var x=0;x<l.params.length;x++)b.push(l.params[x]);return Promise.resolve().then(function(){s.emit.apply(s,b)})}if(!s.queue[l.id])return l.method&&l.params?Promise.resolve().then(function(){s.emit(l.method,l.params)}):void 0;"error"in l=="result"in l&&s.queue[l.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),s.queue[l.id].timeout&&clearTimeout(s.queue[l.id].timeout),l.error?s.queue[l.id].promise[1](l.error):s.queue[l.id].promise[0](l.result),delete s.queue[l.id]}),this.socket.addEventListener("error",function(h){return s.emit("error",h)}),this.socket.addEventListener("close",function(h){var l=h.code,b=h.reason;s.ready&&setTimeout(function(){return s.emit("close",l,b)},0),s.ready=!1,s.socket=void 0,l!==1e3&&(s.current_reconnects++,s.reconnect&&(s.max_reconnects>s.current_reconnects||s.max_reconnects===0)&&(s.reconnect_timer_id=setTimeout(function(){return s._connect(o,i)},s.reconnect_interval)))})}}]),e}(fd.EventEmitter);Vo.default=pd});var bu=at(Ds=>{"use strict";var Rn=Rs();Object.defineProperty(Ds,"__esModule",{value:!0});Ds.default=Sd;var yd=Rn(Ms()),gd=Rn(Ps()),md=Rn(Os()),bd=Rn(Us()),mu=Rn(zs()),wd=Fs();function xd(r){var t=vd();return function(){var n=(0,mu.default)(r),o;if(t){var i=(0,mu.default)(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return(0,bd.default)(this,o)}}function vd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var kd=function(r){(0,md.default)(e,r);var t=xd(e);function e(n,o,i){var s;return(0,yd.default)(this,e),s=t.call(this),s.socket=new window.WebSocket(n,i),s.socket.onopen=function(){return s.emit("open")},s.socket.onmessage=function(h){return s.emit("message",h.data)},s.socket.onerror=function(h){return s.emit("error",h)},s.socket.onclose=function(h){s.emit("close",h.code,h.reason)},s}return(0,gd.default)(e,[{key:"send",value:function(o,i,s){var h=s||i;try{this.socket.send(o),h()}catch(l){h(l)}}},{key:"close",value:function(o,i){this.socket.close(o,i)}},{key:"addEventListener",value:function(o,i,s){this.socket.addEventListener(o,i,s)}}]),e}(wd.EventEmitter);function Sd(r,t){return new kd(r,t)}});var C0={};_i(C0,{default:()=>P0});var sf=Re(Ia());var X=Re(Vn());function on(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function sn(r,...t){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function Ga(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");on(r.outputLen),on(r.blockLen)}function Ke(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function $n(r,t){sn(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var jn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Ya=r=>r instanceof Uint8Array;var Za=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),Gn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Te=(r,t)=>r<<32-t|r>>>t,Hf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Hf)throw new Error("Non little-endian hardware is not supported");function zi(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function or(r){if(typeof r=="string"&&(r=zi(r)),!Ya(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Yn(...r){let t=new Uint8Array(r.reduce((n,o)=>n+o.length,0)),e=0;return r.forEach(n=>{if(!Ya(n))throw new Error("Uint8Array expected");t.set(n,e),e+=n.length}),t}var nr=class{clone(){return this._cloneInto()}},H0={}.toString;function qr(r){let t=n=>r().update(or(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ja(r){let t=(n,o)=>r(o).update(or(n)).digest(),e=r({});return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=n=>r(n),t}function Zn(r=32){if(jn&&typeof jn.getRandomValues=="function")return jn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Vf(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),h=Number(e&i),l=n?4:0,b=n?0:4;r.setUint32(t+l,s,n),r.setUint32(t+b,h,n)}var Fr=class extends nr{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Gn(this.buffer)}update(t){Ke(this);let{view:e,buffer:n,blockLen:o}=this;t=or(t);let i=t.length;for(let s=0;s<i;){let h=Math.min(o-this.pos,i-s);if(h===o){let l=Gn(t);for(;o<=i-s;s+=o)this.process(l,s);continue}n.set(t.subarray(s,s+h),this.pos),this.pos+=h,s+=h,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ke(this),$n(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let k=s;k<o;k++)e[k]=0;Vf(n,o-8,BigInt(this.length*8),i),this.process(n,0);let h=Gn(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let b=l/4,x=this.get();if(b>x.length)throw new Error("_sha2: outputLen bigger than state");for(let k=0;k<b;k++)h.setUint32(4*k,x[k],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:h}=this;return t.length=o,t.pos=h,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var Jn=BigInt(4294967295),qi=BigInt(32);function Xa(r,t=!1){return t?{h:Number(r&Jn),l:Number(r>>qi&Jn)}:{h:Number(r>>qi&Jn)|0,l:Number(r&Jn)|0}}function Fi(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=Xa(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var $f=(r,t)=>BigInt(r>>>0)<<qi|BigInt(t>>>0),jf=(r,t,e)=>r>>>e,Gf=(r,t,e)=>r<<32-e|t>>>e,Yf=(r,t,e)=>r>>>e|t<<32-e,Zf=(r,t,e)=>r<<32-e|t>>>e,Jf=(r,t,e)=>r<<64-e|t>>>e-32,Xf=(r,t,e)=>r>>>e-32|t<<64-e,Qf=(r,t)=>t,tl=(r,t)=>r,Di=(r,t,e)=>r<<e|t>>>32-e,Ki=(r,t,e)=>t<<e|r>>>32-e,Wi=(r,t,e)=>t<<e-32|r>>>64-e,Hi=(r,t,e)=>r<<e-32|t>>>64-e;function el(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var rl=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),nl=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ol=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),il=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,sl=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),al=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var cl={fromBig:Xa,split:Fi,toBig:$f,shrSH:jf,shrSL:Gf,rotrSH:Yf,rotrSL:Zf,rotrBH:Jf,rotrBL:Xf,rotr32H:Qf,rotr32L:tl,rotlSH:Di,rotlSL:Ki,rotlBH:Wi,rotlBL:Hi,add:el,add3L:rl,add3H:nl,add4L:ol,add4H:il,add5H:al,add5L:sl},et=cl;var[ul,fl]=et.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))),ir=new Uint32Array(80),sr=new Uint32Array(80),Vi=class extends Fr{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:t,Al:e,Bh:n,Bl:o,Ch:i,Cl:s,Dh:h,Dl:l,Eh:b,El:x,Fh:k,Fl:R,Gh:I,Gl:P,Hh:B,Hl:A}=this;return[t,e,n,o,i,s,h,l,b,x,k,R,I,P,B,A]}set(t,e,n,o,i,s,h,l,b,x,k,R,I,P,B,A){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=h|0,this.Dl=l|0,this.Eh=b|0,this.El=x|0,this.Fh=k|0,this.Fl=R|0,this.Gh=I|0,this.Gl=P|0,this.Hh=B|0,this.Hl=A|0}process(t,e){for(let N=0;N<16;N++,e+=4)ir[N]=t.getUint32(e),sr[N]=t.getUint32(e+=4);for(let N=16;N<80;N++){let W=ir[N-15]|0,q=sr[N-15]|0,z=et.rotrSH(W,q,1)^et.rotrSH(W,q,8)^et.shrSH(W,q,7),H=et.rotrSL(W,q,1)^et.rotrSL(W,q,8)^et.shrSL(W,q,7),j=ir[N-2]|0,ot=sr[N-2]|0,nt=et.rotrSH(j,ot,19)^et.rotrBH(j,ot,61)^et.shrSH(j,ot,6),G=et.rotrSL(j,ot,19)^et.rotrBL(j,ot,61)^et.shrSL(j,ot,6),lt=et.add4L(H,G,sr[N-7],sr[N-16]),v=et.add4H(lt,z,nt,ir[N-7],ir[N-16]);ir[N]=v|0,sr[N]=lt|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:h,Cl:l,Dh:b,Dl:x,Eh:k,El:R,Fh:I,Fl:P,Gh:B,Gl:A,Hh:T,Hl:F}=this;for(let N=0;N<80;N++){let W=et.rotrSH(k,R,14)^et.rotrSH(k,R,18)^et.rotrBH(k,R,41),q=et.rotrSL(k,R,14)^et.rotrSL(k,R,18)^et.rotrBL(k,R,41),z=k&I^~k&B,H=R&P^~R&A,j=et.add5L(F,q,H,fl[N],sr[N]),ot=et.add5H(j,T,W,z,ul[N],ir[N]),nt=j|0,G=et.rotrSH(n,o,28)^et.rotrBH(n,o,34)^et.rotrBH(n,o,39),lt=et.rotrSL(n,o,28)^et.rotrBL(n,o,34)^et.rotrBL(n,o,39),v=n&i^n&h^i&h,a=o&s^o&l^s&l;T=B|0,F=A|0,B=I|0,A=P|0,I=k|0,P=R|0,{h:k,l:R}=et.add(b|0,x|0,ot|0,nt|0),b=h|0,x=l|0,h=i|0,l=s|0,i=n|0,s=o|0;let u=et.add3L(nt,lt,a);n=et.add3H(u,ot,G,v),o=u|0}({h:n,l:o}=et.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=et.add(this.Bh|0,this.Bl|0,i|0,s|0),{h,l}=et.add(this.Ch|0,this.Cl|0,h|0,l|0),{h:b,l:x}=et.add(this.Dh|0,this.Dl|0,b|0,x|0),{h:k,l:R}=et.add(this.Eh|0,this.El|0,k|0,R|0),{h:I,l:P}=et.add(this.Fh|0,this.Fl|0,I|0,P|0),{h:B,l:A}=et.add(this.Gh|0,this.Gl|0,B|0,A|0),{h:T,l:F}=et.add(this.Hh|0,this.Hl|0,T|0,F|0),this.set(n,o,i,s,h,l,b,x,k,R,I,P,B,A,T,F)}roundClean(){ir.fill(0),sr.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 $i=qr(()=>new Vi);var to={};_i(to,{bitGet:()=>ml,bitLen:()=>gl,bitMask:()=>an,bitSet:()=>bl,bytesToHex:()=>We,bytesToNumberBE:()=>He,bytesToNumberLE:()=>ar,concatBytes:()=>Ve,createHmacDrbg:()=>Yi,ensureBytes:()=>Ot,equalBytes:()=>pl,hexToBytes:()=>Sr,hexToNumber:()=>Gi,numberToBytesBE:()=>cr,numberToBytesLE:()=>Br,numberToHexUnpadded:()=>ec,numberToVarBytesBE:()=>dl,utf8ToBytes:()=>yl,validateObject:()=>Ne});var tc=BigInt(0),Xn=BigInt(1),ll=BigInt(2),Qn=r=>r instanceof Uint8Array,hl=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function We(r){if(!Qn(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=hl[r[e]];return t}function ec(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Gi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Sr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let e=new Uint8Array(t/2);for(let n=0;n<e.length;n++){let o=n*2,i=r.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");e[n]=s}return e}function He(r){return Gi(We(r))}function ar(r){if(!Qn(r))throw new Error("Uint8Array expected");return Gi(We(Uint8Array.from(r).reverse()))}function cr(r,t){return Sr(r.toString(16).padStart(t*2,"0"))}function Br(r,t){return cr(r,t).reverse()}function dl(r){return Sr(ec(r))}function Ot(r,t,e){let n;if(typeof t=="string")try{n=Sr(t)}catch(i){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Qn(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function Ve(...r){let t=new Uint8Array(r.reduce((n,o)=>n+o.length,0)),e=0;return r.forEach(n=>{if(!Qn(n))throw new Error("Uint8Array expected");t.set(n,e),e+=n.length}),t}function pl(r,t){if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}function yl(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function gl(r){let t;for(t=0;r>tc;r>>=Xn,t+=1);return t}function ml(r,t){return r>>BigInt(t)&Xn}var bl=(r,t,e)=>r|(e?Xn:tc)<<BigInt(t),an=r=>(ll<<BigInt(r-1))-Xn,ji=r=>new Uint8Array(r),Qa=r=>Uint8Array.from(r);function Yi(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=ji(r),o=ji(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},h=(...k)=>e(o,n,...k),l=(k=ji())=>{o=h(Qa([0]),k),n=h(),k.length!==0&&(o=h(Qa([1]),k),n=h())},b=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let k=0,R=[];for(;k<t;){n=h();let I=n.slice();R.push(I),k+=n.length}return Ve(...R)};return(k,R)=>{s(),l(k);let I;for(;!(I=R(b()));)l();return s(),I}}var wl={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"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Ne(r,t,e={}){let n=(o,i,s)=>{let h=wl[i];if(typeof h!="function")throw new Error(`Invalid validator "${i}", expected function`);let l=r[o];if(!(s&&l===void 0)&&!h(l,r))throw new Error(`Invalid param ${String(o)}=${l} (${typeof l}), expected ${i}`)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var ne=BigInt(0),vt=BigInt(1),Er=BigInt(2),xl=BigInt(3),Zi=BigInt(4),rc=BigInt(5),nc=BigInt(8),vl=BigInt(9),kl=BigInt(16);function pt(r,t){let e=r%t;return e>=ne?e:t+e}function Sl(r,t,e){if(e<=ne||t<ne)throw new Error("Expected power/modulo > 0");if(e===vt)return ne;let n=vt;for(;t>ne;)t&vt&&(n=n*r%e),r=r*r%e,t>>=vt;return n}function kt(r,t,e){let n=r;for(;t-- >ne;)n*=n,n%=e;return n}function eo(r,t){if(r===ne||t<=ne)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=pt(r,t),n=t,o=ne,i=vt,s=vt,h=ne;for(;e!==ne;){let b=n/e,x=n%e,k=o-s*b,R=i-h*b;n=e,e=x,o=s,i=h,s=k,h=R}if(n!==vt)throw new Error("invert: does not exist");return pt(o,t)}function Bl(r){let t=(r-vt)/Er,e,n,o;for(e=r-vt,n=0;e%Er===ne;e/=Er,n++);for(o=Er;o<r&&Sl(o,t,r)!==r-vt;o++);if(n===1){let s=(r+vt)/Zi;return function(l,b){let x=l.pow(b,s);if(!l.eql(l.sqr(x),b))throw new Error("Cannot find square root");return x}}let i=(e+vt)/Er;return function(h,l){if(h.pow(l,t)===h.neg(h.ONE))throw new Error("Cannot find square root");let b=n,x=h.pow(h.mul(h.ONE,o),e),k=h.pow(l,i),R=h.pow(l,e);for(;!h.eql(R,h.ONE);){if(h.eql(R,h.ZERO))return h.ZERO;let I=1;for(let B=h.sqr(R);I<b&&!h.eql(B,h.ONE);I++)B=h.sqr(B);let P=h.pow(x,vt<<BigInt(b-I-1));x=h.sqr(P),k=h.mul(k,P),R=h.mul(R,x),b=I}return k}}function El(r){if(r%Zi===xl){let t=(r+vt)/Zi;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%nc===rc){let t=(r-rc)/nc;return function(n,o){let i=n.mul(o,Er),s=n.pow(i,t),h=n.mul(o,s),l=n.mul(n.mul(h,Er),s),b=n.mul(h,n.sub(l,n.ONE));if(!n.eql(n.sqr(b),o))throw new Error("Cannot find square root");return b}}return r%kl,Bl(r)}var oc=(r,t)=>(pt(r,t)&vt)===vt,_l=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ji(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=_l.reduce((n,o)=>(n[o]="function",n),t);return Ne(r,e)}function Il(r,t,e){if(e<ne)throw new Error("Expected power > 0");if(e===ne)return r.ONE;if(e===vt)return t;let n=r.ONE,o=t;for(;e>ne;)e&vt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=vt;return n}function Al(r,t){let e=new Array(t.length),n=t.reduce((i,s,h)=>r.is0(s)?i:(e[h]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return t.reduceRight((i,s,h)=>r.is0(s)?i:(e[h]=r.mul(i,e[h]),r.mul(i,s)),o),e}function Xi(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function ro(r,t,e=!1,n={}){if(r<=ne)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Xi(r,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=El(r),h=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:an(o),ZERO:ne,ONE:vt,create:l=>pt(l,r),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return ne<=l&&l<r},is0:l=>l===ne,isOdd:l=>(l&vt)===vt,neg:l=>pt(-l,r),eql:(l,b)=>l===b,sqr:l=>pt(l*l,r),add:(l,b)=>pt(l+b,r),sub:(l,b)=>pt(l-b,r),mul:(l,b)=>pt(l*b,r),pow:(l,b)=>Il(h,l,b),div:(l,b)=>pt(l*eo(b,r),r),sqrN:l=>l*l,addN:(l,b)=>l+b,subN:(l,b)=>l-b,mulN:(l,b)=>l*b,inv:l=>eo(l,r),sqrt:n.sqrt||(l=>s(h,l)),invertBatch:l=>Al(h,l),cmov:(l,b,x)=>x?b:l,toBytes:l=>e?Br(l,i):cr(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return e?ar(l):He(l)}});return Object.freeze(h)}function ic(r,t){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let e=r.sqrt(t);return r.isOdd(e)?r.neg(e):e}function sc(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Qi(r){let t=sc(r);return t+Math.ceil(t/2)}function ac(r,t,e=!1){let n=r.length,o=sc(t),i=Qi(t);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=e?He(r):ar(r),h=pt(s,t-vt)+vt;return e?Br(h,o):cr(h,o)}var Rl=BigInt(0),ts=BigInt(1);function no(r,t){let e=(o,i)=>{let s=i.negate();return o?s:i},n=o=>{let i=Math.ceil(t/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:e,unsafeLadder(o,i){let s=r.ZERO,h=o;for(;i>Rl;)i&ts&&(s=s.add(h)),h=h.double(),i>>=ts;return s},precomputeWindow(o,i){let{windows:s,windowSize:h}=n(i),l=[],b=o,x=b;for(let k=0;k<s;k++){x=b,l.push(x);for(let R=1;R<h;R++)x=x.add(b),l.push(x);b=x.double()}return l},wNAF(o,i,s){let{windows:h,windowSize:l}=n(o),b=r.ZERO,x=r.BASE,k=BigInt(2**o-1),R=2**o,I=BigInt(o);for(let P=0;P<h;P++){let B=P*l,A=Number(s&k);s>>=I,A>l&&(A-=R,s+=ts);let T=B,F=B+Math.abs(A)-1,N=P%2!==0,W=A<0;A===0?x=x.add(e(N,i[T])):b=b.add(e(W,i[F]))}return{p:b,f:x}},wNAFCached(o,i,s,h){let l=o._WINDOW_SIZE||1,b=i.get(o);return b||(b=this.precomputeWindow(o,l),l!==1&&i.set(o,h(b))),this.wNAF(l,b,s)}}}function cn(r){return Ji(r.Fp),Ne(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Xi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Me=BigInt(0),Se=BigInt(1),oo=BigInt(2),Tl=BigInt(8),Ml={zip215:!0};function Pl(r){let t=cn(r);return Ne(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function io(r){let t=Pl(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:h,h:l}=t,b=oo<<BigInt(h*8)-Se,x=e.create,k=t.uvRatio||((p,g)=>{try{return{isValid:!0,value:e.sqrt(p*e.inv(g))}}catch{return{isValid:!1,value:Me}}}),R=t.adjustScalarBytes||(p=>p),I=t.domain||((p,g,w)=>{if(g.length||w)throw new Error("Contexts/pre-hash are not supported");return p}),P=p=>typeof p=="bigint"&&Me<p,B=(p,g)=>P(p)&&P(g)&&p<g,A=p=>p===Me||B(p,b);function T(p,g){if(B(p,g))return p;throw new Error(`Expected valid scalar < ${g}, got ${typeof p} ${p}`)}function F(p){return p===Me?p:T(p,n)}let N=new Map;function W(p){if(!(p instanceof q))throw new Error("ExtendedPoint expected")}class q{constructor(g,w,y,c){if(this.ex=g,this.ey=w,this.ez=y,this.et=c,!A(g))throw new Error("x required");if(!A(w))throw new Error("y required");if(!A(y))throw new Error("z required");if(!A(c))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof q)throw new Error("extended point not allowed");let{x:w,y}=g||{};if(!A(w)||!A(y))throw new Error("invalid affine point");return new q(w,y,Se,x(w*y))}static normalizeZ(g){let w=e.invertBatch(g.map(y=>y.ez));return g.map((y,c)=>y.toAffine(w[c])).map(q.fromAffine)}_setWindowSize(g){this._WINDOW_SIZE=g,N.delete(this)}assertValidity(){let{a:g,d:w}=t;if(this.is0())throw new Error("bad point: ZERO");let{ex:y,ey:c,ez:m,et:M}=this,U=x(y*y),O=x(c*c),D=x(m*m),Y=x(D*D),J=x(U*g),mt=x(D*x(J+O)),Q=x(Y+x(w*x(U*O)));if(mt!==Q)throw new Error("bad point: equation left != right (1)");let tt=x(y*c),re=x(m*M);if(tt!==re)throw new Error("bad point: equation left != right (2)")}equals(g){W(g);let{ex:w,ey:y,ez:c}=this,{ex:m,ey:M,ez:U}=g,O=x(w*U),D=x(m*c),Y=x(y*U),J=x(M*c);return O===D&&Y===J}is0(){return this.equals(q.ZERO)}negate(){return new q(x(-this.ex),this.ey,this.ez,x(-this.et))}double(){let{a:g}=t,{ex:w,ey:y,ez:c}=this,m=x(w*w),M=x(y*y),U=x(oo*x(c*c)),O=x(g*m),D=w+y,Y=x(x(D*D)-m-M),J=O+M,mt=J-U,Q=O-M,tt=x(Y*mt),re=x(J*Q),ht=x(Y*Q),dt=x(mt*J);return new q(tt,re,dt,ht)}add(g){W(g);let{a:w,d:y}=t,{ex:c,ey:m,ez:M,et:U}=this,{ex:O,ey:D,ez:Y,et:J}=g;if(w===BigInt(-1)){let tn=x((m-c)*(D+O)),Et=x((m+c)*(D-O)),xt=x(Et-tn);if(xt===Me)return this.double();let en=x(M*oo*J),_t=x(U*oo*Y),It=_t+en,rn=Et+tn,At=_t-en,Mt=x(It*xt),Fn=x(rn*At),Pt=x(It*At),Ct=x(xt*rn);return new q(Mt,Fn,Ct,Pt)}let mt=x(c*O),Q=x(m*D),tt=x(U*y*J),re=x(M*Y),ht=x((c+m)*(O+D)-mt-Q),dt=re-tt,er=re+tt,Bt=x(Q-w*mt),Lt=x(ht*dt),qn=x(er*Bt),Rt=x(ht*Bt),Tt=x(dt*er);return new q(Lt,qn,Tt,Rt)}subtract(g){return this.add(g.negate())}wNAF(g){return j.wNAFCached(this,N,g,q.normalizeZ)}multiply(g){let{p:w,f:y}=this.wNAF(T(g,n));return q.normalizeZ([w,y])[0]}multiplyUnsafe(g){let w=F(g);return w===Me?H:this.equals(H)||w===Se?this:this.equals(z)?this.wNAF(w).p:j.unsafeLadder(this,w)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return j.unsafeLadder(this,n).is0()}toAffine(g){let{ex:w,ey:y,ez:c}=this,m=this.is0();g==null&&(g=m?Tl:e.inv(c));let M=x(w*g),U=x(y*g),O=x(c*g);if(m)return{x:Me,y:Se};if(O!==Se)throw new Error("invZ was invalid");return{x:M,y:U}}clearCofactor(){let{h:g}=t;return g===Se?this:this.multiplyUnsafe(g)}static fromHex(g,w=!1){let{d:y,a:c}=t,m=e.BYTES;g=Ot("pointHex",g,m);let M=g.slice(),U=g[m-1];M[m-1]=U&-129;let O=ar(M);O===Me||(w?T(O,b):T(O,e.ORDER));let D=x(O*O),Y=x(D-Se),J=x(y*D-c),{isValid:mt,value:Q}=k(Y,J);if(!mt)throw new Error("Point.fromHex: invalid y coordinate");let tt=(Q&Se)===Se,re=(U&128)!==0;if(!w&&Q===Me&&re)throw new Error("Point.fromHex: x=0 and x_0=1");return re!==tt&&(Q=x(-Q)),q.fromAffine({x:Q,y:O})}static fromPrivateKey(g){return G(g).point}toRawBytes(){let{x:g,y:w}=this.toAffine(),y=Br(w,e.BYTES);return y[y.length-1]|=g&Se?128:0,y}toHex(){return We(this.toRawBytes())}}q.BASE=new q(t.Gx,t.Gy,Se,x(t.Gx*t.Gy)),q.ZERO=new q(Me,Se,Se,Me);let{BASE:z,ZERO:H}=q,j=no(q,h*8);function ot(p){return pt(p,n)}function nt(p){return ot(ar(p))}function G(p){let g=h;p=Ot("private key",p,g);let w=Ot("hashed private key",i(p),2*g),y=R(w.slice(0,g)),c=w.slice(g,2*g),m=nt(y),M=z.multiply(m),U=M.toRawBytes();return{head:y,prefix:c,scalar:m,point:M,pointBytes:U}}function lt(p){return G(p).pointBytes}function v(p=new Uint8Array,...g){let w=Ve(...g);return nt(i(I(w,Ot("context",p),!!o)))}function a(p,g,w={}){p=Ot("message",p),o&&(p=o(p));let{prefix:y,scalar:c,pointBytes:m}=G(g),M=v(w.context,y,p),U=z.multiply(M).toRawBytes(),O=v(w.context,U,m,p),D=ot(M+O*c);F(D);let Y=Ve(U,Br(D,e.BYTES));return Ot("result",Y,h*2)}let u=Ml;function f(p,g,w,y=u){let{context:c,zip215:m}=y,M=e.BYTES;p=Ot("signature",p,2*M),g=Ot("message",g),o&&(g=o(g));let U=ar(p.slice(M,2*M)),O,D,Y;try{O=q.fromHex(w,m),D=q.fromHex(p.slice(0,M),m),Y=z.multiplyUnsafe(U)}catch{return!1}if(!m&&O.isSmallOrder())return!1;let J=v(c,D.toRawBytes(),O.toRawBytes(),g);return D.add(O.multiplyUnsafe(J)).subtract(Y).clearCofactor().equals(q.ZERO)}return z._setWindowSize(8),{CURVE:t,getPublicKey:lt,sign:a,verify:f,ExtendedPoint:q,utils:{getExtendedPublicKey:G,randomPrivateKey:()=>s(e.BYTES),precompute(p=8,g=q.BASE){return g._setWindowSize(p),g.multiply(BigInt(3)),g}}}}var rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),cc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),hp=BigInt(0),Cl=BigInt(1),es=BigInt(2),Ol=BigInt(5),uc=BigInt(10),Ul=BigInt(20),Nl=BigInt(40),fc=BigInt(80);function zl(r){let t=rs,n=r*r%t*r%t,o=kt(n,es,t)*n%t,i=kt(o,Cl,t)*r%t,s=kt(i,Ol,t)*i%t,h=kt(s,uc,t)*s%t,l=kt(h,Ul,t)*h%t,b=kt(l,Nl,t)*l%t,x=kt(b,fc,t)*b%t,k=kt(x,fc,t)*b%t,R=kt(k,uc,t)*s%t;return{pow_p_5_8:kt(R,es,t)*r%t,b2:n}}function ql(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Fl(r,t){let e=rs,n=pt(t*t*t,e),o=pt(n*n*t,e),i=zl(r*o).pow_p_5_8,s=pt(r*n*i,e),h=pt(t*s*s,e),l=s,b=pt(s*cc,e),x=h===r,k=h===pt(-r,e),R=h===pt(-r*cc,e);return x&&(s=l),(k||R)&&(s=b),oc(s,e)&&(s=pt(-s,e)),{isValid:x||k,value:s}}var $e=ro(rs,void 0,!0),ns={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:$e,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:$i,randomBytes:Zn,adjustScalarBytes:ql,uvRatio:Fl},_r=io(ns);function lc(r,t,e){if(t.length>255)throw new Error("Context is too big");return Yn(zi("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var dp=io({...ns,domain:lc}),pp=io({...ns,domain:lc,prehash:$i});var Dl=($e.ORDER+BigInt(3))/BigInt(8),yp=$e.pow(es,Dl),gp=$e.sqrt($e.neg($e.ONE)),mp=($e.ORDER-BigInt(5))/BigInt(8),bp=BigInt(486662);var wp=ic($e,$e.neg(BigInt(486664)));var xp=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),vp=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),kp=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Sp=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Bp=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Zs=Re(is()),ve=Re(as());var Vl=(r,t,e)=>r&t^~r&e,$l=(r,t,e)=>r&t^r&e^t&e,jl=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]),ur=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fr=new Uint32Array(64),cs=class extends Fr{constructor(){super(64,32,8,!1),this.A=ur[0]|0,this.B=ur[1]|0,this.C=ur[2]|0,this.D=ur[3]|0,this.E=ur[4]|0,this.F=ur[5]|0,this.G=ur[6]|0,this.H=ur[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:h,H:l}=this;return[t,e,n,o,i,s,h,l]}set(t,e,n,o,i,s,h,l){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=h|0,this.H=l|0}process(t,e){for(let k=0;k<16;k++,e+=4)fr[k]=t.getUint32(e,!1);for(let k=16;k<64;k++){let R=fr[k-15],I=fr[k-2],P=Te(R,7)^Te(R,18)^R>>>3,B=Te(I,17)^Te(I,19)^I>>>10;fr[k]=B+fr[k-7]+P+fr[k-16]|0}let{A:n,B:o,C:i,D:s,E:h,F:l,G:b,H:x}=this;for(let k=0;k<64;k++){let R=Te(h,6)^Te(h,11)^Te(h,25),I=x+R+Vl(h,l,b)+jl[k]+fr[k]|0,B=(Te(n,2)^Te(n,13)^Te(n,22))+$l(n,o,i)|0;x=b,b=l,l=h,h=s+I|0,s=i,i=o,o=n,n=I+B|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,h=h+this.E|0,l=l+this.F|0,b=b+this.G|0,x=x+this.H|0,this.set(n,o,i,s,h,l,b,x)}roundClean(){fr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var un=qr(()=>new cs);var Xr=Re(Ec()),S=Re(ms()),Wu=Re(ms()),zn=Re(_c());var bs=class extends TypeError{constructor(t,e){let n,{message:o,...i}=t,{path:s}=t,h=s.length===0?o:"At path: "+s.join(".")+" -- "+o;super(h),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>{var l;return(l=n)!=null?l:n=[t,...e()]}}};function ph(r){return dr(r)&&typeof r[Symbol.iterator]=="function"}function dr(r){return typeof r=="object"&&r!=null}function Pe(r){return typeof r=="string"?JSON.stringify(r):""+r}function yh(r){let{done:t,value:e}=r.next();return t?void 0:e}function gh(r,t,e,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});let{path:o,branch:i}=t,{type:s}=e,{refinement:h,message:l="Expected a value of type `"+s+"`"+(h?" with refinement `"+h+"`":"")+", but received: `"+Pe(n)+"`"}=r;return{value:n,type:s,refinement:h,key:o[o.length-1],path:o,branch:i,...r,message:l}}function*Ic(r,t,e,n){ph(r)||(r=[r]);for(let o of r){let i=gh(o,t,e,n);i&&(yield i)}}function*ws(r,t,e={}){let{path:n=[],branch:o=[r],coerce:i=!1,mask:s=!1}=e,h={path:n,branch:o};if(i&&(r=t.coercer(r,h),s&&t.type!=="type"&&dr(t.schema)&&dr(r)&&!Array.isArray(r)))for(let b in r)t.schema[b]===void 0&&delete r[b];let l=!0;for(let b of t.validator(r,h))l=!1,yield[b,void 0];for(let[b,x,k]of t.entries(r,h)){let R=ws(x,k,{path:b===void 0?n:[...n,b],branch:b===void 0?o:[...o,x],coerce:i,mask:s});for(let I of R)I[0]?(l=!1,yield[I[0],void 0]):i&&(x=I[1],b===void 0?r=x:r instanceof Map?r.set(b,x):r instanceof Set?r.add(x):dr(r)&&(r[b]=x))}if(l)for(let b of t.refiner(r,h))l=!1,yield[b,void 0];l&&(yield[void 0,r])}var _e=class{constructor(t){let{type:e,schema:n,validator:o,refiner:i,coercer:s=l=>l,entries:h=function*(){}}=t;this.type=e,this.schema=n,this.entries=h,this.coercer=s,o?this.validator=(l,b)=>{let x=o(l,b);return Ic(x,b,this,l)}:this.validator=()=>[],i?this.refiner=(l,b)=>{let x=i(l,b);return Ic(x,b,this,l)}:this.refiner=()=>[]}assert(t){return Ac(t,this)}create(t){return $r(t,this)}is(t){return Lc(t,this)}mask(t){return mh(t,this)}validate(t,e={}){return yn(t,this,e)}};function Ac(r,t){let e=yn(r,t);if(e[0])throw e[0]}function $r(r,t){let e=yn(r,t,{coerce:!0});if(e[0])throw e[0];return e[1]}function mh(r,t){let e=yn(r,t,{coerce:!0,mask:!0});if(e[0])throw e[0];return e[1]}function Lc(r,t){return!yn(r,t)[0]}function yn(r,t,e={}){let n=ws(r,t,e),o=yh(n);return o[0]?[new bs(o[0],function*(){for(let s of n)s[0]&&(yield s[0])}),void 0]:[void 0,o[1]]}function Rr(r,t){return new _e({type:r,schema:null,validator:t})}function Rc(){return Rr("any",()=>!0)}function $(r){return new _e({type:"array",schema:r,*entries(t){if(r&&Array.isArray(t))for(let[e,n]of t.entries())yield[e,n,r]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||"Expected an array value, but received: "+Pe(t)}})}function Ce(){return Rr("boolean",r=>typeof r=="boolean")}function Oo(r){return Rr("instance",t=>t instanceof r||"Expected a `"+r.name+"` instance, but received: "+Pe(t))}function St(r){let t=Pe(r),e=typeof r;return new _e({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?r:null,validator(n){return n===r||"Expected the literal `"+t+"`, but received: "+Pe(n)}})}function bh(){return Rr("never",()=>!1)}function V(r){return new _e({...r,validator:(t,e)=>t===null||r.validator(t,e),refiner:(t,e)=>t===null||r.refiner(t,e)})}function E(){return Rr("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+Pe(r))}function Z(r){return new _e({...r,validator:(t,e)=>t===void 0||r.validator(t,e),refiner:(t,e)=>t===void 0||r.refiner(t,e)})}function xs(r,t){return new _e({type:"record",schema:null,*entries(e){if(dr(e))for(let n in e){let o=e[n];yield[n,n,r],yield[n,o,t]}},validator(e){return dr(e)||"Expected an object, but received: "+Pe(e)}})}function K(){return Rr("string",r=>typeof r=="string"||"Expected a string, but received: "+Pe(r))}function Uo(r){let t=bh();return new _e({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){let n=Math.max(r.length,e.length);for(let o=0;o<n;o++)yield[o,e[o],r[o]||t]}},validator(e){return Array.isArray(e)||"Expected an array, but received: "+Pe(e)}})}function C(r){let t=Object.keys(r);return new _e({type:"type",schema:r,*entries(e){if(dr(e))for(let n of t)yield[n,e[n],r[n]]},validator(e){return dr(e)||"Expected an object, but received: "+Pe(e)}})}function me(r){let t=r.map(e=>e.type).join(" | ");return new _e({type:"union",schema:null,validator(e,n){let o=[];for(let i of r){let[...s]=ws(e,i,n),[h]=s;if(h[0])for(let[l]of s)l&&o.push(l);else return[]}return["Expected the value to satisfy a union of `"+t+"`, but received: "+Pe(e),...o]}})}function jr(){return Rr("unknown",()=>!0)}function Gr(r,t,e){return new _e({...r,coercer:(n,o)=>Lc(n,t)?r.coercer(e(n,o),o):r.coercer(n,o)})}var Fd=Re(tu()),Dd=Re(gu()),Kd=Re(bu());var[vu,ku,Su]=[[],[],[]],Bd=BigInt(0),Tn=BigInt(1),Ed=BigInt(2),_d=BigInt(7),Id=BigInt(256),Ad=BigInt(113);for(let r=0,t=Tn,e=1,n=0;r<24;r++){[e,n]=[n,(2*e+3*n)%5],vu.push(2*(5*n+e)),ku.push((r+1)*(r+2)/2%64);let o=Bd;for(let i=0;i<7;i++)t=(t<<Tn^(t>>_d)*Ad)%Id,t&Ed&&(o^=Tn<<(Tn<<BigInt(i))-Tn);Su.push(o)}var[Ld,Rd]=Fi(Su,!0),wu=(r,t,e)=>e>32?Wi(r,t,e):Di(r,t,e),xu=(r,t,e)=>e>32?Hi(r,t,e):Ki(r,t,e);function Td(r,t=24){let e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let s=0;s<10;s++)e[s]=r[s]^r[s+10]^r[s+20]^r[s+30]^r[s+40];for(let s=0;s<10;s+=2){let h=(s+8)%10,l=(s+2)%10,b=e[l],x=e[l+1],k=wu(b,x,1)^e[h],R=xu(b,x,1)^e[h+1];for(let I=0;I<50;I+=10)r[s+I]^=k,r[s+I+1]^=R}let o=r[2],i=r[3];for(let s=0;s<24;s++){let h=ku[s],l=wu(o,i,h),b=xu(o,i,h),x=vu[s];o=r[x],i=r[x+1],r[x]=l,r[x+1]=b}for(let s=0;s<50;s+=10){for(let h=0;h<10;h++)e[h]=r[s+h];for(let h=0;h<10;h++)r[s+h]^=~e[(h+2)%10]&e[(h+4)%10]}r[0]^=Ld[n],r[1]^=Rd[n]}e.fill(0)}var $o=class r extends nr{constructor(t,e,n,o=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=o,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,on(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Za(this.state)}keccak(){Td(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Ke(this);let{blockLen:e,state:n}=this;t=or(t);let o=t.length;for(let i=0;i<o;){let s=Math.min(e-this.pos,o-i);for(let h=0;h<s;h++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:e,pos:n,blockLen:o}=this;t[n]^=e,(e&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){Ke(this,!1),sn(t),this.finish();let e=this.state,{blockLen:n}=this;for(let o=0,i=t.length;o<i;){this.posOut>=n&&this.keccak();let s=Math.min(n-this.posOut,i-o);t.set(e.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return on(t),this.xofInto(new Uint8Array(t))}digestInto(t){if($n(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:e,suffix:n,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new r(e,n,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}},wr=(r,t,e)=>qr(()=>new $o(t,r,e)),Wy=wr(6,144,224/8),Hy=wr(6,136,256/8),Vy=wr(6,104,384/8),$y=wr(6,72,512/8),jy=wr(1,144,224/8),Ks=wr(1,136,256/8),Gy=wr(1,104,384/8),Yy=wr(1,72,512/8),Bu=(r,t,e)=>Ja((n={})=>new $o(t,r,n.dkLen===void 0?e:n.dkLen,!0)),Zy=Bu(31,168,128/8),Jy=Bu(31,136,256/8);function Md(r){let t=cn(r);Ne(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Pd,hexToBytes:Cd}=to,Tr={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Tr;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Pd(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Tr,e=typeof r=="string"?Cd(r):r;if(!(e instanceof Uint8Array))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:o,l:i}=Tr._parseInt(e.subarray(2)),{d:s,l:h}=Tr._parseInt(i);if(h.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(r){let t=b=>Number.parseInt(b[0],16)&8?"00"+b:b,e=b=>{let x=b.toString(16);return x.length&1?`0${x}`:x},n=t(e(r.s)),o=t(e(r.r)),i=n.length/2,s=o.length/2,h=e(i),l=e(s);return`30${e(s+i+4)}02${l}${o}02${h}${n}`}},Qe=BigInt(0),Ie=BigInt(1),rg=BigInt(2),Eu=BigInt(3),ng=BigInt(4);function Od(r){let t=Md(r),{Fp:e}=t,n=t.toBytes||((P,B,A)=>{let T=B.toAffine();return Ve(Uint8Array.from([4]),e.toBytes(T.x),e.toBytes(T.y))}),o=t.fromBytes||(P=>{let B=P.subarray(1),A=e.fromBytes(B.subarray(0,e.BYTES)),T=e.fromBytes(B.subarray(e.BYTES,2*e.BYTES));return{x:A,y:T}});function i(P){let{a:B,b:A}=t,T=e.sqr(P),F=e.mul(T,P);return e.add(e.add(F,e.mul(P,B)),A)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(P){return typeof P=="bigint"&&Qe<P&&P<t.n}function h(P){if(!s(P))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(P){let{allowedPrivateKeyLengths:B,nByteLength:A,wrapPrivateKey:T,n:F}=t;if(B&&typeof P!="bigint"){if(P instanceof Uint8Array&&(P=We(P)),typeof P!="string"||!B.includes(P.length))throw new Error("Invalid key");P=P.padStart(A*2,"0")}let N;try{N=typeof P=="bigint"?P:He(Ot("private key",P,A))}catch{throw new Error(`private key must be ${A} bytes, hex or bigint, not ${typeof P}`)}return T&&(N=pt(N,F)),h(N),N}let b=new Map;function x(P){if(!(P instanceof k))throw new Error("ProjectivePoint expected")}class k{constructor(B,A,T){if(this.px=B,this.py=A,this.pz=T,B==null||!e.isValid(B))throw new Error("x required");if(A==null||!e.isValid(A))throw new Error("y required");if(T==null||!e.isValid(T))throw new Error("z required")}static fromAffine(B){let{x:A,y:T}=B||{};if(!B||!e.isValid(A)||!e.isValid(T))throw new Error("invalid affine point");if(B instanceof k)throw new Error("projective point not allowed");let F=N=>e.eql(N,e.ZERO);return F(A)&&F(T)?k.ZERO:new k(A,T,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(B){let A=e.invertBatch(B.map(T=>T.pz));return B.map((T,F)=>T.toAffine(A[F])).map(k.fromAffine)}static fromHex(B){let A=k.fromAffine(o(Ot("pointHex",B)));return A.assertValidity(),A}static fromPrivateKey(B){return k.BASE.multiply(l(B))}_setWindowSize(B){this._WINDOW_SIZE=B,b.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:B,y:A}=this.toAffine();if(!e.isValid(B)||!e.isValid(A))throw new Error("bad point: x or y not FE");let T=e.sqr(A),F=i(B);if(!e.eql(T,F))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:B}=this.toAffine();if(e.isOdd)return!e.isOdd(B);throw new Error("Field doesn't support isOdd")}equals(B){x(B);let{px:A,py:T,pz:F}=this,{px:N,py:W,pz:q}=B,z=e.eql(e.mul(A,q),e.mul(N,F)),H=e.eql(e.mul(T,q),e.mul(W,F));return z&&H}negate(){return new k(this.px,e.neg(this.py),this.pz)}double(){let{a:B,b:A}=t,T=e.mul(A,Eu),{px:F,py:N,pz:W}=this,q=e.ZERO,z=e.ZERO,H=e.ZERO,j=e.mul(F,F),ot=e.mul(N,N),nt=e.mul(W,W),G=e.mul(F,N);return G=e.add(G,G),H=e.mul(F,W),H=e.add(H,H),q=e.mul(B,H),z=e.mul(T,nt),z=e.add(q,z),q=e.sub(ot,z),z=e.add(ot,z),z=e.mul(q,z),q=e.mul(G,q),H=e.mul(T,H),nt=e.mul(B,nt),G=e.sub(j,nt),G=e.mul(B,G),G=e.add(G,H),H=e.add(j,j),j=e.add(H,j),j=e.add(j,nt),j=e.mul(j,G),z=e.add(z,j),nt=e.mul(N,W),nt=e.add(nt,nt),j=e.mul(nt,G),q=e.sub(q,j),H=e.mul(nt,ot),H=e.add(H,H),H=e.add(H,H),new k(q,z,H)}add(B){x(B);let{px:A,py:T,pz:F}=this,{px:N,py:W,pz:q}=B,z=e.ZERO,H=e.ZERO,j=e.ZERO,ot=t.a,nt=e.mul(t.b,Eu),G=e.mul(A,N),lt=e.mul(T,W),v=e.mul(F,q),a=e.add(A,T),u=e.add(N,W);a=e.mul(a,u),u=e.add(G,lt),a=e.sub(a,u),u=e.add(A,F);let f=e.add(N,q);return u=e.mul(u,f),f=e.add(G,v),u=e.sub(u,f),f=e.add(T,F),z=e.add(W,q),f=e.mul(f,z),z=e.add(lt,v),f=e.sub(f,z),j=e.mul(ot,u),z=e.mul(nt,v),j=e.add(z,j),z=e.sub(lt,j),j=e.add(lt,j),H=e.mul(z,j),lt=e.add(G,G),lt=e.add(lt,G),v=e.mul(ot,v),u=e.mul(nt,u),lt=e.add(lt,v),v=e.sub(G,v),v=e.mul(ot,v),u=e.add(u,v),G=e.mul(lt,u),H=e.add(H,G),G=e.mul(f,u),z=e.mul(a,z),z=e.sub(z,G),G=e.mul(a,lt),j=e.mul(f,j),j=e.add(j,G),new k(z,H,j)}subtract(B){return this.add(B.negate())}is0(){return this.equals(k.ZERO)}wNAF(B){return I.wNAFCached(this,b,B,A=>{let T=e.invertBatch(A.map(F=>F.pz));return A.map((F,N)=>F.toAffine(T[N])).map(k.fromAffine)})}multiplyUnsafe(B){let A=k.ZERO;if(B===Qe)return A;if(h(B),B===Ie)return this;let{endo:T}=t;if(!T)return I.unsafeLadder(this,B);let{k1neg:F,k1:N,k2neg:W,k2:q}=T.splitScalar(B),z=A,H=A,j=this;for(;N>Qe||q>Qe;)N&Ie&&(z=z.add(j)),q&Ie&&(H=H.add(j)),j=j.double(),N>>=Ie,q>>=Ie;return F&&(z=z.negate()),W&&(H=H.negate()),H=new k(e.mul(H.px,T.beta),H.py,H.pz),z.add(H)}multiply(B){h(B);let A=B,T,F,{endo:N}=t;if(N){let{k1neg:W,k1:q,k2neg:z,k2:H}=N.splitScalar(A),{p:j,f:ot}=this.wNAF(q),{p:nt,f:G}=this.wNAF(H);j=I.constTimeNegate(W,j),nt=I.constTimeNegate(z,nt),nt=new k(e.mul(nt.px,N.beta),nt.py,nt.pz),T=j.add(nt),F=ot.add(G)}else{let{p:W,f:q}=this.wNAF(A);T=W,F=q}return k.normalizeZ([T,F])[0]}multiplyAndAddUnsafe(B,A,T){let F=k.BASE,N=(q,z)=>z===Qe||z===Ie||!q.equals(F)?q.multiplyUnsafe(z):q.multiply(z),W=N(this,A).add(N(B,T));return W.is0()?void 0:W}toAffine(B){let{px:A,py:T,pz:F}=this,N=this.is0();B==null&&(B=N?e.ONE:e.inv(F));let W=e.mul(A,B),q=e.mul(T,B),z=e.mul(F,B);if(N)return{x:e.ZERO,y:e.ZERO};if(!e.eql(z,e.ONE))throw new Error("invZ was invalid");return{x:W,y:q}}isTorsionFree(){let{h:B,isTorsionFree:A}=t;if(B===Ie)return!0;if(A)return A(k,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:B,clearCofactor:A}=t;return B===Ie?this:A?A(k,this):this.multiplyUnsafe(t.h)}toRawBytes(B=!0){return this.assertValidity(),n(k,this,B)}toHex(B=!0){return We(this.toRawBytes(B))}}k.BASE=new k(t.Gx,t.Gy,e.ONE),k.ZERO=new k(e.ZERO,e.ONE,e.ZERO);let R=t.nBitLength,I=no(k,t.endo?Math.ceil(R/2):R);return{CURVE:t,ProjectivePoint:k,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:s}}function Ud(r){let t=cn(r);return Ne(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function _u(r){let t=Ud(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(u){return Qe<u&&u<e.ORDER}function h(u){return pt(u,n)}function l(u){return eo(u,n)}let{ProjectivePoint:b,normPrivateKeyToScalar:x,weierstrassEquation:k,isWithinCurveOrder:R}=Od({...t,toBytes(u,f,d){let p=f.toAffine(),g=e.toBytes(p.x),w=Ve;return d?w(Uint8Array.from([f.hasEvenY()?2:3]),g):w(Uint8Array.from([4]),g,e.toBytes(p.y))},fromBytes(u){let f=u.length,d=u[0],p=u.subarray(1);if(f===o&&(d===2||d===3)){let g=He(p);if(!s(g))throw new Error("Point is not on curve");let w=k(g),y=e.sqrt(w),c=(y&Ie)===Ie;return(d&1)===1!==c&&(y=e.neg(y)),{x:g,y}}else if(f===i&&d===4){let g=e.fromBytes(p.subarray(0,e.BYTES)),w=e.fromBytes(p.subarray(e.BYTES,2*e.BYTES));return{x:g,y:w}}else throw new Error(`Point of length ${f} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),I=u=>We(cr(u,t.nByteLength));function P(u){let f=n>>Ie;return u>f}function B(u){return P(u)?h(-u):u}let A=(u,f,d)=>He(u.slice(f,d));class T{constructor(f,d,p){this.r=f,this.s=d,this.recovery=p,this.assertValidity()}static fromCompact(f){let d=t.nByteLength;return f=Ot("compactSignature",f,d*2),new T(A(f,0,d),A(f,d,2*d))}static fromDER(f){let{r:d,s:p}=Tr.toSig(Ot("DER",f));return new T(d,p)}assertValidity(){if(!R(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!R(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(f){return new T(this.r,this.s,f)}recoverPublicKey(f){let{r:d,s:p,recovery:g}=this,w=H(Ot("msgHash",f));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let y=g===2||g===3?d+t.n:d;if(y>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let c=(g&1)===0?"02":"03",m=b.fromHex(c+I(y)),M=l(y),U=h(-w*M),O=h(p*M),D=b.BASE.multiplyAndAddUnsafe(m,U,O);if(!D)throw new Error("point at infinify");return D.assertValidity(),D}hasHighS(){return P(this.s)}normalizeS(){return this.hasHighS()?new T(this.r,h(-this.s),this.recovery):this}toDERRawBytes(){return Sr(this.toDERHex())}toDERHex(){return Tr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Sr(this.toCompactHex())}toCompactHex(){return I(this.r)+I(this.s)}}let F={isValidPrivateKey(u){try{return x(u),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{let u=Qi(t.n);return ac(t.randomBytes(u),t.n)},precompute(u=8,f=b.BASE){return f._setWindowSize(u),f.multiply(BigInt(3)),f}};function N(u,f=!0){return b.fromPrivateKey(u).toRawBytes(f)}function W(u){let f=u instanceof Uint8Array,d=typeof u=="string",p=(f||d)&&u.length;return f?p===o||p===i:d?p===2*o||p===2*i:u instanceof b}function q(u,f,d=!0){if(W(u))throw new Error("first arg must be private key");if(!W(f))throw new Error("second arg must be public key");return b.fromHex(f).multiply(x(u)).toRawBytes(d)}let z=t.bits2int||function(u){let f=He(u),d=u.length*8-t.nBitLength;return d>0?f>>BigInt(d):f},H=t.bits2int_modN||function(u){return h(z(u))},j=an(t.nBitLength);function ot(u){if(typeof u!="bigint")throw new Error("bigint expected");if(!(Qe<=u&&u<j))throw new Error(`bigint expected < 2^${t.nBitLength}`);return cr(u,t.nByteLength)}function nt(u,f,d=G){if(["recovered","canonical"].some(J=>J in d))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:g}=t,{lowS:w,prehash:y,extraEntropy:c}=d;w==null&&(w=!0),u=Ot("msgHash",u),y&&(u=Ot("prehashed msgHash",p(u)));let m=H(u),M=x(f),U=[ot(M),ot(m)];if(c!=null){let J=c===!0?g(e.BYTES):c;U.push(Ot("extraEntropy",J))}let O=Ve(...U),D=m;function Y(J){let mt=z(J);if(!R(mt))return;let Q=l(mt),tt=b.BASE.multiply(mt).toAffine(),re=h(tt.x);if(re===Qe)return;let ht=h(Q*h(D+re*M));if(ht===Qe)return;let dt=(tt.x===re?0:2)|Number(tt.y&Ie),er=ht;return w&&P(ht)&&(er=B(ht),dt^=1),new T(re,er,dt)}return{seed:O,k2sig:Y}}let G={lowS:t.lowS,prehash:!1},lt={lowS:t.lowS,prehash:!1};function v(u,f,d=G){let{seed:p,k2sig:g}=nt(u,f,d),w=t;return Yi(w.hash.outputLen,w.nByteLength,w.hmac)(p,g)}b.BASE._setWindowSize(8);function a(u,f,d,p=lt){let g=u;if(f=Ot("msgHash",f),d=Ot("publicKey",d),"strict"in p)throw new Error("options.strict was renamed to lowS");let{lowS:w,prehash:y}=p,c,m;try{if(typeof g=="string"||g instanceof Uint8Array)try{c=T.fromDER(g)}catch(tt){if(!(tt instanceof Tr.Err))throw tt;c=T.fromCompact(g)}else if(typeof g=="object"&&typeof g.r=="bigint"&&typeof g.s=="bigint"){let{r:tt,s:re}=g;c=new T(tt,re)}else throw new Error("PARSE");m=b.fromHex(d)}catch(tt){if(tt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(w&&c.hasHighS())return!1;y&&(f=t.hash(f));let{r:M,s:U}=c,O=H(f),D=l(U),Y=h(O*D),J=h(M*D),mt=b.BASE.multiplyAndAddUnsafe(m,Y,J)?.toAffine();return mt?h(mt.x)===M:!1}return{CURVE:t,getPublicKey:N,getSharedSecret:q,sign:v,verify:a,ProjectivePoint:b,Signature:T,utils:F}}var jo=class extends nr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Ga(t);let n=or(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return Ke(this),this.iHash.update(t),this}digestInto(t){Ke(this),sn(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:h}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=h,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ws=(r,t,e)=>new jo(r,t).update(e).digest();Ws.create=(r,t)=>new jo(r,t);function Nd(r){return{hash:r,hmac:(t,...e)=>Ws(r,t,Yn(...e)),randomBytes:Zn}}function Iu(r,t){let e=n=>_u({...r,...Nd(n)});return Object.freeze({...e(t),create:e})}var Ru=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Au=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),zd=BigInt(1),Hs=BigInt(2),Lu=(r,t)=>(r+t/Hs)/t;function qd(r){let t=Ru,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),h=BigInt(44),l=BigInt(88),b=r*r*r%t,x=b*b*r%t,k=kt(x,e,t)*x%t,R=kt(k,e,t)*x%t,I=kt(R,Hs,t)*b%t,P=kt(I,o,t)*I%t,B=kt(P,i,t)*P%t,A=kt(B,h,t)*B%t,T=kt(A,l,t)*A%t,F=kt(T,h,t)*B%t,N=kt(F,e,t)*x%t,W=kt(N,s,t)*P%t,q=kt(W,n,t)*b%t,z=kt(q,Hs,t);if(!Vs.eql(Vs.sqr(z),r))throw new Error("Cannot find square root");return z}var Vs=ro(Ru,void 0,void 0,{sqrt:qd}),Mn=Iu({a:BigInt(0),b:BigInt(7),Fp:Vs,n:Au,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Au,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-zd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),h=Lu(i*r,t),l=Lu(-n*r,t),b=pt(r-h*e-l*o,t),x=pt(-h*n-l*i,t),k=b>s,R=x>s;if(k&&(b=t-b),R&&(x=t-x),b>s||x>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:k,k1:b,k2neg:R,k2:x}}}},un),yg=BigInt(0);var gg=Mn.ProjectivePoint;var Sg=_r.utils.randomPrivateKey,Tu=()=>{let r=_r.utils.randomPrivateKey(),t=Js(r),e=new Uint8Array(64);return e.set(r),e.set(t,32),{publicKey:t,secretKey:e}},Js=_r.getPublicKey;function Mu(r){try{return _r.ExtendedPoint.fromHex(r),!0}catch{return!1}}var Hu=(r,t)=>_r.sign(r,t.slice(0,32)),Wd=_r.verify,ut=r=>X.Buffer.isBuffer(r)?r:r instanceof Uint8Array?X.Buffer.from(r.buffer,r.byteOffset,r.byteLength):X.Buffer.from(r),Xs=class{constructor(t){Object.assign(this,t)}encode(){return X.Buffer.from((0,Xr.serialize)(Zo,this))}static decode(t){return(0,Xr.deserialize)(Zo,this,t)}static decodeUnchecked(t){return(0,Xr.deserializeUnchecked)(Zo,this,t)}};var Zo=new Map,Vu,$u,Hd=32,Mr=32;function Vd(r){return r._bn!==void 0}var Pu=1;$u=Symbol.toStringTag;var rt=class r extends Xs{constructor(t){if(super({}),this._bn=void 0,Vd(t))this._bn=t._bn;else{if(typeof t=="string"){let e=ve.default.decode(t);if(e.length!=Mr)throw new Error("Invalid public key input");this._bn=new Zs.default(e)}else this._bn=new Zs.default(t);if(this._bn.byteLength()>Mr)throw new Error("Invalid public key input")}}static unique(){let t=new r(Pu);return Pu+=1,new r(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ve.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){let t=this._bn.toArrayLike(X.Buffer);if(t.length===Mr)return t;let e=X.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[$u](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,n){let o=X.Buffer.concat([t.toBuffer(),X.Buffer.from(e),n.toBuffer()]),i=un(o);return new r(i)}static createProgramAddressSync(t,e){let n=X.Buffer.alloc(0);t.forEach(function(i){if(i.length>Hd)throw new TypeError("Max seed length exceeded");n=X.Buffer.concat([n,ut(i)])}),n=X.Buffer.concat([n,e.toBuffer(),X.Buffer.from("ProgramDerivedAddress")]);let o=un(n);if(Mu(o))throw new Error("Invalid seeds, address must fall off the curve");return new r(o)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n=255,o;for(;n!=0;){try{let i=t.concat(X.Buffer.from([n]));o=this.createProgramAddressSync(i,e)}catch(i){if(i instanceof TypeError)throw i;n--;continue}return[o,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){let e=new r(t);return Mu(e.toBytes())}};Vu=rt;rt.default=new Vu("11111111111111111111111111111111");Zo.set(rt,{kind:"struct",fields:[["_bn","u256"]]});var Bg=new rt("BPFLoader1111111111111111111111111111111111"),Jo=1232,$d=127,Qs=64,ta=class extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}};Object.defineProperty(ta.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});var ea=class extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}};Object.defineProperty(ea.prototype,"name",{value:"TransactionExpiredTimeoutError"});var ra=class extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}};Object.defineProperty(ra.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});var Xo=class{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){let t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(let e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");let n=new Map;this.keySegments().flat().forEach((i,s)=>{n.set(i.toBase58(),s)});let o=i=>{let s=n.get(i.toBase58());if(s===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return s};return t.map(i=>({programIdIndex:o(i.programId),accountKeyIndexes:i.keys.map(s=>o(s.pubkey)),data:i.data}))}},st=(r="publicKey")=>S.blob(32,r);var Zr=(r="string")=>{let t=S.struct([S.u32("length"),S.u32("lengthPadding"),S.blob(S.offset(S.u32(),-8),"chars")],r),e=t.decode.bind(t),n=t.encode.bind(t),o=t;return o.decode=(i,s)=>e(i,s).chars.toString(),o.encode=(i,s,h)=>{let l={chars:X.Buffer.from(i,"utf8")};return n(l,s,h)},o.alloc=i=>S.u32().span+S.u32().span+X.Buffer.from(i,"utf8").length,o},jd=(r="authorized")=>S.struct([st("staker"),st("withdrawer")],r),Gd=(r="lockup")=>S.struct([S.ns64("unixTimestamp"),S.ns64("epoch"),st("custodian")],r),Yd=(r="voteInit")=>S.struct([st("nodePubkey"),st("authorizedVoter"),st("authorizedWithdrawer"),S.u8("commission")],r),Zd=(r="voteAuthorizeWithSeedArgs")=>S.struct([S.u32("voteAuthorizationType"),st("currentAuthorityDerivedKeyOwnerPubkey"),Zr("currentAuthorityDerivedKeySeed"),st("newAuthorized")],r);function ju(r,t){let e=o=>{if(o.span>=0)return o.span;if(typeof o.alloc=="function")return o.alloc(t[o.property]);if("count"in o&&"elementLayout"in o){let i=t[o.property];if(Array.isArray(i))return i.length*e(o.elementLayout)}else if("fields"in o)return ju({layout:o},t[o.property]);return 0},n=0;return r.layout.fields.forEach(o=>{n+=e(o)}),n}function Cn(r){let t=0,e=0;for(;;){let n=r.shift();if(t|=(n&127)<<e*7,e+=1,(n&128)===0)break}return t}function On(r,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){r.push(n);break}else n|=128,r.push(n)}}function oe(r,t){if(!r)throw new Error(t||"Assertion failed")}var na=class r{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){let n=new Map,o=s=>{let h=s.toBase58(),l=n.get(h);return l===void 0&&(l={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(h,l)),l},i=o(e);i.isSigner=!0,i.isWritable=!0;for(let s of t){o(s.programId).isInvoked=!0;for(let h of s.keys){let l=o(h.pubkey);l.isSigner||=h.isSigner,l.isWritable||=h.isWritable}}return new r(e,n)}getMessageComponents(){let t=[...this.keyMetaMap.entries()];oe(t.length<=256,"Max static account keys length exceeded");let e=t.filter(([,l])=>l.isSigner&&l.isWritable),n=t.filter(([,l])=>l.isSigner&&!l.isWritable),o=t.filter(([,l])=>!l.isSigner&&l.isWritable),i=t.filter(([,l])=>!l.isSigner&&!l.isWritable),s={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{oe(e.length>0,"Expected at least one writable signer key");let[l]=e[0];oe(l===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let h=[...e.map(([l])=>new rt(l)),...n.map(([l])=>new rt(l)),...o.map(([l])=>new rt(l)),...i.map(([l])=>new rt(l))];return[s,h]}extractTableLookup(t){let[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,s=>!s.isSigner&&!s.isInvoked&&s.isWritable),[o,i]=this.drainKeysFoundInLookupTable(t.state.addresses,s=>!s.isSigner&&!s.isInvoked&&!s.isWritable);if(!(e.length===0&&o.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:o},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(t,e){let n=new Array,o=new Array;for(let[i,s]of this.keyMetaMap.entries())if(e(s)){let h=new rt(i),l=t.findIndex(b=>b.equals(h));l>=0&&(oe(l<256,"Max lookup table index exceeded"),n.push(l),o.push(h),this.keyMetaMap.delete(i))}return[n,o]}},Qo=class r{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new rt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:ve.default.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Xo(this.staticAccountKeys)}static compile(t){let e=na.compile(t.instructions,t.payerKey),[n,o]=e.getMessageComponents(),s=new Xo(o).compileInstructions(t.instructions).map(h=>({programIdIndex:h.programIdIndex,accounts:h.accountKeyIndexes,data:ve.default.encode(h.data)}));return new r({header:n,accountKeys:o,recentBlockhash:t.recentBlockhash,instructions:s})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){let e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){let n=t-e,i=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<i}else{let n=e-this.header.numReadonlySignedAccounts;return t<n}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){let t=this.accountKeys.length,e=[];On(e,t);let n=this.instructions.map(k=>{let{accounts:R,programIdIndex:I}=k,P=Array.from(ve.default.decode(k.data)),B=[];On(B,R.length);let A=[];return On(A,P.length),{programIdIndex:I,keyIndicesCount:X.Buffer.from(B),keyIndices:R,dataLength:X.Buffer.from(A),data:P}}),o=[];On(o,n.length);let i=X.Buffer.alloc(Jo);X.Buffer.from(o).copy(i);let s=o.length;n.forEach(k=>{let I=S.struct([S.u8("programIdIndex"),S.blob(k.keyIndicesCount.length,"keyIndicesCount"),S.seq(S.u8("keyIndex"),k.keyIndices.length,"keyIndices"),S.blob(k.dataLength.length,"dataLength"),S.seq(S.u8("userdatum"),k.data.length,"data")]).encode(k,i,s);s+=I}),i=i.slice(0,s);let h=S.struct([S.blob(1,"numRequiredSignatures"),S.blob(1,"numReadonlySignedAccounts"),S.blob(1,"numReadonlyUnsignedAccounts"),S.blob(e.length,"keyCount"),S.seq(st("key"),t,"keys"),st("recentBlockhash")]),l={numRequiredSignatures:X.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:X.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:X.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:X.Buffer.from(e),keys:this.accountKeys.map(k=>ut(k.toBytes())),recentBlockhash:ve.default.decode(this.recentBlockhash)},b=X.Buffer.alloc(2048),x=h.encode(l,b);return i.copy(b,x),b.slice(0,x+i.length)}static from(t){let e=[...t],n=e.shift();if(n!==(n&$d))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let o=e.shift(),i=e.shift(),s=Cn(e),h=[];for(let R=0;R<s;R++){let I=e.slice(0,Mr);e=e.slice(Mr),h.push(new rt(X.Buffer.from(I)))}let l=e.slice(0,Mr);e=e.slice(Mr);let b=Cn(e),x=[];for(let R=0;R<b;R++){let I=e.shift(),P=Cn(e),B=e.slice(0,P);e=e.slice(P);let A=Cn(e),T=e.slice(0,A),F=ve.default.encode(X.Buffer.from(T));e=e.slice(A),x.push({programIdIndex:I,accounts:B,data:F})}let k={header:{numRequiredSignatures:n,numReadonlySignedAccounts:o,numReadonlyUnsignedAccounts:i},recentBlockhash:ve.default.encode(X.Buffer.from(l)),accountKeys:h,instructions:x};return new r(k)}};var Jd=X.Buffer.alloc(Qs).fill(0),gt=class{constructor(t){this.keys=void 0,this.programId=void 0,this.data=X.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},bt=class r{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){let{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){let{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{let{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new gt(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let B=0;B<e.length;B++)if(e[B].programId===void 0)throw new Error(`Transaction instruction index ${B} has undefined program id`);let o=[],i=[];e.forEach(B=>{B.keys.forEach(T=>{i.push({...T})});let A=B.programId.toString();o.includes(A)||o.push(A)}),o.forEach(B=>{i.push({pubkey:new rt(B),isSigner:!1,isWritable:!1})});let s=[];i.forEach(B=>{let A=B.pubkey.toString(),T=s.findIndex(F=>F.pubkey.toString()===A);T>-1?(s[T].isWritable=s[T].isWritable||B.isWritable,s[T].isSigner=s[T].isSigner||B.isSigner):s.push(B)}),s.sort(function(B,A){if(B.isSigner!==A.isSigner)return B.isSigner?-1:1;if(B.isWritable!==A.isWritable)return B.isWritable?-1:1;let T={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return B.pubkey.toBase58().localeCompare(A.pubkey.toBase58(),"en",T)});let h=s.findIndex(B=>B.pubkey.equals(n));if(h>-1){let[B]=s.splice(h,1);B.isSigner=!0,B.isWritable=!0,s.unshift(B)}else s.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let B of this.signatures){let A=s.findIndex(T=>T.pubkey.equals(B.publicKey));if(A>-1)s[A].isSigner||(s[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: ${B.publicKey.toString()}`)}let l=0,b=0,x=0,k=[],R=[];s.forEach(({pubkey:B,isSigner:A,isWritable:T})=>{A?(k.push(B.toString()),l+=1,T||(b+=1)):(R.push(B.toString()),T||(x+=1))});let I=k.concat(R),P=e.map(B=>{let{data:A,programId:T}=B;return{programIdIndex:I.indexOf(T.toString()),accounts:B.keys.map(F=>I.indexOf(F.pubkey.toString())),data:ve.default.encode(A)}});return P.forEach(B=>{oe(B.programIdIndex>=0),B.accounts.forEach(A=>oe(A>=0))}),new Qo({header:{numRequiredSignatures:l,numReadonlySignedAccounts:b,numReadonlyUnsignedAccounts:x},accountKeys:I,recentBlockhash:t,instructions:P})}_compile(){let t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((o,i)=>e[i].equals(o.publicKey))||(this.signatures=e.map(n=>({signature:null,publicKey:n}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");let e=new Set;this.signatures=t.filter(n=>{let o=n.toString();return e.has(o)?!1:(e.add(o),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...t){if(t.length===0)throw new Error("No signers");let e=new Set,n=[];for(let i of t){let s=i.publicKey.toString();e.has(s)||(e.add(s),n.push(i))}this.signatures=n.map(i=>({signature:null,publicKey:i.publicKey}));let o=this._compile();this._partialSign(o,...n)}partialSign(...t){if(t.length===0)throw new Error("No signers");let e=new Set,n=[];for(let i of t){let s=i.publicKey.toString();e.has(s)||(e.add(s),n.push(i))}let o=this._compile();this._partialSign(o,...n)}_partialSign(t,...e){let n=t.serialize();e.forEach(o=>{let i=Hu(n,o.secretKey);this._addSignature(o.publicKey,ut(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){oe(e.length===64);let n=this.signatures.findIndex(o=>t.equals(o.publicKey));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=X.Buffer.from(e)}verifySignatures(t){return this._verifySignatures(this.serializeMessage(),t===void 0?!0:t)}_verifySignatures(t,e){for(let{signature:n,publicKey:o}of this.signatures)if(n===null){if(e)return!1}else if(!Wd(n,t,o.toBytes()))return!1;return!0}serialize(t){let{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),o=this.serializeMessage();if(n&&!this._verifySignatures(o,e))throw new Error("Signature verification failed");return this._serialize(o)}_serialize(t){let{signatures:e}=this,n=[];On(n,e.length);let o=n.length+e.length*64+t.length,i=X.Buffer.alloc(o);return oe(e.length<256),X.Buffer.from(n).copy(i,0),e.forEach(({signature:s},h)=>{s!==null&&(oe(s.length===64,"signature has invalid length"),X.Buffer.from(s).copy(i,n.length+h*64))}),t.copy(i,n.length+e.length*64),oe(i.length<=Jo,`Transaction too large: ${i.length} > ${Jo}`),i}get keys(){return oe(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return oe(this.instructions.length===1),this.instructions[0].programId}get data(){return oe(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t],n=Cn(e),o=[];for(let i=0;i<n;i++){let s=e.slice(0,Qs);e=e.slice(Qs),o.push(ve.default.encode(X.Buffer.from(s)))}return r.populate(Qo.from(e),o)}static populate(t,e=[]){let n=new r;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((o,i)=>{let s={signature:o==ve.default.encode(Jd)?null:ve.default.decode(o),publicKey:t.accountKeys[i]};n.signatures.push(s)}),t.instructions.forEach(o=>{let i=o.accounts.map(s=>{let h=t.accountKeys[s];return{pubkey:h,isSigner:n.signatures.some(l=>l.publicKey.toString()===h.toString())||t.isAccountSigner(s),isWritable:t.isAccountWritable(s)}});n.instructions.push(new gt({keys:i,programId:t.accountKeys[o.programIdIndex],data:ve.default.decode(o.data)}))}),n._message=t,n._json=n.toJSON(),n}};var Xd=160,Qd=64,t0=Xd/Qd,e0=1e3/t0,tr=new rt("SysvarC1ock11111111111111111111111111111111"),Eg=new rt("SysvarEpochSchedu1e111111111111111111111111"),_g=new rt("Sysvar1nstructions1111111111111111111111111"),$s=new rt("SysvarRecentB1ockHashes11111111111111111111"),Un=new rt("SysvarRent111111111111111111111111111111111"),Ig=new rt("SysvarRewards111111111111111111111111111111"),Ag=new rt("SysvarS1otHashes111111111111111111111111111"),Lg=new rt("SysvarS1otHistory11111111111111111111111111"),js=new rt("SysvarStakeHistory1111111111111111111111111");async function Cu(r,t,e,n){let o=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},i=await r.sendTransaction(t,e,o),s;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)s=(await r.confirmTransaction({abortSignal:n?.abortSignal,signature:i,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},n&&n.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:h}=t.nonceInfo,l=h.keys[0].pubkey;s=(await r.confirmTransaction({abortSignal:n?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:l,nonceValue:t.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."),s=(await r.confirmTransaction(i,n&&n.commitment)).value;if(s.err)throw new Error(`Transaction ${i} failed (${JSON.stringify(s)})`);return i}function r0(r){return new Promise(t=>setTimeout(t,r))}function it(r,t){let e=r.layout.span>=0?r.layout.span:ju(r,t),n=X.Buffer.alloc(e),o=Object.assign({instruction:r.index},t);return r.layout.encode(o,n),n}var n0=S.nu64("lamportsPerSignature"),o0=S.struct([S.u32("version"),S.u32("state"),st("authorizedPubkey"),st("nonce"),S.struct([n0],"feeCalculator")]),Ou=o0.span;var i0=r=>{let t=r.decode.bind(r),e=r.encode.bind(r);return{decode:t,encode:e}},s0=r=>t=>{let e=(0,Wu.blob)(r,t),{encode:n,decode:o}=i0(e),i=e;return i.decode=(s,h)=>{let l=o(s,h);return(0,zn.toBigIntLE)(X.Buffer.from(l))},i.encode=(s,h,l)=>{let b=(0,zn.toBufferLE)(s,r);return n(b,h,l)},i},Jr=s0(8);var Ae=Object.freeze({Create:{index:0,layout:S.struct([S.u32("instruction"),S.ns64("lamports"),S.ns64("space"),st("programId")])},Assign:{index:1,layout:S.struct([S.u32("instruction"),st("programId")])},Transfer:{index:2,layout:S.struct([S.u32("instruction"),Jr("lamports")])},CreateWithSeed:{index:3,layout:S.struct([S.u32("instruction"),st("base"),Zr("seed"),S.ns64("lamports"),S.ns64("space"),st("programId")])},AdvanceNonceAccount:{index:4,layout:S.struct([S.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:S.struct([S.u32("instruction"),st("authorized")])},AuthorizeNonceAccount:{index:7,layout:S.struct([S.u32("instruction"),st("authorized")])},Allocate:{index:8,layout:S.struct([S.u32("instruction"),S.ns64("space")])},AllocateWithSeed:{index:9,layout:S.struct([S.u32("instruction"),st("base"),Zr("seed"),S.ns64("space"),st("programId")])},AssignWithSeed:{index:10,layout:S.struct([S.u32("instruction"),st("base"),Zr("seed"),st("programId")])},TransferWithSeed:{index:11,layout:S.struct([S.u32("instruction"),Jr("lamports"),Zr("seed"),st("programId")])},UpgradeNonceAccount:{index:12,layout:S.struct([S.u32("instruction")])}}),ke=class r{constructor(){}static createAccount(t){let e=Ae.Create,n=it(e,{lamports:t.lamports,space:t.space,programId:ut(t.programId.toBuffer())});return new gt({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(t){let e,n;if("basePubkey"in t){let o=Ae.TransferWithSeed;e=it(o,{lamports:BigInt(t.lamports),seed:t.seed,programId:ut(t.programId.toBuffer())}),n=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{let o=Ae.Transfer;e=it(o,{lamports:BigInt(t.lamports)}),n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new gt({keys:n,programId:this.programId,data:e})}static assign(t){let e,n;if("basePubkey"in t){let o=Ae.AssignWithSeed;e=it(o,{base:ut(t.basePubkey.toBuffer()),seed:t.seed,programId:ut(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{let o=Ae.Assign;e=it(o,{programId:ut(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new gt({keys:n,programId:this.programId,data:e})}static createAccountWithSeed(t){let e=Ae.CreateWithSeed,n=it(e,{base:ut(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:ut(t.programId.toBuffer())}),o=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey!=t.fromPubkey&&o.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new gt({keys:o,programId:this.programId,data:n})}static createNonceAccount(t){let e=new bt;"basePubkey"in t&&"seed"in t?e.add(r.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Ou,programId:this.programId})):e.add(r.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Ou,programId:this.programId}));let n={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(n)),e}static nonceInitialize(t){let e=Ae.InitializeNonceAccount,n=it(e,{authorized:ut(t.authorizedPubkey.toBuffer())}),o={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$s,isSigner:!1,isWritable:!1},{pubkey:Un,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new gt(o)}static nonceAdvance(t){let e=Ae.AdvanceNonceAccount,n=it(e),o={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$s,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new gt(o)}static nonceWithdraw(t){let e=Ae.WithdrawNonceAccount,n=it(e,{lamports:t.lamports});return new gt({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:$s,isSigner:!1,isWritable:!1},{pubkey:Un,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(t){let e=Ae.AuthorizeNonceAccount,n=it(e,{authorized:ut(t.newAuthorizedPubkey.toBuffer())});return new gt({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(t){let e,n;if("basePubkey"in t){let o=Ae.AllocateWithSeed;e=it(o,{base:ut(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:ut(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{let o=Ae.Allocate;e=it(o,{space:t.space}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new gt({keys:n,programId:this.programId,data:e})}};ke.programId=new rt("11111111111111111111111111111111");var a0=Jo-300,oa=class r{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/r.chunkSize)+1+1)}static async load(t,e,n,o,i){{let k=await t.getMinimumBalanceForRentExemption(i.length),R=await t.getAccountInfo(n.publicKey,"confirmed"),I=null;if(R!==null){if(R.executable)return console.error("Program load failed, account is already executable"),!1;R.data.length!==i.length&&(I=I||new bt,I.add(ke.allocate({accountPubkey:n.publicKey,space:i.length}))),R.owner.equals(o)||(I=I||new bt,I.add(ke.assign({accountPubkey:n.publicKey,programId:o}))),R.lamports<k&&(I=I||new bt,I.add(ke.transfer({fromPubkey:e.publicKey,toPubkey:n.publicKey,lamports:k-R.lamports})))}else I=new bt().add(ke.createAccount({fromPubkey:e.publicKey,newAccountPubkey:n.publicKey,lamports:k>0?k:1,space:i.length,programId:o}));I!==null&&await Cu(t,I,[e,n],{commitment:"confirmed"})}let s=S.struct([S.u32("instruction"),S.u32("offset"),S.u32("bytesLength"),S.u32("bytesLengthPadding"),S.seq(S.u8("byte"),S.offset(S.u32(),-8),"bytes")]),h=r.chunkSize,l=0,b=i,x=[];for(;b.length>0;){let k=b.slice(0,h),R=X.Buffer.alloc(h+16);s.encode({instruction:0,offset:l,bytes:k,bytesLength:0,bytesLengthPadding:0},R);let I=new bt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:o,data:R});x.push(Cu(t,I,[e,n],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await r0(1e3/4),l+=h,b=b.slice(h)}await Promise.all(x);{let k=S.struct([S.u32("instruction")]),R=X.Buffer.alloc(k.span);k.encode({instruction:1},R);let I=new bt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Un,isSigner:!1,isWritable:!1}],programId:o,data:R}),P="processed",B=await t.sendTransaction(I,[e,n],{preflightCommitment:P}),{context:A,value:T}=await t.confirmTransaction({signature:B,lastValidBlockHeight:I.lastValidBlockHeight,blockhash:I.recentBlockhash},P);if(T.err)throw new Error(`Transaction ${B} failed (${JSON.stringify(T)})`);for(;;){try{if(await t.getSlot({commitment:P})>A.slot)break}catch{}await new Promise(F=>setTimeout(F,Math.round(e0/2)))}}return!0}};oa.chunkSize=a0;var Rg=new rt("BPFLoader2111111111111111111111111111111111");var Tg=globalThis.fetch;var Mg={index:1,layout:S.struct([S.u32("typeIndex"),Jr("deactivationSlot"),S.nu64("lastExtendedSlot"),S.u8("lastExtendedStartIndex"),S.u8(),S.seq(st(),S.offset(S.u8(),-1),"authority")])};var ie=Gr(Oo(rt),K(),r=>new rt(r)),Gu=Uo([K(),St("base64")]),la=Gr(Oo(X.Buffer),Gu,r=>X.Buffer.from(r[0],"base64")),Pg=30*1e3;function Yu(r){return me([C({jsonrpc:St("2.0"),id:K(),result:r}),C({jsonrpc:St("2.0"),id:K(),error:C({code:jr(),message:K(),data:Z(Rc())})})])}var c0=Yu(jr());function wt(r){return Gr(Yu(r),c0,t=>"error"in t?t:{...t,result:$r(t.result,r)})}function Le(r){return wt(C({context:C({slot:E()}),value:r}))}function ni(r){return C({context:C({slot:E()}),value:r})}var u0=C({foundation:E(),foundationTerm:E(),initial:E(),taper:E(),terminal:E()}),Cg=wt($(V(C({epoch:E(),effectiveSlot:E(),amount:E(),postBalance:E(),commission:Z(V(E()))})))),f0=$(C({slot:E(),prioritizationFee:E()})),l0=C({total:E(),validator:E(),foundation:E(),epoch:E()}),h0=C({epoch:E(),slotIndex:E(),slotsInEpoch:E(),absoluteSlot:E(),blockHeight:Z(E()),transactionCount:Z(E())}),d0=C({slotsPerEpoch:E(),leaderScheduleSlotOffset:E(),warmup:Ce(),firstNormalEpoch:E(),firstNormalSlot:E()}),p0=xs(K(),$(E())),Pr=V(me([C({}),K()])),y0=C({err:Pr}),g0=St("receivedSignature"),Og=C({"solana-core":K(),"feature-set":Z(E())}),Ug=Le(C({err:V(me([C({}),K()])),logs:V($(K())),accounts:Z(V($(V(C({executable:Ce(),owner:K(),lamports:E(),data:$(K()),rentEpoch:Z(E())}))))),unitsConsumed:Z(E()),returnData:Z(V(C({programId:K(),data:Uo([K(),St("base64")])})))})),Ng=Le(C({byIdentity:xs(K(),$(E())),range:C({firstSlot:E(),lastSlot:E()})}));var zg=wt(u0),qg=wt(l0),Fg=wt(f0),Dg=wt(h0),Kg=wt(d0),Wg=wt(p0),Hg=wt(E()),Vg=Le(C({total:E(),circulating:E(),nonCirculating:E(),nonCirculatingAccounts:$(ie)})),m0=C({amount:K(),uiAmount:V(E()),decimals:E(),uiAmountString:Z(K())}),$g=Le($(C({address:ie,amount:K(),uiAmount:V(E()),decimals:E(),uiAmountString:Z(K())}))),jg=Le($(C({pubkey:ie,account:C({executable:Ce(),owner:ie,lamports:E(),data:la,rentEpoch:E()})}))),ia=C({program:K(),parsed:jr(),space:E()}),Gg=Le($(C({pubkey:ie,account:C({executable:Ce(),owner:ie,lamports:E(),data:ia,rentEpoch:E()})}))),Yg=Le($(C({lamports:E(),address:ie}))),ha=C({executable:Ce(),owner:ie,lamports:E(),data:la,rentEpoch:E()}),Zg=C({pubkey:ie,account:ha}),b0=Gr(me([Oo(X.Buffer),ia]),me([Gu,ia]),r=>Array.isArray(r)?$r(r,la):r),w0=C({executable:Ce(),owner:ie,lamports:E(),data:b0,rentEpoch:E()}),Jg=C({pubkey:ie,account:w0}),Xg=C({state:me([St("active"),St("inactive"),St("activating"),St("deactivating")]),active:E(),inactive:E()}),Qg=wt($(C({signature:K(),slot:E(),err:Pr,memo:V(K()),blockTime:Z(V(E()))}))),tm=wt($(C({signature:K(),slot:E(),err:Pr,memo:V(K()),blockTime:Z(V(E()))}))),em=C({subscription:E(),result:ni(ha)}),x0=C({pubkey:ie,account:ha}),rm=C({subscription:E(),result:ni(x0)}),v0=C({parent:E(),slot:E(),root:E()}),nm=C({subscription:E(),result:v0}),k0=me([C({type:me([St("firstShredReceived"),St("completed"),St("optimisticConfirmation"),St("root")]),slot:E(),timestamp:E()}),C({type:St("createdBank"),parent:E(),slot:E(),timestamp:E()}),C({type:St("frozen"),slot:E(),timestamp:E(),stats:C({numTransactionEntries:E(),numSuccessfulTransactions:E(),numFailedTransactions:E(),maxTransactionsPerEntry:E()})}),C({type:St("dead"),slot:E(),timestamp:E(),err:K()})]),om=C({subscription:E(),result:k0}),im=C({subscription:E(),result:ni(me([y0,g0]))}),sm=C({subscription:E(),result:E()}),am=C({pubkey:K(),gossip:V(K()),tpu:V(K()),rpc:V(K()),version:V(K())}),Uu=C({votePubkey:K(),nodePubkey:K(),activatedStake:E(),epochVoteAccount:Ce(),epochCredits:$(Uo([E(),E(),E()])),commission:E(),lastVote:E(),rootSlot:V(E())}),cm=wt(C({current:$(Uu),delinquent:$(Uu)})),S0=me([St("processed"),St("confirmed"),St("finalized")]),B0=C({slot:E(),confirmations:V(E()),err:Pr,confirmationStatus:Z(S0)}),um=Le($(V(B0))),fm=wt(E()),Zu=C({accountKey:ie,writableIndexes:$(E()),readonlyIndexes:$(E())}),da=C({signatures:$(K()),message:C({accountKeys:$(K()),header:C({numRequiredSignatures:E(),numReadonlySignedAccounts:E(),numReadonlyUnsignedAccounts:E()}),instructions:$(C({accounts:$(E()),data:K(),programIdIndex:E()})),recentBlockhash:K(),addressTableLookups:Z($(Zu))})}),Ju=C({pubkey:ie,signer:Ce(),writable:Ce(),source:Z(me([St("transaction"),St("lookupTable")]))}),Xu=C({accountKeys:$(Ju),signatures:$(K())}),Qu=C({parsed:jr(),program:K(),programId:ie}),tf=C({accounts:$(ie),data:K(),programId:ie}),E0=me([tf,Qu]),_0=me([C({parsed:jr(),program:K(),programId:K()}),C({accounts:$(K()),data:K(),programId:K()})]),ef=Gr(E0,_0,r=>"accounts"in r?$r(r,tf):$r(r,Qu)),rf=C({signatures:$(K()),message:C({accountKeys:$(Ju),instructions:$(ef),recentBlockhash:K(),addressTableLookups:Z(V($(Zu)))})}),ti=C({accountIndex:E(),mint:K(),owner:Z(K()),uiTokenAmount:m0}),nf=C({writable:$(ie),readonly:$(ie)}),oi=C({err:Pr,fee:E(),innerInstructions:Z(V($(C({index:E(),instructions:$(C({accounts:$(E()),data:K(),programIdIndex:E()}))})))),preBalances:$(E()),postBalances:$(E()),logMessages:Z(V($(K()))),preTokenBalances:Z(V($(ti))),postTokenBalances:Z(V($(ti))),loadedAddresses:Z(nf),computeUnitsConsumed:Z(E())}),pa=C({err:Pr,fee:E(),innerInstructions:Z(V($(C({index:E(),instructions:$(ef)})))),preBalances:$(E()),postBalances:$(E()),logMessages:Z(V($(K()))),preTokenBalances:Z(V($(ti))),postTokenBalances:Z(V($(ti))),loadedAddresses:Z(nf),computeUnitsConsumed:Z(E())}),Qr=me([St(0),St("legacy")]),Cr=C({pubkey:K(),lamports:E(),postBalance:V(E()),rewardType:V(K()),commission:Z(V(E()))}),lm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:da,meta:V(oi),version:Z(Qr)})),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),hm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),dm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:Xu,meta:V(oi),version:Z(Qr)})),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),pm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:rf,meta:V(pa),version:Z(Qr)})),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),ym=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:Xu,meta:V(pa),version:Z(Qr)})),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),gm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),rewards:Z($(Cr)),blockTime:V(E()),blockHeight:V(E())}))),mm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),transactions:$(C({transaction:da,meta:V(oi)})),rewards:Z($(Cr)),blockTime:V(E())}))),bm=wt(V(C({blockhash:K(),previousBlockhash:K(),parentSlot:E(),signatures:$(K()),blockTime:V(E())}))),wm=wt(V(C({slot:E(),meta:oi,blockTime:Z(V(E())),transaction:da,version:Z(Qr)}))),xm=wt(V(C({slot:E(),transaction:rf,meta:V(pa),blockTime:Z(V(E())),version:Z(Qr)}))),vm=Le(C({blockhash:K(),feeCalculator:C({lamportsPerSignature:E()})})),km=Le(C({blockhash:K(),lastValidBlockHeight:E()})),Sm=Le(Ce()),I0=C({slot:E(),numTransactions:E(),numSlots:E(),samplePeriodSecs:E()}),Bm=wt($(I0)),Em=Le(V(C({feeCalculator:C({lamportsPerSignature:E()})}))),_m=wt(K()),Im=wt(K()),A0=C({err:Pr,logs:$(K()),signature:K()}),Am=C({result:ni(A0),subscription:E()});var sa=class r{constructor(t){this._keypair=void 0,this._keypair=t??Tu()}static generate(){return new r(Tu())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");let n=t.slice(32,64);if(!e||!e.skipValidation){let o=t.slice(0,32),i=Js(o);for(let s=0;s<32;s++)if(n[s]!==i[s])throw new Error("provided secretKey is invalid")}return new r({publicKey:n,secretKey:t})}static fromSeed(t){let e=Js(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new r({publicKey:e,secretKey:n})}get publicKey(){return new rt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},Pn=Object.freeze({CreateLookupTable:{index:0,layout:S.struct([S.u32("instruction"),Jr("recentSlot"),S.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:S.struct([S.u32("instruction")])},ExtendLookupTable:{index:2,layout:S.struct([S.u32("instruction"),Jr(),S.seq(st(),S.offset(S.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:S.struct([S.u32("instruction")])},CloseLookupTable:{index:4,layout:S.struct([S.u32("instruction")])}});var aa=class{constructor(){}static createLookupTable(t){let[e,n]=rt.findProgramAddressSync([t.authority.toBuffer(),(0,zn.toBufferLE)(BigInt(t.recentSlot),8)],this.programId),o=Pn.CreateLookupTable,i=it(o,{recentSlot:BigInt(t.recentSlot),bumpSeed:n}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ke.programId,isSigner:!1,isWritable:!1}];return[new gt({programId:this.programId,keys:s,data:i}),e]}static freezeLookupTable(t){let e=Pn.FreezeLookupTable,n=it(e),o=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new gt({programId:this.programId,keys:o,data:n})}static extendLookupTable(t){let e=Pn.ExtendLookupTable,n=it(e,{addresses:t.addresses.map(i=>i.toBytes())}),o=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&o.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ke.programId,isSigner:!1,isWritable:!1}),new gt({programId:this.programId,keys:o,data:n})}static deactivateLookupTable(t){let e=Pn.DeactivateLookupTable,n=it(e),o=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new gt({programId:this.programId,keys:o,data:n})}static closeLookupTable(t){let e=Pn.CloseLookupTable,n=it(e),o=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new gt({programId:this.programId,keys:o,data:n})}};aa.programId=new rt("AddressLookupTab1e1111111111111111111111111");var Go=Object.freeze({RequestUnits:{index:0,layout:S.struct([S.u8("instruction"),S.u32("units"),S.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:S.struct([S.u8("instruction"),S.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:S.struct([S.u8("instruction"),S.u32("units")])},SetComputeUnitPrice:{index:3,layout:S.struct([S.u8("instruction"),Jr("microLamports")])}}),ca=class{constructor(){}static requestUnits(t){let e=Go.RequestUnits,n=it(e,t);return new gt({keys:[],programId:this.programId,data:n})}static requestHeapFrame(t){let e=Go.RequestHeapFrame,n=it(e,t);return new gt({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(t){let e=Go.SetComputeUnitLimit,n=it(e,t);return new gt({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(t){let e=Go.SetComputeUnitPrice,n=it(e,{microLamports:BigInt(t.microLamports)});return new gt({keys:[],programId:this.programId,data:n})}};ca.programId=new rt("ComputeBudget111111111111111111111111111111");var Nu=64,zu=32,qu=64,Fu=S.struct([S.u8("numSignatures"),S.u8("padding"),S.u16("signatureOffset"),S.u16("signatureInstructionIndex"),S.u16("publicKeyOffset"),S.u16("publicKeyInstructionIndex"),S.u16("messageDataOffset"),S.u16("messageDataSize"),S.u16("messageInstructionIndex")]),ua=class r{constructor(){}static createInstructionWithPublicKey(t){let{publicKey:e,message:n,signature:o,instructionIndex:i}=t;oe(e.length===zu,`Public Key must be ${zu} bytes but received ${e.length} bytes`),oe(o.length===qu,`Signature must be ${qu} bytes but received ${o.length} bytes`);let s=Fu.span,h=s+e.length,l=h+o.length,b=1,x=X.Buffer.alloc(l+n.length),k=i??65535;return Fu.encode({numSignatures:b,padding:0,signatureOffset:h,signatureInstructionIndex:k,publicKeyOffset:s,publicKeyInstructionIndex:k,messageDataOffset:l,messageDataSize:n.length,messageInstructionIndex:k},x),x.fill(e,s),x.fill(o,h),x.fill(n,l),new gt({keys:[],programId:r.programId,data:x})}static createInstructionWithPrivateKey(t){let{privateKey:e,message:n,instructionIndex:o}=t;oe(e.length===Nu,`Private key must be ${Nu} bytes but received ${e.length} bytes`);try{let i=sa.fromSecretKey(e),s=i.publicKey.toBytes(),h=Hu(n,i.secretKey);return this.createInstructionWithPublicKey({publicKey:s,message:n,signature:h,instructionIndex:o})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}};ua.programId=new rt("Ed25519SigVerify111111111111111111111111111");var L0=(r,t)=>{let e=Mn.sign(r,t);return[e.toCompactRawBytes(),e.recovery]};Mn.utils.isValidPrivateKey;var R0=Mn.getPublicKey,Du=32,Gs=20,Ku=64,T0=11,Ys=S.struct([S.u8("numSignatures"),S.u16("signatureOffset"),S.u8("signatureInstructionIndex"),S.u16("ethAddressOffset"),S.u8("ethAddressInstructionIndex"),S.u16("messageDataOffset"),S.u16("messageDataSize"),S.u8("messageInstructionIndex"),S.blob(20,"ethAddress"),S.blob(64,"signature"),S.u8("recoveryId")]),fa=class r{constructor(){}static publicKeyToEthAddress(t){oe(t.length===Ku,`Public key must be ${Ku} bytes but received ${t.length} bytes`);try{return X.Buffer.from(Ks(ut(t))).slice(-Gs)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){let{publicKey:e,message:n,signature:o,recoveryId:i,instructionIndex:s}=t;return r.createInstructionWithEthAddress({ethAddress:r.publicKeyToEthAddress(e),message:n,signature:o,recoveryId:i,instructionIndex:s})}static createInstructionWithEthAddress(t){let{ethAddress:e,message:n,signature:o,recoveryId:i,instructionIndex:s=0}=t,h;typeof e=="string"?e.startsWith("0x")?h=X.Buffer.from(e.substr(2),"hex"):h=X.Buffer.from(e,"hex"):h=e,oe(h.length===Gs,`Address must be ${Gs} bytes but received ${h.length} bytes`);let l=1+T0,b=l,x=l+h.length,k=x+o.length+1,R=1,I=X.Buffer.alloc(Ys.span+n.length);return Ys.encode({numSignatures:R,signatureOffset:x,signatureInstructionIndex:s,ethAddressOffset:b,ethAddressInstructionIndex:s,messageDataOffset:k,messageDataSize:n.length,messageInstructionIndex:s,signature:ut(o),ethAddress:ut(h),recoveryId:i},I),I.fill(ut(n),Ys.span),new gt({keys:[],programId:r.programId,data:I})}static createInstructionWithPrivateKey(t){let{privateKey:e,message:n,instructionIndex:o}=t;oe(e.length===Du,`Private key must be ${Du} bytes but received ${e.length} bytes`);try{let i=ut(e),s=R0(i,!1).slice(1),h=X.Buffer.from(Ks(ut(n))),[l,b]=L0(h,i);return this.createInstructionWithPublicKey({publicKey:s,message:n,signature:l,recoveryId:b,instructionIndex:o})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}};fa.programId=new rt("KeccakSecp256k11111111111111111111111111111");var of,M0=new rt("StakeConfig11111111111111111111111111111111");var Nn=class{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}};of=Nn;Nn.default=new of(0,0,rt.default);var xr=Object.freeze({Initialize:{index:0,layout:S.struct([S.u32("instruction"),jd(),Gd()])},Authorize:{index:1,layout:S.struct([S.u32("instruction"),st("newAuthorized"),S.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:S.struct([S.u32("instruction")])},Split:{index:3,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},Withdraw:{index:4,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},Deactivate:{index:5,layout:S.struct([S.u32("instruction")])},Merge:{index:7,layout:S.struct([S.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:S.struct([S.u32("instruction"),st("newAuthorized"),S.u32("stakeAuthorizationType"),Zr("authoritySeed"),st("authorityOwner")])}}),Lm=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),ei=class{constructor(){}static initialize(t){let{stakePubkey:e,authorized:n,lockup:o}=t,i=o||Nn.default,s=xr.Initialize,h=it(s,{authorized:{staker:ut(n.staker.toBuffer()),withdrawer:ut(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:ut(i.custodian.toBuffer())}}),l={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Un,isSigner:!1,isWritable:!1}],programId:this.programId,data:h};return new gt(l)}static createAccountWithSeed(t){let e=new bt;e.add(ke.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:o,lockup:i}=t;return e.add(this.initialize({stakePubkey:n,authorized:o,lockup:i}))}static createAccount(t){let e=new bt;e.add(ke.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:o,lockup:i}=t;return e.add(this.initialize({stakePubkey:n,authorized:o,lockup:i}))}static delegate(t){let{stakePubkey:e,authorizedPubkey:n,votePubkey:o}=t,i=xr.Delegate,s=it(i);return new bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:js,isSigner:!1,isWritable:!1},{pubkey:M0,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static authorize(t){let{stakePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:o,stakeAuthorizationType:i,custodianPubkey:s}=t,h=xr.Authorize,l=it(h,{newAuthorized:ut(o.toBuffer()),stakeAuthorizationType:i.index}),b=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return s&&b.push({pubkey:s,isSigner:!1,isWritable:!1}),new bt().add({keys:b,programId:this.programId,data:l})}static authorizeWithSeed(t){let{stakePubkey:e,authorityBase:n,authoritySeed:o,authorityOwner:i,newAuthorizedPubkey:s,stakeAuthorizationType:h,custodianPubkey:l}=t,b=xr.AuthorizeWithSeed,x=it(b,{newAuthorized:ut(s.toBuffer()),stakeAuthorizationType:h.index,authoritySeed:o,authorityOwner:ut(i.toBuffer())}),k=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:tr,isSigner:!1,isWritable:!1}];return l&&k.push({pubkey:l,isSigner:!1,isWritable:!1}),new bt().add({keys:k,programId:this.programId,data:x})}static splitInstruction(t){let{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:o,lamports:i}=t,s=xr.Split,h=it(s,{lamports:i});return new gt({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:h})}static split(t){let e=new bt;return e.add(ke.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:0,space:this.space,programId:this.programId})),e.add(this.splitInstruction(t))}static splitWithSeed(t){let{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:o,basePubkey:i,seed:s,lamports:h}=t,l=new bt;return l.add(ke.allocate({accountPubkey:o,basePubkey:i,seed:s,space:this.space,programId:this.programId})),l.add(this.splitInstruction({stakePubkey:e,authorizedPubkey:n,splitStakePubkey:o,lamports:h}))}static merge(t){let{stakePubkey:e,sourceStakePubKey:n,authorizedPubkey:o}=t,i=xr.Merge,s=it(i);return new bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:js,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static withdraw(t){let{stakePubkey:e,authorizedPubkey:n,toPubkey:o,lamports:i,custodianPubkey:s}=t,h=xr.Withdraw,l=it(h,{lamports:i}),b=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:js,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return s&&b.push({pubkey:s,isSigner:!1,isWritable:!1}),new bt().add({keys:b,programId:this.programId,data:l})}static deactivate(t){let{stakePubkey:e,authorizedPubkey:n}=t,o=xr.Deactivate,i=it(o);return new bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}};ei.programId=new rt("Stake11111111111111111111111111111111111111");ei.space=200;var Yo=Object.freeze({InitializeAccount:{index:0,layout:S.struct([S.u32("instruction"),Yd()])},Authorize:{index:1,layout:S.struct([S.u32("instruction"),st("newAuthorized"),S.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},AuthorizeWithSeed:{index:10,layout:S.struct([S.u32("instruction"),Zd()])}}),Rm=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),ri=class r{constructor(){}static initializeAccount(t){let{votePubkey:e,nodePubkey:n,voteInit:o}=t,i=Yo.InitializeAccount,s=it(i,{voteInit:{nodePubkey:ut(o.nodePubkey.toBuffer()),authorizedVoter:ut(o.authorizedVoter.toBuffer()),authorizedWithdrawer:ut(o.authorizedWithdrawer.toBuffer()),commission:o.commission}}),h={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Un,isSigner:!1,isWritable:!1},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s};return new gt(h)}static createAccount(t){let e=new bt;return e.add(ke.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){let{votePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:o,voteAuthorizationType:i}=t,s=Yo.Authorize,h=it(s,{newAuthorized:ut(o.toBuffer()),voteAuthorizationType:i.index}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new bt().add({keys:l,programId:this.programId,data:h})}static authorizeWithSeed(t){let{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:o,newAuthorizedPubkey:i,voteAuthorizationType:s,votePubkey:h}=t,l=Yo.AuthorizeWithSeed,b=it(l,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:ut(n.toBuffer()),currentAuthorityDerivedKeySeed:o,newAuthorized:ut(i.toBuffer()),voteAuthorizationType:s.index}}),x=[{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:tr,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new bt().add({keys:x,programId:this.programId,data:b})}static withdraw(t){let{votePubkey:e,authorizedWithdrawerPubkey:n,lamports:o,toPubkey:i}=t,s=Yo.Withdraw,h=it(s,{lamports:o}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new bt().add({keys:l,programId:this.programId,data:h})}static safeWithdraw(t,e,n){if(t.lamports>e-n)throw new Error("Withdraw will leave vote account with insuffcient funds.");return r.withdraw(t)}};ri.programId=new rt("Vote111111111111111111111111111111111111111");ri.space=3731;var Tm=new rt("Va1idator1nfo111111111111111111111111111111"),Mm=C({name:K(),website:Z(K()),details:Z(K()),keybaseUsername:Z(K())});var Pm=new rt("Vote111111111111111111111111111111111111111"),Cm=S.struct([st("nodePubkey"),st("authorizedWithdrawer"),S.u8("commission"),S.nu64(),S.seq(S.struct([S.nu64("slot"),S.u32("confirmationCount")]),S.offset(S.u32(),-8),"votes"),S.u8("rootSlotValid"),S.nu64("rootSlot"),S.nu64(),S.seq(S.struct([S.nu64("epoch"),st("authorizedVoter")]),S.offset(S.u32(),-8),"authorizedVoters"),S.struct([S.seq(S.struct([st("authorizedPubkey"),S.nu64("epochOfLastAuthorizedSwitch"),S.nu64("targetEpoch")]),32,"buf"),S.nu64("idx"),S.u8("isEmpty")],"priorVoters"),S.nu64(),S.seq(S.struct([S.nu64("epoch"),S.nu64("credits"),S.nu64("prevCredits")]),S.offset(S.u32(),-8),"epochCredits"),S.struct([S.nu64("slot"),S.nu64("timestamp")],"lastTimestamp")]);var ii={SIGN_TRANSACTION:"sol_signTransaction",SIGN_MESSAGE:"sol_signMessage",PARTIAL_SIGN_TRANSACTION:"sol_partialSignTransaction"};var si=class extends sf.MultichainExtension{constructor(e){super({rpcUrl:e.rpcUrl,chainType:"SOLANA"});this.solanaConfig=e}name="solana";signTransaction=(e,n)=>this.request({id:42,jsonrpc:"2.0",method:ii.SIGN_TRANSACTION,params:{type:e instanceof bt?"legacy":0,serialized:e.serialize(n),serializeConfig:n}});signMessage=e=>this.request({id:42,jsonrpc:"2.0",method:ii.SIGN_MESSAGE,params:{message:e}});partialSignTransaction=(e,n)=>this.request({id:42,jsonrpc:"2.0",method:ii.PARTIAL_SIGN_TRANSACTION,params:{type:e instanceof bt?"legacy":0,serialized:e.serialize(n),serializeConfig:n}})};var P0=si;return Ii(C0);})();
|
|
2
2
|
if (MagicSolanaExtension && MagicSolanaExtension.default != null) { MagicSolanaExtension = Object.assign(MagicSolanaExtension.default, MagicSolanaExtension); delete MagicSolanaExtension.default; }
|