@solarpunkltd/swarm-chat-js 0.0.2 → 2.1.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.
Files changed (58) hide show
  1. package/README.md +3 -1
  2. package/dist/index.d.ts +2 -4
  3. package/dist/index.esm.js +43205 -23583
  4. package/dist/index.js +23 -26
  5. package/dist/src/index.d.ts +5 -0
  6. package/dist/src/index.d.ts.map +1 -0
  7. package/dist/{libs → src/lib}/constants.d.ts +5 -5
  8. package/dist/src/lib/constants.d.ts.map +1 -0
  9. package/dist/src/lib/core.d.ts +47 -0
  10. package/dist/src/lib/core.d.ts.map +1 -0
  11. package/dist/src/lib/history.d.ts +49 -0
  12. package/dist/src/lib/history.d.ts.map +1 -0
  13. package/dist/src/lib/mine.d.ts +2 -0
  14. package/dist/src/lib/mine.d.ts.map +1 -0
  15. package/dist/src/lib/swarmEventEmitterReader.d.ts +15 -0
  16. package/dist/src/lib/swarmEventEmitterReader.d.ts.map +1 -0
  17. package/dist/src/lib/types/chat.d.ts +59 -0
  18. package/dist/src/lib/types/chat.d.ts.map +1 -0
  19. package/dist/src/lib/types/index.d.ts +4 -0
  20. package/dist/src/lib/types/index.d.ts.map +1 -0
  21. package/dist/src/lib/types/message.d.ts +14 -0
  22. package/dist/src/lib/types/message.d.ts.map +1 -0
  23. package/dist/src/lib/types/user.d.ts +35 -0
  24. package/dist/src/lib/types/user.d.ts.map +1 -0
  25. package/dist/src/lib/utils.d.ts +34 -0
  26. package/dist/src/lib/utils.d.ts.map +1 -0
  27. package/dist/src/utils/bee.d.ts +18 -0
  28. package/dist/src/utils/bee.d.ts.map +1 -0
  29. package/dist/src/utils/common.d.ts +4 -0
  30. package/dist/src/utils/common.d.ts.map +1 -0
  31. package/dist/src/utils/error.d.ts +6 -0
  32. package/dist/src/utils/error.d.ts.map +1 -0
  33. package/dist/src/utils/eventEmitter.d.ts.map +1 -0
  34. package/dist/src/utils/logger.d.ts +12 -0
  35. package/dist/src/utils/logger.d.ts.map +1 -0
  36. package/dist/{utils → src/utils}/queue.d.ts +3 -8
  37. package/dist/src/utils/queue.d.ts.map +1 -0
  38. package/dist/src/utils/validation.d.ts +7 -0
  39. package/dist/src/utils/validation.d.ts.map +1 -0
  40. package/dist/src/utils/waitForBroadcast.d.ts +10 -0
  41. package/dist/src/utils/waitForBroadcast.d.ts.map +1 -0
  42. package/dist/swarm-chat-umd.js +23 -26
  43. package/package.json +11 -5
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/libs/constants.d.ts.map +0 -1
  46. package/dist/libs/core.d.ts +0 -59
  47. package/dist/libs/core.d.ts.map +0 -1
  48. package/dist/libs/mine.d.ts +0 -4
  49. package/dist/libs/mine.d.ts.map +0 -1
  50. package/dist/libs/types.d.ts +0 -85
  51. package/dist/libs/types.d.ts.map +0 -1
  52. package/dist/libs/utils.d.ts +0 -34
  53. package/dist/libs/utils.d.ts.map +0 -1
  54. package/dist/utils/common.d.ts +0 -2
  55. package/dist/utils/common.d.ts.map +0 -1
  56. package/dist/utils/eventEmitter.d.ts.map +0 -1
  57. package/dist/utils/queue.d.ts.map +0 -1
  58. /package/dist/{utils → src/utils}/eventEmitter.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,30 +1,27 @@
1
- "use strict";var Er=Object.defineProperty;var wr=t=>{throw TypeError(t)};var Ar=(t,e,n)=>e in t?Er(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Fe=(t,e,n)=>Ar(t,typeof e!="symbol"?e+"":e,n),pr=(t,e,n)=>e.has(t)||wr("Cannot "+n);var Re=(t,e,n)=>(pr(t,e,"read from private field"),n?n.call(t):e.get(t)),Le=(t,e,n)=>e.has(t)?wr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),we=(t,e,n,a)=>(pr(t,e,"write to private field"),a?a.call(t,n):e.set(t,n),n),it=(t,e,n)=>(pr(t,e,"access private method"),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const beeJs=require("@ethersphere/bee-js"),version$1="6.13.4";async function resolveProperties(t){const e=Object.keys(t);return(await Promise.all(e.map(a=>Promise.resolve(t[a])))).reduce((a,c,o)=>(a[e[o]]=c,a),{})}function defineProperties(t,e,n){for(let a in e){let c=e[a];Object.defineProperty(t,a,{enumerable:!0,value:c,writable:!1})}}function stringify(t){if(t==null)return"null";if(Array.isArray(t))return"[ "+t.map(stringify).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let n="0x";for(let a=0;a<t.length;a++)n+=e[t[a]>>4],n+=e[t[a]&15];return n}if(typeof t=="object"&&typeof t.toJSON=="function")return stringify(t.toJSON());switch(typeof t){case"boolean":case"symbol":return t.toString();case"bigint":return BigInt(t).toString();case"number":return t.toString();case"string":return JSON.stringify(t);case"object":{const e=Object.keys(t);return e.sort(),"{ "+e.map(n=>`${stringify(n)}: ${stringify(t[n])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function makeError(t,e,n){let a=t;{const o=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${stringify(n)}`);for(const u in n){if(u==="shortMessage")continue;const h=n[u];o.push(u+"="+stringify(h))}}o.push(`code=${e}`),o.push(`version=${version$1}`),o.length&&(t+=" ("+o.join(", ")+")")}let c;switch(e){case"INVALID_ARGUMENT":c=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":c=new RangeError(t);break;default:c=new Error(t)}return defineProperties(c,{code:e}),n&&Object.assign(c,n),c.shortMessage==null&&defineProperties(c,{shortMessage:a}),c}function assert$f(t,e,n,a){if(!t)throw makeError(e,n,a)}function assertArgument(t,e,n,a){assert$f(t,e,"INVALID_ARGUMENT",{argument:n,value:a})}const _normalizeForms=["NFD","NFC","NFKD","NFKC"].reduce((t,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");t.push(e)}catch{}return t},[]);function assertNormalize(t){assert$f(_normalizeForms.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}function assertPrivate(t,e,n){if(n==null&&(n=""),t!==e){let a=n,c="new";n&&(a+=".",c+=" "+n),assert$f(!1,`private constructor; use ${a}from* methods`,"UNSUPPORTED_OPERATION",{operation:c})}}function _getBytes(t,e,n){if(t instanceof Uint8Array)return n?new Uint8Array(t):t;if(typeof t=="string"&&t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const a=new Uint8Array((t.length-2)/2);let c=2;for(let o=0;o<a.length;o++)a[o]=parseInt(t.substring(c,c+2),16),c+=2;return a}assertArgument(!1,"invalid BytesLike value",e||"value",t)}function getBytes(t,e){return _getBytes(t,e,!1)}function getBytesCopy(t,e){return _getBytes(t,e,!0)}function isHexString$1(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&t.length!==2+2*e||e===!0&&t.length%2!==0)}function isBytesLike(t){return isHexString$1(t,!0)||t instanceof Uint8Array}const HexCharacters="0123456789abcdef";function hexlify(t){const e=getBytes(t);let n="0x";for(let a=0;a<e.length;a++){const c=e[a];n+=HexCharacters[(c&240)>>4]+HexCharacters[c&15]}return n}function concat(t){return"0x"+t.map(e=>hexlify(e).substring(2)).join("")}function dataLength(t){return isHexString$1(t,!0)?(t.length-2)/2:getBytes(t).length}function dataSlice(t,e,n){const a=getBytes(t);return n>a.length&&assert$f(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:a,length:a.length,offset:n}),hexlify(a.slice(e,n))}function zeroPad(t,e,n){const a=getBytes(t);assert$f(e>=a.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(a),length:e,offset:e+1});const c=new Uint8Array(e);return c.fill(0),c.set(a,e-a.length),hexlify(c)}function zeroPadValue(t,e){return zeroPad(t,e)}const BN_0$5=BigInt(0),BN_1$2=BigInt(1),maxValue=9007199254740991;function toTwos(t,e){let n=getBigInt(t,"value");const a=BigInt(getNumber(e,"width")),c=BN_1$2<<a-BN_1$2;if(n<BN_0$5){n=-n,assert$f(n<=c,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});const o=(BN_1$2<<a)-BN_1$2;return(~n&o)+BN_1$2}else assert$f(n<c,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return n}function mask(t,e){const n=getUint(t,"value"),a=BigInt(getNumber(e,"bits"));return n&(BN_1$2<<a)-BN_1$2}function getBigInt(t,e){switch(typeof t){case"bigint":return t;case"number":return assertArgument(Number.isInteger(t),"underflow",e||"value",t),assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),BigInt(t);case"string":try{if(t==="")throw new Error("empty string");return t[0]==="-"&&t[1]!=="-"?-BigInt(t.substring(1)):BigInt(t)}catch(n){assertArgument(!1,`invalid BigNumberish string: ${n.message}`,e||"value",t)}}assertArgument(!1,"invalid BigNumberish value",e||"value",t)}function getUint(t,e){const n=getBigInt(t,e);return assert$f(n>=BN_0$5,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),n}const Nibbles$1="0123456789abcdef";function toBigInt(t){if(t instanceof Uint8Array){let e="0x0";for(const n of t)e+=Nibbles$1[n>>4],e+=Nibbles$1[n&15];return BigInt(e)}return getBigInt(t)}function getNumber(t,e){switch(typeof t){case"bigint":return assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),Number(t);case"number":return assertArgument(Number.isInteger(t),"underflow",e||"value",t),assertArgument(t>=-maxValue&&t<=maxValue,"overflow",e||"value",t),t;case"string":try{if(t==="")throw new Error("empty string");return getNumber(BigInt(t),e)}catch(n){assertArgument(!1,`invalid numeric string: ${n.message}`,e||"value",t)}}assertArgument(!1,"invalid numeric value",e||"value",t)}function toBeHex(t,e){let a=getUint(t,"value").toString(16);{const c=getNumber(e,"width");for(assert$f(c*2>=a.length,`value exceeds width (${c} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});a.length<c*2;)a="0"+a}return"0x"+a}function toBeArray(t){const e=getUint(t,"value");if(e===BN_0$5)return new Uint8Array([]);let n=e.toString(16);n.length%2&&(n="0"+n);const a=new Uint8Array(n.length/2);for(let c=0;c<a.length;c++){const o=c*2;a[c]=parseInt(n.substring(o,o+2),16)}return a}function toQuantity(t){let e=hexlify(isBytesLike(t)?t:toBeArray(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const Alphabet="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";let Lookup=null;function getAlpha(t){if(Lookup==null){Lookup={};for(let n=0;n<Alphabet.length;n++)Lookup[Alphabet[n]]=BigInt(n)}const e=Lookup[t];return assertArgument(e!=null,"invalid base58 value","letter",t),e}const BN_0$4=BigInt(0),BN_58=BigInt(58);function encodeBase58(t){const e=getBytes(t);let n=toBigInt(e),a="";for(;n;)a=Alphabet[Number(n%BN_58)]+a,n/=BN_58;for(let c=0;c<e.length&&!e[c];c++)a=Alphabet[0]+a;return a}function decodeBase58(t){let e=BN_0$4;for(let n=0;n<t.length;n++)e*=BN_58,e+=getAlpha(t[n]);return e}function toUtf8Bytes(t,e){assertArgument(typeof t=="string","invalid string value","str",t),e!=null&&(assertNormalize(e),t=t.normalize(e));let n=[];for(let a=0;a<t.length;a++){const c=t.charCodeAt(a);if(c<128)n.push(c);else if(c<2048)n.push(c>>6|192),n.push(c&63|128);else if((c&64512)==55296){a++;const o=t.charCodeAt(a);assertArgument(a<t.length&&(o&64512)===56320,"invalid surrogate pair","str",t);const u=65536+((c&1023)<<10)+(o&1023);n.push(u>>18|240),n.push(u>>12&63|128),n.push(u>>6&63|128),n.push(u&63|128)}else n.push(c>>12|224),n.push(c>>6&63|128),n.push(c&63|128)}return new Uint8Array(n)}function hexlifyByte(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function unarrayifyInteger(t,e,n){let a=0;for(let c=0;c<n;c++)a=a*256+t[e+c];return a}function _decodeChildren(t,e,n,a){const c=[];for(;n<e+1+a;){const o=_decode(t,n);c.push(o.result),n+=o.consumed,assert$f(n<=e+1+a,"child data too short","BUFFER_OVERRUN",{buffer:t,length:a,offset:e})}return{consumed:1+a,result:c}}function _decode(t,e){assert$f(t.length!==0,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const n=a=>{assert$f(a<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:a})};if(t[e]>=248){const a=t[e]-247;n(e+1+a);const c=unarrayifyInteger(t,e+1,a);return n(e+1+a+c),_decodeChildren(t,e,e+1+a,a+c)}else if(t[e]>=192){const a=t[e]-192;return n(e+1+a),_decodeChildren(t,e,e+1,a)}else if(t[e]>=184){const a=t[e]-183;n(e+1+a);const c=unarrayifyInteger(t,e+1,a);n(e+1+a+c);const o=hexlify(t.slice(e+1+a,e+1+a+c));return{consumed:1+a+c,result:o}}else if(t[e]>=128){const a=t[e]-128;n(e+1+a);const c=hexlify(t.slice(e+1,e+1+a));return{consumed:1+a,result:c}}return{consumed:1,result:hexlifyByte(t[e])}}function decodeRlp(t){const e=getBytes(t,"data"),n=_decode(e,0);return assertArgument(n.consumed===e.length,"unexpected junk after rlp payload","data",t),n.result}function arrayifyInteger(t){const e=[];for(;t;)e.unshift(t&255),t>>=8;return e}function _encode(t){if(Array.isArray(t)){let a=[];if(t.forEach(function(o){a=a.concat(_encode(o))}),a.length<=55)return a.unshift(192+a.length),a;const c=arrayifyInteger(a.length);return c.unshift(247+c.length),c.concat(a)}const e=Array.prototype.slice.call(getBytes(t,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const n=arrayifyInteger(e.length);return n.unshift(183+n.length),n.concat(e)}const nibbles="0123456789abcdef";function encodeRlp(t){let e="0x";for(const n of _encode(t))e+=nibbles[n>>4],e+=nibbles[n&15];return e}function uuidV4(t){const e=getBytes(t,"randomBytes");e[6]=e[6]&15|64,e[8]=e[8]&63|128;const n=hexlify(e);return[n.substring(2,10),n.substring(10,14),n.substring(14,18),n.substring(18,22),n.substring(22,34)].join("-")}const global$1=globalThis||void 0||self;function number(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function bytes(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function hash$4(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number(t.outputLen),number(t.blockLen)}function exists(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function output(t,e){bytes(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const crypto$2=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const u8a$1=t=>t instanceof Uint8Array,u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),rotr=(t,e)=>t<<32-e|t>>>e,isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!isLE)throw new Error("Non little-endian hardware is not supported");const nextTick=async()=>{};async function asyncLoop(t,e,n){let a=Date.now();for(let c=0;c<t;c++){n(c);const o=Date.now()-a;o>=0&&o<e||(await nextTick(),a+=o)}}function utf8ToBytes$1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function toBytes(t){if(typeof t=="string"&&(t=utf8ToBytes$1(t)),!u8a$1(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function concatBytes$1(...t){const e=new Uint8Array(t.reduce((a,c)=>a+c.length,0));let n=0;return t.forEach(a=>{if(!u8a$1(a))throw new Error("Uint8Array expected");e.set(a,n),n+=a.length}),e}class Hash{clone(){return this._cloneInto()}}const toStr={}.toString;function checkOpts(t,e){if(e!==void 0&&toStr.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function wrapConstructor(t){const e=a=>t().update(toBytes(a)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function randomBytes$2(t=32){if(crypto$2&&typeof crypto$2.getRandomValues=="function")return crypto$2.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class HMAC extends Hash{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,hash$4(e);const a=toBytes(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const c=this.blockLen,o=new Uint8Array(c);o.set(a.length>c?e.create().update(a).digest():a);for(let u=0;u<o.length;u++)o[u]^=54;this.iHash.update(o),this.oHash=e.create();for(let u=0;u<o.length;u++)o[u]^=106;this.oHash.update(o),o.fill(0)}update(e){return exists(this),this.iHash.update(e),this}digestInto(e){exists(this),bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:a,finished:c,destroyed:o,blockLen:u,outputLen:h}=this;return e=e,e.finished=c,e.destroyed=o,e.blockLen=u,e.outputLen=h,e.oHash=n._cloneInto(e.oHash),e.iHash=a._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac$1=(t,e,n)=>new HMAC(t,e).update(n).digest();hmac$1.create=(t,e)=>new HMAC(t,e);function pbkdf2Init(t,e,n,a){hash$4(t);const c=checkOpts({dkLen:32,asyncTick:10},a),{c:o,dkLen:u,asyncTick:h}=c;if(number(o),number(u),number(h),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=toBytes(e),b=toBytes(n),d=new Uint8Array(u),p=hmac$1.create(t,l),x=p._cloneInto().update(b);return{c:o,dkLen:u,asyncTick:h,DK:d,PRF:p,PRFSalt:x}}function pbkdf2Output(t,e,n,a,c){return t.destroy(),e.destroy(),a&&a.destroy(),c.fill(0),n}function pbkdf2$1(t,e,n,a){const{c,dkLen:o,DK:u,PRF:h,PRFSalt:l}=pbkdf2Init(t,e,n,a);let b;const d=new Uint8Array(4),p=createView(d),x=new Uint8Array(h.outputLen);for(let m=1,v=0;v<o;m++,v+=h.outputLen){const g=u.subarray(v,v+h.outputLen);p.setInt32(0,m,!1),(b=l._cloneInto(b)).update(d).digestInto(x),g.set(x.subarray(0,g.length));for(let $=1;$<c;$++){h._cloneInto(b).update(x).digestInto(x);for(let B=0;B<g.length;B++)g[B]^=x[B]}}return pbkdf2Output(h,l,u,b,x)}function setBigUint64(t,e,n,a){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,a);const c=BigInt(32),o=BigInt(4294967295),u=Number(n>>c&o),h=Number(n&o),l=a?4:0,b=a?0:4;t.setUint32(e+l,u,a),t.setUint32(e+b,h,a)}class SHA2 extends Hash{constructor(e,n,a,c){super(),this.blockLen=e,this.outputLen=n,this.padOffset=a,this.isLE=c,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){exists(this);const{view:n,buffer:a,blockLen:c}=this;e=toBytes(e);const o=e.length;for(let u=0;u<o;){const h=Math.min(c-this.pos,o-u);if(h===c){const l=createView(e);for(;c<=o-u;u+=c)this.process(l,u);continue}a.set(e.subarray(u,u+h),this.pos),this.pos+=h,u+=h,this.pos===c&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){exists(this),output(e,this),this.finished=!0;const{buffer:n,view:a,blockLen:c,isLE:o}=this;let{pos:u}=this;n[u++]=128,this.buffer.subarray(u).fill(0),this.padOffset>c-u&&(this.process(a,0),u=0);for(let p=u;p<c;p++)n[p]=0;setBigUint64(a,c-8,BigInt(this.length*8),o),this.process(a,0);const h=createView(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const b=l/4,d=this.get();if(b>d.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<b;p++)h.setUint32(4*p,d[p],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const a=e.slice(0,n);return this.destroy(),a}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:a,length:c,finished:o,destroyed:u,pos:h}=this;return e.length=c,e.pos=h,e.finished=o,e.destroyed=u,c%n&&e.buffer.set(a),e}}const Chi=(t,e,n)=>t&e^~t&n,Maj=(t,e,n)=>t&e^t&n^e&n,SHA256_K=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]),IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W=new Uint32Array(64);let SHA256$2=class extends SHA2{constructor(){super(64,32,8,!1),this.A=IV[0]|0,this.B=IV[1]|0,this.C=IV[2]|0,this.D=IV[3]|0,this.E=IV[4]|0,this.F=IV[5]|0,this.G=IV[6]|0,this.H=IV[7]|0}get(){const{A:e,B:n,C:a,D:c,E:o,F:u,G:h,H:l}=this;return[e,n,a,c,o,u,h,l]}set(e,n,a,c,o,u,h,l){this.A=e|0,this.B=n|0,this.C=a|0,this.D=c|0,this.E=o|0,this.F=u|0,this.G=h|0,this.H=l|0}process(e,n){for(let p=0;p<16;p++,n+=4)SHA256_W[p]=e.getUint32(n,!1);for(let p=16;p<64;p++){const x=SHA256_W[p-15],m=SHA256_W[p-2],v=rotr(x,7)^rotr(x,18)^x>>>3,g=rotr(m,17)^rotr(m,19)^m>>>10;SHA256_W[p]=g+SHA256_W[p-7]+v+SHA256_W[p-16]|0}let{A:a,B:c,C:o,D:u,E:h,F:l,G:b,H:d}=this;for(let p=0;p<64;p++){const x=rotr(h,6)^rotr(h,11)^rotr(h,25),m=d+x+Chi(h,l,b)+SHA256_K[p]+SHA256_W[p]|0,g=(rotr(a,2)^rotr(a,13)^rotr(a,22))+Maj(a,c,o)|0;d=b,b=l,l=h,h=u+m|0,u=o,o=c,c=a,a=m+g|0}a=a+this.A|0,c=c+this.B|0,o=o+this.C|0,u=u+this.D|0,h=h+this.E|0,l=l+this.F|0,b=b+this.G|0,d=d+this.H|0,this.set(a,c,o,u,h,l,b,d)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$3=wrapConstructor(()=>new SHA256$2),U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(t,e=!1){return e?{h:Number(t&U32_MASK64),l:Number(t>>_32n&U32_MASK64)}:{h:Number(t>>_32n&U32_MASK64)|0,l:Number(t&U32_MASK64)|0}}function split(t,e=!1){let n=new Uint32Array(t.length),a=new Uint32Array(t.length);for(let c=0;c<t.length;c++){const{h:o,l:u}=fromBig(t[c],e);[n[c],a[c]]=[o,u]}return[n,a]}const toBig=(t,e)=>BigInt(t>>>0)<<_32n|BigInt(e>>>0),shrSH=(t,e,n)=>t>>>n,shrSL=(t,e,n)=>t<<32-n|e>>>n,rotrSH=(t,e,n)=>t>>>n|e<<32-n,rotrSL=(t,e,n)=>t<<32-n|e>>>n,rotrBH=(t,e,n)=>t<<64-n|e>>>n-32,rotrBL=(t,e,n)=>t>>>n-32|e<<64-n,rotr32H=(t,e)=>e,rotr32L=(t,e)=>t,rotlSH=(t,e,n)=>t<<n|e>>>32-n,rotlSL=(t,e,n)=>e<<n|t>>>32-n,rotlBH=(t,e,n)=>e<<n-32|t>>>64-n,rotlBL=(t,e,n)=>t<<n-32|e>>>64-n;function add(t,e,n,a){const c=(e>>>0)+(a>>>0);return{h:t+n+(c/2**32|0)|0,l:c|0}}const add3L=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H=(t,e,n,a)=>e+n+a+(t/2**32|0)|0,add4L=(t,e,n,a)=>(t>>>0)+(e>>>0)+(n>>>0)+(a>>>0),add4H=(t,e,n,a,c)=>e+n+a+c+(t/2**32|0)|0,add5L=(t,e,n,a,c)=>(t>>>0)+(e>>>0)+(n>>>0)+(a>>>0)+(c>>>0),add5H=(t,e,n,a,c,o)=>e+n+a+c+o+(t/2**32|0)|0,u64={fromBig,split,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L},[SHA512_Kh,SHA512_Kl]=u64.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(t=>BigInt(t))),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);let SHA512$2=class extends SHA2{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(){const{Ah:e,Al:n,Bh:a,Bl:c,Ch:o,Cl:u,Dh:h,Dl:l,Eh:b,El:d,Fh:p,Fl:x,Gh:m,Gl:v,Hh:g,Hl:$}=this;return[e,n,a,c,o,u,h,l,b,d,p,x,m,v,g,$]}set(e,n,a,c,o,u,h,l,b,d,p,x,m,v,g,$){this.Ah=e|0,this.Al=n|0,this.Bh=a|0,this.Bl=c|0,this.Ch=o|0,this.Cl=u|0,this.Dh=h|0,this.Dl=l|0,this.Eh=b|0,this.El=d|0,this.Fh=p|0,this.Fl=x|0,this.Gh=m|0,this.Gl=v|0,this.Hh=g|0,this.Hl=$|0}process(e,n){for(let F=0;F<16;F++,n+=4)SHA512_W_H[F]=e.getUint32(n),SHA512_W_L[F]=e.getUint32(n+=4);for(let F=16;F<80;F++){const H=SHA512_W_H[F-15]|0,W=SHA512_W_L[F-15]|0,Z=u64.rotrSH(H,W,1)^u64.rotrSH(H,W,8)^u64.shrSH(H,W,7),ie=u64.rotrSL(H,W,1)^u64.rotrSL(H,W,8)^u64.shrSL(H,W,7),te=SHA512_W_H[F-2]|0,ae=SHA512_W_L[F-2]|0,de=u64.rotrSH(te,ae,19)^u64.rotrBH(te,ae,61)^u64.shrSH(te,ae,6),J=u64.rotrSL(te,ae,19)^u64.rotrBL(te,ae,61)^u64.shrSL(te,ae,6),R=u64.add4L(ie,J,SHA512_W_L[F-7],SHA512_W_L[F-16]),A=u64.add4H(R,Z,de,SHA512_W_H[F-7],SHA512_W_H[F-16]);SHA512_W_H[F]=A|0,SHA512_W_L[F]=R|0}let{Ah:a,Al:c,Bh:o,Bl:u,Ch:h,Cl:l,Dh:b,Dl:d,Eh:p,El:x,Fh:m,Fl:v,Gh:g,Gl:$,Hh:B,Hl:C}=this;for(let F=0;F<80;F++){const H=u64.rotrSH(p,x,14)^u64.rotrSH(p,x,18)^u64.rotrBH(p,x,41),W=u64.rotrSL(p,x,14)^u64.rotrSL(p,x,18)^u64.rotrBL(p,x,41),Z=p&m^~p&g,ie=x&v^~x&$,te=u64.add5L(C,W,ie,SHA512_Kl[F],SHA512_W_L[F]),ae=u64.add5H(te,B,H,Z,SHA512_Kh[F],SHA512_W_H[F]),de=te|0,J=u64.rotrSH(a,c,28)^u64.rotrBH(a,c,34)^u64.rotrBH(a,c,39),R=u64.rotrSL(a,c,28)^u64.rotrBL(a,c,34)^u64.rotrBL(a,c,39),A=a&o^a&h^o&h,y=c&u^c&l^u&l;B=g|0,C=$|0,g=m|0,$=v|0,m=p|0,v=x|0,{h:p,l:x}=u64.add(b|0,d|0,ae|0,de|0),b=h|0,d=l|0,h=o|0,l=u|0,o=a|0,u=c|0;const w=u64.add3L(de,R,y);a=u64.add3H(w,ae,J,A),c=w|0}({h:a,l:c}=u64.add(this.Ah|0,this.Al|0,a|0,c|0)),{h:o,l:u}=u64.add(this.Bh|0,this.Bl|0,o|0,u|0),{h,l}=u64.add(this.Ch|0,this.Cl|0,h|0,l|0),{h:b,l:d}=u64.add(this.Dh|0,this.Dl|0,b|0,d|0),{h:p,l:x}=u64.add(this.Eh|0,this.El|0,p|0,x|0),{h:m,l:v}=u64.add(this.Fh|0,this.Fl|0,m|0,v|0),{h:g,l:$}=u64.add(this.Gh|0,this.Gl|0,g|0,$|0),{h:B,l:C}=u64.add(this.Hh|0,this.Hl|0,B|0,C|0),this.set(a,c,o,u,h,l,b,d,p,x,m,v,g,$,B,C)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.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)}};const sha512$2=wrapConstructor(()=>new SHA512$2);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global$1<"u")return global$1;throw new Error("unable to locate global object")}const anyGlobal=getGlobal(),crypto$1=anyGlobal.crypto||anyGlobal.msCrypto;function createHash(t){switch(t){case"sha256":return sha256$3.create();case"sha512":return sha512$2.create()}assertArgument(!1,"invalid hashing algorithm name","algorithm",t)}function createHmac(t,e){const n={sha256:sha256$3,sha512:sha512$2}[t];return assertArgument(n!=null,"invalid hmac algorithm","algorithm",t),hmac$1.create(n,e)}function pbkdf2Sync(t,e,n,a,c){const o={sha256:sha256$3,sha512:sha512$2}[c];return assertArgument(o!=null,"invalid pbkdf2 algorithm","algorithm",c),pbkdf2$1(o,t,e,{c:n,dkLen:a})}function randomBytes$1(t){assert$f(crypto$1!=null,"platform does not support secure random numbers","UNSUPPORTED_OPERATION",{operation:"randomBytes"}),assertArgument(Number.isInteger(t)&&t>0&&t<=1024,"invalid length","length",t);const e=new Uint8Array(t);return crypto$1.getRandomValues(e),e}let locked$4=!1;const _computeHmac=function(t,e,n){return createHmac(t,e).update(n).digest()};let __computeHmac=_computeHmac;function computeHmac(t,e,n){const a=getBytes(e,"key"),c=getBytes(n,"data");return hexlify(__computeHmac(t,a,c))}computeHmac._=_computeHmac;computeHmac.lock=function(){locked$4=!0};computeHmac.register=function(t){if(locked$4)throw new Error("computeHmac is locked");__computeHmac=t};Object.freeze(computeHmac);const[SHA3_PI,SHA3_ROTL,_SHA3_IOTA]=[[],[],[]],_0n$4=BigInt(0),_1n$5=BigInt(1),_2n$3=BigInt(2),_7n=BigInt(7),_256n=BigInt(256),_0x71n=BigInt(113);for(let t=0,e=_1n$5,n=1,a=0;t<24;t++){[n,a]=[a,(2*n+3*a)%5],SHA3_PI.push(2*(5*a+n)),SHA3_ROTL.push((t+1)*(t+2)/2%64);let c=_0n$4;for(let o=0;o<7;o++)e=(e<<_1n$5^(e>>_7n)*_0x71n)%_256n,e&_2n$3&&(c^=_1n$5<<(_1n$5<<BigInt(o))-_1n$5);_SHA3_IOTA.push(c)}const[SHA3_IOTA_H,SHA3_IOTA_L]=split(_SHA3_IOTA,!0),rotlH=(t,e,n)=>n>32?rotlBH(t,e,n):rotlSH(t,e,n),rotlL=(t,e,n)=>n>32?rotlBL(t,e,n):rotlSL(t,e,n);function keccakP(t,e=24){const n=new Uint32Array(10);for(let a=24-e;a<24;a++){for(let u=0;u<10;u++)n[u]=t[u]^t[u+10]^t[u+20]^t[u+30]^t[u+40];for(let u=0;u<10;u+=2){const h=(u+8)%10,l=(u+2)%10,b=n[l],d=n[l+1],p=rotlH(b,d,1)^n[h],x=rotlL(b,d,1)^n[h+1];for(let m=0;m<50;m+=10)t[u+m]^=p,t[u+m+1]^=x}let c=t[2],o=t[3];for(let u=0;u<24;u++){const h=SHA3_ROTL[u],l=rotlH(c,o,h),b=rotlL(c,o,h),d=SHA3_PI[u];c=t[d],o=t[d+1],t[d]=l,t[d+1]=b}for(let u=0;u<50;u+=10){for(let h=0;h<10;h++)n[h]=t[u+h];for(let h=0;h<10;h++)t[u+h]^=~n[(h+2)%10]&n[(h+4)%10]}t[0]^=SHA3_IOTA_H[a],t[1]^=SHA3_IOTA_L[a]}n.fill(0)}class Keccak extends Hash{constructor(e,n,a,c=!1,o=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=a,this.enableXOF=c,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,number(a),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=u32(this.state)}keccak(){keccakP(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){exists(this);const{blockLen:n,state:a}=this;e=toBytes(e);const c=e.length;for(let o=0;o<c;){const u=Math.min(n-this.pos,c-o);for(let h=0;h<u;h++)a[this.pos++]^=e[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:a,blockLen:c}=this;e[a]^=n,n&128&&a===c-1&&this.keccak(),e[c-1]^=128,this.keccak()}writeInto(e){exists(this,!1),bytes(e),this.finish();const n=this.state,{blockLen:a}=this;for(let c=0,o=e.length;c<o;){this.posOut>=a&&this.keccak();const u=Math.min(a-this.posOut,o-c);e.set(n.subarray(this.posOut,this.posOut+u),c),this.posOut+=u,c+=u}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:n,suffix:a,outputLen:c,rounds:o,enableXOF:u}=this;return e||(e=new Keccak(n,a,c,u,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=a,e.outputLen=c,e.enableXOF=u,e.destroyed=this.destroyed,e}}const gen=(t,e,n)=>wrapConstructor(()=>new Keccak(e,t,n)),keccak_256=gen(1,136,256/8);let locked$3=!1;const _keccak256=function(t){return keccak_256(t)};let __keccak256=_keccak256;function keccak256(t){const e=getBytes(t,"data");return hexlify(__keccak256(e))}keccak256._=_keccak256;keccak256.lock=function(){locked$3=!0};keccak256.register=function(t){if(locked$3)throw new TypeError("keccak256 is locked");__keccak256=t};Object.freeze(keccak256);const Rho=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Id=Uint8Array.from({length:16},(t,e)=>e),Pi=Id.map(t=>(9*t+5)%16);let idxL=[Id],idxR=[Pi];for(let t=0;t<4;t++)for(let e of[idxL,idxR])e.push(e[t].map(n=>Rho[n]));const shifts=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),shiftsL=idxL.map((t,e)=>t.map(n=>shifts[e][n])),shiftsR=idxR.map((t,e)=>t.map(n=>shifts[e][n])),Kl=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),rotl$1=(t,e)=>t<<e|t>>>32-e;function f$1(t,e,n,a){return t===0?e^n^a:t===1?e&n|~e&a:t===2?(e|~n)^a:t===3?e&a|n&~a:e^(n|~a)}const BUF=new Uint32Array(16);let RIPEMD160$1=class extends SHA2{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:n,h2:a,h3:c,h4:o}=this;return[e,n,a,c,o]}set(e,n,a,c,o){this.h0=e|0,this.h1=n|0,this.h2=a|0,this.h3=c|0,this.h4=o|0}process(e,n){for(let m=0;m<16;m++,n+=4)BUF[m]=e.getUint32(n,!0);let a=this.h0|0,c=a,o=this.h1|0,u=o,h=this.h2|0,l=h,b=this.h3|0,d=b,p=this.h4|0,x=p;for(let m=0;m<5;m++){const v=4-m,g=Kl[m],$=Kr[m],B=idxL[m],C=idxR[m],F=shiftsL[m],H=shiftsR[m];for(let W=0;W<16;W++){const Z=rotl$1(a+f$1(m,o,h,b)+BUF[B[W]]+g,F[W])+p|0;a=p,p=b,b=rotl$1(h,10)|0,h=o,o=Z}for(let W=0;W<16;W++){const Z=rotl$1(c+f$1(v,u,l,d)+BUF[C[W]]+$,H[W])+x|0;c=x,x=d,d=rotl$1(l,10)|0,l=u,u=Z}}this.set(this.h1+h+d|0,this.h2+b+x|0,this.h3+p+c|0,this.h4+a+u|0,this.h0+o+l|0)}roundClean(){BUF.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const ripemd160$2=wrapConstructor(()=>new RIPEMD160$1);let locked$2=!1;const _ripemd160=function(t){return ripemd160$2(t)};let __ripemd160=_ripemd160;function ripemd160$1(t){const e=getBytes(t,"data");return hexlify(__ripemd160(e))}ripemd160$1._=_ripemd160;ripemd160$1.lock=function(){locked$2=!0};ripemd160$1.register=function(t){if(locked$2)throw new TypeError("ripemd160 is locked");__ripemd160=t};Object.freeze(ripemd160$1);let locked$1=!1;const _pbkdf2=function(t,e,n,a,c){return pbkdf2Sync(t,e,n,a,c)};let __pbkdf2=_pbkdf2;function pbkdf2(t,e,n,a,c){const o=getBytes(t,"password"),u=getBytes(e,"salt");return hexlify(__pbkdf2(o,u,n,a,c))}pbkdf2._=_pbkdf2;pbkdf2.lock=function(){locked$1=!0};pbkdf2.register=function(t){if(locked$1)throw new Error("pbkdf2 is locked");__pbkdf2=t};Object.freeze(pbkdf2);let locked=!1;const _randomBytes=function(t){return new Uint8Array(randomBytes$1(t))};let __randomBytes=_randomBytes;function randomBytes(t){return __randomBytes(t)}randomBytes._=_randomBytes;randomBytes.lock=function(){locked=!0};randomBytes.register=function(t){if(locked)throw new Error("randomBytes is locked");__randomBytes=t};Object.freeze(randomBytes);const rotl=(t,e)=>t<<e|t>>>32-e;function XorAndSalsa(t,e,n,a,c,o){let u=t[e++]^n[a++],h=t[e++]^n[a++],l=t[e++]^n[a++],b=t[e++]^n[a++],d=t[e++]^n[a++],p=t[e++]^n[a++],x=t[e++]^n[a++],m=t[e++]^n[a++],v=t[e++]^n[a++],g=t[e++]^n[a++],$=t[e++]^n[a++],B=t[e++]^n[a++],C=t[e++]^n[a++],F=t[e++]^n[a++],H=t[e++]^n[a++],W=t[e++]^n[a++],Z=u,ie=h,te=l,ae=b,de=d,J=p,R=x,A=m,y=v,w=g,I=$,M=B,k=C,P=F,_=H,q=W;for(let E=0;E<8;E+=2)de^=rotl(Z+k|0,7),y^=rotl(de+Z|0,9),k^=rotl(y+de|0,13),Z^=rotl(k+y|0,18),w^=rotl(J+ie|0,7),P^=rotl(w+J|0,9),ie^=rotl(P+w|0,13),J^=rotl(ie+P|0,18),_^=rotl(I+R|0,7),te^=rotl(_+I|0,9),R^=rotl(te+_|0,13),I^=rotl(R+te|0,18),ae^=rotl(q+M|0,7),A^=rotl(ae+q|0,9),M^=rotl(A+ae|0,13),q^=rotl(M+A|0,18),ie^=rotl(Z+ae|0,7),te^=rotl(ie+Z|0,9),ae^=rotl(te+ie|0,13),Z^=rotl(ae+te|0,18),R^=rotl(J+de|0,7),A^=rotl(R+J|0,9),de^=rotl(A+R|0,13),J^=rotl(de+A|0,18),M^=rotl(I+w|0,7),y^=rotl(M+I|0,9),w^=rotl(y+M|0,13),I^=rotl(w+y|0,18),k^=rotl(q+_|0,7),P^=rotl(k+q|0,9),_^=rotl(P+k|0,13),q^=rotl(_+P|0,18);c[o++]=u+Z|0,c[o++]=h+ie|0,c[o++]=l+te|0,c[o++]=b+ae|0,c[o++]=d+de|0,c[o++]=p+J|0,c[o++]=x+R|0,c[o++]=m+A|0,c[o++]=v+y|0,c[o++]=g+w|0,c[o++]=$+I|0,c[o++]=B+M|0,c[o++]=C+k|0,c[o++]=F+P|0,c[o++]=H+_|0,c[o++]=W+q|0}function BlockMix(t,e,n,a,c){let o=a+0,u=a+16*c;for(let h=0;h<16;h++)n[u+h]=t[e+(2*c-1)*16+h];for(let h=0;h<c;h++,o+=16,e+=16)XorAndSalsa(n,u,t,e,n,o),h>0&&(u+=16),XorAndSalsa(n,o,t,e+=16,n,u)}function scryptInit(t,e,n){const a=checkOpts({dkLen:32,asyncTick:10,maxmem:1073742848},n),{N:c,r:o,p:u,dkLen:h,asyncTick:l,maxmem:b,onProgress:d}=a;if(number(c),number(o),number(u),number(h),number(l),number(b),d!==void 0&&typeof d!="function")throw new Error("progressCb should be function");const p=128*o,x=p/4;if(c<=1||c&c-1||c>=2**(p/8)||c>2**32)throw new Error("Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32");if(u<0||u>(2**32-1)*32/p)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(h<0||h>(2**32-1)*32)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const m=p*(c+u);if(m>b)throw new Error(`Scrypt: parameters too large, ${m} (128 * r * (N + p)) > ${b} (maxmem)`);const v=pbkdf2$1(sha256$3,t,e,{c:1,dkLen:p*u}),g=u32(v),$=u32(new Uint8Array(p*c)),B=u32(new Uint8Array(p));let C=()=>{};if(d){const F=2*c*u,H=Math.max(Math.floor(F/1e4),1);let W=0;C=()=>{W++,d&&(!(W%H)||W===F)&&d(W/F)}}return{N:c,r:o,p:u,dkLen:h,blockSize32:x,V:$,B32:g,B:v,tmp:B,blockMixCb:C,asyncTick:l}}function scryptOutput(t,e,n,a,c){const o=pbkdf2$1(sha256$3,t,n,{c:1,dkLen:e});return n.fill(0),a.fill(0),c.fill(0),o}function scrypt$1(t,e,n){const{N:a,r:c,p:o,dkLen:u,blockSize32:h,V:l,B32:b,B:d,tmp:p,blockMixCb:x}=scryptInit(t,e,n);for(let m=0;m<o;m++){const v=h*m;for(let g=0;g<h;g++)l[g]=b[v+g];for(let g=0,$=0;g<a-1;g++)BlockMix(l,$,l,$+=h,c),x();BlockMix(l,(a-1)*h,b,v,c),x();for(let g=0;g<a;g++){const $=b[v+h-16]%a;for(let B=0;B<h;B++)p[B]=b[v+B]^l[$*h+B];BlockMix(p,0,b,v,c),x()}}return scryptOutput(t,u,d,l,p)}async function scryptAsync(t,e,n){const{N:a,r:c,p:o,dkLen:u,blockSize32:h,V:l,B32:b,B:d,tmp:p,blockMixCb:x,asyncTick:m}=scryptInit(t,e,n);for(let v=0;v<o;v++){const g=h*v;for(let B=0;B<h;B++)l[B]=b[g+B];let $=0;await asyncLoop(a-1,m,()=>{BlockMix(l,$,l,$+=h,c),x()}),BlockMix(l,(a-1)*h,b,g,c),x(),await asyncLoop(a,m,()=>{const B=b[g+h-16]%a;for(let C=0;C<h;C++)p[C]=b[g+C]^l[B*h+C];BlockMix(p,0,b,g,c),x()})}return scryptOutput(t,u,d,l,p)}let lockedSync=!1,lockedAsync=!1;const _scryptAsync=async function(t,e,n,a,c,o,u){return await scryptAsync(t,e,{N:n,r:a,p:c,dkLen:o,onProgress:u})},_scryptSync=function(t,e,n,a,c,o){return scrypt$1(t,e,{N:n,r:a,p:c,dkLen:o})};let __scryptAsync=_scryptAsync,__scryptSync=_scryptSync;async function scrypt(t,e,n,a,c,o,u){const h=getBytes(t,"passwd"),l=getBytes(e,"salt");return hexlify(await __scryptAsync(h,l,n,a,c,o,u))}scrypt._=_scryptAsync;scrypt.lock=function(){lockedAsync=!0};scrypt.register=function(t){if(lockedAsync)throw new Error("scrypt is locked");__scryptAsync=t};Object.freeze(scrypt);function scryptSync(t,e,n,a,c,o){const u=getBytes(t,"passwd"),h=getBytes(e,"salt");return hexlify(__scryptSync(u,h,n,a,c,o))}scryptSync._=_scryptSync;scryptSync.lock=function(){lockedSync=!0};scryptSync.register=function(t){if(lockedSync)throw new Error("scryptSync is locked");__scryptSync=t};Object.freeze(scryptSync);const _sha256=function(t){return createHash("sha256").update(t).digest()};let __sha256=_sha256,locked256=!1;function sha256$2(t){const e=getBytes(t,"data");return hexlify(__sha256(e))}sha256$2._=_sha256;sha256$2.lock=function(){locked256=!0};sha256$2.register=function(t){if(locked256)throw new Error("sha256 is locked");__sha256=t};Object.freeze(sha256$2);Object.freeze(sha256$2);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$3=BigInt(0),_1n$4=BigInt(1),_2n$2=BigInt(2),u8a=t=>t instanceof Uint8Array,hexes=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function bytesToHex$2(t){if(!u8a(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=hexes[t[n]];return e}function numberToHexUnpadded(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function hexToNumber(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function hexToBytes$1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let a=0;a<n.length;a++){const c=a*2,o=t.slice(c,c+2),u=Number.parseInt(o,16);if(Number.isNaN(u)||u<0)throw new Error("Invalid byte sequence");n[a]=u}return n}function bytesToNumberBE(t){return hexToNumber(bytesToHex$2(t))}function bytesToNumberLE(t){if(!u8a(t))throw new Error("Uint8Array expected");return hexToNumber(bytesToHex$2(Uint8Array.from(t).reverse()))}function numberToBytesBE(t,e){return hexToBytes$1(t.toString(16).padStart(e*2,"0"))}function numberToBytesLE(t,e){return numberToBytesBE(t,e).reverse()}function numberToVarBytesBE(t){return hexToBytes$1(numberToHexUnpadded(t))}function ensureBytes(t,e,n){let a;if(typeof e=="string")try{a=hexToBytes$1(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(u8a(e))a=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const c=a.length;if(typeof n=="number"&&c!==n)throw new Error(`${t} expected ${n} bytes, got ${c}`);return a}function concatBytes(...t){const e=new Uint8Array(t.reduce((a,c)=>a+c.length,0));let n=0;return t.forEach(a=>{if(!u8a(a))throw new Error("Uint8Array expected");e.set(a,n),n+=a.length}),e}function equalBytes$1(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function utf8ToBytes(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function bitLen(t){let e;for(e=0;t>_0n$3;t>>=_1n$4,e+=1);return e}function bitGet(t,e){return t>>BigInt(e)&_1n$4}const bitSet=(t,e,n)=>t|(n?_1n$4:_0n$3)<<BigInt(e),bitMask=t=>(_2n$2<<BigInt(t-1))-_1n$4,u8n=t=>new Uint8Array(t),u8fr=t=>Uint8Array.from(t);function createHmacDrbg(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let a=u8n(t),c=u8n(t),o=0;const u=()=>{a.fill(1),c.fill(0),o=0},h=(...p)=>n(c,a,...p),l=(p=u8n())=>{c=h(u8fr([0]),p),a=h(),p.length!==0&&(c=h(u8fr([1]),p),a=h())},b=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let p=0;const x=[];for(;p<e;){a=h();const m=a.slice();x.push(m),p+=a.length}return concatBytes(...x)};return(p,x)=>{u(),l(p);let m;for(;!(m=x(b()));)l();return u(),m}}const validatorFns={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function validateObject(t,e,n={}){const a=(c,o,u)=>{const h=validatorFns[o];if(typeof h!="function")throw new Error(`Invalid validator "${o}", expected function`);const l=t[c];if(!(u&&l===void 0)&&!h(l,t))throw new Error(`Invalid param ${String(c)}=${l} (${typeof l}), expected ${o}`)};for(const[c,o]of Object.entries(e))a(c,o,!1);for(const[c,o]of Object.entries(n))a(c,o,!0);return t}const ut=Object.freeze(Object.defineProperty({__proto__:null,bitGet,bitLen,bitMask,bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE,bytesToNumberLE,concatBytes,createHmacDrbg,ensureBytes,equalBytes:equalBytes$1,hexToBytes:hexToBytes$1,hexToNumber,numberToBytesBE,numberToBytesLE,numberToHexUnpadded,numberToVarBytesBE,utf8ToBytes,validateObject},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_4n=BigInt(4),_5n=BigInt(5),_8n=BigInt(8);BigInt(9);BigInt(16);function mod(t,e){const n=t%e;return n>=_0n$2?n:e+n}function pow(t,e,n){if(n<=_0n$2||e<_0n$2)throw new Error("Expected power/modulo > 0");if(n===_1n$3)return _0n$2;let a=_1n$3;for(;e>_0n$2;)e&_1n$3&&(a=a*t%n),t=t*t%n,e>>=_1n$3;return a}function pow2(t,e,n){let a=t;for(;e-- >_0n$2;)a*=a,a%=n;return a}function invert(t,e){if(t===_0n$2||e<=_0n$2)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=mod(t,e),a=e,c=_0n$2,o=_1n$3;for(;n!==_0n$2;){const h=a/n,l=a%n,b=c-o*h;a=n,n=l,c=o,o=b}if(a!==_1n$3)throw new Error("invert: does not exist");return mod(c,e)}function tonelliShanks(t){const e=(t-_1n$3)/_2n$1;let n,a,c;for(n=t-_1n$3,a=0;n%_2n$1===_0n$2;n/=_2n$1,a++);for(c=_2n$1;c<t&&pow(c,e,t)!==t-_1n$3;c++);if(a===1){const u=(t+_1n$3)/_4n;return function(l,b){const d=l.pow(b,u);if(!l.eql(l.sqr(d),b))throw new Error("Cannot find square root");return d}}const o=(n+_1n$3)/_2n$1;return function(h,l){if(h.pow(l,e)===h.neg(h.ONE))throw new Error("Cannot find square root");let b=a,d=h.pow(h.mul(h.ONE,c),n),p=h.pow(l,o),x=h.pow(l,n);for(;!h.eql(x,h.ONE);){if(h.eql(x,h.ZERO))return h.ZERO;let m=1;for(let g=h.sqr(x);m<b&&!h.eql(g,h.ONE);m++)g=h.sqr(g);const v=h.pow(d,_1n$3<<BigInt(b-m-1));d=h.sqr(v),p=h.mul(p,v),x=h.mul(x,d),b=m}return p}}function FpSqrt(t){if(t%_4n===_3n$1){const e=(t+_1n$3)/_4n;return function(a,c){const o=a.pow(c,e);if(!a.eql(a.sqr(o),c))throw new Error("Cannot find square root");return o}}if(t%_8n===_5n){const e=(t-_5n)/_8n;return function(a,c){const o=a.mul(c,_2n$1),u=a.pow(o,e),h=a.mul(c,u),l=a.mul(a.mul(h,_2n$1),u),b=a.mul(h,a.sub(l,a.ONE));if(!a.eql(a.sqr(b),c))throw new Error("Cannot find square root");return b}}return tonelliShanks(t)}const FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=FIELD_FIELDS.reduce((a,c)=>(a[c]="function",a),e);return validateObject(t,n)}function FpPow(t,e,n){if(n<_0n$2)throw new Error("Expected power > 0");if(n===_0n$2)return t.ONE;if(n===_1n$3)return e;let a=t.ONE,c=e;for(;n>_0n$2;)n&_1n$3&&(a=t.mul(a,c)),c=t.sqr(c),n>>=_1n$3;return a}function FpInvertBatch(t,e){const n=new Array(e.length),a=e.reduce((o,u,h)=>t.is0(u)?o:(n[h]=o,t.mul(o,u)),t.ONE),c=t.inv(a);return e.reduceRight((o,u,h)=>t.is0(u)?o:(n[h]=t.mul(o,n[h]),t.mul(o,u)),c),n}function nLength(t,e){const n=e!==void 0?e:t.toString(2).length,a=Math.ceil(n/8);return{nBitLength:n,nByteLength:a}}function Field(t,e,n=!1,a={}){if(t<=_0n$2)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:c,nByteLength:o}=nLength(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const u=FpSqrt(t),h=Object.freeze({ORDER:t,BITS:c,BYTES:o,MASK:bitMask(c),ZERO:_0n$2,ONE:_1n$3,create:l=>mod(l,t),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return _0n$2<=l&&l<t},is0:l=>l===_0n$2,isOdd:l=>(l&_1n$3)===_1n$3,neg:l=>mod(-l,t),eql:(l,b)=>l===b,sqr:l=>mod(l*l,t),add:(l,b)=>mod(l+b,t),sub:(l,b)=>mod(l-b,t),mul:(l,b)=>mod(l*b,t),pow:(l,b)=>FpPow(h,l,b),div:(l,b)=>mod(l*invert(b,t),t),sqrN:l=>l*l,addN:(l,b)=>l+b,subN:(l,b)=>l-b,mulN:(l,b)=>l*b,inv:l=>invert(l,t),sqrt:a.sqrt||(l=>u(h,l)),invertBatch:l=>FpInvertBatch(h,l),cmov:(l,b,d)=>d?b:l,toBytes:l=>n?numberToBytesLE(l,o):numberToBytesBE(l,o),fromBytes:l=>{if(l.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${l.length}`);return n?bytesToNumberLE(l):bytesToNumberBE(l)}});return Object.freeze(h)}function getFieldBytesLength(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function getMinHashLength(t){const e=getFieldBytesLength(t);return e+Math.ceil(e/2)}function mapHashToField(t,e,n=!1){const a=t.length,c=getFieldBytesLength(e),o=getMinHashLength(e);if(a<16||a<o||a>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${a}`);const u=n?bytesToNumberBE(t):bytesToNumberLE(t),h=mod(u,e-_1n$3)+_1n$3;return n?numberToBytesLE(h,c):numberToBytesBE(h,c)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1);function wNAF(t,e){const n=(c,o)=>{const u=o.negate();return c?u:o},a=c=>{const o=Math.ceil(e/c)+1,u=2**(c-1);return{windows:o,windowSize:u}};return{constTimeNegate:n,unsafeLadder(c,o){let u=t.ZERO,h=c;for(;o>_0n$1;)o&_1n$2&&(u=u.add(h)),h=h.double(),o>>=_1n$2;return u},precomputeWindow(c,o){const{windows:u,windowSize:h}=a(o),l=[];let b=c,d=b;for(let p=0;p<u;p++){d=b,l.push(d);for(let x=1;x<h;x++)d=d.add(b),l.push(d);b=d.double()}return l},wNAF(c,o,u){const{windows:h,windowSize:l}=a(c);let b=t.ZERO,d=t.BASE;const p=BigInt(2**c-1),x=2**c,m=BigInt(c);for(let v=0;v<h;v++){const g=v*l;let $=Number(u&p);u>>=m,$>l&&($-=x,u+=_1n$2);const B=g,C=g+Math.abs($)-1,F=v%2!==0,H=$<0;$===0?d=d.add(n(F,o[B])):b=b.add(n(H,o[C]))}return{p:b,f:d}},wNAFCached(c,o,u,h){const l=c._WINDOW_SIZE||1;let b=o.get(c);return b||(b=this.precomputeWindow(c,l),l!==1&&o.set(c,h(b))),this.wNAF(l,b,u)}}}function validateBasic(t){return validateField(t.Fp),validateObject(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(t){const e=validateBasic(t);validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:a,a:c}=e;if(n){if(!a.eql(c,a.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:b2n,hexToBytes:h2b}=ut,DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=DER;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],a=t.subarray(2,n+2);if(!n||a.length!==n)throw new e("Invalid signature integer: wrong length");if(a[0]&128)throw new e("Invalid signature integer: negative");if(a[0]===0&&!(a[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:b2n(a),l:t.subarray(n+2)}},toSig(t){const{Err:e}=DER,n=typeof t=="string"?h2b(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let a=n.length;if(a<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==a-2)throw new e("Invalid signature: incorrect length");const{d:c,l:o}=DER._parseInt(n.subarray(2)),{d:u,l:h}=DER._parseInt(o);if(h.length)throw new e("Invalid signature: left bytes after parsing");return{r:c,s:u}},hexFromSig(t){const e=b=>Number.parseInt(b[0],16)&8?"00"+b:b,n=b=>{const d=b.toString(16);return d.length&1?`0${d}`:d},a=e(n(t.s)),c=e(n(t.r)),o=a.length/2,u=c.length/2,h=n(o),l=n(u);return`30${n(u+o+4)}02${l}${c}02${h}${a}`}},_0n=BigInt(0),_1n$1=BigInt(1);BigInt(2);const _3n=BigInt(3);BigInt(4);function weierstrassPoints(t){const e=validatePointOpts(t),{Fp:n}=e,a=e.toBytes||((v,g,$)=>{const B=g.toAffine();return concatBytes(Uint8Array.from([4]),n.toBytes(B.x),n.toBytes(B.y))}),c=e.fromBytes||(v=>{const g=v.subarray(1),$=n.fromBytes(g.subarray(0,n.BYTES)),B=n.fromBytes(g.subarray(n.BYTES,2*n.BYTES));return{x:$,y:B}});function o(v){const{a:g,b:$}=e,B=n.sqr(v),C=n.mul(B,v);return n.add(n.add(C,n.mul(v,g)),$)}if(!n.eql(n.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function u(v){return typeof v=="bigint"&&_0n<v&&v<e.n}function h(v){if(!u(v))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(v){const{allowedPrivateKeyLengths:g,nByteLength:$,wrapPrivateKey:B,n:C}=e;if(g&&typeof v!="bigint"){if(v instanceof Uint8Array&&(v=bytesToHex$2(v)),typeof v!="string"||!g.includes(v.length))throw new Error("Invalid key");v=v.padStart($*2,"0")}let F;try{F=typeof v=="bigint"?v:bytesToNumberBE(ensureBytes("private key",v,$))}catch{throw new Error(`private key must be ${$} bytes, hex or bigint, not ${typeof v}`)}return B&&(F=mod(F,C)),h(F),F}const b=new Map;function d(v){if(!(v instanceof p))throw new Error("ProjectivePoint expected")}class p{constructor(g,$,B){if(this.px=g,this.py=$,this.pz=B,g==null||!n.isValid(g))throw new Error("x required");if($==null||!n.isValid($))throw new Error("y required");if(B==null||!n.isValid(B))throw new Error("z required")}static fromAffine(g){const{x:$,y:B}=g||{};if(!g||!n.isValid($)||!n.isValid(B))throw new Error("invalid affine point");if(g instanceof p)throw new Error("projective point not allowed");const C=F=>n.eql(F,n.ZERO);return C($)&&C(B)?p.ZERO:new p($,B,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const $=n.invertBatch(g.map(B=>B.pz));return g.map((B,C)=>B.toAffine($[C])).map(p.fromAffine)}static fromHex(g){const $=p.fromAffine(c(ensureBytes("pointHex",g)));return $.assertValidity(),$}static fromPrivateKey(g){return p.BASE.multiply(l(g))}_setWindowSize(g){this._WINDOW_SIZE=g,b.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:g,y:$}=this.toAffine();if(!n.isValid(g)||!n.isValid($))throw new Error("bad point: x or y not FE");const B=n.sqr($),C=o(g);if(!n.eql(B,C))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:g}=this.toAffine();if(n.isOdd)return!n.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){d(g);const{px:$,py:B,pz:C}=this,{px:F,py:H,pz:W}=g,Z=n.eql(n.mul($,W),n.mul(F,C)),ie=n.eql(n.mul(B,W),n.mul(H,C));return Z&&ie}negate(){return new p(this.px,n.neg(this.py),this.pz)}double(){const{a:g,b:$}=e,B=n.mul($,_3n),{px:C,py:F,pz:H}=this;let W=n.ZERO,Z=n.ZERO,ie=n.ZERO,te=n.mul(C,C),ae=n.mul(F,F),de=n.mul(H,H),J=n.mul(C,F);return J=n.add(J,J),ie=n.mul(C,H),ie=n.add(ie,ie),W=n.mul(g,ie),Z=n.mul(B,de),Z=n.add(W,Z),W=n.sub(ae,Z),Z=n.add(ae,Z),Z=n.mul(W,Z),W=n.mul(J,W),ie=n.mul(B,ie),de=n.mul(g,de),J=n.sub(te,de),J=n.mul(g,J),J=n.add(J,ie),ie=n.add(te,te),te=n.add(ie,te),te=n.add(te,de),te=n.mul(te,J),Z=n.add(Z,te),de=n.mul(F,H),de=n.add(de,de),te=n.mul(de,J),W=n.sub(W,te),ie=n.mul(de,ae),ie=n.add(ie,ie),ie=n.add(ie,ie),new p(W,Z,ie)}add(g){d(g);const{px:$,py:B,pz:C}=this,{px:F,py:H,pz:W}=g;let Z=n.ZERO,ie=n.ZERO,te=n.ZERO;const ae=e.a,de=n.mul(e.b,_3n);let J=n.mul($,F),R=n.mul(B,H),A=n.mul(C,W),y=n.add($,B),w=n.add(F,H);y=n.mul(y,w),w=n.add(J,R),y=n.sub(y,w),w=n.add($,C);let I=n.add(F,W);return w=n.mul(w,I),I=n.add(J,A),w=n.sub(w,I),I=n.add(B,C),Z=n.add(H,W),I=n.mul(I,Z),Z=n.add(R,A),I=n.sub(I,Z),te=n.mul(ae,w),Z=n.mul(de,A),te=n.add(Z,te),Z=n.sub(R,te),te=n.add(R,te),ie=n.mul(Z,te),R=n.add(J,J),R=n.add(R,J),A=n.mul(ae,A),w=n.mul(de,w),R=n.add(R,A),A=n.sub(J,A),A=n.mul(ae,A),w=n.add(w,A),J=n.mul(R,w),ie=n.add(ie,J),J=n.mul(I,w),Z=n.mul(y,Z),Z=n.sub(Z,J),J=n.mul(y,R),te=n.mul(I,te),te=n.add(te,J),new p(Z,ie,te)}subtract(g){return this.add(g.negate())}is0(){return this.equals(p.ZERO)}wNAF(g){return m.wNAFCached(this,b,g,$=>{const B=n.invertBatch($.map(C=>C.pz));return $.map((C,F)=>C.toAffine(B[F])).map(p.fromAffine)})}multiplyUnsafe(g){const $=p.ZERO;if(g===_0n)return $;if(h(g),g===_1n$1)return this;const{endo:B}=e;if(!B)return m.unsafeLadder(this,g);let{k1neg:C,k1:F,k2neg:H,k2:W}=B.splitScalar(g),Z=$,ie=$,te=this;for(;F>_0n||W>_0n;)F&_1n$1&&(Z=Z.add(te)),W&_1n$1&&(ie=ie.add(te)),te=te.double(),F>>=_1n$1,W>>=_1n$1;return C&&(Z=Z.negate()),H&&(ie=ie.negate()),ie=new p(n.mul(ie.px,B.beta),ie.py,ie.pz),Z.add(ie)}multiply(g){h(g);let $=g,B,C;const{endo:F}=e;if(F){const{k1neg:H,k1:W,k2neg:Z,k2:ie}=F.splitScalar($);let{p:te,f:ae}=this.wNAF(W),{p:de,f:J}=this.wNAF(ie);te=m.constTimeNegate(H,te),de=m.constTimeNegate(Z,de),de=new p(n.mul(de.px,F.beta),de.py,de.pz),B=te.add(de),C=ae.add(J)}else{const{p:H,f:W}=this.wNAF($);B=H,C=W}return p.normalizeZ([B,C])[0]}multiplyAndAddUnsafe(g,$,B){const C=p.BASE,F=(W,Z)=>Z===_0n||Z===_1n$1||!W.equals(C)?W.multiplyUnsafe(Z):W.multiply(Z),H=F(this,$).add(F(g,B));return H.is0()?void 0:H}toAffine(g){const{px:$,py:B,pz:C}=this,F=this.is0();g==null&&(g=F?n.ONE:n.inv(C));const H=n.mul($,g),W=n.mul(B,g),Z=n.mul(C,g);if(F)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Z,n.ONE))throw new Error("invZ was invalid");return{x:H,y:W}}isTorsionFree(){const{h:g,isTorsionFree:$}=e;if(g===_1n$1)return!0;if($)return $(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:$}=e;return g===_1n$1?this:$?$(p,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return this.assertValidity(),a(p,this,g)}toHex(g=!0){return bytesToHex$2(this.toRawBytes(g))}}p.BASE=new p(e.Gx,e.Gy,n.ONE),p.ZERO=new p(n.ZERO,n.ONE,n.ZERO);const x=e.nBitLength,m=wNAF(p,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:u}}function validateOpts(t){const e=validateBasic(t);return validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function weierstrass(t){const e=validateOpts(t),{Fp:n,n:a}=e,c=n.BYTES+1,o=2*n.BYTES+1;function u(w){return _0n<w&&w<n.ORDER}function h(w){return mod(w,a)}function l(w){return invert(w,a)}const{ProjectivePoint:b,normPrivateKeyToScalar:d,weierstrassEquation:p,isWithinCurveOrder:x}=weierstrassPoints({...e,toBytes(w,I,M){const k=I.toAffine(),P=n.toBytes(k.x),_=concatBytes;return M?_(Uint8Array.from([I.hasEvenY()?2:3]),P):_(Uint8Array.from([4]),P,n.toBytes(k.y))},fromBytes(w){const I=w.length,M=w[0],k=w.subarray(1);if(I===c&&(M===2||M===3)){const P=bytesToNumberBE(k);if(!u(P))throw new Error("Point is not on curve");const _=p(P);let q=n.sqrt(_);const E=(q&_1n$1)===_1n$1;return(M&1)===1!==E&&(q=n.neg(q)),{x:P,y:q}}else if(I===o&&M===4){const P=n.fromBytes(k.subarray(0,n.BYTES)),_=n.fromBytes(k.subarray(n.BYTES,2*n.BYTES));return{x:P,y:_}}else throw new Error(`Point of length ${I} was invalid. Expected ${c} compressed bytes or ${o} uncompressed bytes`)}}),m=w=>bytesToHex$2(numberToBytesBE(w,e.nByteLength));function v(w){const I=a>>_1n$1;return w>I}function g(w){return v(w)?h(-w):w}const $=(w,I,M)=>bytesToNumberBE(w.slice(I,M));class B{constructor(I,M,k){this.r=I,this.s=M,this.recovery=k,this.assertValidity()}static fromCompact(I){const M=e.nByteLength;return I=ensureBytes("compactSignature",I,M*2),new B($(I,0,M),$(I,M,2*M))}static fromDER(I){const{r:M,s:k}=DER.toSig(ensureBytes("DER",I));return new B(M,k)}assertValidity(){if(!x(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!x(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(I){return new B(this.r,this.s,I)}recoverPublicKey(I){const{r:M,s:k,recovery:P}=this,_=ie(ensureBytes("msgHash",I));if(P==null||![0,1,2,3].includes(P))throw new Error("recovery id invalid");const q=P===2||P===3?M+e.n:M;if(q>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const E=P&1?"03":"02",j=b.fromHex(E+m(q)),ee=l(q),oe=h(-_*ee),Y=h(k*ee),L=b.BASE.multiplyAndAddUnsafe(j,oe,Y);if(!L)throw new Error("point at infinify");return L.assertValidity(),L}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new B(this.r,h(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$1(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$1(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}const C={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const w=getMinHashLength(e.n);return mapHashToField(e.randomBytes(w),e.n)},precompute(w=8,I=b.BASE){return I._setWindowSize(w),I.multiply(BigInt(3)),I}};function F(w,I=!0){return b.fromPrivateKey(w).toRawBytes(I)}function H(w){const I=w instanceof Uint8Array,M=typeof w=="string",k=(I||M)&&w.length;return I?k===c||k===o:M?k===2*c||k===2*o:w instanceof b}function W(w,I,M=!0){if(H(w))throw new Error("first arg must be private key");if(!H(I))throw new Error("second arg must be public key");return b.fromHex(I).multiply(d(w)).toRawBytes(M)}const Z=e.bits2int||function(w){const I=bytesToNumberBE(w),M=w.length*8-e.nBitLength;return M>0?I>>BigInt(M):I},ie=e.bits2int_modN||function(w){return h(Z(w))},te=bitMask(e.nBitLength);function ae(w){if(typeof w!="bigint")throw new Error("bigint expected");if(!(_0n<=w&&w<te))throw new Error(`bigint expected < 2^${e.nBitLength}`);return numberToBytesBE(w,e.nByteLength)}function de(w,I,M=J){if(["recovered","canonical"].some(re=>re in M))throw new Error("sign() legacy options not supported");const{hash:k,randomBytes:P}=e;let{lowS:_,prehash:q,extraEntropy:E}=M;_==null&&(_=!0),w=ensureBytes("msgHash",w),q&&(w=ensureBytes("prehashed msgHash",k(w)));const j=ie(w),ee=d(I),oe=[ae(ee),ae(j)];if(E!=null){const re=E===!0?P(n.BYTES):E;oe.push(ensureBytes("extraEntropy",re))}const Y=concatBytes(...oe),L=j;function z(re){const D=Z(re);if(!x(D))return;const G=l(D),U=b.BASE.multiply(D).toAffine(),Q=h(U.x);if(Q===_0n)return;const fe=h(G*h(L+Q*ee));if(fe===_0n)return;let he=(U.x===Q?0:2)|Number(U.y&_1n$1),le=fe;return _&&v(fe)&&(le=g(fe),he^=1),new B(Q,le,he)}return{seed:Y,k2sig:z}}const J={lowS:e.lowS,prehash:!1},R={lowS:e.lowS,prehash:!1};function A(w,I,M=J){const{seed:k,k2sig:P}=de(w,I,M),_=e;return createHmacDrbg(_.hash.outputLen,_.nByteLength,_.hmac)(k,P)}b.BASE._setWindowSize(8);function y(w,I,M,k=R){var U;const P=w;if(I=ensureBytes("msgHash",I),M=ensureBytes("publicKey",M),"strict"in k)throw new Error("options.strict was renamed to lowS");const{lowS:_,prehash:q}=k;let E,j;try{if(typeof P=="string"||P instanceof Uint8Array)try{E=B.fromDER(P)}catch(Q){if(!(Q instanceof DER.Err))throw Q;E=B.fromCompact(P)}else if(typeof P=="object"&&typeof P.r=="bigint"&&typeof P.s=="bigint"){const{r:Q,s:fe}=P;E=new B(Q,fe)}else throw new Error("PARSE");j=b.fromHex(M)}catch(Q){if(Q.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(_&&E.hasHighS())return!1;q&&(I=e.hash(I));const{r:ee,s:oe}=E,Y=ie(I),L=l(oe),z=h(Y*L),re=h(ee*L),D=(U=b.BASE.multiplyAndAddUnsafe(j,z,re))==null?void 0:U.toAffine();return D?h(D.x)===ee:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:W,sign:A,verify:y,ProjectivePoint:b,Signature:B,utils:C}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(t){return{hash:t,hmac:(e,...n)=>hmac$1(t,e,concatBytes$1(...n)),randomBytes:randomBytes$2}}function createCurve(t,e){const n=a=>weierstrass({...t,...getHash(a)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n=BigInt(1),_2n=BigInt(2),divNearest=(t,e)=>(t+e/_2n)/e;function sqrtMod(t){const e=secp256k1P,n=BigInt(3),a=BigInt(6),c=BigInt(11),o=BigInt(22),u=BigInt(23),h=BigInt(44),l=BigInt(88),b=t*t*t%e,d=b*b*t%e,p=pow2(d,n,e)*d%e,x=pow2(p,n,e)*d%e,m=pow2(x,_2n,e)*b%e,v=pow2(m,c,e)*m%e,g=pow2(v,o,e)*v%e,$=pow2(g,h,e)*g%e,B=pow2($,l,e)*$%e,C=pow2(B,h,e)*g%e,F=pow2(C,n,e)*d%e,H=pow2(F,u,e)*v%e,W=pow2(H,a,e)*b%e,Z=pow2(W,_2n,e);if(!Fp.eql(Fp.sqr(Z),t))throw new Error("Cannot find square root");return Z}const Fp=Field(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1$1=createCurve({a:BigInt(0),b:BigInt(7),Fp,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=secp256k1N,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),a=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),c=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,u=BigInt("0x100000000000000000000000000000000"),h=divNearest(o*t,e),l=divNearest(-a*t,e);let b=mod(t-h*n-l*c,e),d=mod(-h*a-l*o,e);const p=b>u,x=d>u;if(p&&(b=e-b),x&&(d=e-d),b>u||d>u)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:p,k1:b,k2neg:x,k2:d}}}},sha256$3);BigInt(0);secp256k1$1.ProjectivePoint;const ZeroAddress="0x0000000000000000000000000000000000000000",ZeroHash="0x0000000000000000000000000000000000000000000000000000000000000000",MessagePrefix=`Ethereum Signed Message:
2
- `,BN_0$3=BigInt(0),BN_1$1=BigInt(1),BN_2$1=BigInt(2),BN_27$1=BigInt(27),BN_28$1=BigInt(28),BN_35$1=BigInt(35),_guard$2={};function toUint256(t){return zeroPadValue(toBeArray(t),32)}var Dt,Lt,Ft,qt,nt;let Signature$3=(nt=class{constructor(e,n,a,c){Le(this,Dt);Le(this,Lt);Le(this,Ft);Le(this,qt);assertPrivate(e,_guard$2,"Signature"),we(this,Dt,n),we(this,Lt,a),we(this,Ft,c),we(this,qt,null)}get r(){return Re(this,Dt)}set r(e){assertArgument(dataLength(e)===32,"invalid r","value",e),we(this,Dt,hexlify(e))}get s(){return Re(this,Lt)}set s(e){assertArgument(dataLength(e)===32,"invalid s","value",e);const n=hexlify(e);assertArgument(parseInt(n.substring(0,3))<8,"non-canonical s","value",n),we(this,Lt,n)}get v(){return Re(this,Ft)}set v(e){const n=getNumber(e,"value");assertArgument(n===27||n===28,"invalid v","v",e),we(this,Ft,n)}get networkV(){return Re(this,qt)}get legacyChainId(){const e=this.networkV;return e==null?null:nt.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=getBytes(this.s);return this.yParity&&(e[0]|=128),hexlify(e)}get compactSerialized(){return concat([this.r,this.yParityAndS])}get serialized(){return concat([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new nt(_guard$2,this.r,this.s,this.v);return this.networkV&&we(e,qt,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const n=getBigInt(e,"v");return n==BN_27$1||n==BN_28$1?BN_0$3:(assertArgument(n>=BN_35$1,"invalid EIP-155 v","v",e),(n-BN_35$1)/BN_2$1)}static getChainIdV(e,n){return getBigInt(e)*BN_2$1+BigInt(35+n-27)}static getNormalizedV(e){const n=getBigInt(e);return n===BN_0$3||n===BN_27$1?27:n===BN_1$1||n===BN_28$1?28:(assertArgument(n>=BN_35$1,"invalid v","v",e),n&BN_1$1?27:28)}static from(e){function n(b,d){assertArgument(b,d,"signature",e)}if(e==null)return new nt(_guard$2,ZeroHash,ZeroHash,27);if(typeof e=="string"){const b=getBytes(e,"signature");if(b.length===64){const d=hexlify(b.slice(0,32)),p=b.slice(32,64),x=p[0]&128?28:27;return p[0]&=127,new nt(_guard$2,d,hexlify(p),x)}if(b.length===65){const d=hexlify(b.slice(0,32)),p=b.slice(32,64);n((p[0]&128)===0,"non-canonical s");const x=nt.getNormalizedV(b[64]);return new nt(_guard$2,d,hexlify(p),x)}n(!1,"invalid raw signature length")}if(e instanceof nt)return e.clone();const a=e.r;n(a!=null,"missing r");const c=toUint256(a),o=function(b,d){if(b!=null)return toUint256(b);if(d!=null){n(isHexString$1(d,32),"invalid yParityAndS");const p=getBytes(d);return p[0]&=127,hexlify(p)}n(!1,"missing s")}(e.s,e.yParityAndS);n((getBytes(o)[0]&128)==0,"non-canonical s");const{networkV:u,v:h}=function(b,d,p){if(b!=null){const x=getBigInt(b);return{networkV:x>=BN_35$1?x:void 0,v:nt.getNormalizedV(x)}}if(d!=null)return n(isHexString$1(d,32),"invalid yParityAndS"),{v:getBytes(d)[0]&128?28:27};if(p!=null){switch(getNumber(p,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}n(!1,"invalid yParity")}n(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new nt(_guard$2,c,o,h);return u&&we(l,qt,u),n(e.yParity==null||getNumber(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),n(e.yParityAndS==null||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}},Dt=new WeakMap,Lt=new WeakMap,Ft=new WeakMap,qt=new WeakMap,nt);var gt;const Tt=class Tt{constructor(e){Le(this,gt);assertArgument(dataLength(e)===32,"invalid private key","privateKey","[REDACTED]"),we(this,gt,hexlify(e))}get privateKey(){return Re(this,gt)}get publicKey(){return Tt.computePublicKey(Re(this,gt))}get compressedPublicKey(){return Tt.computePublicKey(Re(this,gt),!0)}sign(e){assertArgument(dataLength(e)===32,"invalid digest length","digest",e);const n=secp256k1$1.sign(getBytesCopy(e),getBytesCopy(Re(this,gt)),{lowS:!0});return Signature$3.from({r:toBeHex(n.r,32),s:toBeHex(n.s,32),v:n.recovery?28:27})}computeSharedSecret(e){const n=Tt.computePublicKey(e);return hexlify(secp256k1$1.getSharedSecret(getBytesCopy(Re(this,gt)),getBytes(n),!1))}static computePublicKey(e,n){let a=getBytes(e,"key");if(a.length===32){const o=secp256k1$1.getPublicKey(a,!!n);return hexlify(o)}if(a.length===64){const o=new Uint8Array(65);o[0]=4,o.set(a,1),a=o}const c=secp256k1$1.ProjectivePoint.fromHex(a);return hexlify(c.toRawBytes(n))}static recoverPublicKey(e,n){assertArgument(dataLength(e)===32,"invalid digest length","digest",e);const a=Signature$3.from(n);let c=secp256k1$1.Signature.fromCompact(getBytesCopy(concat([a.r,a.s])));c=c.addRecoveryBit(a.yParity);const o=c.recoverPublicKey(getBytesCopy(e));return assertArgument(o!=null,"invalid signautre for digest","signature",n),"0x"+o.toHex(!1)}static addPoints(e,n,a){const c=secp256k1$1.ProjectivePoint.fromHex(Tt.computePublicKey(e).substring(2)),o=secp256k1$1.ProjectivePoint.fromHex(Tt.computePublicKey(n).substring(2));return"0x"+c.add(o).toHex(!!a)}};gt=new WeakMap;let SigningKey=Tt;const BN_0$2=BigInt(0),BN_36=BigInt(36);function getChecksumAddress(t){t=t.toLowerCase();const e=t.substring(2).split(""),n=new Uint8Array(40);for(let c=0;c<40;c++)n[c]=e[c].charCodeAt(0);const a=getBytes(keccak256(n));for(let c=0;c<40;c+=2)a[c>>1]>>4>=8&&(e[c]=e[c].toUpperCase()),(a[c>>1]&15)>=8&&(e[c+1]=e[c+1].toUpperCase());return"0x"+e.join("")}const ibanLookup={};for(let t=0;t<10;t++)ibanLookup[String(t)]=String(t);for(let t=0;t<26;t++)ibanLookup[String.fromCharCode(65+t)]=String(10+t);const safeDigits=15;function ibanChecksum(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(a=>ibanLookup[a]).join("");for(;e.length>=safeDigits;){let a=e.substring(0,safeDigits);e=parseInt(a,10)%97+e.substring(a.length)}let n=String(98-parseInt(e,10)%97);for(;n.length<2;)n="0"+n;return n}const Base36=function(){const t={};for(let e=0;e<36;e++){const n="0123456789abcdefghijklmnopqrstuvwxyz"[e];t[n]=BigInt(e)}return t}();function fromBase36(t){t=t.toLowerCase();let e=BN_0$2;for(let n=0;n<t.length;n++)e=e*BN_36+Base36[t[n]];return e}function getAddress(t){if(assertArgument(typeof t=="string","invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=getChecksumAddress(t);return assertArgument(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){assertArgument(t.substring(2,4)===ibanChecksum(t),"bad icap checksum","address",t);let e=fromBase36(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return getChecksumAddress("0x"+e)}assertArgument(!1,"invalid address","address",t)}function isAddressable(t){return t&&typeof t.getAddress=="function"}async function checkAddress(t,e){const n=await e;return(n==null||n==="0x0000000000000000000000000000000000000000")&&(assert$f(typeof t!="string","unconfigured name","UNCONFIGURED_NAME",{value:t}),assertArgument(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),getAddress(n)}function resolveAddress(t,e){if(typeof t=="string")return t.match(/^0x[0-9a-f]{40}$/i)?getAddress(t):(assert$f(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),checkAddress(t,e.resolveName(t)));if(isAddressable(t))return checkAddress(t,t.getAddress());if(t&&typeof t.then=="function")return checkAddress(t,t);assertArgument(!1,"unsupported addressable value","target",t)}function id(t){return keccak256(toUtf8Bytes(t))}function accessSetify(t,e){return{address:getAddress(t),storageKeys:e.map((n,a)=>(assertArgument(isHexString$1(n,32),"invalid slot",`storageKeys[${a}]`,n),n.toLowerCase()))}}function accessListify(t){if(Array.isArray(t))return t.map((n,a)=>Array.isArray(n)?(assertArgument(n.length===2,"invalid slot set",`value[${a}]`,n),accessSetify(n[0],n[1])):(assertArgument(n!=null&&typeof n=="object","invalid address-slot set","value",t),accessSetify(n.address,n.storageKeys)));assertArgument(t!=null&&typeof t=="object","invalid access list","value",t);const e=Object.keys(t).map(n=>{const a=t[n].reduce((c,o)=>(c[o]=!0,c),{});return accessSetify(n,Object.keys(a).sort())});return e.sort((n,a)=>n.address.localeCompare(a.address)),e}function computeAddress(t){let e;return typeof t=="string"?e=SigningKey.computePublicKey(t,!1):e=t.publicKey,getAddress(keccak256("0x"+e.substring(4)).substring(26))}function recoverAddress(t,e){return computeAddress(SigningKey.recoverPublicKey(t,e))}const BN_0$1=BigInt(0),BN_2=BigInt(2),BN_27=BigInt(27),BN_28=BigInt(28),BN_35=BigInt(35),BN_MAX_UINT=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),BLOB_SIZE=4096*32;function getVersionedHash(t,e){let n=t.toString(16);for(;n.length<2;)n="0"+n;return n+=sha256$2(e).substring(4),"0x"+n}function handleAddress(t){return t==="0x"?null:getAddress(t)}function handleAccessList(t,e){try{return accessListify(t)}catch(n){assertArgument(!1,n.message,e,t)}}function handleNumber(t,e){return t==="0x"?0:getNumber(t,e)}function handleUint(t,e){if(t==="0x")return BN_0$1;const n=getBigInt(t,e);return assertArgument(n<=BN_MAX_UINT,"value exceeds uint size",e,n),n}function formatNumber(t,e){const n=getBigInt(t,"value"),a=toBeArray(n);return assertArgument(a.length<=32,"value too large",`tx.${e}`,n),a}function formatAccessList(t){return accessListify(t).map(e=>[e.address,e.storageKeys])}function formatHashes(t,e){assertArgument(Array.isArray(t),`invalid ${e}`,"value",t);for(let n=0;n<t.length;n++)assertArgument(isHexString$1(t[n],32),"invalid ${ param } hash",`value[${n}]`,t[n]);return t}function _parseLegacy(t){const e=decodeRlp(t);assertArgument(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",t);const n={type:0,nonce:handleNumber(e[0],"nonce"),gasPrice:handleUint(e[1],"gasPrice"),gasLimit:handleUint(e[2],"gasLimit"),to:handleAddress(e[3]),value:handleUint(e[4],"value"),data:hexlify(e[5]),chainId:BN_0$1};if(e.length===6)return n;const a=handleUint(e[6],"v"),c=handleUint(e[7],"r"),o=handleUint(e[8],"s");if(c===BN_0$1&&o===BN_0$1)n.chainId=a;else{let u=(a-BN_35)/BN_2;u<BN_0$1&&(u=BN_0$1),n.chainId=u,assertArgument(u!==BN_0$1||a===BN_27||a===BN_28,"non-canonical legacy v","v",e[6]),n.signature=Signature$3.from({r:zeroPadValue(e[7],32),s:zeroPadValue(e[8],32),v:a})}return n}function _serializeLegacy(t,e){const n=[formatNumber(t.nonce,"nonce"),formatNumber(t.gasPrice||0,"gasPrice"),formatNumber(t.gasLimit,"gasLimit"),t.to||"0x",formatNumber(t.value,"value"),t.data];let a=BN_0$1;if(t.chainId!=BN_0$1)a=getBigInt(t.chainId,"tx.chainId"),assertArgument(!e||e.networkV==null||e.legacyChainId===a,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const o=t.signature.legacyChainId;o!=null&&(a=o)}if(!e)return a!==BN_0$1&&(n.push(toBeArray(a)),n.push("0x"),n.push("0x")),encodeRlp(n);let c=BigInt(27+e.yParity);return a!==BN_0$1?c=Signature$3.getChainIdV(a,e.v):BigInt(e.v)!==c&&assertArgument(!1,"tx.chainId/sig.v mismatch","sig",e),n.push(toBeArray(c)),n.push(toBeArray(e.r)),n.push(toBeArray(e.s)),encodeRlp(n)}function _parseEipSignature(t,e){let n;try{if(n=handleNumber(e[0],"yParity"),n!==0&&n!==1)throw new Error("bad yParity")}catch{assertArgument(!1,"invalid yParity","yParity",e[0])}const a=zeroPadValue(e[1],32),c=zeroPadValue(e[2],32),o=Signature$3.from({r:a,s:c,yParity:n});t.signature=o}function _parseEip1559(t){const e=decodeRlp(getBytes(t).slice(1));assertArgument(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",hexlify(t));const n={type:2,chainId:handleUint(e[0],"chainId"),nonce:handleNumber(e[1],"nonce"),maxPriorityFeePerGas:handleUint(e[2],"maxPriorityFeePerGas"),maxFeePerGas:handleUint(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:handleUint(e[4],"gasLimit"),to:handleAddress(e[5]),value:handleUint(e[6],"value"),data:hexlify(e[7]),accessList:handleAccessList(e[8],"accessList")};return e.length===9||_parseEipSignature(n,e.slice(9)),n}function _serializeEip1559(t,e){const n=[formatNumber(t.chainId,"chainId"),formatNumber(t.nonce,"nonce"),formatNumber(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),formatNumber(t.maxFeePerGas||0,"maxFeePerGas"),formatNumber(t.gasLimit,"gasLimit"),t.to||"0x",formatNumber(t.value,"value"),t.data,formatAccessList(t.accessList||[])];return e&&(n.push(formatNumber(e.yParity,"yParity")),n.push(toBeArray(e.r)),n.push(toBeArray(e.s))),concat(["0x02",encodeRlp(n)])}function _parseEip2930(t){const e=decodeRlp(getBytes(t).slice(1));assertArgument(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",hexlify(t));const n={type:1,chainId:handleUint(e[0],"chainId"),nonce:handleNumber(e[1],"nonce"),gasPrice:handleUint(e[2],"gasPrice"),gasLimit:handleUint(e[3],"gasLimit"),to:handleAddress(e[4]),value:handleUint(e[5],"value"),data:hexlify(e[6]),accessList:handleAccessList(e[7],"accessList")};return e.length===8||_parseEipSignature(n,e.slice(8)),n}function _serializeEip2930(t,e){const n=[formatNumber(t.chainId,"chainId"),formatNumber(t.nonce,"nonce"),formatNumber(t.gasPrice||0,"gasPrice"),formatNumber(t.gasLimit,"gasLimit"),t.to||"0x",formatNumber(t.value,"value"),t.data,formatAccessList(t.accessList||[])];return e&&(n.push(formatNumber(e.yParity,"recoveryParam")),n.push(toBeArray(e.r)),n.push(toBeArray(e.s))),concat(["0x01",encodeRlp(n)])}function _parseEip4844(t){let e=decodeRlp(getBytes(t).slice(1)),n="3",a=null;if(e.length===4&&Array.isArray(e[0])){n="3 (network format)";const o=e[1],u=e[2],h=e[3];assertArgument(Array.isArray(o),"invalid network format: blobs not an array","fields[1]",o),assertArgument(Array.isArray(u),"invalid network format: commitments not an array","fields[2]",u),assertArgument(Array.isArray(h),"invalid network format: proofs not an array","fields[3]",h),assertArgument(o.length===u.length,"invalid network format: blobs/commitments length mismatch","fields",e),assertArgument(o.length===h.length,"invalid network format: blobs/proofs length mismatch","fields",e),a=[];for(let l=0;l<e[1].length;l++)a.push({data:o[l],commitment:u[l],proof:h[l]});e=e[0]}assertArgument(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${n}`,"data",hexlify(t));const c={type:3,chainId:handleUint(e[0],"chainId"),nonce:handleNumber(e[1],"nonce"),maxPriorityFeePerGas:handleUint(e[2],"maxPriorityFeePerGas"),maxFeePerGas:handleUint(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:handleUint(e[4],"gasLimit"),to:handleAddress(e[5]),value:handleUint(e[6],"value"),data:hexlify(e[7]),accessList:handleAccessList(e[8],"accessList"),maxFeePerBlobGas:handleUint(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};a&&(c.blobs=a),assertArgument(c.to!=null,`invalid address for transaction type: ${n}`,"data",t),assertArgument(Array.isArray(c.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let o=0;o<c.blobVersionedHashes.length;o++)assertArgument(isHexString$1(c.blobVersionedHashes[o],32),`invalid blobVersionedHash at index ${o}: must be length 32`,"data",t);return e.length===11||_parseEipSignature(c,e.slice(11)),c}function _serializeEip4844(t,e,n){const a=[formatNumber(t.chainId,"chainId"),formatNumber(t.nonce,"nonce"),formatNumber(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),formatNumber(t.maxFeePerGas||0,"maxFeePerGas"),formatNumber(t.gasLimit,"gasLimit"),t.to||ZeroAddress,formatNumber(t.value,"value"),t.data,formatAccessList(t.accessList||[]),formatNumber(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),formatHashes(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(a.push(formatNumber(e.yParity,"yParity")),a.push(toBeArray(e.r)),a.push(toBeArray(e.s)),n)?concat(["0x03",encodeRlp([a,n.map(c=>c.data),n.map(c=>c.commitment),n.map(c=>c.proof)])]):concat(["0x03",encodeRlp(a)])}var mt,Ut,Ht,jt,Gt,Kt,zt,Vt,Wt,Jt,Zt,Xt,Ct,St,wt,Et,Yt,cr;const vt=class vt{constructor(){Le(this,Yt);Le(this,mt);Le(this,Ut);Le(this,Ht);Le(this,jt);Le(this,Gt);Le(this,Kt);Le(this,zt);Le(this,Vt);Le(this,Wt);Le(this,Jt);Le(this,Zt);Le(this,Xt);Le(this,Ct);Le(this,St);Le(this,wt);Le(this,Et);we(this,mt,null),we(this,Ut,null),we(this,jt,0),we(this,Gt,BN_0$1),we(this,Kt,null),we(this,zt,null),we(this,Vt,null),we(this,Ht,"0x"),we(this,Wt,BN_0$1),we(this,Jt,BN_0$1),we(this,Zt,null),we(this,Xt,null),we(this,Ct,null),we(this,St,null),we(this,Et,null),we(this,wt,null)}get type(){return Re(this,mt)}set type(e){switch(e){case null:we(this,mt,null);break;case 0:case"legacy":we(this,mt,0);break;case 1:case"berlin":case"eip-2930":we(this,mt,1);break;case 2:case"london":case"eip-1559":we(this,mt,2);break;case 3:case"cancun":case"eip-4844":we(this,mt,3);break;default:assertArgument(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=Re(this,Ut);return e==null&&this.type===3?ZeroAddress:e}set to(e){we(this,Ut,e==null?null:getAddress(e))}get nonce(){return Re(this,jt)}set nonce(e){we(this,jt,getNumber(e,"value"))}get gasLimit(){return Re(this,Gt)}set gasLimit(e){we(this,Gt,getBigInt(e))}get gasPrice(){const e=Re(this,Kt);return e==null&&(this.type===0||this.type===1)?BN_0$1:e}set gasPrice(e){we(this,Kt,e==null?null:getBigInt(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=Re(this,zt);return e??(this.type===2||this.type===3?BN_0$1:null)}set maxPriorityFeePerGas(e){we(this,zt,e==null?null:getBigInt(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=Re(this,Vt);return e??(this.type===2||this.type===3?BN_0$1:null)}set maxFeePerGas(e){we(this,Vt,e==null?null:getBigInt(e,"maxFeePerGas"))}get data(){return Re(this,Ht)}set data(e){we(this,Ht,hexlify(e))}get value(){return Re(this,Wt)}set value(e){we(this,Wt,getBigInt(e,"value"))}get chainId(){return Re(this,Jt)}set chainId(e){we(this,Jt,getBigInt(e))}get signature(){return Re(this,Zt)||null}set signature(e){we(this,Zt,e==null?null:Signature$3.from(e))}get accessList(){const e=Re(this,Xt)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){we(this,Xt,e==null?null:accessListify(e))}get maxFeePerBlobGas(){const e=Re(this,Ct);return e==null&&this.type===3?BN_0$1:e}set maxFeePerBlobGas(e){we(this,Ct,e==null?null:getBigInt(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=Re(this,St);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){assertArgument(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let n=0;n<e.length;n++)assertArgument(isHexString$1(e[n],32),"invalid blobVersionedHash",`value[${n}]`,e[n])}we(this,St,e)}get blobs(){return Re(this,Et)==null?null:Re(this,Et).map(e=>Object.assign({},e))}set blobs(e){if(e==null){we(this,Et,null);return}const n=[],a=[];for(let c=0;c<e.length;c++){const o=e[c];if(isBytesLike(o)){assert$f(Re(this,wt),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let u=getBytes(o);if(assertArgument(u.length<=BLOB_SIZE,"blob is too large",`blobs[${c}]`,o),u.length!==BLOB_SIZE){const b=new Uint8Array(BLOB_SIZE);b.set(u),u=b}const h=Re(this,wt).blobToKzgCommitment(u),l=hexlify(Re(this,wt).computeBlobKzgProof(u,h));n.push({data:hexlify(u),commitment:hexlify(h),proof:l}),a.push(getVersionedHash(1,h))}else{const u=hexlify(o.commitment);n.push({data:hexlify(o.data),commitment:u,proof:hexlify(o.proof)}),a.push(getVersionedHash(1,u))}}we(this,Et,n),we(this,St,a)}get kzg(){return Re(this,wt)}set kzg(e){we(this,wt,e)}get hash(){return this.signature==null?null:keccak256(it(this,Yt,cr).call(this,!0,!1))}get unsignedHash(){return keccak256(this.unsignedSerialized)}get from(){return this.signature==null?null:recoverAddress(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:SigningKey.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return it(this,Yt,cr).call(this,!0,!0)}get unsignedSerialized(){return it(this,Yt,cr).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,n=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,a=this.accessList!=null,c=Re(this,Ct)!=null||Re(this,St);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&assert$f(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),assert$f(!n||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),assert$f(this.type!==0||!a,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const o=[];return this.type!=null?o.push(this.type):n?o.push(2):e?(o.push(1),a||o.push(0)):a?(o.push(1),o.push(2)):(c&&this.to||(o.push(0),o.push(1),o.push(2)),o.push(3)),o.sort(),o}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return vt.from(this)}toJSON(){const e=n=>n==null?null:n.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new vt;if(typeof e=="string"){const a=getBytes(e);if(a[0]>=127)return vt.from(_parseLegacy(a));switch(a[0]){case 1:return vt.from(_parseEip2930(a));case 2:return vt.from(_parseEip1559(a));case 3:return vt.from(_parseEip4844(a))}assert$f(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const n=new vt;return e.type!=null&&(n.type=e.type),e.to!=null&&(n.to=e.to),e.nonce!=null&&(n.nonce=e.nonce),e.gasLimit!=null&&(n.gasLimit=e.gasLimit),e.gasPrice!=null&&(n.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(n.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(n.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(n.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(n.data=e.data),e.value!=null&&(n.value=e.value),e.chainId!=null&&(n.chainId=e.chainId),e.signature!=null&&(n.signature=Signature$3.from(e.signature)),e.accessList!=null&&(n.accessList=e.accessList),e.blobVersionedHashes!=null&&(n.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(n.kzg=e.kzg),e.blobs!=null&&(n.blobs=e.blobs),e.hash!=null&&(assertArgument(n.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),assertArgument(n.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(assertArgument(n.isSigned(),"unsigned transaction cannot define '.from'","tx",e),assertArgument(n.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),n}};mt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,zt=new WeakMap,Vt=new WeakMap,Wt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,Ct=new WeakMap,St=new WeakMap,wt=new WeakMap,Et=new WeakMap,Yt=new WeakSet,cr=function(e,n){assert$f(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const a=e?this.signature:null;switch(this.inferType()){case 0:return _serializeLegacy(this,a);case 1:return _serializeEip2930(this,a);case 2:return _serializeEip1559(this,a);case 3:return _serializeEip4844(this,a,n?this.blobs:null)}assert$f(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Transaction=vt;function hashMessage(t){return typeof t=="string"&&(t=toUtf8Bytes(t)),keccak256(concat([toUtf8Bytes(MessagePrefix),toUtf8Bytes(String(t.length)),t]))}function verifyMessage(t,e){const n=hashMessage(t);return recoverAddress(n,e)}const padding=new Uint8Array(32);padding.fill(0);const BN__1=BigInt(-1),BN_0=BigInt(0),BN_1=BigInt(1),BN_MAX_UINT256=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function hexPadRight(t){const e=getBytes(t),n=e.length%32;return n?concat([e,padding.slice(n)]):hexlify(e)}const hexTrue=toBeHex(BN_1,32),hexFalse=toBeHex(BN_0,32),domainFieldTypes={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},domainFieldNames=["name","version","chainId","verifyingContract","salt"];function checkString(t){return function(e){return assertArgument(typeof e=="string",`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const domainChecks={name:checkString("name"),version:checkString("version"),chainId:function(t){const e=getBigInt(t,"domain.chainId");return assertArgument(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):toQuantity(e)},verifyingContract:function(t){try{return getAddress(t).toLowerCase()}catch{}assertArgument(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=getBytes(t,"domain.salt");return assertArgument(e.length===32,'invalid domain value "salt"',"domain.salt",t),hexlify(e)}};function getBaseEncoder(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const n=e[1]==="",a=parseInt(e[2]);assertArgument(a%8===0&&a!==0&&a<=256&&e[2]===String(a),"invalid numeric width","type",t);const c=mask(BN_MAX_UINT256,n?a-1:a),o=n?(c+BN_1)*BN__1:BN_0;return function(u){const h=getBigInt(u,"value");return assertArgument(h>=o&&h<=c,`value out-of-bounds for ${t}`,"value",h),toBeHex(n?toTwos(h,256):h,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const n=parseInt(e[1]);return assertArgument(n!==0&&n<=32&&e[1]===String(n),"invalid bytes width","type",t),function(a){const c=getBytes(a);return assertArgument(c.length===n,`invalid length for ${t}`,"value",a),hexPadRight(a)}}}switch(t){case"address":return function(e){return zeroPadValue(getAddress(e),32)};case"bool":return function(e){return e?hexTrue:hexFalse};case"bytes":return function(e){return keccak256(e)};case"string":return function(e){return id(e)}}return null}function encodeType(t,e){return`${t}(${e.map(({name:n,type:a})=>a+" "+n).join(",")})`}function splitArray(t){const e=t.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:t}}var nr,_t,Qt,dr,_r;const xt=class xt{constructor(e){Le(this,dr);Fe(this,"primaryType");Le(this,nr);Le(this,_t);Le(this,Qt);we(this,_t,new Map),we(this,Qt,new Map);const n=new Map,a=new Map,c=new Map,o={};Object.keys(e).forEach(l=>{o[l]=e[l].map(({name:b,type:d})=>{let{base:p,index:x}=splitArray(d);return p==="int"&&!e.int&&(p="int256"),p==="uint"&&!e.uint&&(p="uint256"),{name:b,type:p+(x||"")}}),n.set(l,new Set),a.set(l,[]),c.set(l,new Set)}),we(this,nr,JSON.stringify(o));for(const l in o){const b=new Set;for(const d of o[l]){assertArgument(!b.has(d.name),`duplicate variable name ${JSON.stringify(d.name)} in ${JSON.stringify(l)}`,"types",e),b.add(d.name);const p=splitArray(d.type).base;assertArgument(p!==l,`circular type reference to ${JSON.stringify(p)}`,"types",e),!getBaseEncoder(p)&&(assertArgument(a.has(p),`unknown type ${JSON.stringify(p)}`,"types",e),a.get(p).push(l),n.get(l).add(p))}}const u=Array.from(a.keys()).filter(l=>a.get(l).length===0);assertArgument(u.length!==0,"missing primary type","types",e),assertArgument(u.length===1,`ambiguous primary types or unused types: ${u.map(l=>JSON.stringify(l)).join(", ")}`,"types",e),defineProperties(this,{primaryType:u[0]});function h(l,b){assertArgument(!b.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",e),b.add(l);for(const d of n.get(l))if(a.has(d)){h(d,b);for(const p of b)c.get(p).add(d)}b.delete(l)}h(this.primaryType,new Set);for(const[l,b]of c){const d=Array.from(b);d.sort(),Re(this,_t).set(l,encodeType(l,o[l])+d.map(p=>encodeType(p,o[p])).join(""))}}get types(){return JSON.parse(Re(this,nr))}getEncoder(e){let n=Re(this,Qt).get(e);return n||(n=it(this,dr,_r).call(this,e),Re(this,Qt).set(e,n)),n}encodeType(e){const n=Re(this,_t).get(e);return assertArgument(n,`unknown type: ${JSON.stringify(e)}`,"name",e),n}encodeData(e,n){return this.getEncoder(e)(n)}hashStruct(e,n){return keccak256(this.encodeData(e,n))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,n,a){if(getBaseEncoder(e))return a(e,n);const c=splitArray(e).array;if(c)return assertArgument(c.count===-1||c.count===n.length,`array length mismatch; expected length ${c.count}`,"value",n),n.map(u=>this._visit(c.prefix,u,a));const o=this.types[e];if(o)return o.reduce((u,{name:h,type:l})=>(u[h]=this._visit(l,n[h],a),u),{});assertArgument(!1,`unknown type: ${e}`,"type",e)}visit(e,n){return this._visit(this.primaryType,e,n)}static from(e){return new xt(e)}static getPrimaryType(e){return xt.from(e).primaryType}static hashStruct(e,n,a){return xt.from(n).hashStruct(e,a)}static hashDomain(e){const n=[];for(const a in e){if(e[a]==null)continue;const c=domainFieldTypes[a];assertArgument(c,`invalid typed-data domain key: ${JSON.stringify(a)}`,"domain",e),n.push({name:a,type:c})}return n.sort((a,c)=>domainFieldNames.indexOf(a.name)-domainFieldNames.indexOf(c.name)),xt.hashStruct("EIP712Domain",{EIP712Domain:n},e)}static encode(e,n,a){return concat(["0x1901",xt.hashDomain(e),xt.from(n).hash(a)])}static hash(e,n,a){return keccak256(xt.encode(e,n,a))}static async resolveNames(e,n,a,c){e=Object.assign({},e);for(const h in e)e[h]==null&&delete e[h];const o={};e.verifyingContract&&!isHexString$1(e.verifyingContract,20)&&(o[e.verifyingContract]="0x");const u=xt.from(n);u.visit(a,(h,l)=>(h==="address"&&!isHexString$1(l,20)&&(o[l]="0x"),l));for(const h in o)o[h]=await c(h);return e.verifyingContract&&o[e.verifyingContract]&&(e.verifyingContract=o[e.verifyingContract]),a=u.visit(a,(h,l)=>h==="address"&&o[l]?o[l]:l),{domain:e,value:a}}static getPayload(e,n,a){xt.hashDomain(e);const c={},o=[];domainFieldNames.forEach(l=>{const b=e[l];b!=null&&(c[l]=domainChecks[l](b),o.push({name:l,type:domainFieldTypes[l]}))});const u=xt.from(n);n=u.types;const h=Object.assign({},n);return assertArgument(h.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",n),h.EIP712Domain=o,u.encode(a),{types:h,domain:c,primaryType:u.primaryType,message:u.visit(a,(l,b)=>{if(l.match(/^bytes(\d*)/))return hexlify(getBytes(b));if(l.match(/^u?int/))return getBigInt(b).toString();switch(l){case"address":return b.toLowerCase();case"bool":return!!b;case"string":return assertArgument(typeof b=="string","invalid string","value",b),b}assertArgument(!1,"unsupported type","type",l)})}}};nr=new WeakMap,_t=new WeakMap,Qt=new WeakMap,dr=new WeakSet,_r=function(e){{const c=getBaseEncoder(e);if(c)return c}const n=splitArray(e).array;if(n){const c=n.prefix,o=this.getEncoder(c);return u=>{assertArgument(n.count===-1||n.count===u.length,`array length mismatch; expected length ${n.count}`,"value",u);let h=u.map(o);return Re(this,_t).has(c)&&(h=h.map(keccak256)),keccak256(concat(h))}}const a=this.types[e];if(a){const c=id(Re(this,_t).get(e));return o=>{const u=a.map(({name:h,type:l})=>{const b=this.getEncoder(l)(o[h]);return Re(this,_t).has(l)?keccak256(b):b});return u.unshift(c),concat(u)}}assertArgument(!1,`unknown type: ${e}`,"type",e)};let TypedDataEncoder=xt;BigInt(0);function copyRequest(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=hexlify(t.data));const n="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const c of n)!(c in t)||t[c]==null||(e[c]=getBigInt(t[c],`request.${c}`));const a="type,nonce".split(/,/);for(const c of a)!(c in t)||t[c]==null||(e[c]=getNumber(t[c],`request.${c}`));return t.accessList&&(e.accessList=accessListify(t.accessList)),"blockTag"in t&&(e.blockTag=t.blockTag),"enableCcipRead"in t&&(e.enableCcipRead=!!t.enableCcipRead),"customData"in t&&(e.customData=t.customData),"blobVersionedHashes"in t&&t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.slice()),"kzg"in t&&(e.kzg=t.kzg),"blobs"in t&&t.blobs&&(e.blobs=t.blobs.map(c=>isBytesLike(c)?hexlify(c):Object.assign({},c))),e}function checkProvider(t,e){if(t.provider)return t.provider;assert$f(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function populate(t,e){let n=copyRequest(e);if(n.to!=null&&(n.to=resolveAddress(n.to,t)),n.from!=null){const a=n.from;n.from=Promise.all([t.getAddress(),resolveAddress(a,t)]).then(([c,o])=>(assertArgument(c.toLowerCase()===o.toLowerCase(),"transaction from mismatch","tx.from",o),c))}else n.from=t.getAddress();return await resolveProperties(n)}class AbstractSigner{constructor(e){Fe(this,"provider");defineProperties(this,{provider:e||null})}async getNonce(e){return checkProvider(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await populate(this,e)}async populateTransaction(e){const n=checkProvider(this,"populateTransaction"),a=await populate(this,e);a.nonce==null&&(a.nonce=await this.getNonce("pending")),a.gasLimit==null&&(a.gasLimit=await this.estimateGas(a));const c=await this.provider.getNetwork();if(a.chainId!=null){const u=getBigInt(a.chainId);assertArgument(u===c.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else a.chainId=c.chainId;const o=a.maxFeePerGas!=null||a.maxPriorityFeePerGas!=null;if(a.gasPrice!=null&&(a.type===2||o)?assertArgument(!1,"eip-1559 transaction do not support gasPrice","tx",e):(a.type===0||a.type===1)&&o&&assertArgument(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(a.type===2||a.type==null)&&a.maxFeePerGas!=null&&a.maxPriorityFeePerGas!=null)a.type=2;else if(a.type===0||a.type===1){const u=await n.getFeeData();assert$f(u.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),a.gasPrice==null&&(a.gasPrice=u.gasPrice)}else{const u=await n.getFeeData();if(a.type==null)if(u.maxFeePerGas!=null&&u.maxPriorityFeePerGas!=null)if(a.type=2,a.gasPrice!=null){const h=a.gasPrice;delete a.gasPrice,a.maxFeePerGas=h,a.maxPriorityFeePerGas=h}else a.maxFeePerGas==null&&(a.maxFeePerGas=u.maxFeePerGas),a.maxPriorityFeePerGas==null&&(a.maxPriorityFeePerGas=u.maxPriorityFeePerGas);else u.gasPrice!=null?(assert$f(!o,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),a.gasPrice==null&&(a.gasPrice=u.gasPrice),a.type=0):assert$f(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(a.type===2||a.type===3)&&(a.maxFeePerGas==null&&(a.maxFeePerGas=u.maxFeePerGas),a.maxPriorityFeePerGas==null&&(a.maxPriorityFeePerGas=u.maxPriorityFeePerGas))}return await resolveProperties(a)}async estimateGas(e){return checkProvider(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return checkProvider(this,"call").call(await this.populateCall(e))}async resolveName(e){return await checkProvider(this,"resolveName").resolveName(e)}async sendTransaction(e){const n=checkProvider(this,"sendTransaction"),a=await this.populateTransaction(e);delete a.from;const c=Transaction.from(a);return await n.broadcastTransaction(await this.signTransaction(c))}}var er,ur;const vr=class vr extends AbstractSigner{constructor(n,a){super(a);Le(this,er);Fe(this,"address");defineProperties(this,{address:n})}async getAddress(){return this.address}connect(n){return new vr(this.address,n)}async signTransaction(n){it(this,er,ur).call(this,"transactions","signTransaction")}async signMessage(n){it(this,er,ur).call(this,"messages","signMessage")}async signTypedData(n,a,c){it(this,er,ur).call(this,"typed-data","signTypedData")}};er=new WeakSet,ur=function(n,a){assert$f(!1,`VoidSigner cannot sign ${n}`,"UNSUPPORTED_OPERATION",{operation:a})};let VoidSigner=vr;var tr;const gr=class gr extends AbstractSigner{constructor(n,a){super(a);Fe(this,"address");Le(this,tr);assertArgument(n&&typeof n.sign=="function","invalid private key","privateKey","[ REDACTED ]"),we(this,tr,n);const c=computeAddress(this.signingKey.publicKey);defineProperties(this,{address:c})}get signingKey(){return Re(this,tr)}get privateKey(){return this.signingKey.privateKey}async getAddress(){return this.address}connect(n){return new gr(Re(this,tr),n)}async signTransaction(n){n=copyRequest(n);const{to:a,from:c}=await resolveProperties({to:n.to?resolveAddress(n.to,this.provider):void 0,from:n.from?resolveAddress(n.from,this.provider):void 0});a!=null&&(n.to=a),c!=null&&(n.from=c),n.from!=null&&(assertArgument(getAddress(n.from)===this.address,"transaction from address mismatch","tx.from",n.from),delete n.from);const o=Transaction.from(n);return o.signature=this.signingKey.sign(o.unsignedHash),o.serialized}async signMessage(n){return this.signMessageSync(n)}signMessageSync(n){return this.signingKey.sign(hashMessage(n)).serialized}async signTypedData(n,a,c){const o=await TypedDataEncoder.resolveNames(n,a,c,async u=>{assert$f(this.provider!=null,"cannot resolve ENS names without a provider","UNSUPPORTED_OPERATION",{operation:"resolveName",info:{name:u}});const h=await this.provider.resolveName(u);return assert$f(h!=null,"unconfigured ENS name","UNCONFIGURED_NAME",{value:u}),h});return this.signingKey.sign(TypedDataEncoder.hash(o.domain,a,o.value)).serialized}};tr=new WeakMap;let BaseWallet=gr;const subsChrs=" !#$%&'()*+,-./<=>?@[]^_`{|}~",Word=/^[a-z]*$/i;function unfold(t,e){let n=97;return t.reduce((a,c)=>(c===e?n++:c.match(Word)?a.push(String.fromCharCode(n)+c):(n=97,a.push(c)),a),[])}function decode(t,e){for(let c=subsChrs.length-1;c>=0;c--)t=t.split(subsChrs[c]).join(e.substring(2*c,2*c+2));const n=[],a=t.replace(/(:|([0-9])|([A-Z][a-z]*))/g,(c,o,u,h)=>{if(u)for(let l=parseInt(u);l>=0;l--)n.push(";");else n.push(o.toLowerCase());return""});if(a)throw new Error(`leftovers: ${JSON.stringify(a)}`);return unfold(unfold(n,";"),":")}function decodeOwl(t){return assertArgument(t[0]==="0","unsupported auwl data","data",t),decode(t.substring(1+2*subsChrs.length),t.substring(1,1+2*subsChrs.length))}class Wordlist{constructor(e){Fe(this,"locale");defineProperties(this,{locale:e})}split(e){return e.toLowerCase().split(/\s+/g)}join(e){return e.join(" ")}}var rr,ar,Nt,sr,br;class WordlistOwl extends Wordlist{constructor(n,a,c){super(n);Le(this,sr);Le(this,rr);Le(this,ar);Le(this,Nt);we(this,rr,a),we(this,ar,c),we(this,Nt,null)}get _data(){return Re(this,rr)}_decodeWords(){return decodeOwl(Re(this,rr))}getWord(n){const a=it(this,sr,br).call(this);return assertArgument(n>=0&&n<a.length,`invalid word index: ${n}`,"index",n),a[n]}getWordIndex(n){return it(this,sr,br).call(this).indexOf(n)}}rr=new WeakMap,ar=new WeakMap,Nt=new WeakMap,sr=new WeakSet,br=function(){if(Re(this,Nt)==null){const n=this._decodeWords();if(id(n.join(`
3
- `)+`
4
- `)!==Re(this,ar))throw new Error(`BIP39 Wordlist for ${this.locale} FAILED`);we(this,Nt,n)}return Re(this,Nt)};const words="0erleonalorenseinceregesticitStanvetearctssi#ch2Athck&tneLl0And#Il.yLeOutO=S|S%b/ra@SurdU'0Ce[Cid|CountCu'Hie=IdOu,-Qui*Ro[TT]T%T*[Tu$0AptDD-tD*[Ju,M.UltV<)Vi)0Rob-0FairF%dRaid0A(EEntRee0Ead0MRRp%tS!_rmBumCoholErtI&LLeyLowMo,O}PhaReadySoT Ways0A>urAz(gOngOuntU'd0Aly,Ch%Ci|G G!GryIm$K!Noun)Nu$O` Sw T&naTiqueXietyY1ArtOlogyPe?P!Pro=Ril1ChCt-EaEnaGueMMedM%MyOundR<+Re,Ri=RowTTefa@Ti,Tw%k0KPe@SaultSetSi,SumeThma0H!>OmTa{T&dT.udeTra@0Ct]D.Gu,NtTh%ToTumn0Era+OcadoOid0AkeA*AyEsomeFulKw?d0Is:ByChel%C#D+GL<)Lc#y~MbooN<aNn RRelyRga(R*lSeS-SketTt!3A^AnAutyCau'ComeEfF%eG(Ha=H(dLie=LowLtN^Nef./TrayTt Twe&Y#d3Cyc!DKeNdOlogyRdR`Tt _{AdeAmeAnketA,EakE[IndOodO[omOu'UeUrUsh_rdAtDyIlMbNeNusOkO,Rd R(gRrowSsTtomUn)XY_{etA(AndA[A=EadEezeI{Id+IefIghtIngIskOccoliOk&OnzeOomO` OwnUsh2Bb!DdyD+tFf$oIldLbLkL!tNd!Nk Rd&Rg R,SS(e[SyTt Y Zz:Bba+B(B!CtusGeKe~LmM aMpNN$N)lNdyNn#NoeNvasNy#Pab!P.$Pta(RRb#RdRgoRpetRryRtSeShS(o/!Su$TT$ogT^Teg%yTt!UghtU'Ut]Ve3Il(gL yM|NsusNturyRe$Rta(_irAlkAmp]An+AosApt Ar+A'AtEapE{Ee'EfErryE,I{&IefIldIm}yOi)Oo'R#-U{!UnkUrn0G?Nnam#Rc!Tiz&TyVil_imApArifyAwAyE<ErkEv I{I|IffImbIn-IpO{OgO'O`OudOwnUbUmpU, Ut^_^A,C#utDeFfeeIlInL!@L%LumnMb(eMeMf%tM-Mm#Mp<yNc tNdu@NfirmNg*[N}@Nsid NtrolNv()OkOlPp PyR$ReRnR*@/Tt#U^UntryUp!Ur'Us(V Yo>_{Ad!AftAmA}AshAt AwlAzyEamEd.EekEwI{etImeIspIt-OpO[Ou^OwdUci$UelUi'Umb!Un^UshYY,$2BeLtu*PPbo?dRiousRr|Rta(R=Sh]/omTe3C!:DMa+MpN)Ng R(gShUght WnY3AlBa>BrisCadeCemb CideCl(eC%a>C*a'ErF&'F(eFyG*eLayLiv M<dMi'Ni$Nti,NyP?tP&dPos.P`PutyRi=ScribeS tSignSkSpair/royTailTe@VelopVi)Vo>3AgramAlAm#dAryCeE'lEtFf G.$Gn.yLemmaNn NosaurRe@RtSag*eScov Sea'ShSmi[S%d Splay/<)V tVideV%)Zzy5Ct%Cum|G~Lph(Ma(Na>NkeyN%OrSeUb!Ve_ftAg#AmaA,-AwEamE[IftIllInkIpI=OpUmY2CkMbNeR(g/T^Ty1Arf1Nam-:G G!RlyRnR`Sily/Sy1HoOlogyOnomy0GeItUca>1F%t0G1GhtTh 2BowD E@r-Eg<tEm|Eph<tEvat%I>Se0B?kBodyBra)Er+Ot]PloyPow Pty0Ab!A@DD![D%'EmyErgyF%)Ga+G(eH<)JoyLi,OughR-hRollSu*T Ti*TryVelope1Isode0U$Uip0AA'OdeOs]R%Upt0CapeSayS&)Ta>0Ern$H-s1Id&)IlOkeOl=1A@Amp!Ce[Ch<+C.eCludeCu'Ecu>Erci'Hau,Hib.I!I,ItOt-P<dPe@Pi*Pla(Po'P*[T&dTra0EEbrow:Br-CeCultyDeIntI`~L'MeMilyMousNNcyNtasyRmSh]TT$Th TigueUltV%.e3Atu*Bru?yD $EEdElMa!N)/iv$T^V W3B Ct]EldGu*LeLmLt N$NdNeNg NishReRmR,Sc$ShTT}[X_gAmeAshAtAv%EeIghtIpOatO{O%Ow UidUshY_mCusGIlLd~owOdOtR)Re,R+tRkRtu}RumRw?dSsil/ UndX_gi!AmeEqu|EshI&dIn+OgOntO,OwnOz&U.2ElNNnyRna)RyTu*:D+tInLaxy~ yMePRa+Rba+Rd&Rl-Rm|SSpTeTh U+Ze3N $NiusN*Nt!Nu(e/u*2O,0AntFtGg!Ng RaffeRlVe_dAn)A*A[IdeImp'ObeOomOryO=OwUe_tDde[LdOdO'RillaSpelSsipV nWn_bA)A(AntApeA[Av.yEatE&IdIefItOc yOupOwUnt_rdE[IdeIltIt?N3M:B.IrLfMm M, NdPpyRb%RdRshR=,TVeWkZ?d3AdAl`ArtAvyD+hogIght~oLmetLpNRo3Dd&Gh~NtPRe/%y5BbyCkeyLdLeLiday~owMeNeyOdPeRnRr%R'Sp.$/TelUrV 5BGeM<Mb!M%Nd*dNgryNtRd!RryRtSb<d3Brid:1EOn0EaEntifyLe2N%e4LLeg$L}[0A+Ita>M&'Mu}Pa@Po'Pro=Pul'0ChCludeComeC*a'DexD-a>Do%Du,ryF<tFl-tF%mHa!H .Iti$Je@JuryMa>N Noc|PutQuiryS<eSe@SideSpi*/$lTa@T e,ToVe,V.eVol=3On0L<dOla>Sue0Em1Ory:CketGu?RZz3AlousAns~yWel9BInKeUr}yY5D+I)MpNg!Ni%Nk/:Ng?oo3EnEpT^upY3CkDD}yNdNgdomSsTT^&TeTt&Wi4EeIfeO{Ow:BBelB%Dd DyKeMpNgua+PtopR+T T(UghUndryVaWWnWsu.Y Zy3Ad AfArnA=Ctu*FtGG$G&dIsu*M#NdNg`NsOp?dSs#Tt Vel3ArB tyBr?yC&'FeFtGhtKeMbM.NkOnQuid/Tt!VeZ?d5AdAnB, C$CkG-NelyNgOpTt yUdUn+VeY$5CkyGga+Mb N?N^Xury3R-s:Ch(eDG-G}tIdIlInJ%KeMm$NNa+Nda>NgoNs]Nu$P!Rb!R^Rg(R(eRketRria+SkSs/ T^T i$ThTrixTt XimumZe3AdowAnAsu*AtCh<-D$DiaLodyLtMb M%yNt]NuRcyR+R.RryShSsa+T$Thod3Dd!DnightLk~]M-NdNimumN%Nu>Rac!Rr%S ySs/akeXXedXtu*5Bi!DelDifyMM|N.%NkeyN, N`OnR$ReRn(gSqu.oTh T]T%Unta(U'VeVie5ChFf(LeLtiplySc!SeumShroomS-/Tu$3Self/ yTh:I=MePk(Rrow/yT]Tu*3ArCkEdGati=G!@I` PhewR=/TTw%kUtr$V WsXt3CeGht5B!I'M(eeOd!Rm$R`SeTab!TeTh(gTi)VelW5C!?Mb R'T:K0EyJe@Li+Scu*S =Ta(Vious0CurE<Tob 0Or1FF Fi)T&2L1Ay0DI=Ymp-0It0CeEI#L(eLy1EnEraIn]Po'T]1An+B.Ch?dD D(?yG<I|Ig($Ph<0Tr-h0H 0Tdo%T TputTside0AlEnEr0NN 0Yg&0/ 0O}:CtDd!GeIrLa)LmNdaNelN-N` P RadeR|RkRrotRtySsT^ThTi|TrolTt nU'VeYm|3A)AnutArAs<tL-<NN$tyNcilOp!Pp Rfe@Rm.Rs#T2O}OtoRa'Ys-$0AnoCn-Ctu*E)GGe#~LotNkO} Pe/olT^Zza_)A}tA,-A>AyEa'Ed+U{UgUn+2EmEtIntL?LeLi)NdNyOlPul?Rt]S.]Ssib!/TatoTt yV tyWd W _@i)Ai'Ed-tEf Epa*Es|EttyEv|I)IdeIm?yIntI%.yIs#Iva>IzeOb!mO)[Odu)Of.OgramOje@Omo>OofOp tyOsp O>@OudOvide2Bl-Dd(g~LpL'Mpk(N^PilPpyR^a'R.yRpo'R'ShTZz!3Ramid:99Al.yAntumArt E,]I{ItIzO>:Bb.Cco#CeCkD?DioIlInI'~yMpN^NdomN+PidReTeTh V&WZ%3AdyAlAs#BelBuildC$lCei=CipeC%dCyc!Du)F!@F%mFu'G]G*tGul?Je@LaxLea'LiefLyMa(Memb M(dMo=Nd NewNtOp&PairPeatPla)P%tQui*ScueSemb!Si,Sour)Sp#'SultTi*T*atTurnUn]Ve$ViewW?d2Y`m0BBb#CeChDeD+F!GhtGidNgOtPp!SkTu$V$V 5AdA,BotBu,CketM<)OfOkieOmSeTa>UghUndU>Y$5Bb DeGLeNNwayR$:DDd!D}[FeIlLadLm#L#LtLu>MeMp!NdTisfyToshiU)Usa+VeY1A!AnA*Att E}HemeHoolI&)I[%sOrp]OutRapRe&RiptRub1AAr^As#AtC#dC*tCt]Cur.yEdEkGm|Le@~M(?Ni%N'Nt&)RiesRvi)Ss]Tt!TupV&_dowAftAllowA*EdEllEriffIeldIftI}IpIv O{OeOotOpOrtOuld O=RimpRugUff!Y0Bl(gCkDeE+GhtGnL|Lk~yLv Mil?Mp!N)NgR&/ Tua>XZe1A>Et^IIllInIrtUll0AbAmEepEnd I)IdeIghtImOg<OtOwUsh0AllArtI!OkeOo`0A{AkeApIffOw0ApCc Ci$CkDaFtL?Ldi LidLut]L=Me#eNgOnRryRtUlUndUpUr)U`0A)A*Ati$AwnEakEci$EedEllEndH eI)Id IkeInIr.L.OilOns%O#OrtOtRayReadR(gY0Ua*UeezeUir*l_b!AdiumAffA+AirsAmpAndArtA>AyEakEelEmEpE*oI{IllIngO{Oma^O}OolOryO=Ra>gyReetRikeR#gRugg!Ud|UffUmb!Y!0Bje@Bm.BwayC)[ChDd&Ff G?G+,ItMm NNnyN'tP PplyP*meReRfa)R+Rpri'RroundR=ySpe@/a(1AllowAmpApArmE?EetIftImIngIt^Ord1MbolMptomRup/em:B!Ck!GIlL|LkNkPeR+tSk/eTtooXi3A^Am~NN<tNnisNtRm/Xt_nkAtEmeEnE%yE*EyIngIsOughtReeRi=RowUmbUnd 0CketDeG LtMb MeNyPRedSsueT!5A,BaccoDayDdl EGe` I!tK&MatoM%rowNeNgueNightOlO`PP-Pp!R^RnadoRtoi'SsT$Uri,W?dW WnY_{AdeAff-Ag-A(Ansf ApAshA=lAyEatEeEndI$IbeI{Igg ImIpOphyOub!U{UeUlyUmpetU,U`Y2BeIt]Mb!NaN}lRkeyRnRt!1El=EntyI)InI,O1PeP-$:5Ly5B*lla0Ab!Awa*C!Cov D DoFairFoldHappyIf%mIqueItIv 'KnownLo{TilUsu$Veil1Da>GradeHoldOnP Set1B<Ge0A+EEdEfulE![U$0Il.y:C<tCuumGueLidL!yL=NNishP%Rious/Ult3H-!L=tNd%Ntu*NueRbRifyRs]RyS'lT <3Ab!Br<tCiousCt%yDeoEw~a+Nta+Ol(Rtu$RusSaS.Su$T$Vid5C$I)IdLc<oLumeTeYa+:GeG#ItLk~LnutNtRfa*RmRri%ShSp/eT VeY3Al`Ap#ArA'lA` BDd(gEk&dIrdLcome/T_!AtEatEelEnE*IpIsp 0DeD`FeLd~NNdowNeNgNkNn Nt ReSdomSeShT}[5LfM<Nd OdOlRdRkRldRryR`_pE{E,!I,I>Ong::Rd3Ar~ow9UUngU`:3BraRo9NeO",checksum="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60";let wordlist=null;class LangEn extends WordlistOwl{constructor(){super("en",words,checksum)}static wordlist(){return wordlist==null&&(wordlist=new LangEn),wordlist}}function getUpperMask(t){return(1<<t)-1<<8-t&255}function getLowerMask(t){return(1<<t)-1&255}function mnemonicToEntropy(t,e){assertNormalize("NFKD"),e==null&&(e=LangEn.wordlist());const n=e.split(t);assertArgument(n.length%3===0&&n.length>=12&&n.length<=24,"invalid mnemonic length","mnemonic","[ REDACTED ]");const a=new Uint8Array(Math.ceil(11*n.length/8));let c=0;for(let b=0;b<n.length;b++){let d=e.getWordIndex(n[b].normalize("NFKD"));assertArgument(d>=0,`invalid mnemonic word at index ${b}`,"mnemonic","[ REDACTED ]");for(let p=0;p<11;p++)d&1<<10-p&&(a[c>>3]|=1<<7-c%8),c++}const o=32*n.length/3,u=n.length/3,h=getUpperMask(u),l=getBytes(sha256$2(a.slice(0,o/8)))[0]&h;return assertArgument(l===(a[a.length-1]&h),"invalid mnemonic checksum","mnemonic","[ REDACTED ]"),hexlify(a.slice(0,o/8))}function entropyToMnemonic(t,e){assertArgument(t.length%4===0&&t.length>=16&&t.length<=32,"invalid entropy size","entropy","[ REDACTED ]"),e==null&&(e=LangEn.wordlist());const n=[0];let a=11;for(let u=0;u<t.length;u++)a>8?(n[n.length-1]<<=8,n[n.length-1]|=t[u],a-=8):(n[n.length-1]<<=a,n[n.length-1]|=t[u]>>8-a,n.push(t[u]&getLowerMask(8-a)),a+=3);const c=t.length/4,o=parseInt(sha256$2(t).substring(2,4),16)&getUpperMask(c);return n[n.length-1]<<=c,n[n.length-1]|=o>>8-c,e.join(n.map(u=>e.getWord(u)))}const _guard$1={};class Mnemonic{constructor(e,n,a,c,o){Fe(this,"phrase");Fe(this,"password");Fe(this,"wordlist");Fe(this,"entropy");c==null&&(c=""),o==null&&(o=LangEn.wordlist()),assertPrivate(e,_guard$1,"Mnemonic"),defineProperties(this,{phrase:a,password:c,wordlist:o,entropy:n})}computeSeed(){const e=toUtf8Bytes("mnemonic"+this.password,"NFKD");return pbkdf2(toUtf8Bytes(this.phrase,"NFKD"),e,2048,64,"sha512")}static fromPhrase(e,n,a){const c=mnemonicToEntropy(e,a);return e=entropyToMnemonic(getBytes(c),a),new Mnemonic(_guard$1,c,e,n,a)}static fromEntropy(e,n,a){const c=getBytes(e,"entropy"),o=entropyToMnemonic(c,a);return new Mnemonic(_guard$1,hexlify(c),o,n,a)}static entropyToPhrase(e,n){const a=getBytes(e,"entropy");return entropyToMnemonic(a,n)}static phraseToEntropy(e,n){return mnemonicToEntropy(e,n)}static isValidMnemonic(e,n){try{return mnemonicToEntropy(e,n),!0}catch{}return!1}}/*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */var __classPrivateFieldGet$2=function(t,e,n,a){if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?a:n==="a"?a.call(t):a?a.value:e.get(t)},__classPrivateFieldSet$2=function(t,e,n,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!c:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(t,n):c?c.value=n:e.set(t,n),n},_AES_key,_AES_Kd,_AES_Ke;const numberOfRounds={16:10,24:12,32:14},rcon=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],S=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],Si=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],T1=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],T2=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],T3=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],T4=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],T5=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],T6=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],T7=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],T8=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],U1=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],U2=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],U3=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],U4=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function convertToInt32(t){const e=[];for(let n=0;n<t.length;n+=4)e.push(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3]);return e}class AES{get key(){return __classPrivateFieldGet$2(this,_AES_key,"f").slice()}constructor(e){if(_AES_key.set(this,void 0),_AES_Kd.set(this,void 0),_AES_Ke.set(this,void 0),!(this instanceof AES))throw Error("AES must be instanitated with `new`");__classPrivateFieldSet$2(this,_AES_key,new Uint8Array(e),"f");const n=numberOfRounds[this.key.length];if(n==null)throw new TypeError("invalid key size (must be 16, 24 or 32 bytes)");__classPrivateFieldSet$2(this,_AES_Ke,[],"f"),__classPrivateFieldSet$2(this,_AES_Kd,[],"f");for(let d=0;d<=n;d++)__classPrivateFieldGet$2(this,_AES_Ke,"f").push([0,0,0,0]),__classPrivateFieldGet$2(this,_AES_Kd,"f").push([0,0,0,0]);const a=(n+1)*4,c=this.key.length/4,o=convertToInt32(this.key);let u;for(let d=0;d<c;d++)u=d>>2,__classPrivateFieldGet$2(this,_AES_Ke,"f")[u][d%4]=o[d],__classPrivateFieldGet$2(this,_AES_Kd,"f")[n-u][d%4]=o[d];let h=0,l=c,b;for(;l<a;){if(b=o[c-1],o[0]^=S[b>>16&255]<<24^S[b>>8&255]<<16^S[b&255]<<8^S[b>>24&255]^rcon[h]<<24,h+=1,c!=8)for(let m=1;m<c;m++)o[m]^=o[m-1];else{for(let m=1;m<c/2;m++)o[m]^=o[m-1];b=o[c/2-1],o[c/2]^=S[b&255]^S[b>>8&255]<<8^S[b>>16&255]<<16^S[b>>24&255]<<24;for(let m=c/2+1;m<c;m++)o[m]^=o[m-1]}let d=0,p,x;for(;d<c&&l<a;)p=l>>2,x=l%4,__classPrivateFieldGet$2(this,_AES_Ke,"f")[p][x]=o[d],__classPrivateFieldGet$2(this,_AES_Kd,"f")[n-p][x]=o[d++],l++}for(let d=1;d<n;d++)for(let p=0;p<4;p++)b=__classPrivateFieldGet$2(this,_AES_Kd,"f")[d][p],__classPrivateFieldGet$2(this,_AES_Kd,"f")[d][p]=U1[b>>24&255]^U2[b>>16&255]^U3[b>>8&255]^U4[b&255]}encrypt(e){if(e.length!=16)throw new TypeError("invalid plaintext size (must be 16 bytes)");const n=__classPrivateFieldGet$2(this,_AES_Ke,"f").length-1,a=[0,0,0,0];let c=convertToInt32(e);for(let h=0;h<4;h++)c[h]^=__classPrivateFieldGet$2(this,_AES_Ke,"f")[0][h];for(let h=1;h<n;h++){for(let l=0;l<4;l++)a[l]=T1[c[l]>>24&255]^T2[c[(l+1)%4]>>16&255]^T3[c[(l+2)%4]>>8&255]^T4[c[(l+3)%4]&255]^__classPrivateFieldGet$2(this,_AES_Ke,"f")[h][l];c=a.slice()}const o=new Uint8Array(16);let u=0;for(let h=0;h<4;h++)u=__classPrivateFieldGet$2(this,_AES_Ke,"f")[n][h],o[4*h]=(S[c[h]>>24&255]^u>>24)&255,o[4*h+1]=(S[c[(h+1)%4]>>16&255]^u>>16)&255,o[4*h+2]=(S[c[(h+2)%4]>>8&255]^u>>8)&255,o[4*h+3]=(S[c[(h+3)%4]&255]^u)&255;return o}decrypt(e){if(e.length!=16)throw new TypeError("invalid ciphertext size (must be 16 bytes)");const n=__classPrivateFieldGet$2(this,_AES_Kd,"f").length-1,a=[0,0,0,0];let c=convertToInt32(e);for(let h=0;h<4;h++)c[h]^=__classPrivateFieldGet$2(this,_AES_Kd,"f")[0][h];for(let h=1;h<n;h++){for(let l=0;l<4;l++)a[l]=T5[c[l]>>24&255]^T6[c[(l+3)%4]>>16&255]^T7[c[(l+2)%4]>>8&255]^T8[c[(l+1)%4]&255]^__classPrivateFieldGet$2(this,_AES_Kd,"f")[h][l];c=a.slice()}const o=new Uint8Array(16);let u=0;for(let h=0;h<4;h++)u=__classPrivateFieldGet$2(this,_AES_Kd,"f")[n][h],o[4*h]=(Si[c[h]>>24&255]^u>>24)&255,o[4*h+1]=(Si[c[(h+3)%4]>>16&255]^u>>16)&255,o[4*h+2]=(Si[c[(h+2)%4]>>8&255]^u>>8)&255,o[4*h+3]=(Si[c[(h+1)%4]&255]^u)&255;return o}}_AES_key=new WeakMap,_AES_Kd=new WeakMap,_AES_Ke=new WeakMap;class ModeOfOperation{constructor(e,n,a){if(a&&!(this instanceof a))throw new Error(`${e} must be instantiated with "new"`);Object.defineProperties(this,{aes:{enumerable:!0,value:new AES(n)},name:{enumerable:!0,value:e}})}}var __classPrivateFieldSet$1=function(t,e,n,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!c:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(t,n):c?c.value=n:e.set(t,n),n},__classPrivateFieldGet$1=function(t,e,n,a){if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?a:n==="a"?a.call(t):a?a.value:e.get(t)},_CBC_iv,_CBC_lastBlock;class CBC extends ModeOfOperation{constructor(e,n){if(super("ECC",e,CBC),_CBC_iv.set(this,void 0),_CBC_lastBlock.set(this,void 0),n){if(n.length%16)throw new TypeError("invalid iv size (must be 16 bytes)");__classPrivateFieldSet$1(this,_CBC_iv,new Uint8Array(n),"f")}else __classPrivateFieldSet$1(this,_CBC_iv,new Uint8Array(16),"f");__classPrivateFieldSet$1(this,_CBC_lastBlock,this.iv,"f")}get iv(){return new Uint8Array(__classPrivateFieldGet$1(this,_CBC_iv,"f"))}encrypt(e){if(e.length%16)throw new TypeError("invalid plaintext size (must be multiple of 16 bytes)");const n=new Uint8Array(e.length);for(let a=0;a<e.length;a+=16){for(let c=0;c<16;c++)__classPrivateFieldGet$1(this,_CBC_lastBlock,"f")[c]^=e[a+c];__classPrivateFieldSet$1(this,_CBC_lastBlock,this.aes.encrypt(__classPrivateFieldGet$1(this,_CBC_lastBlock,"f")),"f"),n.set(__classPrivateFieldGet$1(this,_CBC_lastBlock,"f"),a)}return n}decrypt(e){if(e.length%16)throw new TypeError("invalid ciphertext size (must be multiple of 16 bytes)");const n=new Uint8Array(e.length);for(let a=0;a<e.length;a+=16){const c=this.aes.decrypt(e.subarray(a,a+16));for(let o=0;o<16;o++)n[a+o]=c[o]^__classPrivateFieldGet$1(this,_CBC_lastBlock,"f")[o],__classPrivateFieldGet$1(this,_CBC_lastBlock,"f")[o]=e[a+o]}return n}}_CBC_iv=new WeakMap,_CBC_lastBlock=new WeakMap;var __classPrivateFieldSet=function(t,e,n,a,c){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!c:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?c.call(t,n):c?c.value=n:e.set(t,n),n},__classPrivateFieldGet=function(t,e,n,a){if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?a:n==="a"?a.call(t):a?a.value:e.get(t)},_CTR_remaining,_CTR_remainingIndex,_CTR_counter;class CTR extends ModeOfOperation{constructor(e,n){super("CTR",e,CTR),_CTR_remaining.set(this,void 0),_CTR_remainingIndex.set(this,void 0),_CTR_counter.set(this,void 0),__classPrivateFieldSet(this,_CTR_counter,new Uint8Array(16),"f"),__classPrivateFieldGet(this,_CTR_counter,"f").fill(0),__classPrivateFieldSet(this,_CTR_remaining,__classPrivateFieldGet(this,_CTR_counter,"f"),"f"),__classPrivateFieldSet(this,_CTR_remainingIndex,16,"f"),n==null&&(n=1),typeof n=="number"?this.setCounterValue(n):this.setCounterBytes(n)}get counter(){return new Uint8Array(__classPrivateFieldGet(this,_CTR_counter,"f"))}setCounterValue(e){if(!Number.isInteger(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new TypeError("invalid counter initial integer value");for(let n=15;n>=0;--n)__classPrivateFieldGet(this,_CTR_counter,"f")[n]=e%256,e=Math.floor(e/256)}setCounterBytes(e){if(e.length!==16)throw new TypeError("invalid counter initial Uint8Array value length");__classPrivateFieldGet(this,_CTR_counter,"f").set(e)}increment(){for(let e=15;e>=0;e--)if(__classPrivateFieldGet(this,_CTR_counter,"f")[e]===255)__classPrivateFieldGet(this,_CTR_counter,"f")[e]=0;else{__classPrivateFieldGet(this,_CTR_counter,"f")[e]++;break}}encrypt(e){var n,a;const c=new Uint8Array(e);for(let o=0;o<c.length;o++)__classPrivateFieldGet(this,_CTR_remainingIndex,"f")===16&&(__classPrivateFieldSet(this,_CTR_remaining,this.aes.encrypt(__classPrivateFieldGet(this,_CTR_counter,"f")),"f"),__classPrivateFieldSet(this,_CTR_remainingIndex,0,"f"),this.increment()),c[o]^=__classPrivateFieldGet(this,_CTR_remaining,"f")[__classPrivateFieldSet(this,_CTR_remainingIndex,(a=__classPrivateFieldGet(this,_CTR_remainingIndex,"f"),n=a++,a),"f"),n];return c}decrypt(e){return this.encrypt(e)}}_CTR_remaining=new WeakMap,_CTR_remainingIndex=new WeakMap,_CTR_counter=new WeakMap;function pkcs7Strip(t){if(t.length<16)throw new TypeError("PKCS#7 invalid length");const e=t[t.length-1];if(e>16)throw new TypeError("PKCS#7 padding byte out of range");const n=t.length-e;for(let a=0;a<e;a++)if(t[n+a]!==e)throw new TypeError("PKCS#7 invalid padding byte");return new Uint8Array(t.subarray(0,n))}function looseArrayify(t){return typeof t=="string"&&!t.startsWith("0x")&&(t="0x"+t),getBytesCopy(t)}function zpad$1(t,e){for(t=String(t);t.length<e;)t="0"+t;return t}function getPassword(t){return typeof t=="string"?toUtf8Bytes(t,"NFKC"):getBytesCopy(t)}function spelunk(t,e){const n=e.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i);assertArgument(n!=null,"invalid path","path",e);const a=n[1],c=n[3],o=n[4]==="!";let u=t;for(const h of a.toLowerCase().split(".")){if(Array.isArray(u)){if(!h.match(/^[0-9]+$/))break;u=u[parseInt(h)]}else if(typeof u=="object"){let l=null;for(const b in u)if(b.toLowerCase()===h){l=u[b];break}u=l}else u=null;if(u==null)break}if(assertArgument(!o||u!=null,"missing required value","path",a),c&&u!=null){if(c==="int"){if(typeof u=="string"&&u.match(/^-?[0-9]+$/))return parseInt(u);if(Number.isSafeInteger(u))return u}if(c==="number"&&typeof u=="string"&&u.match(/^-?[0-9.]*$/))return parseFloat(u);if(c==="data"&&typeof u=="string")return looseArrayify(u);if(c==="array"&&Array.isArray(u)||c===typeof u)return u;assertArgument(!1,`wrong type found for ${c} `,"path",a)}return u}const defaultPath$1="m/44'/60'/0'/0/0";function isKeystoreJson(t){try{const e=JSON.parse(t);if((e.version!=null?parseInt(e.version):0)===3)return!0}catch{}return!1}function decrypt(t,e,n){if(spelunk(t,"crypto.cipher:string")==="aes-128-ctr"){const c=spelunk(t,"crypto.cipherparams.iv:data!"),o=new CTR(e,c);return hexlify(o.decrypt(n))}assert$f(!1,"unsupported cipher","UNSUPPORTED_OPERATION",{operation:"decrypt"})}function getAccount(t,e){const n=getBytes(e),a=spelunk(t,"crypto.ciphertext:data!"),c=hexlify(keccak256(concat([n.slice(16,32),a]))).substring(2);assertArgument(c===spelunk(t,"crypto.mac:string!").toLowerCase(),"incorrect password","password","[ REDACTED ]");const o=decrypt(t,n.slice(0,16),a),u=computeAddress(o);if(t.address){let b=t.address.toLowerCase();b.startsWith("0x")||(b="0x"+b),assertArgument(getAddress(b)===u,"keystore address/privateKey mismatch","address",t.address)}const h={address:u,privateKey:o};if(spelunk(t,"x-ethers.version:string")==="0.1"){const b=n.slice(32,64),d=spelunk(t,"x-ethers.mnemonicCiphertext:data!"),p=spelunk(t,"x-ethers.mnemonicCounter:data!"),x=new CTR(b,p);h.mnemonic={path:spelunk(t,"x-ethers.path:string")||defaultPath$1,locale:spelunk(t,"x-ethers.locale:string")||"en",entropy:hexlify(getBytes(x.decrypt(d)))}}return h}function getDecryptKdfParams(t){const e=spelunk(t,"crypto.kdf:string");if(e&&typeof e=="string"){if(e.toLowerCase()==="scrypt"){const n=spelunk(t,"crypto.kdfparams.salt:data!"),a=spelunk(t,"crypto.kdfparams.n:int!"),c=spelunk(t,"crypto.kdfparams.r:int!"),o=spelunk(t,"crypto.kdfparams.p:int!");assertArgument(a>0&&(a&a-1)===0,"invalid kdf.N","kdf.N",a),assertArgument(c>0&&o>0,"invalid kdf","kdf",e);const u=spelunk(t,"crypto.kdfparams.dklen:int!");return assertArgument(u===32,"invalid kdf.dklen","kdf.dflen",u),{name:"scrypt",salt:n,N:a,r:c,p:o,dkLen:64}}else if(e.toLowerCase()==="pbkdf2"){const n=spelunk(t,"crypto.kdfparams.salt:data!"),a=spelunk(t,"crypto.kdfparams.prf:string!"),c=a.split("-").pop();assertArgument(c==="sha256"||c==="sha512","invalid kdf.pdf","kdf.pdf",a);const o=spelunk(t,"crypto.kdfparams.c:int!"),u=spelunk(t,"crypto.kdfparams.dklen:int!");return assertArgument(u===32,"invalid kdf.dklen","kdf.dklen",u),{name:"pbkdf2",salt:n,count:o,dkLen:u,algorithm:c}}}assertArgument(!1,"unsupported key-derivation function","kdf",e)}function decryptKeystoreJsonSync(t,e){const n=JSON.parse(t),a=getPassword(e),c=getDecryptKdfParams(n);if(c.name==="pbkdf2"){const{salt:p,count:x,dkLen:m,algorithm:v}=c,g=pbkdf2(a,p,x,m,v);return getAccount(n,g)}assert$f(c.name==="scrypt","cannot be reached","UNKNOWN_ERROR",{params:c});const{salt:o,N:u,r:h,p:l,dkLen:b}=c,d=scryptSync(a,o,u,h,l,b);return getAccount(n,d)}function stall$1(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}async function decryptKeystoreJson(t,e,n){const a=JSON.parse(t),c=getPassword(e),o=getDecryptKdfParams(a);if(o.name==="pbkdf2"){n&&(n(0),await stall$1(0));const{salt:x,count:m,dkLen:v,algorithm:g}=o,$=pbkdf2(c,x,m,v,g);return n&&(n(1),await stall$1(0)),getAccount(a,$)}assert$f(o.name==="scrypt","cannot be reached","UNKNOWN_ERROR",{params:o});const{salt:u,N:h,r:l,p:b,dkLen:d}=o,p=await scrypt(c,u,h,l,b,d,n);return getAccount(a,p)}function getEncryptKdfParams(t){const e=t.salt!=null?getBytes(t.salt,"options.salt"):randomBytes(32);let n=1<<17,a=8,c=1;return t.scrypt&&(t.scrypt.N&&(n=t.scrypt.N),t.scrypt.r&&(a=t.scrypt.r),t.scrypt.p&&(c=t.scrypt.p)),assertArgument(typeof n=="number"&&n>0&&Number.isSafeInteger(n)&&(BigInt(n)&BigInt(n-1))===BigInt(0),"invalid scrypt N parameter","options.N",n),assertArgument(typeof a=="number"&&a>0&&Number.isSafeInteger(a),"invalid scrypt r parameter","options.r",a),assertArgument(typeof c=="number"&&c>0&&Number.isSafeInteger(c),"invalid scrypt p parameter","options.p",c),{name:"scrypt",dkLen:32,salt:e,N:n,r:a,p:c}}function _encryptKeystore(t,e,n,a){const c=getBytes(n.privateKey,"privateKey"),o=a.iv!=null?getBytes(a.iv,"options.iv"):randomBytes(16);assertArgument(o.length===16,"invalid options.iv length","options.iv",a.iv);const u=a.uuid!=null?getBytes(a.uuid,"options.uuid"):randomBytes(16);assertArgument(u.length===16,"invalid options.uuid length","options.uuid",a.iv);const h=t.slice(0,16),l=t.slice(16,32),b=new CTR(h,o),d=getBytes(b.encrypt(c)),p=keccak256(concat([l,d])),x={address:n.address.substring(2).toLowerCase(),id:uuidV4(u),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:hexlify(o).substring(2)},ciphertext:hexlify(d).substring(2),kdf:"scrypt",kdfparams:{salt:hexlify(e.salt).substring(2),n:e.N,dklen:32,p:e.p,r:e.r},mac:p.substring(2)}};if(n.mnemonic){const m=a.client!=null?a.client:`ethers/${version$1}`,v=n.mnemonic.path||defaultPath$1,g=n.mnemonic.locale||"en",$=t.slice(32,64),B=getBytes(n.mnemonic.entropy,"account.mnemonic.entropy"),C=randomBytes(16),F=new CTR($,C),H=getBytes(F.encrypt(B)),W=new Date,ie="UTC--"+(W.getUTCFullYear()+"-"+zpad$1(W.getUTCMonth()+1,2)+"-"+zpad$1(W.getUTCDate(),2)+"T"+zpad$1(W.getUTCHours(),2)+"-"+zpad$1(W.getUTCMinutes(),2)+"-"+zpad$1(W.getUTCSeconds(),2)+".0Z")+"--"+x.address;x["x-ethers"]={client:m,gethFilename:ie,path:v,locale:g,mnemonicCounter:hexlify(C).substring(2),mnemonicCiphertext:hexlify(H).substring(2),version:"0.1"}}return JSON.stringify(x)}function encryptKeystoreJsonSync(t,e,n){n==null&&(n={});const a=getPassword(e),c=getEncryptKdfParams(n),o=scryptSync(a,c.salt,c.N,c.r,c.p,64);return _encryptKeystore(getBytes(o),c,t,n)}async function encryptKeystoreJson(t,e,n){n==null&&(n={});const a=getPassword(e),c=getEncryptKdfParams(n),o=await scrypt(a,c.salt,c.N,c.r,c.p,64,n.progressCallback);return _encryptKeystore(getBytes(o),c,t,n)}const defaultPath="m/44'/60'/0'/0/0",MasterSecret=new Uint8Array([66,105,116,99,111,105,110,32,115,101,101,100]),HardenedBit=2147483648,N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Nibbles="0123456789abcdef";function zpad(t,e){let n="";for(;t;)n=Nibbles[t%16]+n,t=Math.trunc(t/16);for(;n.length<e*2;)n="0"+n;return"0x"+n}function encodeBase58Check(t){const e=getBytes(t),n=dataSlice(sha256$2(sha256$2(e)),0,4),a=concat([e,n]);return encodeBase58(a)}const _guard={};function ser_I(t,e,n,a){const c=new Uint8Array(37);t&HardenedBit?(assert$f(a!=null,"cannot derive child of neutered node","UNSUPPORTED_OPERATION",{operation:"deriveChild"}),c.set(getBytes(a),1)):c.set(getBytes(n));for(let u=24;u>=0;u-=8)c[33+(u>>3)]=t>>24-u&255;const o=getBytes(computeHmac("sha512",e,c));return{IL:o.slice(0,32),IR:o.slice(32)}}function derivePath(t,e){const n=e.split("/");assertArgument(n.length>0,"invalid path","path",e),n[0]==="m"&&(assertArgument(t.depth===0,`cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${t.depth}`,"path",e),n.shift());let a=t;for(let c=0;c<n.length;c++){const o=n[c];if(o.match(/^[0-9]+'$/)){const u=parseInt(o.substring(0,o.length-1));assertArgument(u<HardenedBit,"invalid path index",`path[${c}]`,o),a=a.deriveChild(HardenedBit+u)}else if(o.match(/^[0-9]+$/)){const u=parseInt(o);assertArgument(u<HardenedBit,"invalid path index",`path[${c}]`,o),a=a.deriveChild(u)}else assertArgument(!1,"invalid path component",`path[${c}]`,o)}return a}var or,xr,Ot,ir;const yt=class yt extends BaseWallet{constructor(n,a,c,o,u,h,l,b,d){super(a,d);Le(this,or);Fe(this,"publicKey");Fe(this,"fingerprint");Fe(this,"parentFingerprint");Fe(this,"mnemonic");Fe(this,"chainCode");Fe(this,"path");Fe(this,"index");Fe(this,"depth");assertPrivate(n,_guard,"HDNodeWallet"),defineProperties(this,{publicKey:a.compressedPublicKey});const p=dataSlice(ripemd160$1(sha256$2(this.publicKey)),0,4);defineProperties(this,{parentFingerprint:c,fingerprint:p,chainCode:o,path:u,index:h,depth:l}),defineProperties(this,{mnemonic:b})}connect(n){return new yt(_guard,this.signingKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.mnemonic,n)}async encrypt(n,a){return await encryptKeystoreJson(it(this,or,xr).call(this),n,{progressCallback:a})}encryptSync(n){return encryptKeystoreJsonSync(it(this,or,xr).call(this),n)}get extendedKey(){return assert$f(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),encodeBase58Check(concat(["0x0488ADE4",zpad(this.depth,1),this.parentFingerprint,zpad(this.index,4),this.chainCode,concat(["0x00",this.privateKey])]))}hasPath(){return this.path!=null}neuter(){return new HDNodeVoidWallet(_guard,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.provider)}deriveChild(n){const a=getNumber(n,"index");assertArgument(a<=4294967295,"invalid index","index",a);let c=this.path;c&&(c+="/"+(a&~HardenedBit),a&HardenedBit&&(c+="'"));const{IR:o,IL:u}=ser_I(a,this.chainCode,this.publicKey,this.privateKey),h=new SigningKey(toBeHex((toBigInt(u)+BigInt(this.privateKey))%N,32));return new yt(_guard,h,this.fingerprint,hexlify(o),c,a,this.depth+1,this.mnemonic,this.provider)}derivePath(n){return derivePath(this,n)}static fromExtendedKey(n){const a=toBeArray(decodeBase58(n));assertArgument(a.length===82||encodeBase58Check(a.slice(0,78))===n,"invalid extended key","extendedKey","[ REDACTED ]");const c=a[4],o=hexlify(a.slice(5,9)),u=parseInt(hexlify(a.slice(9,13)).substring(2),16),h=hexlify(a.slice(13,45)),l=a.slice(45,78);switch(hexlify(a.slice(0,4))){case"0x0488b21e":case"0x043587cf":{const b=hexlify(l);return new HDNodeVoidWallet(_guard,computeAddress(b),b,o,h,null,u,c,null)}case"0x0488ade4":case"0x04358394 ":if(l[0]!==0)break;return new yt(_guard,new SigningKey(l.slice(1)),o,h,null,u,c,null,null)}assertArgument(!1,"invalid extended key prefix","extendedKey","[ REDACTED ]")}static createRandom(n,a,c){var u;n==null&&(n=""),a==null&&(a=defaultPath),c==null&&(c=LangEn.wordlist());const o=Mnemonic.fromEntropy(randomBytes(16),n,c);return it(u=yt,Ot,ir).call(u,o.computeSeed(),o).derivePath(a)}static fromMnemonic(n,a){var c;return a||(a=defaultPath),it(c=yt,Ot,ir).call(c,n.computeSeed(),n).derivePath(a)}static fromPhrase(n,a,c,o){var h;a==null&&(a=""),c==null&&(c=defaultPath),o==null&&(o=LangEn.wordlist());const u=Mnemonic.fromPhrase(n,a,o);return it(h=yt,Ot,ir).call(h,u.computeSeed(),u).derivePath(c)}static fromSeed(n){var a;return it(a=yt,Ot,ir).call(a,n,null)}};or=new WeakSet,xr=function(){const n={address:this.address,privateKey:this.privateKey},a=this.mnemonic;return this.path&&a&&a.wordlist.locale==="en"&&a.password===""&&(n.mnemonic={path:this.path,locale:"en",entropy:a.entropy}),n},Ot=new WeakSet,ir=function(n,a){assertArgument(isBytesLike(n),"invalid seed","seed","[REDACTED]");const c=getBytes(n,"seed");assertArgument(c.length>=16&&c.length<=64,"invalid seed","seed","[REDACTED]");const o=getBytes(computeHmac("sha512",MasterSecret,c)),u=new SigningKey(hexlify(o.slice(0,32)));return new yt(_guard,u,"0x00000000",hexlify(o.slice(32)),"m",0,0,a,null)},Le(yt,Ot);let HDNodeWallet=yt;class HDNodeVoidWallet extends VoidSigner{constructor(n,a,c,o,u,h,l,b,d){super(a,d);Fe(this,"publicKey");Fe(this,"fingerprint");Fe(this,"parentFingerprint");Fe(this,"chainCode");Fe(this,"path");Fe(this,"index");Fe(this,"depth");assertPrivate(n,_guard,"HDNodeVoidWallet"),defineProperties(this,{publicKey:c});const p=dataSlice(ripemd160$1(sha256$2(c)),0,4);defineProperties(this,{publicKey:c,fingerprint:p,parentFingerprint:o,chainCode:u,path:h,index:l,depth:b})}connect(n){return new HDNodeVoidWallet(_guard,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,n)}get extendedKey(){return assert$f(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),encodeBase58Check(concat(["0x0488B21E",zpad(this.depth,1),this.parentFingerprint,zpad(this.index,4),this.chainCode,this.publicKey]))}hasPath(){return this.path!=null}deriveChild(n){const a=getNumber(n,"index");assertArgument(a<=4294967295,"invalid index","index",a);let c=this.path;c&&(c+="/"+(a&~HardenedBit),a&HardenedBit&&(c+="'"));const{IR:o,IL:u}=ser_I(a,this.chainCode,this.publicKey,null),h=SigningKey.addPoints(u,this.publicKey,!0),l=computeAddress(h);return new HDNodeVoidWallet(_guard,l,h,this.fingerprint,hexlify(o),c,a,this.depth+1,this.provider)}derivePath(n){return derivePath(this,n)}}function isCrowdsaleJson(t){try{if(JSON.parse(t).encseed)return!0}catch{}return!1}function decryptCrowdsaleJson(t,e){const n=JSON.parse(t),a=getPassword(e),c=getAddress(spelunk(n,"ethaddr:string!")),o=looseArrayify(spelunk(n,"encseed:string!"));assertArgument(o&&o.length%16===0,"invalid encseed","json",t);const u=getBytes(pbkdf2(a,a,2e3,32,"sha256")).slice(0,16),h=o.slice(0,16),l=o.slice(16),b=new CBC(u,h),d=pkcs7Strip(getBytes(b.decrypt(l)));let p="";for(let x=0;x<d.length;x++)p+=String.fromCharCode(d[x]);return{address:c,privateKey:id(p)}}function stall(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}var fr,yr;const kt=class kt extends BaseWallet{constructor(e,n){typeof e=="string"&&!e.startsWith("0x")&&(e="0x"+e);let a=typeof e=="string"?new SigningKey(e):e;super(a,n)}connect(e){return new kt(this.signingKey,e)}async encrypt(e,n){const a={address:this.address,privateKey:this.privateKey};return await encryptKeystoreJson(a,e,{progressCallback:n})}encryptSync(e){const n={address:this.address,privateKey:this.privateKey};return encryptKeystoreJsonSync(n,e)}static async fromEncryptedJson(e,n,a){var o;let c=null;return isKeystoreJson(e)?c=await decryptKeystoreJson(e,n,a):isCrowdsaleJson(e)&&(a&&(a(0),await stall(0)),c=decryptCrowdsaleJson(e,n),a&&(a(1),await stall(0))),it(o=kt,fr,yr).call(o,c)}static fromEncryptedJsonSync(e,n){var c;let a=null;return isKeystoreJson(e)?a=decryptKeystoreJsonSync(e,n):isCrowdsaleJson(e)?a=decryptCrowdsaleJson(e,n):assertArgument(!1,"invalid JSON wallet","json","[ REDACTED ]"),it(c=kt,fr,yr).call(c,a)}static createRandom(e){const n=HDNodeWallet.createRandom();return e?n.connect(e):n}static fromPhrase(e,n){const a=HDNodeWallet.fromPhrase(e);return n?a.connect(n):a}};fr=new WeakSet,yr=function(e){if(assertArgument(e,"invalid JSON wallet","json","[ REDACTED ]"),"mnemonic"in e&&e.mnemonic&&e.mnemonic.locale==="en"){const a=Mnemonic.fromEntropy(e.mnemonic.entropy),c=HDNodeWallet.fromMnemonic(a,e.mnemonic.path);if(c.address===e.address&&c.privateKey===e.privateKey)return c;console.log("WARNING: JSON mismatch address/privateKey != mnemonic; fallback onto private key")}const n=new kt(e.privateKey);return assertArgument(n.address===e.address,"address/privateKey mismatch","json","[ REDACTED ]"),n},Le(kt,fr);let Wallet=kt;const byteToHex=[];for(let t=0;t<256;++t)byteToHex.push((t+256).toString(16).slice(1));function unsafeStringify(t,e=0){return(byteToHex[t[e+0]]+byteToHex[t[e+1]]+byteToHex[t[e+2]]+byteToHex[t[e+3]]+"-"+byteToHex[t[e+4]]+byteToHex[t[e+5]]+"-"+byteToHex[t[e+6]]+byteToHex[t[e+7]]+"-"+byteToHex[t[e+8]]+byteToHex[t[e+9]]+"-"+byteToHex[t[e+10]]+byteToHex[t[e+11]]+byteToHex[t[e+12]]+byteToHex[t[e+13]]+byteToHex[t[e+14]]+byteToHex[t[e+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(t,e,n){if(native.randomUUID&&!e&&!t)return native.randomUUID();t=t||{};const a=t.random||(t.rng||rng)();return a[6]=a[6]&15|64,a[8]=a[8]&63|128,unsafeStringify(a)}function sleep(t){return new Promise(e=>{setTimeout(e,t)})}class EventEmitter{constructor(){this.events={},this.on=this.on.bind(this),this.off=this.off.bind(this),this.cleanAll=this.cleanAll.bind(this),this.emit=this.emit.bind(this)}on(e,n){this.events[e]||(this.events[e]=[]),this.events[e].push(n)}off(e,n){if(!this.events[e])return;const a=this.events[e].indexOf(n);a>-1&&this.events[e].splice(a,1)}cleanAll(){this.events={}}emit(e,n){this.events[e]&&this.events[e].forEach(a=>a(n))}}class Queue{constructor(e={},n){this.tasks=[],this.isProcessing=!1,this.isWaiting=!1,this.clearWaitTime=e.clearWaitTime||500,this.handleError=n}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.tasks.length>0;){const e=this.tasks.shift();if(e)try{const n=e();n instanceof Promise&&await n}catch(n){this.handleError({error:n,context:"Error processing task",throw:!1})}}this.isProcessing=!1}}enqueue(e){this.tasks.push(e),this.processQueue()}async clearQueue(){for(this.tasks=[];this.isProcessing;)await sleep(this.clearWaitTime)}async waitForProcessing(){if(this.isWaiting)return!0;for(this.isWaiting=!0;this.isProcessing;)await sleep(this.clearWaitTime);return this.isWaiting=!1,!1}}const CONSENSUS_ID="SwarmStream",EVENTS={LOADING_INIT_USERS:"loadingInitUsers",MESSAGE_RECEIVED:"messageReceived",MESSAGE_REQUEST_SENT:"messageRequestSent",MESSAGE_REQUEST_ERROR:"messageRequestError",ERROR:"errorEvent"},SECOND=1e3,HEX_RADIX=16;var BeeType=(t=>(t.READER="reader",t.WRITER="writer",t.GSOC="gsoc",t))(BeeType||{}),buffer$1={},base64Js={};base64Js.byteLength=byteLength;base64Js.toByteArray=toByteArray;base64Js.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;revLookup[45]=62;revLookup[95]=63;function getLens(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var a=n===e?0:4-n%4;return[n,a]}function byteLength(t){var e=getLens(t),n=e[0],a=e[1];return(n+a)*3/4-a}function _byteLength(t,e,n){return(e+n)*3/4-n}function toByteArray(t){var e,n=getLens(t),a=n[0],c=n[1],o=new Arr(_byteLength(t,a,c)),u=0,h=c>0?a-4:a,l;for(l=0;l<h;l+=4)e=revLookup[t.charCodeAt(l)]<<18|revLookup[t.charCodeAt(l+1)]<<12|revLookup[t.charCodeAt(l+2)]<<6|revLookup[t.charCodeAt(l+3)],o[u++]=e>>16&255,o[u++]=e>>8&255,o[u++]=e&255;return c===2&&(e=revLookup[t.charCodeAt(l)]<<2|revLookup[t.charCodeAt(l+1)]>>4,o[u++]=e&255),c===1&&(e=revLookup[t.charCodeAt(l)]<<10|revLookup[t.charCodeAt(l+1)]<<4|revLookup[t.charCodeAt(l+2)]>>2,o[u++]=e>>8&255,o[u++]=e&255),o}function tripletToBase64(t){return lookup[t>>18&63]+lookup[t>>12&63]+lookup[t>>6&63]+lookup[t&63]}function encodeChunk(t,e,n){for(var a,c=[],o=e;o<n;o+=3)a=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),c.push(tripletToBase64(a));return c.join("")}function fromByteArray(t){for(var e,n=t.length,a=n%3,c=[],o=16383,u=0,h=n-a;u<h;u+=o)c.push(encodeChunk(t,u,u+o>h?h:u+o));return a===1?(e=t[n-1],c.push(lookup[e>>2]+lookup[e<<4&63]+"==")):a===2&&(e=(t[n-2]<<8)+t[n-1],c.push(lookup[e>>10]+lookup[e>>4&63]+lookup[e<<2&63]+"=")),c.join("")}var ieee754={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ieee754.read=function(t,e,n,a,c){var o,u,h=c*8-a-1,l=(1<<h)-1,b=l>>1,d=-7,p=n?c-1:0,x=n?-1:1,m=t[e+p];for(p+=x,o=m&(1<<-d)-1,m>>=-d,d+=h;d>0;o=o*256+t[e+p],p+=x,d-=8);for(u=o&(1<<-d)-1,o>>=-d,d+=a;d>0;u=u*256+t[e+p],p+=x,d-=8);if(o===0)o=1-b;else{if(o===l)return u?NaN:(m?-1:1)*(1/0);u=u+Math.pow(2,a),o=o-b}return(m?-1:1)*u*Math.pow(2,o-a)};ieee754.write=function(t,e,n,a,c,o){var u,h,l,b=o*8-c-1,d=(1<<b)-1,p=d>>1,x=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=a?0:o-1,v=a?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(h=isNaN(e)?1:0,u=d):(u=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-u))<1&&(u--,l*=2),u+p>=1?e+=x/l:e+=x*Math.pow(2,1-p),e*l>=2&&(u++,l/=2),u+p>=d?(h=0,u=d):u+p>=1?(h=(e*l-1)*Math.pow(2,c),u=u+p):(h=e*Math.pow(2,p-1)*Math.pow(2,c),u=0));c>=8;t[n+m]=h&255,m+=v,h/=256,c-=8);for(u=u<<c|h,b+=c;b>0;t[n+m]=u&255,m+=v,u/=256,b-=8);t[n+m-v]|=g*128};/*!
1
+ "use strict";var yP=Object.defineProperty;var JA=r=>{throw TypeError(r)};var mP=(r,e,t)=>e in r?yP(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Q=(r,e,t)=>mP(r,typeof e!="symbol"?e+"":e,t),$y=(r,e,t)=>e.has(r)||JA("Cannot "+t);var T=(r,e,t)=>($y(r,e,"read from private field"),t?t.call(r):e.get(r)),se=(r,e,t)=>e.has(r)?JA("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),F=(r,e,t,n)=>($y(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Ee=(r,e,t)=>($y(r,e,"access private method"),t);var _f=(r,e,t,n)=>({set _(i){F(r,e,i,t)},get _(){return T(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt=require("@ethersphere/bee-js");var Qr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function no(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function gp(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}function wP(){this.__data__=[],this.size=0}var bP=wP;function _P(r,e){return r===e||r!==r&&e!==e}var Wh=_P,AP=Wh;function vP(r,e){for(var t=r.length;t--;)if(AP(r[t][0],e))return t;return-1}var yp=vP,EP=yp,xP=Array.prototype,RP=xP.splice;function IP(r){var e=this.__data__,t=EP(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():RP.call(e,t,1),--this.size,!0}var SP=IP,kP=yp;function TP(r){var e=this.__data__,t=kP(e,r);return t<0?void 0:e[t][1]}var OP=TP,NP=yp;function CP(r){return NP(this.__data__,r)>-1}var BP=CP,PP=yp;function MP(r,e){var t=this.__data__,n=PP(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var LP=MP,UP=bP,DP=SP,$P=OP,FP=BP,HP=LP;function kl(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}kl.prototype.clear=UP;kl.prototype.delete=DP;kl.prototype.get=$P;kl.prototype.has=FP;kl.prototype.set=HP;var mp=kl,zP=mp;function GP(){this.__data__=new zP,this.size=0}var KP=GP;function jP(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var WP=jP;function VP(r){return this.__data__.get(r)}var qP=VP;function ZP(r){return this.__data__.has(r)}var QP=ZP,JP=typeof Qr=="object"&&Qr&&Qr.Object===Object&&Qr,MR=JP,YP=MR,XP=typeof self=="object"&&self&&self.Object===Object&&self,e5=YP||XP||Function("return this")(),Mn=e5,t5=Mn,r5=t5.Symbol,Tl=r5,YA=Tl,LR=Object.prototype,n5=LR.hasOwnProperty,i5=LR.toString,Af=YA?YA.toStringTag:void 0;function s5(r){var e=n5.call(r,Af),t=r[Af];try{r[Af]=void 0;var n=!0}catch{}var i=i5.call(r);return n&&(e?r[Af]=t:delete r[Af]),i}var o5=s5,a5=Object.prototype,c5=a5.toString;function u5(r){return c5.call(r)}var l5=u5,XA=Tl,f5=o5,h5=l5,d5="[object Null]",p5="[object Undefined]",ev=XA?XA.toStringTag:void 0;function g5(r){return r==null?r===void 0?p5:d5:ev&&ev in Object(r)?f5(r):h5(r)}var Rc=g5;function y5(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Bi=y5,m5=Rc,w5=Bi,b5="[object AsyncFunction]",_5="[object Function]",A5="[object GeneratorFunction]",v5="[object Proxy]";function E5(r){if(!w5(r))return!1;var e=m5(r);return e==_5||e==A5||e==b5||e==v5}var wp=E5,x5=Mn,R5=x5["__core-js_shared__"],I5=R5,Fy=I5,tv=function(){var r=/[^.]+$/.exec(Fy&&Fy.keys&&Fy.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function S5(r){return!!tv&&tv in r}var k5=S5,T5=Function.prototype,O5=T5.toString;function N5(r){if(r!=null){try{return O5.call(r)}catch{}try{return r+""}catch{}}return""}var UR=N5,C5=wp,B5=k5,P5=Bi,M5=UR,L5=/[\\^$.*+?()[\]{}|]/g,U5=/^\[object .+?Constructor\]$/,D5=Function.prototype,$5=Object.prototype,F5=D5.toString,H5=$5.hasOwnProperty,z5=RegExp("^"+F5.call(H5).replace(L5,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function G5(r){if(!P5(r)||B5(r))return!1;var e=C5(r)?z5:U5;return e.test(M5(r))}var K5=G5;function j5(r,e){return r==null?void 0:r[e]}var W5=j5,V5=K5,q5=W5;function Z5(r,e){var t=q5(r,e);return V5(t)?t:void 0}var Ic=Z5,Q5=Ic,J5=Mn,Y5=Q5(J5,"Map"),qw=Y5,X5=Ic,e4=X5(Object,"create"),bp=e4,rv=bp;function t4(){this.__data__=rv?rv(null):{},this.size=0}var r4=t4;function n4(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var i4=n4,s4=bp,o4="__lodash_hash_undefined__",a4=Object.prototype,c4=a4.hasOwnProperty;function u4(r){var e=this.__data__;if(s4){var t=e[r];return t===o4?void 0:t}return c4.call(e,r)?e[r]:void 0}var l4=u4,f4=bp,h4=Object.prototype,d4=h4.hasOwnProperty;function p4(r){var e=this.__data__;return f4?e[r]!==void 0:d4.call(e,r)}var g4=p4,y4=bp,m4="__lodash_hash_undefined__";function w4(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=y4&&e===void 0?m4:e,this}var b4=w4,_4=r4,A4=i4,v4=l4,E4=g4,x4=b4;function Ol(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Ol.prototype.clear=_4;Ol.prototype.delete=A4;Ol.prototype.get=v4;Ol.prototype.has=E4;Ol.prototype.set=x4;var R4=Ol,nv=R4,I4=mp,S4=qw;function k4(){this.size=0,this.__data__={hash:new nv,map:new(S4||I4),string:new nv}}var T4=k4;function O4(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var N4=O4,C4=N4;function B4(r,e){var t=r.__data__;return C4(e)?t[typeof e=="string"?"string":"hash"]:t.map}var _p=B4,P4=_p;function M4(r){var e=P4(this,r).delete(r);return this.size-=e?1:0,e}var L4=M4,U4=_p;function D4(r){return U4(this,r).get(r)}var $4=D4,F4=_p;function H4(r){return F4(this,r).has(r)}var z4=H4,G4=_p;function K4(r,e){var t=G4(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var j4=K4,W4=T4,V4=L4,q4=$4,Z4=z4,Q4=j4;function Nl(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Nl.prototype.clear=W4;Nl.prototype.delete=V4;Nl.prototype.get=q4;Nl.prototype.has=Z4;Nl.prototype.set=Q4;var Zw=Nl,J4=mp,Y4=qw,X4=Zw,eM=200;function tM(r,e){var t=this.__data__;if(t instanceof J4){var n=t.__data__;if(!Y4||n.length<eM-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new X4(n)}return t.set(r,e),this.size=t.size,this}var rM=tM,nM=mp,iM=KP,sM=WP,oM=qP,aM=QP,cM=rM;function Cl(r){var e=this.__data__=new nM(r);this.size=e.size}Cl.prototype.clear=iM;Cl.prototype.delete=sM;Cl.prototype.get=oM;Cl.prototype.has=aM;Cl.prototype.set=cM;var Ap=Cl,uM="__lodash_hash_undefined__";function lM(r){return this.__data__.set(r,uM),this}var fM=lM;function hM(r){return this.__data__.has(r)}var dM=hM,pM=Zw,gM=fM,yM=dM;function A0(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new pM;++e<t;)this.add(r[e])}A0.prototype.add=A0.prototype.push=gM;A0.prototype.has=yM;var mM=A0;function wM(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var bM=wM;function _M(r,e){return r.has(e)}var AM=_M,vM=mM,EM=bM,xM=AM,RM=1,IM=2;function SM(r,e,t,n,i,s){var o=t&RM,a=r.length,u=e.length;if(a!=u&&!(o&&u>a))return!1;var l=s.get(r),h=s.get(e);if(l&&h)return l==e&&h==r;var g=-1,b=!0,w=t&IM?new vM:void 0;for(s.set(r,e),s.set(e,r);++g<a;){var I=r[g],S=e[g];if(n)var x=o?n(S,I,g,e,r,s):n(I,S,g,r,e,s);if(x!==void 0){if(x)continue;b=!1;break}if(w){if(!EM(e,function(C,H){if(!xM(w,H)&&(I===C||i(I,C,t,n,s)))return w.push(H)})){b=!1;break}}else if(!(I===S||i(I,S,t,n,s))){b=!1;break}}return s.delete(r),s.delete(e),b}var DR=SM,kM=Mn,TM=kM.Uint8Array,$R=TM;function OM(r){var e=-1,t=Array(r.size);return r.forEach(function(n,i){t[++e]=[i,n]}),t}var NM=OM;function CM(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var BM=CM,iv=Tl,sv=$R,PM=Wh,MM=DR,LM=NM,UM=BM,DM=1,$M=2,FM="[object Boolean]",HM="[object Date]",zM="[object Error]",GM="[object Map]",KM="[object Number]",jM="[object RegExp]",WM="[object Set]",VM="[object String]",qM="[object Symbol]",ZM="[object ArrayBuffer]",QM="[object DataView]",ov=iv?iv.prototype:void 0,Hy=ov?ov.valueOf:void 0;function JM(r,e,t,n,i,s,o){switch(t){case QM:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case ZM:return!(r.byteLength!=e.byteLength||!s(new sv(r),new sv(e)));case FM:case HM:case KM:return PM(+r,+e);case zM:return r.name==e.name&&r.message==e.message;case jM:case VM:return r==e+"";case GM:var a=LM;case WM:var u=n&DM;if(a||(a=UM),r.size!=e.size&&!u)return!1;var l=o.get(r);if(l)return l==e;n|=$M,o.set(r,e);var h=MM(a(r),a(e),n,i,s,o);return o.delete(r),h;case qM:if(Hy)return Hy.call(r)==Hy.call(e)}return!1}var YM=JM;function XM(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Qw=XM,eL=Array.isArray,Ln=eL,tL=Qw,rL=Ln;function nL(r,e,t){var n=e(r);return rL(r)?n:tL(n,t(r))}var FR=nL;function iL(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var sL=iL;function oL(){return[]}var HR=oL,aL=sL,cL=HR,uL=Object.prototype,lL=uL.propertyIsEnumerable,av=Object.getOwnPropertySymbols,fL=av?function(r){return r==null?[]:(r=Object(r),aL(av(r),function(e){return lL.call(r,e)}))}:cL,Jw=fL;function hL(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var dL=hL;function pL(r){return r!=null&&typeof r=="object"}var di=pL,gL=Rc,yL=di,mL="[object Arguments]";function wL(r){return yL(r)&&gL(r)==mL}var bL=wL,cv=bL,_L=di,zR=Object.prototype,AL=zR.hasOwnProperty,vL=zR.propertyIsEnumerable,EL=cv(function(){return arguments}())?cv:function(r){return _L(r)&&AL.call(r,"callee")&&!vL.call(r,"callee")},vp=EL,v0={exports:{}};function xL(){return!1}var RL=xL;v0.exports;(function(r,e){var t=Mn,n=RL,i=e&&!e.nodeType&&e,s=i&&!0&&r&&!r.nodeType&&r,o=s&&s.exports===i,a=o?t.Buffer:void 0,u=a?a.isBuffer:void 0,l=u||n;r.exports=l})(v0,v0.exports);var Ep=v0.exports,IL=9007199254740991,SL=/^(?:0|[1-9]\d*)$/;function kL(r,e){var t=typeof r;return e=e??IL,!!e&&(t=="number"||t!="symbol"&&SL.test(r))&&r>-1&&r%1==0&&r<e}var xp=kL,TL=9007199254740991;function OL(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=TL}var Yw=OL,NL=Rc,CL=Yw,BL=di,PL="[object Arguments]",ML="[object Array]",LL="[object Boolean]",UL="[object Date]",DL="[object Error]",$L="[object Function]",FL="[object Map]",HL="[object Number]",zL="[object Object]",GL="[object RegExp]",KL="[object Set]",jL="[object String]",WL="[object WeakMap]",VL="[object ArrayBuffer]",qL="[object DataView]",ZL="[object Float32Array]",QL="[object Float64Array]",JL="[object Int8Array]",YL="[object Int16Array]",XL="[object Int32Array]",eU="[object Uint8Array]",tU="[object Uint8ClampedArray]",rU="[object Uint16Array]",nU="[object Uint32Array]",Gt={};Gt[ZL]=Gt[QL]=Gt[JL]=Gt[YL]=Gt[XL]=Gt[eU]=Gt[tU]=Gt[rU]=Gt[nU]=!0;Gt[PL]=Gt[ML]=Gt[VL]=Gt[LL]=Gt[qL]=Gt[UL]=Gt[DL]=Gt[$L]=Gt[FL]=Gt[HL]=Gt[zL]=Gt[GL]=Gt[KL]=Gt[jL]=Gt[WL]=!1;function iU(r){return BL(r)&&CL(r.length)&&!!Gt[NL(r)]}var sU=iU;function oU(r){return function(e){return r(e)}}var Xw=oU,E0={exports:{}};E0.exports;(function(r,e){var t=MR,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,s=i&&i.exports===n,o=s&&t.process,a=function(){try{var u=i&&i.require&&i.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}}();r.exports=a})(E0,E0.exports);var eb=E0.exports,aU=sU,cU=Xw,uv=eb,lv=uv&&uv.isTypedArray,uU=lv?cU(lv):aU,tb=uU,lU=dL,fU=vp,hU=Ln,dU=Ep,pU=xp,gU=tb,yU=Object.prototype,mU=yU.hasOwnProperty;function wU(r,e){var t=hU(r),n=!t&&fU(r),i=!t&&!n&&dU(r),s=!t&&!n&&!i&&gU(r),o=t||n||i||s,a=o?lU(r.length,String):[],u=a.length;for(var l in r)(e||mU.call(r,l))&&!(o&&(l=="length"||i&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||pU(l,u)))&&a.push(l);return a}var GR=wU,bU=Object.prototype;function _U(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||bU;return r===t}var rb=_U;function AU(r,e){return function(t){return r(e(t))}}var KR=AU,vU=KR,EU=vU(Object.keys,Object),xU=EU,RU=rb,IU=xU,SU=Object.prototype,kU=SU.hasOwnProperty;function TU(r){if(!RU(r))return IU(r);var e=[];for(var t in Object(r))kU.call(r,t)&&t!="constructor"&&e.push(t);return e}var jR=TU,OU=wp,NU=Yw;function CU(r){return r!=null&&NU(r.length)&&!OU(r)}var Rp=CU,BU=GR,PU=jR,MU=Rp;function LU(r){return MU(r)?BU(r):PU(r)}var Ip=LU,UU=FR,DU=Jw,$U=Ip;function FU(r){return UU(r,$U,DU)}var WR=FU,fv=WR,HU=1,zU=Object.prototype,GU=zU.hasOwnProperty;function KU(r,e,t,n,i,s){var o=t&HU,a=fv(r),u=a.length,l=fv(e),h=l.length;if(u!=h&&!o)return!1;for(var g=u;g--;){var b=a[g];if(!(o?b in e:GU.call(e,b)))return!1}var w=s.get(r),I=s.get(e);if(w&&I)return w==e&&I==r;var S=!0;s.set(r,e),s.set(e,r);for(var x=o;++g<u;){b=a[g];var C=r[b],H=e[b];if(n)var D=o?n(H,C,b,e,r,s):n(C,H,b,r,e,s);if(!(D===void 0?C===H||i(C,H,t,n,s):D)){S=!1;break}x||(x=b=="constructor")}if(S&&!x){var z=r.constructor,V=e.constructor;z!=V&&"constructor"in r&&"constructor"in e&&!(typeof z=="function"&&z instanceof z&&typeof V=="function"&&V instanceof V)&&(S=!1)}return s.delete(r),s.delete(e),S}var jU=KU,WU=Ic,VU=Mn,qU=WU(VU,"DataView"),ZU=qU,QU=Ic,JU=Mn,YU=QU(JU,"Promise"),XU=YU,eD=Ic,tD=Mn,rD=eD(tD,"Set"),nD=rD,iD=Ic,sD=Mn,oD=iD(sD,"WeakMap"),VR=oD,k1=ZU,T1=qw,O1=XU,N1=nD,C1=VR,qR=Rc,Bl=UR,hv="[object Map]",aD="[object Object]",dv="[object Promise]",pv="[object Set]",gv="[object WeakMap]",yv="[object DataView]",cD=Bl(k1),uD=Bl(T1),lD=Bl(O1),fD=Bl(N1),hD=Bl(C1),ga=qR;(k1&&ga(new k1(new ArrayBuffer(1)))!=yv||T1&&ga(new T1)!=hv||O1&&ga(O1.resolve())!=dv||N1&&ga(new N1)!=pv||C1&&ga(new C1)!=gv)&&(ga=function(r){var e=qR(r),t=e==aD?r.constructor:void 0,n=t?Bl(t):"";if(n)switch(n){case cD:return yv;case uD:return hv;case lD:return dv;case fD:return pv;case hD:return gv}return e});var Vh=ga,zy=Ap,dD=DR,pD=YM,gD=jU,mv=Vh,wv=Ln,bv=Ep,yD=tb,mD=1,_v="[object Arguments]",Av="[object Array]",Ld="[object Object]",wD=Object.prototype,vv=wD.hasOwnProperty;function bD(r,e,t,n,i,s){var o=wv(r),a=wv(e),u=o?Av:mv(r),l=a?Av:mv(e);u=u==_v?Ld:u,l=l==_v?Ld:l;var h=u==Ld,g=l==Ld,b=u==l;if(b&&bv(r)){if(!bv(e))return!1;o=!0,h=!1}if(b&&!h)return s||(s=new zy),o||yD(r)?dD(r,e,t,n,i,s):pD(r,e,u,t,n,i,s);if(!(t&mD)){var w=h&&vv.call(r,"__wrapped__"),I=g&&vv.call(e,"__wrapped__");if(w||I){var S=w?r.value():r,x=I?e.value():e;return s||(s=new zy),i(S,x,t,n,s)}}return b?(s||(s=new zy),gD(r,e,t,n,i,s)):!1}var _D=bD,AD=_D,Ev=di;function ZR(r,e,t,n,i){return r===e?!0:r==null||e==null||!Ev(r)&&!Ev(e)?r!==r&&e!==e:AD(r,e,t,n,ZR,i)}var nb=ZR,vD=nb;function ED(r,e){return vD(r,e)}var xD=ED;const RD=no(xD),zr=[];for(let r=0;r<256;++r)zr.push((r+256).toString(16).slice(1));function ID(r,e=0){return(zr[r[e+0]]+zr[r[e+1]]+zr[r[e+2]]+zr[r[e+3]]+"-"+zr[r[e+4]]+zr[r[e+5]]+"-"+zr[r[e+6]]+zr[r[e+7]]+"-"+zr[r[e+8]]+zr[r[e+9]]+"-"+zr[r[e+10]]+zr[r[e+11]]+zr[r[e+12]]+zr[r[e+13]]+zr[r[e+14]]+zr[r[e+15]]).toLowerCase()}let Gy;const SD=new Uint8Array(16);function kD(){if(!Gy){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Gy=crypto.getRandomValues.bind(crypto)}return Gy(SD)}const TD=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xv={randomUUID:TD};function OD(r,e,t){if(xv.randomUUID&&!e&&!r)return xv.randomUUID();r=r||{};const n=r.random||(r.rng||kD)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,ID(n)}function B1(r){return new Promise(e=>{setTimeout(e,r)})}function Rv(r,e,t,n){const i=new Map;return r.forEach(s=>{i.set(t(s),s)}),e.forEach(s=>{i.set(t(s),s)}),Array.from(i.values()).sort(n)}function P1(r){return(r.startsWith("0x")?r.slice(2):r).toLowerCase()}class ns{constructor(){}static getInstance(){return ns.instance||(ns.instance=new ns),ns.instance}formatMessage(e,...t){return`[${new Date().toISOString()}] [${e.toUpperCase()}] - ${t.map(i=>typeof i=="object"?JSON.stringify(i):i).join(" ")}`}log(...e){console.log(this.formatMessage("log",...e))}info(...e){console.info(this.formatMessage("info",...e))}warn(...e){console.warn(this.formatMessage("warn",...e))}error(...e){console.error(this.formatMessage("error",...e))}debug(...e){console.debug(this.formatMessage("debug",...e))}}class Sp{constructor(){this.logger=ns.getInstance()}handleError(e,t){const n=e instanceof Error?e.message:"Unknown error occurred",i=e instanceof Error?e.stack:null;this.logger.error(`Error in ${t||"unknown context"}: ${n}`,{stack:i})}}let ND=class{constructor(){this.events={},this.on=this.on.bind(this),this.off=this.off.bind(this),this.cleanAll=this.cleanAll.bind(this),this.emit=this.emit.bind(this)}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){if(!this.events[e])return;const n=this.events[e].indexOf(t);n>-1&&this.events[e].splice(n,1)}cleanAll(){this.events={}}emit(e,t){this.events[e]&&this.events[e].forEach(n=>n(t))}};class M1{constructor(e={}){this.tasks=[],this.isProcessing=!1,this.isWaiting=!1,this.errorHandler=new Sp,this.clearWaitTime=e.clearWaitTime||500}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.tasks.length>0;){const e=this.tasks.shift();if(e)try{const t=e();t instanceof Promise&&await t}catch(t){this.errorHandler.handleError(t,"Queue.processQueue")}}this.isProcessing=!1}}enqueue(e){this.tasks.push(e),this.processQueue()}async waitForProcessing(){if(this.isWaiting)return!0;for(this.isWaiting=!0;this.isProcessing;)await B1(this.clearWaitTime);return this.isWaiting=!1,!1}}var QR={};(function(r){var e;Object.defineProperty(r,"__esModule",{value:!0}),r.Vector=r.Cache=r.Assertions=r.Strings=r.Types=r.Objects=r.Dates=r.Promises=r.Numbers=r.System=r.Arrays=r.Random=r.Elliptic=r.Binary=r.AsyncQueue=r.PubSubChannel=r.FixedPointNumber=r.MerkleTree=r.Chunk=r.Uint8ArrayWriter=r.Uint8ArrayReader=r.AsyncLazy=r.Lazy=r.Optional=void 0;async function t(c){return new Promise((f,d)=>c.then(d,f))}async function n(c){return t(Promise.all(c.map(t)))}async function i(c,f=1){const d=vA(c,f),y=[],R=d.map(async L=>{for(const Y of L)y.push(await Y())});return await Promise.all(R),y}async function s(c){return new Promise(f=>setTimeout(()=>{f(!0)},c))}function o(c,f=Math.random){for(let d=c.length-1;d>0;d--){const y=Math.floor(f()*(d+1)),R=c[d];c[d]=c[y],c[y]=R}return c}function a(c){if(c.length===1)return c[0];throw Error(`Expected exactly one element, actual: ${c.length}`)}function u(c){return c.length===1?c[0]:null}function l(c){return c.length>0?c[0]:null}function h(c){if(!c.length)throw Error("Received empty array");return c[0]}function g(c,f){const d=[];for(let y=0;y<c;y++)d.push(f(y));return d}function b(c){const f=[];for(let d=0;d<c[0].length;d++){f.push([]);for(let y=0;y<c.length;y++)f[d].push(c[y][d])}return f}function w(c,f,d){const y=[];for(let R=0;R<c;R++){y.push([]);for(let L=0;L<f;L++)y[R].push(d)}return y}function I(c,f,d,y){if(d<0||y<0||y+f[0].length>c[0].length||d+f.length>c.length)return!1;for(let R=0;R<f.length;R++)for(let L=0;L<f[R].length;L++)if(f[R][L]!==void 0&&c[d+R][y+L]!==f[R][L])return!1;return!0}function S(c,f,d=Math.random){return o(K_(0,c.length-1),d).slice(0,f)}function x(c,f){return c.map(d=>d[f])}function C(c){let f=c,d=3405648695,y=3735928559;return function(){return f+=d,d^=f<<7,f*=y,y^=f<<13,f^=d^y,(f>>>0)/4294967296}}function H(c,f,d=Math.random){return Math.floor(d()*(f-c+1))+c}function D(c,f,d=Math.random){return d()*(f-c)+c}function z(){return Math.random()*2-1}function V(c,f,d){return f>=c.x&&f<c.x+c.width&&d>=c.y&&d<c.y+c.height}function Z(c,f,d,y=Math.random){let R,L;do R=H(0,c-1,y),L=H(0,f-1,y);while(d&&V(d,R,L));return[R,L]}function K(c,f=Math.random){const d=Math.floor(c),y=c-d;return W(y,f)?d+1:d}function W(c,f=Math.random){return f()<c}function oe(c,f=Math.random){return c[Math.floor(c.length*f())]}function ce(c,f,d=Math.random){if(f>c.length)throw new Error(`Count (${f}) is greater than array length (${c.length})`);return S(c,f,d).map(y=>c[y])}function ne(c,f,d,y=Math.random){if(f>c.length)throw new Error(`Count (${f}) is greater than array length (${c.length})`);const R=[];for(;R.length<f;){const L=oe(c,y);R.some(Y=>d(Y,L))||R.push(L)}return R}function ue(c,f,d,y,R,L=Math.random){const Y=c.filter(fe=>fe!==f&&fe!==d),de=[];for(f!==null&&de.push(f);Y.length&&de.length<y;){const fe=r.Random.intBetween(0,Y.length-1,L);R(Y[fe],de)&&de.push(Y[fe]),Y.splice(fe,1)}return o(de,L),{values:de,indexOfGuaranteed:f!==null?de.indexOf(f):-1}}function B(c){if(!c.length)throw Error("Received empty array");return c[c.length-1]}function p(c,f,d){return d(f.reduce((y,R)=>R(y),c))}function m(c,f){return d=>p(d,c,f)}function E(c,f,d){if(d===void 0&&(d=Math.random()),c.length!==f.length)throw new Error("Array length mismatch");let y=f.reduce((L,Y)=>L+Y,0);const R=d*y;for(let L=0;L<c.length-1;L++)if(y-=f[L],R>=y)return c[L];return B(c)}function k(c,f,d=Math.random){const y=f.map(L=>d()*L),R=[];for(let L=0;L<c.length;L++)R.push([c[L],y[L]]);return R.sort((L,Y)=>Y[1]-L[1]).map(L=>L[0])}function O(c,f){if(c==null)return null;const d=f.split(".");let y=c;for(const R of d){if(y[R]===null||y[R]===void 0)return null;y=y[R]}return y}function M(c,f,d){const y=f.split(/\.|\[/);let R=c;for(let L=0;L<y.length;L++){const Y=y[L],de=L<y.length-1&&y[L+1].includes("]"),fe=Y.includes("]")?Y.replace(/\[|\]/g,""):Y;if(L===y.length-1)return R[fe]=d,d;Jt(R[fe])||(de?R[fe]=[]:R[fe]={}),R=R[fe]}return d}function G(c,f,d=1){const y=O(c,f)||0;return M(c,f,y+d),y}function P(c,f,d){return O(c,f)||M(c,f,d)}function A(c,f){const d=xg(f,"."),y=W_(f,".");if(!d||!y)return;const R=O(c,d);delete R[y]}function U(c,f,d){const y=O(c,f);if(!y)throw new Error("Key '"+f+"' does not exist.");return M(c,f,d),y}function le(c,f,d){for(const y of f){const R=O(c,y);if(R)return R}if(d){const y=Object.values(c);if(y.length)return y[0]}return null}async function ee(c,f,d){for(;;){try{await c()}catch(y){d&&d("Error in forever",y)}await s(f)}}function re(c,f){c();const d=setInterval(()=>{c()},f);return()=>clearInterval(d)}function he(c){return c/1024/1024}function ye(c){return c>=1024*1024*1024*1024?(c/1024/1024/1024/1024).toFixed(3)+" TB":c>=1024*1024*1024?(c/1024/1024/1024).toFixed(3)+" GB":c>=1024*1024?(c/1024/1024).toFixed(3)+" MB":c>=1024?(c/1024).toFixed(3)+" KB":c+" B"}function be(c){const f=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c.toLowerCase());if(!f)throw new Error("Invalid hex color: "+c);return[parseInt(f[1],16),parseInt(f[2],16),parseInt(f[3],16)]}function je(c){return"#"+c.map(f=>f.toString(16).padStart(2,"0")).join("")}function $e(c,f,d,y){const R=c*Math.PI/180,L=d*Math.PI/180,Y=(d-c)*Math.PI/180,de=(y-f)*Math.PI/180,fe=Math.sin(Y/2)*Math.sin(Y/2)+Math.cos(R)*Math.cos(L)*Math.sin(de/2)*Math.sin(de/2);return 6371e3*(2*Math.atan2(Math.sqrt(fe),Math.sqrt(1-fe)))}function Oe(c,f){return Math.round(c/f)*f}function Xe(c){return c>1e3?(c/1e3).toFixed(0)+" km":c>=500?Oe(c,100)+" m":c>=100?Oe(c,50)+" m":Oe(c,10)+" m"}function qe(c){return c*(c+1)/2}function et(c){const f=c.match(/-?\d+(\.\d+)?/);if(!f)throw Error("No float found in "+c);return parseFloat(f[0])}function Jt(c,f=!0){return!c||f&&!Et(c._readableState)||f&&c.constructor&&(c.constructor.isBuffer||c.constructor.name=="Uint8Array"||c.constructor.name==="ArrayBuffer"||c.constructor.name==="ReadableStream")?!1:typeof c=="object"}function lt(c){return Jt(c)&&!Array.isArray(c)}function Mt(c){return Array.isArray(c)&&c.length===0}function oo(c){return lt(c)&&Object.keys(c).length===0}function Et(c){return c===void 0}function St(c){return Object.prototype.toString.call(c)==="[object Function]"||Object.prototype.toString.call(c)==="[object AsyncFunction]"}function Ar(c){return Object.prototype.toString.call(c)==="[object String]"}function ft(c){return typeof c=="number"&&isFinite(c)}function xt(c){return c===!0||c===!1}function Yt(c){return Object.prototype.toString.call(c)==="[object Date]"}function bt(c){return!Ar(c)||c.trim().length===0}function kt(c){return ft(c)&&Number.isInteger(c)&&c>=1}function Xr(c){return Ar(c)&&c.match(/^-?\d+$/)!==null}function Lt(c){return Ar(c)&&c.match(/^(0x)?[0-9a-f]+$/i)!==null}const N="!@#$%^&*()_+-=[]{}|;:<>?,./",_="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),v="abcdefghijklmnopqrstuvwxyz",$="ABCDEFGHIJKLMNOPQRSTUVWXYZ",j="1234567890",J=v+$+j,ae=J+N,Ze=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],Ve="0123456789abcdef";function We(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=v[Math.floor(f()*v.length)];return d}function Ut(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=J[Math.floor(f()*J.length)];return d}function He(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=ae[Math.floor(f()*ae.length)];return d}function ar(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=Ze[Math.floor(f()*Ze.length)];return d}function Ad(c,f){const d=new RegExp(`[0-9a-f]{${f}}`,"i"),y=c.match(d);return y?y[0]:null}function cr(c,f,d=_){const y=V_(c,d);for(const R of y)if(f(R))return R;return null}function ur(c,f=Math.random){let d="";for(let y=0;y<c;y++)d+=Ve[Math.floor(f()*Ve.length)];return d}function vd(c,f){if(!Xr(c))throw new TypeError(`Expected integer string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=BigInt(c);if(f&&(f.min&&d<f.min||f.max&&d>f.max))throw RangeError(`Expected integer string${f!=null&&f.name?` for ${f.name}`:""} in range: ${f.min??"-inf"}..${f.max??"inf"}; got: `+d);return c}function Xt(c,f){if(bt(c))throw new TypeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);if(f&&(f.min!==void 0&&c.length<f.min||f.max!==void 0&&c.length>f.max))throw RangeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""} length in range: ${f.min??"-inf"}..${f.max??"inf"}; got: ${c.length}`);return c}function lr(c,f){if(!Lt(c))throw new TypeError(`Expected hex string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=c.replace(/^0x/,"");if(f&&f.byteLength&&d.length!==f.byteLength*2)throw RangeError(`Expected hex string${f!=null&&f.name?` for ${f.name}`:""} of byte length ${f.byteLength}; got: `+d);return d}function Ed(c,f){if(!Xt(c,f).split("").every(d=>d==="_"||af(d)))throw new TypeError(`Expected safe string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function er(c,f){if(f.min!==void 0&&c<f.min||f.max!==void 0&&c>f.max)throw RangeError(`Expected value${f!=null&&f.name?` for ${f.name}`:""} in range: ${f.min??"-inf"}..${f.max??"inf"}; got: ${c}`)}function fr(c,f){if(!St(c))throw new TypeError(`Expected function${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function ua(c,f){if(ft(c))return f&&er(c,f),c;if(!Ar(c)||!c.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=parseFloat(c);return f&&er(d,f),d}function Vt(c,f){return ua(c,f)|0}function hr(c,f){if(c==="true")return!0;if(c==="false")return!1;if(!xt(c))throw new TypeError(`Expected boolean${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function xd(c,f){if(!Yt(c))throw new TypeError(`Expected date${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function dr(c){return bt(c)?null:c}function pr(c,f){if(!Ar(c))throw new TypeError(`Expected string${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function Rd(c,f){if(kt(c))return c;const d=parseInt(c,10);if(!kt(d))throw new TypeError(`Expected id${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function gr(c,f){if(!Ar(c))throw new TypeError(`Expected time${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const d=c.split(":");if(d.length!==2)throw new TypeError(`Expected time${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);const y=parseInt(d[0],10),R=parseInt(d[1],10);if(!ft(y)||!ft(R)||y<0||y>23||R<0||R>59)throw new TypeError(`Expected time, got${f!=null&&f.name?` for ${f.name}`:""}: `+c);return`${String(y).padStart(2,"0")}:${String(R).padStart(2,"0")}`}function yr(c,f){if(!Array.isArray(c))throw new TypeError(`Expected array${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function la(c,f){if(!lt(c))throw new TypeError(`Expected object${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function mr(c,f){return c===null?null:la(c,f)}function wr(c,f){const d=la(c,f);for(const y of Object.keys(d))if(!Ar(d[y]))throw new TypeError(`Expected string map${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function Wl(c,f){const d=la(c),y=Object.keys(d),R=Object.values(d);if(!y.every(Ar)||!R.every(ft))throw new TypeError(`Expected numeric dictionary${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return d}function Pc(c){return Ar(c)&&c.match(/^https?:\/\/.+/)!==null}function Vl(c,f){if(!Pc(c))throw new TypeError(`Expected url${f!=null&&f.name?` for ${f.name}`:""}, got: `+c);return c}function ql(c,f){return f==null?!0:c(f)}function Zl(c,f){return f==null?null:c(f)}function Ql(c,f){return f==null?void 0:c(f)}function Mc(c,f){for(const[d,y]of Object.entries(f))if(!y(c[d]))throw TypeError(`${d} in value does not exist or match shape`);for(const d of Object.keys(c))if(!f[d])throw TypeError(`${d} exists in value but not in shape`);return!0}function Jl(c,f){return c.every(d=>Mc(d,f))}function ms(c,f="json",d=0){if(Jt(c,!1)){if(d>1)return"[object Object]";if(f==="json"){if(Array.isArray(c)){const R=c.map(L=>ms(L,"json",d+1));return d===0?JSON.stringify(R):R}const y={};c.message&&(y.message=ms(c.message,"json",d+1));for(const[R,L]of Object.entries(c))y[R]=ms(L,"json",d+1);return d===0?JSON.stringify(y):y}else if(f==="key-value"){const y=Object.keys(c);return c.message&&!y.includes("message")&&y.unshift("message"),y.map(R=>`${R}=${JSON.stringify(ms(c[R],"json",d+1))}`).join(" ")}}return Et(c)&&(c="undefined"),d===0?JSON.stringify(c):c}function Yl(c,f){if(Ar(c))return c;const d=Object.keys(c);c.message&&!d.includes("message")&&d.push("message");const y=d.map(R=>`${R}: ${c[R]}`).join("; ");return f&&c.stack?y+`
2
+ `+c.stack:y}function pi(c,f){if(lt(c)&&lt(f))for(const d in f)lt(f[d])?(c[d]||(c[d]={}),pi(c[d],f[d])):Array.isArray(f[d])?c[d]=[...f[d]]:(f[d]!==null&&f[d]!==void 0||c[d]===null||c[d]===void 0)&&(c[d]=f[d]);return c}function Xl(c,f){const d={};return pi(d,c),pi(d,f),d}function ef(c,f,d){const y={};return pi(y,c),pi(y,f),pi(y,d),y}function Lc(c,f){const d={};for(const y of c)for(const R of Object.keys(y))d[R]?d[R]=f(d[R],y[R]):d[R]=y[R];return d}function tf(c){return Lc(c,(f,d)=>f+d)}function rf(c,f,d){c[f]||(c[f]=[]),c[f].push(d)}function nf(c,f,d){for(c.unshift(f);c.length>d;)c.pop()}function sf(c,f){let d=f%c.length;return d<0&&(d+=c.length),c[d]}function ao(c,f){Array.prototype.push.apply(c,f)}function p6(c,f){Array.prototype.unshift.apply(c,f)}async function g6(c,f){const d=[];for(const y of c)d.push(await f(y));return d}function y6(c,f){const d=[];for(let y=0;y<c.length;y++)d.push(c[y]),y<c.length-1&&(St(f)?d.push(f()):d.push(f));return d}function m6(c,f){if(c!==f)throw Error(`Expected [${c}] to equal [${f}]`);return[c,f]}function w6(c){if(c!==!0)throw Error(`Expected [true], got: [${c}]`);return c}function b6(c){if(!c)throw Error(`Expected truthy value, got: [${c}]`);return c}function _6(c){if(c!==!1)throw Error(`Expected [false], got: [${c}]`);return c}function A6(c){if(c)throw Error(`Expected falsy value, got: [${c}]`);return c}function v6(c,f){if(!f.includes(c))throw Error(`Expected any of [${f.join(", ")}], got: [${c}]`);return c}function E6(c,f){for(let d=0;d<c.length;d++){const y=c[d],R=f[d],L=Math.max(0,R.getTime()-Date.now());setTimeout(y,L)}}function x6(c,f,d){return c+(f-c)*d}function R6(c){return c.reduce((f,d)=>f+d,0)}function I6(c){return c.reduce((f,d)=>f+d,0)/c.length}function S6(c){const f=[...c].sort((y,R)=>y-R),d=Math.floor(f.length/2);return f.length%2===0?(f[d]+f[d-1])/2:f[d]}function k6(c,f){return c-(f-1)/2}function K_(c,f){const d=[];for(let y=c;y<=f;y++)d.push(y);return d}function T6(c,f){return f.some(d=>c.includes(d))}function O6(c){return/^[\u4E00-\u9FA5]+$/.test(c)}function vg(c,f=()=>!1){return c.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(d=>/[a-z0-9]/.test(d)||f(d)?d:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function N6(c){return vg(c).replaceAll("-","")}function C6(c){return Sd(c.replace(/([A-Z])/g," $1"))}function B6(c){return c.split("-").map(Sd).join(" ")}function P6(c){return Z_(c.split("-").map(Sd).join(""))}function M6(c,f=", ",d=" and "){return!c||!c.length?"":c.length===1?c[0]:c.length===2?`${c[0]}${d}${c[1]}`:`${c.slice(0,c.length-1).join(f)}${d}${c[c.length-1]}`}function L6(c,f){return f+c.split("").join(f)+f}function U6(c){return vg(c).replace(/-/g,"_").toUpperCase()}function Id(c,f){if(f.length===0)return 0;const d=c.toLowerCase(),y=f.toLowerCase();return c===f?1e4:d.startsWith(y)?1e4-c.length:d.includes(y)?5e3-c.length:new RegExp(".*"+y.split("").join(".*")+".*").test(d)?1e3-c.length:0}function D6(c,f){return c.filter(d=>Id(d,f)).sort((d,y)=>Id(y,f)-Id(d,f))}function $6(c){return c.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const F6={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function H6(c){let f=c.replace(/&#(\d+);/g,(d,y)=>String.fromCharCode(y)).replace(/&#x(\d+);/g,(d,y)=>String.fromCharCode(parseInt(y,16)));for(const[d,y]of Object.entries(F6))f=f.replaceAll(d,y);return f}function j_(c,f){const d=c.indexOf(f);return d===-1?null:c.slice(0,d)}function Eg(c,f){const d=c.indexOf(f);return d===-1?null:c.slice(d+f.length)}function xg(c,f){const d=c.lastIndexOf(f);return d===-1?null:c.slice(0,d)}function W_(c,f){const d=c.lastIndexOf(f);return d===-1?null:c.slice(d+f.length)}function z6(c,f,d){const y=xg(c,d);return y?Eg(y,f):null}function G6(c,f,d){const y=Eg(c,f);return y?j_(y,d):null}function Rg(c,f,d=!1){const y=d?c.lastIndexOf(f):c.indexOf(f);return y===-1?d?[null,c]:[c,null]:[c.slice(0,y),c.slice(y+f.length)]}function V_(c,f){let d=[c];for(const y of f)d=d.flatMap(R=>R.split(y));return d.filter(y=>y)}function Ig(c){const f=B(c.split(/\\|\//g)),d=f.lastIndexOf(".",f.length-1);return d<=0?"":f.slice(d+1)}function Sg(c){const f=B(c.split(/\\|\//g)),d=f.lastIndexOf(".",f.length-1);return d<=0?f:f.slice(0,d)}function K6(c){let[f,d]=c.split("@");f=of(f.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[y]=f.split("+");if(!y||!d||d.indexOf(".")===-1||d.indexOf(".")===d.length-1)throw new Error("Invalid email");return d=of(d.toLowerCase()).replaceAll(" ",""),`${y}@${d}`}function j6(c){const f=Sg(c),d=Ig(c);return d?`${f}.${d}`:f}function W6(c){const f=Sg(c),d=Ig(c);return{basename:f,extension:d,filename:d?`${f}.${d}`:f}}function V6(c,f=Math.random){return c.replace(/\{(.+?)\}/g,(d,y)=>oe(y.split("|"),f))}function q_(c){const f=/\{(.+?)\}/,d=c.match(f);if(!d||!d.index)return[c];const y=d[1].split(","),R=c.slice(0,d.index),L=c.slice(d.index+d[0].length);let Y=[];for(const de of y){const fe=q_(R+de+L);Y=Y.concat(fe)}return Y}function of(c){return c.split(`
3
+ `).map(f=>f.trim().replace(/\s+/g," ")).filter(f=>f.length>0).join(`
4
+ `)}function Sd(c){return c.charAt(0).toUpperCase()+c.slice(1)}function Z_(c){return c.charAt(0).toLowerCase()+c.slice(1)}function Q_(c){if(!c)return!1;const f=c.charCodeAt(0);return f>=65&&f<=90||f>=97&&f<=122}function J_(c){if(!c)return!1;const f=c.charCodeAt(0);return f>=48&&f<=57}function af(c){return Q_(c)||J_(c)}const q6=`
5
+ \r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function Z6(c){return q6.includes(c)}function Q6(c){return af(c)||c==="."||c==="["||c==="]"||c==="_"}function J6(c,f,d,y,R){return c.slice(0,f)+y+c.slice(f,f+d)+R+c.slice(f+d)}function Y_(c,f,d=0){const y=f.exec(c.slice(d));return y?{index:y.index,match:y[0]}:null}function X_(c,f,d=!0){if(!d)return f.every(R=>R instanceof RegExp?R.test(c):c.indexOf(R,0)!==-1);let y=0;for(const R of f)if(R instanceof RegExp){const L=Y_(c,R,y);if(!L)return!1;y=L.index+L.match.length}else{const L=c.indexOf(R,y);if(L===-1)return!1;y=L+R.length}return!0}function Y6(c,f,d=!0){let y=0;for(const R of f){let L=!1;for(;!L&&y<c.length;)X_(c[y],R,d)&&(L=!0),y++;if(!L)return!1}return!0}function X6(c){return c.match(/"|,/)?`"${c.replace(/"/g,'""')}"`:c}function Uc(c,f,d=0){let y=-1;for(const R of f){const L=c.indexOf(R,d);L!==-1&&(y===-1||L<y)&&(y=L)}return y}function e3(c,f=0){for(let d=f;d<c.length;d++)if(Z6(c[d]))return d;return-1}function t3(c,f=0){for(let d=f;d<c.length;d++)if(c[d]==="#"&&af(c[d+1]))return d;return-1}function eA(c,f,d=0){return c.slice(0,d).lastIndexOf(f)}function tA(c,f=0,d="{",y="}"){let R=1;for(let L=f;L<c.length;L++)if(c.slice(L,L+y.length)===y){if(--R===0)return L}else c.slice(L,L+d.length)===d&&R++;return-1}function rA(c,f){const d=f.wordBoundary?Uc(c,[`${f.opening} `,`${f.opening}
6
+ `],f.start||0):c.indexOf(f.opening,f.start||0);if(d===-1)return null;const y=tA(c,d+f.opening.length,f.opening,f.closing);return y===-1?null:f.exclusive?c.slice(d+f.opening.length,y):c.slice(d,y+f.closing.length)}function r3(c,f){const d=[];let y=f.wordBoundary?Uc(c,[`${f.opening} `,`${f.opening}
7
+ `],f.start||0):c.indexOf(f.opening,f.start||0);for(;;){if(y===-1)return d;const R=rA(c,{...f,start:y});if(!R)return d;d.push(R),y=f.wordBoundary?Uc(c,[`${f.opening} `,`${f.opening}
8
+ `],y+R.length):c.indexOf(f.opening,y+R.length)}}function n3(c,f,d){let y=0;for(;;){const R=r.Strings.extractBlock(c,{...d,start:y});if(!R)return c;const L=f(R);y=c.indexOf(R,y)+L.length,c=c.replace(R,L)}}function i3(c,f){const d=[];let y=0;for(;y<c.length;){const R=c.indexOf(f,y);if(R===-1){d.push({string:c.slice(y),symbol:null});break}const L=c.indexOf(f,R+f.length);if(R>y&&L!==-1&&d.push({string:c.slice(y,R),symbol:null}),L===-1){d.push({string:c.slice(y),symbol:null});break}d.push({string:c.slice(R+f.length,L),symbol:f}),y=L+f.length}return d}function s3(c){const f=[];let d=0;for(;d<c.length;){const y=t3(c,d);if(y===-1){f.push({string:c.slice(d),symbol:null});break}const R=e3(c,y+1);if(R===-1){f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y+1),symbol:"#"});break}y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y+1,R),symbol:"#"}),d=R}return f}function o3(c){const f=[];let d=0;for(;d<c.length;){const y=Uc(c,["http://","https://"],d);if(y===-1){f.push({string:c.slice(d),symbol:null});break}const R=Uc(c,[" ",`
9
+ `],y);if(R===-1){y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y),symbol:"http"});break}y>d&&f.push({string:c.slice(d,y),symbol:null}),f.push({string:c.slice(y,R),symbol:"http"}),d=R}return f}const nA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",iA="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function a3(c){return sA(c,nA)}function c3(c){return oA(c,nA)}function u3(c){return sA(c,iA)}function l3(c){return oA(c,iA)}function sA(c,f){const d="=",y=f.length;let R=0,L=0;const Y=[];for(let de=0;de<c.length;de++){const fe=c[de];if(fe===d)break;const Le=f.indexOf(fe);if(Le===-1)throw new Error(`Invalid character: ${fe}`);L=L<<Math.log2(y)|Le,R+=Math.log2(y),R>=8&&(R-=8,Y.push(L>>R&255))}return new Uint8Array(Y)}function oA(c,f){const d=f.length;let y=0,R=0,L="";for(let Y=0;Y<c.length;Y++)for(R=R<<8|c[Y],y+=8;y>=Math.log2(d);)y-=Math.log2(d),L+=f[R>>y&d-1];return y>0&&(L+=f[R<<Math.log2(d)-y&d-1]),L.length%4!==0&&(L+="=".repeat(4-L.length%4)),L}function f3(c){c.startsWith("0x")&&(c=c.slice(2));const f=c.length/2,d=new Uint8Array(f);for(let y=0;y<f;y++){const R=parseInt(c.slice(y*2,y*2+2),16);d[y]=R}return d}function h3(c){return Array.from(c).map(f=>f.toString(16).padStart(2,"0")).join("")}function d3(c,f){const d=c.split("/").filter(L=>L),y=f.split("/").filter(L=>L);if(d.length!==y.length)return null;const R={};for(let L=0;L<d.length;L++){const Y=d[L];if(Y.startsWith(":"))R[Y.slice(1)]=y[L];else if(Y!==y[L])return null}return R}function kg(c,f,d){const y=[];for(const R of d)R!==f&&y.push(c.replace(f,R));return y}function p3(c,f,d,y=Math.random){const R=r.Arrays.shuffle(f.map(Y=>({variants:r.Arrays.shuffle(Y.variants.map(de=>de),y),avoid:Y.avoid})),y),L=[];for(const Y of R){const de=Y.variants.filter(Le=>Le!==Y.avoid),fe=de.find(Le=>c.includes(Le));if(fe&&(ao(L,kg(c,fe,de)),L.length>=d))break}if(L.length<d)for(const Y of R){const de=Y.variants.find(fe=>c.includes(fe));if(de&&(ao(L,kg(c,de,Y.variants)),L.length>=d))break}return L.slice(0,d)}function g3(c,f,d,y=!1){const R=new RegExp(y?`(?<=\\s|^)${f}(?=\\s|$)`:`\\b${f}\\b`,"g");return c.replace(R,d)}function y3(c,f){const d=/\b[A-Z][a-zA-Z0-9]*\b/g;return c.replace(d,y=>y.toUpperCase()===y?y:f(y))}function m3(c){return c.replace(/<[^>]*>/g,"")}function aA(c){const f=c.lastIndexOf(" ");if(f===-1)return{line:c,rest:""};const d=c.slice(0,f),y=c.slice(f+1);return{line:d,rest:y}}function w3(c,f={}){return[...c].reduce((d,y)=>d+(f[y]||1),0)}function b3(c,f,d={}){const y=[];let R="",L=0;for(let Y=0;Y<c.length;Y++){const de=c[Y],fe=d[de]||1;if(R+=de,L+=fe,L>f){const{line:Le,rest:Ct}=aA(R);y.push(Le),R=Ct,L=Ct.split("").map(Pr=>d[Pr]||1).reduce((Pr,Hc)=>Pr+Hc,0)}}return R&&y.push(R),y}function _3(c,f){const d=[];for(let y=0;y<=c.length;y++)d[y]=[y];for(let y=0;y<=f.length;y++)d[0][y]=y;for(let y=1;y<=c.length;y++)for(let R=1;R<=f.length;R++){const L=c[y-1]===f[R-1]?0:1;d[y][R]=Math.min(d[y-1][R]+1,d[y][R-1]+1,d[y-1][R-1]+L)}return d[c.length][f.length]}function Tg(c,f){return new RegExp(`\\b${f}\\b`).test(c)}function A3(c,f,d){return d==="any"?f.some(y=>Tg(c,y)):f.every(y=>Tg(c,y))}function v3(c){const f={},d=c.match(/([a-z\-]+)="([^"]+)"/g);if(d)for(const y of d){const[R,L]=Rg(y,"=");f[R]=L.slice(1,L.length-1)}return f}function kd(c,f,d=[]){let y="";for(;f<c.length&&(af(c[f])||d.includes(c[f]));)y+=c[f++];return y}function E3(c,f,d="$",y=":"){for(const R in f)c=cA(c,R,f[R],d,y);return c=uA(c),c}function cA(c,f,d,y="$",R=":"){if(d==="")return c;let L=c.indexOf(`${y}${f}`);for(;L!==-1;){if(c[L+f.length+1]===R)if(c[L+f.length+2]===R)c=c.replace(`${y}${f}${R}${R}`,d);else{const Y=kd(c,L+f.length+2,["_"]);c=c.replace(`${y}${f}${R}${Y}`,d)}else c=c.replace(`${y}${f}`,d);L=c.indexOf(`${y}${f}`,L+d.length)}return c}function uA(c,f="$",d=":"){let y=c.indexOf(f);for(;y!==-1;){const R=kd(c,y+1);if(c[y+R.length+1]===d)if(c[y+R.length+2]===d)c=c.replace(`${f}${R}${d}${d}`,"");else{const L=kd(c,y+R.length+2);c=c.replace(`${f}${R}${d}${L}`,L)}y=c.indexOf(f,y+1)}return c}function x3(c,f){let d=c.indexOf("](");for(;d!==-1;){const y=eA(c,"[",d),R=c.indexOf(")",d);if(y!==-1&&R!==-1){const[L,Y]=c.slice(y+1,R).split("]("),de=f(L,Y);c=c.slice(0,y)+de+c.slice(R+1)}d=c.indexOf("](",d+1)}return c}function lA(c,f=!0){const d=Object.entries(c).filter(([y,R])=>R!=null).map(([y,R])=>`${y}=${encodeURIComponent(R)}`).join("&");return d?(f?"?":"")+d:""}function R3(c){const f={},d=c.split("&");for(const y of d){const[R,L]=y.split("=");R&&L&&(f[R]=decodeURIComponent(L))}return f}function I3(c,f){return Object.prototype.hasOwnProperty.call(c,f)}function S3(c,f){let d=null,y=-1/0;for(const[R,L]of Object.entries(c)){const Y=f(L);Y>y&&(y=Y,d=R)}return d?[d,c[d]]:null}function k3(c,f,d,y){const R=c.find(Y=>Y[f]===d),L=c.find(Y=>Y[f]===d+y);R&&L?(R[f]=d+y,L[f]=d):R&&(R[f]=d+y),c.sort((Y,de)=>ua(Y[f])-ua(de[f])),c.forEach((Y,de)=>Y[f]=de+1)}function T3(c){const f=Object.keys(c);if(f.length===1)return c[f[0]];throw new Error("Expected object to have a single key")}function O3(c,f=":"){return Object.fromEntries(c.map(d=>Rg(d,f)).map(d=>d[0]&&d[1]?[of(d[0]),of(d[1])]:null).filter(d=>d))}function N3(c,f,d){return pA(c,f)+lA(d||{})}function C3(c,f=",",d='"'){const y=[];let R="",L=!1;const Y=c.split("");for(const de of Y)de===f&&!L?(y.push(R),R=""):de===d&&(!R&&!L||L)?L=!L:R+=de;return y.push(R),y}function B3(c){return`[${Math.floor(c.progress*100)}%] ${Td(c.deltaMs)} out of ${Td(c.totalTimeMs)} (${Td(c.remainingTimeMs)} left) [${Math.round(c.baseTimeMs)} ms each]`}async function P3(c,f,d){for(let y=0;y<d;y++){try{if(await c())return!0}catch{}y<d-1&&await s(f)}return!1}function M3(c,f){const d=[];for(let y=c.length-1;y>=0;y--)f(c[y])&&d.push(c.splice(y,1)[0]);return d}function L3(c){return JSON.parse(JSON.stringify(c))}function U3(c){return Math.ceil((c||Date.now())/1e3)}function D3(c){return(c||new Date).toISOString().slice(0,10)}function $3(c){return(c||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function F3(c){const f=new Date(c);return new Date(f.getTime()-f.getTimezoneOffset()*6e4)}function H3(c){return new Date(c)}function Mi(c){return String(Math.floor(c)).padStart(2,"0")}function z3(c){let[f,d]=c.split(":");ft(parseInt(f,10))||(f="0"),ft(parseInt(d,10))||(d="0");let y=Pg(Vt(f),0,23),R=Pg(Vt(d),0,59);return`${Mi(y)}:${Mi(R)}`}function Td(c){const f=Math.floor(c/36e5);c=c%36e5;const d=Math.floor(c/6e4);c=c%6e4;const y=Math.floor(c/1e3);return f?`${Mi(f)}:${Mi(d)}:${Mi(y)}`:`${Mi(d)}:${Mi(y)}`}function fa(c){return Math.floor((Yt(c)?c.getTime():c)/864e5)}const G3={today:(c,f)=>Mi(c)+":"+Mi(f),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:c=>`${c}w`};function K3(c,f){const d=new Date((f==null?void 0:f.now)||Date.now()),y=(f==null?void 0:f.labels)||G3,R=Yt(c)?c:new Date(c);if(fa(d)===fa(R))return y.today(R.getUTCHours(),R.getUTCMinutes(),R.getUTCHours()>12);if(fa(d)-fa(R)===1)return y.yesterday();const L=Ng(R);return fa(d)-fa(R)<7?y[L.day]():y.weeks(Math.round((d.getTime()-R.getTime())/6048e5))}const fA={now:()=>"A few seconds",seconds:c=>`${c} seconds`,minutes:c=>`${c} minutes`,hours:c=>`${c} hours`,days:c=>`${c} days`,weeks:c=>`${c} weeks`};function hA(c,f){const d=(f==null?void 0:f.now)??Date.now(),y=(f==null?void 0:f.labels)||fA,R=r.Types.isDate(c)?c.getTime():c;let L=(d-R)/1e3;return L<10?y.now():L<120?y.seconds(Math.floor(L)):(L/=60,L<120?y.minutes(Math.floor(L)):(L/=60,L<48?y.hours(Math.floor(L)):(L/=24,L<14?y.days(Math.floor(L)):(L/=7,y.weeks(Math.floor(L))))))}function j3(c,f=fA){return hA(0,{now:c*1e3,labels:f})}function W3(c,f,d){const y=((d==null?void 0:d.now)??Date.now())-c,R=Math.floor(y/f),L=f/((d==null?void 0:d.precision)??1)-Math.ceil(y%f/((d==null?void 0:d.precision)??1));return{cycles:R,remaining:L}}const Og={};function V3(c,f){return!Og[c]||Date.now()>Og[c]?(Og[c]=Date.now()+f,!0):!1}const q3={s:1e3,m:6e4,h:36e5,d:864e5};function Z3(c,f,d){return f=Yt(f)?f.getTime():f,d=d?Yt(d)?d.getTime():d:Date.now(),(d-f)/q3[c]}function Q3(c,f,d,y){y||(y=Date.now());const R=f/d,L=y-c,Y=L/f,de=Y*d,fe=de-L;return{deltaMs:L,progress:R,baseTimeMs:Y,totalTimeMs:de,remainingTimeMs:fe}}const J3={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function dA(c){return{zeroBasedIndex:c,day:J3[c]}}function Ng(c){return dA(c.getDay())}function Y3(c){return Ng(new Date(c))}function X3(c){return c*1e3}function eB(c){return c*6e4}function tB(c){return c*36e5}function rB(c){return c*864e5}const nB={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};function iB(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),y=nB[d];if(!y)throw Error(`Unknown unit: "${d}"`);return f*y}const sB={b:1,byte:1,bytes:1,kb:1024,kilobyte:1024,kilobytes:1024,mb:1024**2,megabyte:1024**2,megabytes:1024**2,gb:1024**3,gigabyte:1024**3,gigabytes:1024**3,tb:1024**4,terabyte:1024**4,terabytes:1024**4};function oB(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),y=sB[d];if(!y)throw Error(`Unknown unit: "${d}"`);return f*y}function aB(c){return c.replace(/ +/g," ").replace(/^ /gm,"")}const Cg={};async function cB(c,f,d){const y=Date.now(),R=Cg[c];if(R&&R.validUntil>y)return R.value;const L=await d(),Y=y+f;return Cg[c]={value:L,validUntil:Y},L}function uB(c){delete Cg[c]}function pA(...c){return c.filter(f=>f).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function lB(c,f,d,y,R=!0){const L=c.indexOf(f),Y=c.indexOf(d,L+f.length);if(L===-1||Y===-1)throw Error("Start or end not found");return R?c.substring(0,L+f.length)+y+c.substring(Y):c.substring(0,L)+y+c.substring(Y+d.length)}function fB(c){let f="p";c.startsWith("#")?(f="h1",c=c.slice(1).trim()):c.startsWith("-")&&(f="li",c=c.slice(1).trim());const d=c[0]===c[0].toUpperCase(),y=/[.?!]$/.test(c),R=/:$/.test(c);return{type:f,isCapitalized:d,hasPunctuation:y,endsWithColon:R}}function hB(c,f="(",d=")"){let y=0,R=0;for(;R<c.length;)if(c.startsWith(f,R)?(y++,R+=f.length):c.startsWith(d,R)?(y--,R+=d.length):R++,y<0)return!1;return f===d?y%2===0:y===0}function dB(c){c=c.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let f=c.length;for(;c=c.replace(/(\w+)[\s,']+\w+/g,"$1"),c.length!==f;)f=c.length;return c=c.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A"),c=c.replaceAll(/[a-z][a-zA-Z0-9]*/g,"a"),c=c.replaceAll(/[\u4E00-\u9FA5]+/g,"Z"),c}function gA(c){const f=Object.keys(c).sort((y,R)=>y.localeCompare(R)),d={};for(const y of f)d[y]=ha(c[y]);return d}function yA(c){const f=[];return c.sort((d,y)=>JSON.stringify(ha(d)).localeCompare(JSON.stringify(ha(y)))).forEach(d=>f.push(ha(d))),f}function ha(c){return Array.isArray(c)?yA(c):Jt(c)?gA(c):c}function mA(c,f){return JSON.stringify(ha(c))===JSON.stringify(ha(f))}function pB(...c){for(let f=1;f<c.length;f++)if(!mA(c[f-1],c[f]))return!1;return!0}function gB(c){try{return JSON.parse(c)}catch{return null}}function yB(){let c=0;return{next:()=>c++}}function mB(c){let f=0;return{next:()=>c[f++%c.length]}}function wB(c){let f;return d=>{const y=d===c&&f!==c;return f=d,y}}function bB(c,f,d,y,R){const L={};for(const Y of Object.keys(f))L[Y]=[];L[y]=[],R&&(c=c.sort(R));for(const Y of c){const de=Y[d],fe=f[de]?de:y;L[fe].length>=f[fe]?L[y].push(Y):L[fe].push(Y)}return L}function _B(c,f){const d=Object.keys(c),y=Object.keys(f);return{uniqueToA:d.filter(R=>!y.includes(R)),uniqueToB:y.filter(R=>!d.includes(R))}}function wA(c){const f=Object.keys(c);return f[Math.floor(Math.random()*f.length)]}function AB(c,f){const d=wA(c);return c[d]=f(c[d]),d}function vB(c){return c=c.replace(/\r\n/g,`
10
+ `),c=c.replace(/(\w+)\((.+)\)/g,(f,d,y)=>`${d}(${y.replaceAll(",","&comma;")})`),c=c.replace(/(,)(\s+})/g,"$2"),c=c.replace(/\.\.\..+?,/g,""),c=c.replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),c=c.replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),c=c.replace(/:(.+)\?(.+):/g,(f,d,y)=>`: (${d.trim()} && ${y.trim()}) ||`),c=c.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),c=c.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(f,d,y,R)=>`"${d}":"${y.trim()}"${R}`),c=c.replace(/("'|'")/g,'"'),c=c.replaceAll("&comma;",","),JSON.parse(c)}const co=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],EB=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],bA=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function xB(c,f,d){let y=c.length-f;if(y<=0)return"0."+"0".repeat(-y)+c+(d?" "+d:"");let R=c.substring(0,y),L=c.substring(y);return R===""&&(R="0"),R+"."+L+(d?" "+d:"")}function RB(c,f){const d=(f==null?void 0:f.longForm)??!1,y=f!=null&&f.unit?` ${f.unit}`:"",R=d?EB:bA,L=(f==null?void 0:f.precision)??1;if(c<co[0])return`${c}${y}`;for(let Y=0;Y<co.length-1;Y++)if(c<co[Y+1])return`${(c/co[Y]).toFixed(L)}${d?" ":""}${R[Y]}${y}`;return`${(c/co[co.length-1]).toFixed(L)}${d?" ":""}${R[co.length-1]}${y}`}function Bg(c){const f=parseFloat(c);if(isNaN(f))throw Error("makeNumber got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim(),y=bA.findIndex(R=>R.toLowerCase()===d.toLowerCase());return y===-1?f:f*co[y]}function Pg(c,f,d){return c<f?f:c>d?d:c}function IB(c,f,d){const y=c+f;return y>d?d:y}function SB(c,f,d){const y=c-f;return y<d?d:y}function kB(c,f){return f(c),c}function TB(c,f){c&&f(c)}function OB(c,f){const d=Object.keys(f);for(const y of d)Array.isArray(f[y])&&Array.isArray(c[y])&&ao(c[y],f[y])}function NB(c){return c.splice(0,c.length),c}function CB(c){for(const f of Object.keys(c))(Mt(c[f])||Array.isArray(c[f])&&c[f].every(d=>d==null))&&delete c[f];return c}function BB(c){for(const f of Object.entries(c))(f[1]===null||f[1]===void 0||Ar(f[1])&&bt(f[1]))&&delete c[f[0]];return c}function PB(c,f){const d={};for(const[y,R]of Object.entries(c))f(y)&&(d[y]=R);return d}function MB(c,f){const d={};for(const[y,R]of Object.entries(c))f(R)&&(d[y]=R);return d}function LB(c,f){const d={};for(const y of Object.entries(c))d[y[0]]=f(y[1]);return d}function UB(c,f){const d=[];let y=0;for(const R of c)d.push(f(R,y++));return d}async function DB(c,f){try{return await c()}catch{throw f}}function $B(c,f,d){d!=null&&(c[f]=d)}function FB(c,f,d,y){const R=O(d,y);R!=null&&M(c,f,R)}function HB(c){const f={};for(const[d,y]of Object.entries(c))f[y]=d;return f}function zB(c){const f=Object.keys(c),d=f.map(de=>c[de].length),y=d.reduce((de,fe)=>de*=fe);let R=1;const L=[1];for(let de=0;de<d.length-1;de++)R*=d[de],L.push(R);const Y=[];for(let de=0;de<y;de++){const fe={};for(let Le=0;Le<f.length;Le++){const Ct=c[f[Le]],Pr=Math.floor(de/L[Le])%Ct.length;fe[f[Le]]=Ct[Pr]}Y.push(fe)}return Y}function GB(c){return Object.values(c).filter(f=>f).length}function KB(c,f,d){return c+(d?"["+f+"]":(c.length?".":"")+f)}function Od(c,f,d,y,R){if(!Jt(f))return f;for(const[L,Y]of Object.entries(f)){const de=KB(d,L,y);Array.isArray(Y)?R?Od(c,Y,de,!0,R):c[de]=Y.map(fe=>Od(Array.isArray(fe)?[]:{},fe,"",!1,R)):Jt(Y)?Od(c,Y,de,!1,R):c[de]=Y}return c}function jB(c,f=!1,d){return Od({},c,d||"",!1,f)}function _A(c){if(!Jt(c))return c;const f=Array.isArray(c)?[]:{};for(const[d,y]of Object.entries(c))Array.isArray(y)?M(f,d,y.map(R=>_A(R))):M(f,d,y);return f}function WB(c,f,d){return f[c]?f[c]:d}function AA(c,f){const d={};for(const y of c){const R=f(y);d[R]=y}return d}function VB(c,f){const d={};for(const y of c){const R=f(y);d[R]||(d[R]=[]),d[R].push(y)}return d}function qB(c,f){const d=[];for(let y=0;y<c.length;y+=f)d.push(c.slice(y,y+f));return d}function vA(c,f){const d=Math.ceil(c.length/f),y=[];for(let R=0;R<c.length;R+=d)y.push(c.slice(R,R+d));return y}function EA(c,f){const d=[],y=Math.ceil(c.length/f);for(let R=0;R<y;R++)d.push(c.slice(R*f,R*f+f));return d}function ZB(c,f){const d=Math.ceil(c.length/f);return EA(c,d)}function QB(c,f){return Object.values(AA(c,f))}function JB(c,f,d,y,R){const L=f?c.map(f):c,Y={};for(const fe of L)Y[fe]=(Y[fe]||0)+1;const de=y?xA(Y,R?(fe,Le)=>fe[1]-Le[1]:(fe,Le)=>Le[1]-fe[1]):Y;return d?Object.keys(de):de}function xA(c,f){return Object.fromEntries(Object.entries(c).sort(f))}function YB(c){const f=[],d=Object.keys(c),y=c[d[0]].length;for(let R=0;R<y;R++){const L={};for(const Y of d)L[Y]=c[Y][R];f.push(L)}return f}function XB(c,f,d=1){for(const y of c)y[f]+=d}function e8(c,f,d){for(const y of c)y[f]=d}function Mg(c,f){const d=[];let y=[];return c.forEach((R,L)=>{(L===0||!f(R,c[L-1]))&&(y=[],d.push(y)),y.push(R)}),d}function t8(){return{map:new Map,keys:[]}}function r8(){return{map:new Map,keys:[]}}function RA(c,f,d,y=100){if(c.map.has(f)){const R=c.keys.indexOf(f);c.keys.splice(R,1)}if(c.map.set(f,d),c.keys.push(f),c.keys.length>y){const R=c.keys.shift();R&&c.map.delete(R)}}function n8(c,f,d,y=100){if(c.map.has(f)){const R=c.keys.indexOf(f);c.keys.splice(R,1)}if(c.map.set(f,d),c.keys.unshift(f),c.keys.length>y){const R=c.keys.shift();R&&c.map.delete(R)}}function i8(c,f,d,y,R=100){RA(c,f,{validUntil:Date.now()+y,data:d},R)}function s8(c,f){const d=c.map.get(f);return d&&d.validUntil>Date.now()?d.data:null}class uo{constructor(f){this.value=f}static of(f){return new uo(f)}static empty(){return new uo(null)}map(f){return new uo(this.value!==null&&this.value!==void 0?f(this.value):null)}mapAsync(f){return this.value!==null&&this.value!==void 0?f(this.value).then(d=>uo.of(d)):Promise.resolve(uo.empty())}ifPresent(f){return this.value!==null&&this.value!==void 0&&f(this.value),this}ifPresentAsync(f){return this.value!==null&&this.value!==void 0?f(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(f){return(this.value===null||this.value===void 0)&&f(),this}ifAbsentAsync(f){return this.value===null||this.value===void 0?f().then(()=>this):Promise.resolve(this)}getOrFallback(f){return this.value??f()}getOrFallbackAsync(f){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):f()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}r.Optional=uo;class o8{constructor(f){this.supplier=f,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}r.Lazy=o8;class a8{constructor(f){this.supplier=f,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}r.AsyncLazy=a8;function c8(c){return()=>c.forEach(f=>f())}function u8(c,f){return c.reduce((d,y)=>f(d)>f(y)?d:y)}function l8(c,f){const d=c.find(y=>y instanceof f);return uo.of(d)}function f8(c,f){return c.filter(d=>d instanceof f)}function h8(c,f){const d=[],y=Math.max(c.length,f.length);for(let R=0;R<y;R++)c[R]&&d.push(c[R]),f[R]&&d.push(f[R]);return d}function d8(c,f){return c.includes(f)?c.filter(d=>d!==f):[...c,f]}class p8{constructor(f){this.value=f,this.children=[]}}function g8(c,f,d,y,R=!1){const L=new Map,Y=[];c.forEach(fe=>{const Le=new p8(fe);L.set(fe[f],Le)}),c.forEach(fe=>{const Le=L.get(fe[f]);if(!Le)return;const Ct=fe[d];if(Ct){const Pr=L.get(Ct);Pr&&Pr.children.push(Le)}else Y.push(Le)});const de=fe=>{fe.children.sort((Le,Ct)=>{const Pr=Le.value[y],Hc=Ct.value[y];return R?Hc-Pr:Pr-Hc}),fe.children.forEach(de)};return Y.forEach(de),Y}function IA(c,f){if(Math.log2(c.length)%1!==0)throw new Error("Array length must be a power of 2");let d=[...c];for(;d.length>1;){const y=[];for(let R=0;R<d.length;R+=2){const L=d[R+1];y.push(f(d[R],L))}d=y}return d[0]}function Dc(...c){const f=c.reduce((R,L)=>R+L.length,0),d=new Uint8Array(f);let y=0;return c.forEach(R=>{d.set(R,y),y+=R.length}),d}function SA(c){return c[0]===137&&c[1]===80&&c[2]===78&&c[3]===71}function kA(c){return c[0]===255&&c[1]===216}function TA(c){return c[8]===87&&c[9]===69&&c[10]===66&&c[11]===80}function y8(c){return SA(c)||kA(c)||TA(c)}function m8(c){return new Uint8Array([c])}function w8(c){return c[0]}function b8(c,f){const d=new ArrayBuffer(2);return new DataView(d).setUint16(0,c,f==="LE"),new Uint8Array(d)}function _8(c,f){return new DataView(c.buffer).getUint16(c.byteOffset,f==="LE")}function A8(c,f){const d=new ArrayBuffer(4);return new DataView(d).setUint32(0,c,f==="LE"),new Uint8Array(d)}function v8(c,f){return new DataView(c.buffer).getUint32(c.byteOffset,f==="LE")}function Lg(c,f){const d=new ArrayBuffer(8);return new DataView(d).setBigUint64(0,BigInt(c),f==="LE"),new Uint8Array(d)}function E8(c,f){return new DataView(c.buffer).getBigUint64(c.byteOffset,f==="LE")}function $c(c,f){const d=new Uint8Array(32);let y=c;if(f==="LE"){for(let R=0;R<32;R++)d[R]=Number(y&0xffn),y>>=8n;return d}for(let R=31;R>=0;R--)d[R]=Number(y&0xffn),y>>=8n;return d}function Fc(c,f){let d=0n;if(f==="LE"){for(let y=31;y>=0;y--)d=d<<8n|BigInt(c[y]);return d}for(let y=0;y<32;y++)d=d<<8n|BigInt(c[y]);return d}function x8(c,f){const d=[];let y=0;for(const R of f)d.push(c.subarray(y,y+R)),y+=R;return d}function Ug(c,f){const d=[];for(let y=0;y<c.length;y+=f)d.push(c.subarray(y,y+f));return d}const OA=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function R8(c){for(let f=0;f<24;f++){const d=c[0]^c[10]^c[20]^c[30]^c[40],y=c[1]^c[11]^c[21]^c[31]^c[41],R=c[2]^c[12]^c[22]^c[32]^c[42],L=c[3]^c[13]^c[23]^c[33]^c[43],Y=c[4]^c[14]^c[24]^c[34]^c[44],de=c[5]^c[15]^c[25]^c[35]^c[45],fe=c[6]^c[16]^c[26]^c[36]^c[46],Le=c[7]^c[17]^c[27]^c[37]^c[47],Ct=c[8]^c[18]^c[28]^c[38]^c[48],Pr=c[9]^c[19]^c[29]^c[39]^c[49],Hc=R<<1|L>>>31,aP=L<<1|R>>>31,lf=Ct^Hc,ff=Pr^aP,cP=Y<<1|de>>>31,uP=de<<1|Y>>>31,hf=d^cP,df=y^uP,lP=fe<<1|Le>>>31,fP=Le<<1|fe>>>31,pf=R^lP,gf=L^fP,hP=Ct<<1|Pr>>>31,dP=Pr<<1|Ct>>>31,yf=Y^hP,mf=de^dP,pP=d<<1|y>>>31,gP=y<<1|d>>>31,wf=fe^pP,bf=Le^gP;c[0]^=lf,c[1]^=ff,c[2]^=hf,c[3]^=df,c[4]^=pf,c[5]^=gf,c[6]^=yf,c[7]^=mf,c[8]^=wf,c[9]^=bf,c[10]^=lf,c[11]^=ff,c[12]^=hf,c[13]^=df,c[14]^=pf,c[15]^=gf,c[16]^=yf,c[17]^=mf,c[18]^=wf,c[19]^=bf,c[20]^=lf,c[21]^=ff,c[22]^=hf,c[23]^=df,c[24]^=pf,c[25]^=gf,c[26]^=yf,c[27]^=mf,c[28]^=wf,c[29]^=bf,c[30]^=lf,c[31]^=ff,c[32]^=hf,c[33]^=df,c[34]^=pf,c[35]^=gf,c[36]^=yf,c[37]^=mf,c[38]^=wf,c[39]^=bf,c[40]^=lf,c[41]^=ff,c[42]^=hf,c[43]^=df,c[44]^=pf,c[45]^=gf,c[46]^=yf,c[47]^=mf,c[48]^=wf,c[49]^=bf;const Gg=c[0],Kg=c[1],jg=c[2]<<1|c[3]>>>31,Wg=c[3]<<1|c[2]>>>31,Vg=c[5]<<30|c[4]>>>2,qg=c[4]<<30|c[5]>>>2,Zg=c[6]<<28|c[7]>>>4,Qg=c[7]<<28|c[6]>>>4,Jg=c[8]<<27|c[9]>>>5,Yg=c[9]<<27|c[8]>>>5,Xg=c[11]<<4|c[10]>>>28,ey=c[10]<<4|c[11]>>>28,ty=c[13]<<12|c[12]>>>20,ry=c[12]<<12|c[13]>>>20,ny=c[14]<<6|c[15]>>>26,iy=c[15]<<6|c[14]>>>26,sy=c[17]<<23|c[16]>>>9,oy=c[16]<<23|c[17]>>>9,ay=c[18]<<20|c[19]>>>12,cy=c[19]<<20|c[18]>>>12,uy=c[20]<<3|c[21]>>>29,ly=c[21]<<3|c[20]>>>29,fy=c[22]<<10|c[23]>>>22,hy=c[23]<<10|c[22]>>>22,dy=c[25]<<11|c[24]>>>21,py=c[24]<<11|c[25]>>>21,gy=c[26]<<25|c[27]>>>7,yy=c[27]<<25|c[26]>>>7,my=c[29]<<7|c[28]>>>25,wy=c[28]<<7|c[29]>>>25,by=c[31]<<9|c[30]>>>23,_y=c[30]<<9|c[31]>>>23,Ay=c[33]<<13|c[32]>>>19,vy=c[32]<<13|c[33]>>>19,Ey=c[34]<<15|c[35]>>>17,xy=c[35]<<15|c[34]>>>17,Ry=c[36]<<21|c[37]>>>11,Iy=c[37]<<21|c[36]>>>11,Sy=c[38]<<8|c[39]>>>24,ky=c[39]<<8|c[38]>>>24,Ty=c[40]<<18|c[41]>>>14,Oy=c[41]<<18|c[40]>>>14,Ny=c[42]<<2|c[43]>>>30,Cy=c[43]<<2|c[42]>>>30,By=c[45]<<29|c[44]>>>3,Py=c[44]<<29|c[45]>>>3,My=c[47]<<24|c[46]>>>8,Ly=c[46]<<24|c[47]>>>8,Uy=c[48]<<14|c[49]>>>18,Dy=c[49]<<14|c[48]>>>18;c[0]=Gg^~ty&dy,c[1]=Kg^~ry&py,c[2]=ty^~dy&Ry,c[3]=ry^~py&Iy,c[4]=dy^~Ry&Uy,c[5]=py^~Iy&Dy,c[6]=Ry^~Uy&Gg,c[7]=Iy^~Dy&Kg,c[8]=Uy^~Gg&ty,c[9]=Dy^~Kg&ry,c[10]=Zg^~ay&uy,c[11]=Qg^~cy&ly,c[12]=ay^~uy&Ay,c[13]=cy^~ly&vy,c[14]=uy^~Ay&By,c[15]=ly^~vy&Py,c[16]=Ay^~By&Zg,c[17]=vy^~Py&Qg,c[18]=By^~Zg&ay,c[19]=Py^~Qg&cy,c[20]=jg^~ny&gy,c[21]=Wg^~iy&yy,c[22]=ny^~gy&Sy,c[23]=iy^~yy&ky,c[24]=gy^~Sy&Ty,c[25]=yy^~ky&Oy,c[26]=Sy^~Ty&jg,c[27]=ky^~Oy&Wg,c[28]=Ty^~jg&ny,c[29]=Oy^~Wg&iy,c[30]=Jg^~Xg&fy,c[31]=Yg^~ey&hy,c[32]=Xg^~fy&Ey,c[33]=ey^~hy&xy,c[34]=fy^~Ey&My,c[35]=hy^~xy&Ly,c[36]=Ey^~My&Jg,c[37]=xy^~Ly&Yg,c[38]=My^~Jg&Xg,c[39]=Ly^~Yg&ey,c[40]=Vg^~sy&my,c[41]=qg^~oy&wy,c[42]=sy^~my&by,c[43]=oy^~wy&_y,c[44]=my^~by&Ny,c[45]=wy^~_y&Cy,c[46]=by^~Ny&Vg,c[47]=_y^~Cy&qg,c[48]=Ny^~Vg&sy,c[49]=Cy^~qg&oy,c[0]^=OA[f*2],c[1]^=OA[f*2+1]}}function NA(c){const f=[];for(let d=0;d<c.length;d+=4)f.push(c[d]|c[d+1]<<8|c[d+2]<<16|c[d+3]<<24);return f}function CA(c,f){if(!c.length){const R=new Uint8Array(136);return R[0]=f,R[135]=128,[NA(R)]}const d=Ug(c,136),y=d[d.length-1];if(y.length<136){const R=new Uint8Array(136);R.set(y),R[y.length]=f,R[135]|=128,d[d.length-1]=R}if(y.length===136){const R=new Uint8Array(136);R[0]=f,R[135]=128,d.push(R)}return d.map(NA)}function BA(c,f){for(const d of f){for(let y=0;y<34;y+=2)c[y]^=d[y+1],c[y+1]^=d[y];R8(c)}return c}function PA(c){return new Uint8Array([c[1],c[1]>>-24,c[1]>>-16,c[1]>>-8,c[0],c[0]>>8,c[0]>>16,c[0]>>24,c[3],c[3]>>-24,c[3]>>-16,c[3]>>-8,c[2],c[2]>>8,c[2]>>16,c[2]>>24,c[5],c[5]>>-24,c[5]>>-16,c[5]>>-8,c[4],c[4]>>8,c[4]>>16,c[4]>>24,c[7],c[7]>>-24,c[7]>>-16,c[7]>>-8,c[6],c[6]>>8,c[6]>>16,c[6]>>24])}function ws(c){return PA(BA(new Array(50).fill(0),CA(c,1)))}function I8(c){return PA(BA(new Array(50).fill(0),CA(c,6)))}function S8(c,f,d){const y=Math.min(c.length,f.length,d/8+1);for(let R=0;R<y;R++){const L=c[R]^f[R];for(let Y=0;Y<8;Y++)if(L>>7-Y&1)return R*8+Y}return d}function k8(c,f){const d=Math.min(c.length,f.length);for(let y=0;y<d;y++)if(c[y]!==f[y])return c.subarray(0,y);return c.subarray(0,d)}function T8(c,f,d,y){const R=Math.floor(f/8),L=f%8;d===1?c[R]|=1<<(y==="BE"?7-L:L):c[R]&=~(1<<(y==="BE"?7-L:L))}function O8(c,f,d){const y=Math.floor(f/8),R=f%8;return c[y]>>(d==="BE"?7-R:R)&1}function N8(c,f,d=0){for(let y=d;y<c.length;y++)for(let R=0;R<f.length&&c[y+R]===f[R];R++)if(R===f.length-1)return y;return-1}function MA(c,f,d=0){if(c.length>=f)return c;const y=new Uint8Array(f);return y.fill(d),y.set(c,f-c.length),y}function C8(c,f,d=0){const y=c.length%f;return y===0?c:MA(c,c.length+f-y,d)}function LA(c,f,d=0){if(c.length>=f)return c;const y=new Uint8Array(f);return y.fill(d),y.set(c,0),y}function B8(c,f,d=0){const y=c.length%f;return y===0?c:LA(c,c.length+f-y,d)}function P8(c,f){const d=new Uint8Array(c.length);for(let y=0;y<c.length;y++)d[y]=c[y]^f[y%f.length];return d}function M8(c,f){if(c.length!==f.length)return!1;for(let d=0;d<c.length;d++)if(c[d]!==f[d])return!1;return!0}function Dt(c,f){return(c%f+f)%f}function cf(c,f){c=Dt(c,f);let[d,y]=[0n,1n],[R,L]=[f,c];for(;L!==0n;){const Y=R/L;[d,y]=[y,d-Y*y],[R,L]=[L,R-Y*L]}if(R>1n)throw new Error("a is not invertible");return d<0n&&(d+=f),d}function L8(c,f,d){let y=1n;for(c=Dt(c,d);f>0;)f%2n===1n&&(y=Dt(y*c,d)),c=Dt(c*c,d),f=f/2n;return y}function UA(c,f){return Dt(c,f)===0n?0n:f%4n===3n?L8(c,(f+1n)/4n,f):null}const en=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Br=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Nd=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Cd=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Dg(c,f,d){if(f===0n)return[0n,0n];const y=Dt(3n*c*c*cf(2n*f,d),d),R=Dt(y*y-2n*c,d),L=Dt(y*(c-R)-f,d);return[R,L]}function Bd(c,f,d,y,R){if(c===0n&&f===0n)return[d,y];if(d===0n&&y===0n)return[c,f];if(c===d&&f===Dt(-y,R))return[0n,0n];if(c===d&&f===y)return Dg(c,f,R);const L=Dt((y-f)*cf(d-c,R),R),Y=Dt(L*L-c-d,R),de=Dt(L*(c-Y)-f,R);return[Y,de]}function U8(c){if(c<=0n||c>=Br)throw new Error("Invalid private key");return da(Nd,Cd,c,en)}function D8(c){const f=c[1]%2n===0n?2:3;return new Uint8Array([f,...$c(c[0],"BE")])}function $8(c){if(c.length!==33||c[0]!==2&&c[0]!==3)throw new Error("Invalid compressed public key");const f=Fc(c.slice(1),"BE"),d=UA(Dt(f**3n+7n,en),en);if(!d)throw Error("Invalid x: does not correspond to a valid curve point");const y=Dt(-d,en),R=d%2n===0n;return[f,c[0]===2?R?d:y:R?y:d]}function F8(c){const f=new Uint8Array(20),d=ws(Dc($c(c[0],"BE"),$c(c[1],"BE")));return f.set(d.subarray(12)),f}function H8(c){const f=r.Binary.uint8ArrayToHex(c),d=r.Binary.uint8ArrayToHex(r.Binary.keccak256(new Uint8Array([...f].map(R=>R.charCodeAt(0)))));let y="0x";for(let R=0;R<f.length;R++)parseInt(d[R],16)>7?y+=f[R].toUpperCase():y+=f[R];return y}function da(c,f,d,y){let R=[0n,0n],L=[c,f];const Y=d.toString(2);for(const de of Y)de==="0"?(L=Bd(R[0],R[1],L[0],L[1],y),R=Dg(R[0],R[1],y)):(R=Bd(R[0],R[1],L[0],L[1],y),L=Dg(L[0],L[1],y));return R}function z8(c,f,d){return DA(Fc(ws(c),"BE"),f,d)}function DA(c,f,d){if(f<=0n||f>=Br)throw new Error("Invalid private key");if(d||(d=Dt(Fc(ws(Dc(ws($c(f,"BE")),$c(c,"BE"))),"BE"),Br)),d<=0n||d>=Br)throw new Error("Invalid nonce");const y=Dt(c,Br),R=da(Nd,Cd,d,en),L=Dt(R[0],Br);let Y=Dt((y+Dt(L,Br)*f)*cf(d,Br),Br);if(L===0n||Y===0n)throw new Error("Invalid r or s value");let de=R[1]%2n===0n?27n:28n;return Y>Br/2n&&(Y=Br-Y,de=de===27n?28n:27n),[L,Y,de]}function G8(c,f,d,y){const R=UA(Dt(f**3n+7n,en),en);if(!R)throw new Error("Invalid r: does not correspond to a valid curve point");const L=y===27n?0n:1n,Y=R%2n===L?R:en-R,de=Dt(Fc(ws(c),"BE"),Br),fe=da(f,Y,d,en),Le=da(Nd,Cd,de,en),Ct=Bd(fe[0],fe[1],Le[0],Dt(-Le[1],en),en);return da(Ct[0],Ct[1],cf(f,Br),en)}function K8(c,f,d,y){const R=Dt(Fc(ws(c),"BE"),Br),L=cf(y,Br),Y=Dt(R*L,Br),de=Dt(d*L,Br),fe=da(Nd,Cd,Y,en),Le=da(f[0],f[1],de,en),Ct=Bd(fe[0],fe[1],Le[0],Le[1],en);return d===Dt(Ct[0],Br)}class $A{constructor(f){this.cursor=0,this.buffer=f}read(f){const d=this.buffer.subarray(this.cursor,this.cursor+f);return this.cursor+=f,d}max(){return this.buffer.length-this.cursor}}r.Uint8ArrayReader=$A;class FA{constructor(f){this.buffer=f,this.cursor=0}write(f){const d=Math.min(this.max(),f.max());return this.buffer.set(f.read(d),this.cursor),this.cursor+=d,d}max(){return this.buffer.length-this.cursor}}r.Uint8ArrayWriter=FA;class Pd{constructor(f,d=0n){this.span=d,this.writer=new FA(new Uint8Array(f))}build(){return Dc(Lg(this.span,"LE"),this.writer.buffer)}hash(){const f=IA(Ug(this.writer.buffer,32),(d,y)=>ws(Dc(d,y)));return ws(Dc(Lg(this.span,"LE"),f))}}r.Chunk=Pd;class $g{constructor(f,d=4096){this.counters=[1],this.capacity=d,this.chunks=[new Pd(d)],this.onChunk=f}static async root(f,d=4096){const y=new e(e.NOOP,d);return await y.append(f),y.finalize()}async append(f,d=0,y=0n){const R=new $A(f);for(;R.max()>0;){this.chunks[d].writer.max()===0&&await this.elevate(d);const L=this.chunks[d].writer.write(R);y?this.chunks[d].span+=y:this.chunks[0].span+=BigInt(L)}}async elevate(f){this.counters[f]=++this.counters[f]%(this.capacity/32),this.chunks[f+1]||(this.chunks.push(new Pd(this.capacity)),this.counters.push(1)),await this.append(this.chunks[f].hash(),f+1,this.chunks[f].span),await this.onChunk(this.chunks[f]),this.chunks[f]=new Pd(this.capacity)}async finalize(f=0){return this.chunks[f+1]?this.counters[f]===1?(await this.elevate(f+1),this.chunks[f+1]=this.chunks[f],this.finalize(f+1)):(await this.elevate(f),this.finalize(f+1)):(await this.onChunk(this.chunks[f]),this.chunks[f])}}r.MerkleTree=$g,e=$g,$g.NOOP=async c=>{};class Li{constructor(f,d){if(d<0)throw Error("Scale must be non-negative");this.value=BigInt(f),this.scale=d}static fromDecimalString(f,d){let[y,R]=f.split(".");return R=(R||"").padEnd(d,"0").slice(0,d),new Li(BigInt(y+R),d)}add(f){return this.assertSameScale(f),new Li(this.value+f.value,this.scale)}subtract(f){return this.assertSameScale(f),new Li(this.value-f.value,this.scale)}multiply(f){return new Li(this.value*f,this.scale)}divmod(f){if(f===0n)throw new Error("Division by zero is not allowed");const d=this.value/f,y=this.value%f;return[new Li(d,this.scale),new Li(y,this.scale)]}exchange(f,d,y){if(f==="*"){const L=this.value*d.value/10n**BigInt(this.scale);return new Li(L,y)}this.assertSameScale(d);const R=this.value*10n**BigInt(y)/d.value;return new Li(R,y)}compare(f){return this.assertSameScale(f),this.value>f.value?1:this.value<f.value?-1:0}toDecimalString(){if(this.scale===0)return this.value.toString();const f=this.value.toString(),d=f.slice(0,-this.scale)||"0",y=f.slice(-this.scale).padStart(this.scale,"0");return`${d}.${y}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(f){if(this.scale!==f.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${f.scale}`)}}r.FixedPointNumber=Li;function j8(c){if(c.length===0)return null;const f=c[0];return f.ttlMax?--f.ttl<=0&&c.shift():f.ttlMax=f.ttl,{progress:(f.ttlMax-f.ttl)/f.ttlMax,data:f.data}}function Md(c,f,d,y){const R=c.findIndex(de=>de===`--${f}`||de.startsWith(`--${f}=`)),L=c[R];if(!L)return(d||{})[y||f||""]||null;if(L.includes("="))return L.split("=")[1];const Y=c[R+1];return Y&&!Y.startsWith("-")?Y:(d||{})[y||f||""]||null}function W8(c,f,d,y){const R=Md(c,f,d,y);if(!R)return null;try{return Bg(R)}catch{throw new Error(`Invalid number argument ${f}: ${R}`)}}function V8(c,f,d,y){const R=c.some(fe=>fe.endsWith("-"+f)),L=Md(c,f,d,y);if(!L&&R)return!0;if(!L&&!R)return null;const Y=["true","1","yes","y","on"],de=["false","0","no","n","off"];if(Y.includes(L.toLowerCase()))return!0;if(de.includes(L.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${f}: ${L}`)}function HA(c,f,d,y){const R=Md(c,f,d,y);if(!R)throw new Error(`Missing argument ${f}`);return R}function q8(c,f,d,y){const R=HA(c,f,d,y);try{return Bg(R)}catch{throw new Error(`Invalid argument ${f}: ${R}`)}}function zA(c,f){const d=c[f];c.splice(f,1),c.unshift(d)}function Z8(c,f){const d=[...c];return zA(d,f),d}function GA(c,f){return{x:c.x+f.x,y:c.y+f.y}}function Q8(c,f){return{x:c.x-f.x,y:c.y-f.y}}function Fg(c,f){return{x:c.x*f,y:c.y*f}}function J8(c){const f=Math.sqrt(c.x*c.x+c.y*c.y);return{x:c.x/f,y:c.y/f}}function KA(c,f,d){return{x:c.x+Math.cos(f)*d,y:c.y+Math.sin(f)*d}}function jA(c,f){return Math.sqrt((c.x-f.x)**2+(c.y-f.y)**2)}function uf(c,f,d="row-first"){const y=[];if(d==="column-first")for(let R=0;R<c.length;R++)for(let L=0;L<c[0].length;L++)f(R,L)&&y.push({x:R,y:L});else for(let R=0;R<c[0].length;R++)for(let L=0;L<c.length;L++)f(L,R)&&y.push({x:L,y:R});return y}function Y8(c,f,d){var y,R;return((y=c[f+1])==null?void 0:y[d])&&((R=c[f-1])==null?void 0:R[d])&&!c[f][d-1]&&!c[f][d+1]}function X8(c,f,d){var y,R;return c[f][d+1]&&c[f][d-1]&&!((y=c[f-1])!=null&&y[d])&&!((R=c[f+1])!=null&&R[d])}function WA(c,f,d){var y;return!((y=c[f-1])!=null&&y[d])}function VA(c,f,d){var y;return!((y=c[f+1])!=null&&y[d])}function qA(c,f,d){return!c[f][d-1]}function ZA(c,f,d){return!c[f][d+1]}function eP(c,f,d){var R,L,Y,de,fe,Le,Ct,Pr;const y=[];return c[f][d]?Y8(c,f,d)||X8(c,f,d)?[]:(!((R=c[f-1])!=null&&R[d-1])&&WA(c,f,d)&&qA(c,f,d)&&y.push({x:f,y:d}),!((L=c[f+1])!=null&&L[d-1])&&VA(c,f,d)&&qA(c,f,d)&&y.push({x:f+1,y:d}),!((Y=c[f-1])!=null&&Y[d+1])&&WA(c,f,d)&&ZA(c,f,d)&&y.push({x:f,y:d+1}),!((de=c[f+1])!=null&&de[d+1])&&VA(c,f,d)&&ZA(c,f,d)&&y.push({x:f+1,y:d+1}),y):((fe=c[f-1])!=null&&fe[d]&&c[f][d-1]&&y.push({x:f,y:d}),(Le=c[f+1])!=null&&Le[d]&&c[f][d-1]&&y.push({x:f+1,y:d}),(Ct=c[f-1])!=null&&Ct[d]&&c[f][d+1]&&y.push({x:f,y:d+1}),(Pr=c[f+1])!=null&&Pr[d]&&c[f][d+1]&&y.push({x:f+1,y:d+1}),y)}function tP(c,f,d,y){const R=[{x:0,y:0},{x:d,y:0},{x:0,y},{x:d,y}];for(let L=0;L<c.length;L++)for(let Y=0;Y<c[0].length;Y++){const de=eP(c,L,Y);for(const fe of de)R.some(Le=>Le.x===fe.x&&Le.y===fe.y)||R.push(fe)}return R.map(L=>({x:L.x*f,y:L.y*f}))}function rP(c,f){const d=uf(c,(fe,Le)=>c[fe][Le]===0&&c[fe][Le+1]!==0,"row-first").map(fe=>({...fe,dx:1,dy:0})),y=uf(c,(fe,Le)=>c[fe][Le]===0&&c[fe][Le-1]!==0,"row-first").map(fe=>({...fe,dx:1,dy:0})),R=uf(c,(fe,Le)=>{var Ct;return c[fe][Le]===0&&((Ct=c[fe-1])==null?void 0:Ct[Le])!==0},"column-first").map(fe=>({...fe,dx:0,dy:1})),L=uf(c,(fe,Le)=>{var Ct;return c[fe][Le]===0&&((Ct=c[fe+1])==null?void 0:Ct[Le])!==0},"column-first").map(fe=>({...fe,dx:0,dy:1}));d.forEach(fe=>fe.y++),L.forEach(fe=>fe.x++);const Y=Mg([...R,...L],(fe,Le)=>fe.x===Le.x&&fe.y-1===Le.y),de=Mg([...y,...d],(fe,Le)=>fe.y===Le.y&&fe.x-1===Le.x);return[...Y,...de].map(fe=>({start:fe[0],end:B(fe)})).map(fe=>({start:Fg(fe.start,f),end:Fg(GA(fe.end,{x:fe.start.dx,y:fe.start.dy}),f)}))}function nP(c,f){return Math.atan2(f.y-c.y,f.x-c.x)}function iP(c,f){return f.map(d=>nP(c,d)).sort((d,y)=>d-y)}function QA(c,f,d,y){const R=(y.y-d.y)*(f.x-c.x)-(y.x-d.x)*(f.y-c.y);if(R===0)return null;let L=c.y-d.y,Y=c.x-d.x;const de=(y.x-d.x)*L-(y.y-d.y)*Y,fe=(f.x-c.x)*L-(f.y-c.y)*Y;return L=de/R,Y=fe/R,L>0&&L<1&&Y>0&&Y<1?{x:c.x+L*(f.x-c.x),y:c.y+L*(f.y-c.y)}:null}function Hg(c,f,d){const y=[],R=KA(c,d,1e4);for(const L of f){const Y=QA(c,R,L.start,L.end);Y&&y.push(Y)}return y.length?y.reduce((L,Y)=>{const de=jA(c,Y),fe=jA(c,L);return de<fe?Y:L}):null}function sP(c,f,d){const y=iP(c,d),R=[];for(const L of y){const Y=Hg(c,f,L-.001),de=Hg(c,f,L+.001);Y&&R.push(Y),de&&R.push(de)}return R}class zg{constructor(){this.subscribers=[]}subscribe(f){return this.subscribers.push(f),()=>{this.subscribers=this.subscribers.filter(d=>d!==f)}}publish(f){this.subscribers.forEach(d=>d(f))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}r.PubSubChannel=zg;class oP{constructor(f,d){this.queue=[],this.running=0,this.onProcessed=new zg,this.onDrained=new zg,this.concurrency=f,this.capacity=d}process(){if(this.running>=this.concurrency)return;const f=this.queue.shift();f&&(this.running++,f().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),this.running===0&&this.onDrained.publish()}))}enqueue(f){if(this.queue.length<this.capacity)return this.queue.push(f),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(d=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(f),this.process(),this.onProcessed.clear(),d())})})}drain(){if(this.running===0)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(f=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),f()})})}}r.AsyncQueue=oP,r.Binary={hexToUint8Array:f3,uint8ArrayToHex:h3,base64ToUint8Array:a3,uint8ArrayToBase64:c3,base32ToUint8Array:u3,uint8ArrayToBase32:l3,log2Reduce:IA,partition:Ug,concatBytes:Dc,numberToUint8:m8,uint8ToNumber:w8,numberToUint16:b8,uint16ToNumber:_8,numberToUint32:A8,uint32ToNumber:v8,numberToUint64:Lg,uint64ToNumber:E8,numberToUint256:$c,uint256ToNumber:Fc,sliceBytes:x8,keccak256:ws,sha3_256:I8,proximity:S8,commonPrefix:k8,setBit:T8,getBit:O8,indexOf:N8,equals:M8,padStart:MA,padStartToMultiple:C8,padEnd:LA,padEndToMultiple:B8,xorCypher:P8},r.Elliptic={privateKeyToPublicKey:U8,compressPublicKey:D8,publicKeyFromCompressed:$8,publicKeyToAddress:F8,signMessage:z8,signHash:DA,verifySignature:K8,recoverPublicKey:G8,checksumEncode:H8},r.Random={intBetween:H,floatBetween:D,chance:W,signed:z,makeSeededRng:C,point:Z,procs:K},r.Arrays={countUnique:JB,makeUnique:QB,splitBySize:qB,splitByCount:vA,index:AA,indexCollection:VB,onlyOrThrow:a,onlyOrNull:u,firstOrThrow:h,firstOrNull:l,shuffle:o,initialize:g,initialize2D:w,rotate2D:b,containsShape:I,glue:y6,pluck:x,pick:oe,pickMany:ce,pickManyUnique:ne,pickWeighted:E,pickRandomIndices:S,pickGuaranteed:ue,last:B,pipe:p,makePipe:m,sortWeighted:k,pushAll:ao,unshiftAll:p6,filterAndRemove:M3,merge:OB,empty:NB,pushToBucket:rf,unshiftAndLimit:nf,atRolling:sf,group:Mg,createOscillator:mB,organiseWithLimits:bB,tickPlaybook:j8,getArgument:Md,getBooleanArgument:V8,getNumberArgument:W8,requireStringArgument:HA,requireNumberArgument:q8,bringToFront:Z8,bringToFrontInPlace:zA,findInstance:l8,filterInstances:f8,interleave:h8,toggle:d8,createHierarchy:g8,multicall:c8,maxBy:u8},r.System={sleepMillis:s,forever:ee,scheduleMany:E6,waitFor:P3,expandError:Yl,runAndSetInterval:re},r.Numbers={make:Bg,sum:R6,average:I6,median:S6,getDistanceFromMidpoint:k6,clamp:Pg,range:K_,interpolate:x6,createSequence:yB,increment:IB,decrement:SB,format:RB,fromDecimals:xB,makeStorage:oB,asMegabytes:he,convertBytes:ye,hexToRgb:be,rgbToHex:je,haversineDistanceToMeters:$e,roundToNearest:Oe,formatDistance:Xe,triangularNumber:qe,searchFloat:et},r.Promises={raceFulfilled:n,invert:t,runInParallelBatches:i},r.Dates={getTimestamp:K3,getTimeDelta:hA,secondsToHumanTime:j3,countCycles:W3,isoDate:D3,throttle:V3,timeSince:Z3,dateTimeSlug:$3,unixTimestamp:U3,fromUtcString:F3,fromMillis:H3,getProgress:Q3,humanizeTime:Td,humanizeProgress:B3,createTimeDigits:Mi,mapDayNumber:dA,getDayInfoFromDate:Ng,getDayInfoFromDateTimeString:Y3,seconds:X3,minutes:eB,hours:tB,days:rB,make:iB,normalizeTime:z3,absoluteDays:fa},r.Objects={safeParse:gB,deleteDeep:A,getDeep:O,setDeep:M,incrementDeep:G,ensureDeep:P,replaceDeep:U,getFirstDeep:le,deepMergeInPlace:pi,deepMerge2:Xl,deepMerge3:ef,mapAllAsync:g6,cloneWithJson:L3,sortObject:gA,sortArray:yA,sortAny:ha,deepEquals:mA,deepEqualsEvery:pB,runOn:kB,ifPresent:TB,zip:Lc,zipSum:tf,removeEmptyArrays:CB,removeEmptyValues:BB,flatten:jB,unflatten:_A,match:WB,sort:xA,map:LB,mapIterable:UB,filterKeys:PB,filterValues:MB,rethrow:DB,setSomeOnObject:$B,setSomeDeep:FB,flip:HB,getAllPermutations:zB,countTruthyValues:GB,transformToArray:YB,setMulti:e8,incrementMulti:XB,createBidirectionalMap:t8,createTemporalBidirectionalMap:r8,pushToBidirectionalMap:RA,unshiftToBidirectionalMap:n8,addToTemporalBidirectionalMap:i8,getFromTemporalBidirectionalMap:s8,createStatefulToggle:wB,diffKeys:_B,pickRandomKey:wA,mapRandomKey:AB,fromObjectString:vB,toQueryString:lA,parseQueryString:R3,hasKey:I3,selectMax:S3,reposition:k3,unwrapSingleKey:T3,parseKeyValues:O3},r.Types={isFunction:St,isObject:Jt,isStrictlyObject:lt,isEmptyArray:Mt,isEmptyObject:oo,isUndefined:Et,isString:Ar,isNumber:ft,isBoolean:xt,isDate:Yt,isBlank:bt,isId:kt,isIntegerString:Xr,isHexString:Lt,isUrl:Pc,isNullable:ql,asString:Xt,asHexString:lr,asSafeString:Ed,asIntegerString:vd,asNumber:ua,asFunction:fr,asInteger:Vt,asBoolean:hr,asDate:xd,asNullableString:dr,asEmptiableString:pr,asId:Rd,asTime:gr,asArray:yr,asObject:la,asNullableObject:mr,asStringMap:wr,asNumericDictionary:Wl,asUrl:Vl,asNullable:Zl,asOptional:Ql,enforceObjectShape:Mc,enforceArrayShape:Jl,isPng:SA,isJpg:kA,isWebp:TA,isImage:y8},r.Strings={tokenizeByCount:ZB,tokenizeByLength:EA,searchHex:Ad,searchSubstring:cr,randomHex:ur,randomLetter:We,randomAlphanumeric:Ut,randomRichAscii:He,randomUnicode:ar,includesAny:T6,slugify:vg,normalForm:N6,enumify:U6,escapeHtml:$6,decodeHtmlEntities:H6,after:Eg,afterLast:W_,before:j_,beforeLast:xg,betweenWide:z6,betweenNarrow:G6,getPreLine:aB,containsWord:Tg,containsWords:A3,joinUrl:pA,getFuzzyMatchScore:Id,sortByFuzzyScore:D6,splitOnce:Rg,splitAll:V_,randomize:V6,expand:q_,shrinkTrim:of,capitalize:Sd,decapitalize:Z_,csvEscape:X6,parseCsv:C3,surroundInOut:L6,getExtension:Ig,getBasename:Sg,normalizeEmail:K6,normalizeFilename:j6,parseFilename:W6,camelToTitle:C6,slugToTitle:B6,slugToCamel:P6,joinHumanly:M6,findWeightedPair:tA,extractBlock:rA,extractAllBlocks:r3,replaceBlocks:n3,indexOfEarliest:Uc,lastIndexOfBefore:eA,parseHtmlAttributes:v3,readNextWord:kd,resolveVariables:E3,resolveVariableWithDefaultSyntax:cA,resolveRemainingVariablesWithDefaults:uA,isLetter:Q_,isDigit:J_,isLetterOrDigit:af,isValidObjectPathCharacter:Q6,insert:J6,indexOfRegex:Y_,lineMatches:X_,linesMatchInOrder:Y6,represent:ms,resolveMarkdownLinks:x3,buildUrl:N3,isChinese:O6,replaceBetweenStrings:lB,describeMarkdown:fB,isBalanced:hB,textToFormat:dB,splitFormatting:i3,splitHashtags:s3,splitUrls:o3,route:d3,explodeReplace:kg,generateVariants:p3,replaceWord:g3,replacePascalCaseWords:y3,stripHtml:m3,breakLine:aA,measureTextWidth:w3,toLines:b3,levenshteinDistance:_3},r.Assertions={asEqual:m6,asTrue:w6,asTruthy:b6,asFalse:_6,asFalsy:A6,asEither:v6},r.Cache={get:cB,invalidate:uB},r.Vector={addPoint:GA,subtractPoint:Q8,multiplyPoint:Fg,normalizePoint:J8,pushPoint:KA,filterCoordinates:uf,findCorners:tP,findLines:rP,raycast:Hg,raycastCircle:sP,getLineIntersectionPoint:QA}})(QR);const Wt=no(QR);Wt.Arrays;Wt.Assertions;const un=Wt.Binary;Wt.Cache;Wt.Dates;Wt.Elliptic;Wt.Numbers;Wt.Objects;Wt.Pagination;Wt.Promises;Wt.Random;Wt.Strings;Wt.System;Wt.Types;Wt.Optional;Wt.Vector;Wt.PubSubChannel;Wt.Chunk;const CD=Wt.MerkleTree;Wt.FixedPointNumber;Wt.Lazy;Wt.AsyncLazy;Wt.AsyncQueue;Wt.Uint8ArrayReader;Wt.Uint8ArrayWriter;var yt;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(yt||(yt={}));var L1;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(L1||(L1={}));const ke=yt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Is=r=>{switch(typeof r){case"undefined":return ke.undefined;case"string":return ke.string;case"number":return isNaN(r)?ke.nan:ke.number;case"boolean":return ke.boolean;case"function":return ke.function;case"bigint":return ke.bigint;case"symbol":return ke.symbol;case"object":return Array.isArray(r)?ke.array:r===null?ke.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ke.promise:typeof Map<"u"&&r instanceof Map?ke.map:typeof Set<"u"&&r instanceof Set?ke.set:typeof Date<"u"&&r instanceof Date?ke.date:ke.object;default:return ke.unknown}},we=yt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),BD=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class qn extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let a=n,u=0;for(;u<o.path.length;){const l=o.path[u];u===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(o))):a[l]=a[l]||{_errors:[]},a=a[l],u++}}};return i(this),n}static assert(e){if(!(e instanceof qn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,yt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}qn.create=r=>new qn(r);const ol=(r,e)=>{let t;switch(r.code){case we.invalid_type:r.received===ke.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case we.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,yt.jsonStringifyReplacer)}`;break;case we.unrecognized_keys:t=`Unrecognized key(s) in object: ${yt.joinValues(r.keys,", ")}`;break;case we.invalid_union:t="Invalid input";break;case we.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${yt.joinValues(r.options)}`;break;case we.invalid_enum_value:t=`Invalid enum value. Expected ${yt.joinValues(r.options)}, received '${r.received}'`;break;case we.invalid_arguments:t="Invalid function arguments";break;case we.invalid_return_type:t="Invalid function return type";break;case we.invalid_date:t="Invalid date";break;case we.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:yt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case we.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case we.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case we.custom:t="Invalid input";break;case we.invalid_intersection_types:t="Intersection results could not be merged";break;case we.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case we.not_finite:t="Number must be finite";break;default:t=e.defaultError,yt.assertNever(r)}return{message:t}};let JR=ol;function PD(r){JR=r}function x0(){return JR}const R0=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)a=l(o,{data:e,defaultError:a}).message;return{...i,path:s,message:a}},MD=[];function xe(r,e){const t=x0(),n=R0({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ol?void 0:ol].filter(i=>!!i)});r.common.issues.push(n)}class fn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Ke;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return fn.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Ke;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const Ke=Object.freeze({status:"aborted"}),tu=r=>({status:"dirty",value:r}),An=r=>({status:"valid",value:r}),U1=r=>r.status==="aborted",D1=r=>r.status==="dirty",cc=r=>r.status==="valid",qf=r=>typeof Promise<"u"&&r instanceof Promise;function I0(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function YR(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var Ue;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ue||(Ue={}));var Tf,Of;class ls{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Iv=(r,e)=>{if(cc(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new qn(r.common.issues);return this._error=t,this._error}}};function Ye(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{var u,l;const{message:h}=r;return o.code==="invalid_enum_value"?{message:h??a.defaultError}:typeof a.data>"u"?{message:(u=h??n)!==null&&u!==void 0?u:a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:(l=h??t)!==null&&l!==void 0?l:a.defaultError}},description:i}}class ot{get description(){return this._def.description}_getType(e){return Is(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Is(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new fn,ctx:{common:e.parent.common,data:e.data,parsedType:Is(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qf(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Is(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Iv(i,s)}"~validate"(e){var t,n;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Is(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:i});return cc(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((n=(t=s==null?void 0:s.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(s=>cc(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Is(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(qf(i)?i:Promise.resolve(i));return Iv(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),a=()=>s.addIssue({code:we.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new ki({schema:this,typeName:Ge.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return ss.create(this,this._def)}nullable(){return ra.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ii.create(this)}promise(){return cl.create(this,this._def)}or(e){return Yf.create([this,e],this._def)}and(e){return Xf.create(this,e,this._def)}transform(e){return new ki({...Ye(this._def),schema:this,typeName:Ge.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ih({...Ye(this._def),innerType:this,defaultValue:t,typeName:Ge.ZodDefault})}brand(){return new ib({typeName:Ge.ZodBranded,type:this,...Ye(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new sh({...Ye(this._def),innerType:this,catchValue:t,typeName:Ge.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return qh.create(this,e)}readonly(){return oh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const LD=/^c[^\s-]{8,}$/i,UD=/^[0-9a-z]+$/,DD=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$D=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,FD=/^[a-z0-9_-]{21}$/i,HD=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zD=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,GD=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,KD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ky;const jD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,WD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,VD=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,qD=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ZD=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,QD=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,XR="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",JD=new RegExp(`^${XR}$`);function eI(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function YD(r){return new RegExp(`^${eI(r)}$`)}function tI(r){let e=`${XR}T${eI(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function XD(r,e){return!!((e==="v4"||!e)&&jD.test(r)||(e==="v6"||!e)&&VD.test(r))}function e$(r,e){if(!HD.test(r))return!1;try{const[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function t$(r,e){return!!((e==="v4"||!e)&&WD.test(r)||(e==="v6"||!e)&&qD.test(r))}class xi extends ot{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ke.string){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:ke.string,received:s.parsedType}),Ke}const n=new fn;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,a=e.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(e,i),o?xe(i,{code:we.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&xe(i,{code:we.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")GD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"email",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Ky||(Ky=new RegExp(KD,"u")),Ky.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"emoji",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")$D.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"uuid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")FD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"nanoid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")LD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cuid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")UD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cuid2",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")DD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"ulid",code:we.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),xe(i,{validation:"url",code:we.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"regex",code:we.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?tI(s).test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?JD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?YD(s).test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:we.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?zD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"duration",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?XD(e.data,s.version)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"ip",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?e$(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"jwt",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?t$(e.data,s.version)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cidr",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?ZD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64",code:we.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?QD.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64url",code:we.invalid_string,message:s.message}),n.dirty()):yt.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:we.invalid_string,...Ue.errToObj(n)})}_addCheck(e){return new xi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ue.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ue.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ue.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ue.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ue.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ue.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ue.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ue.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ue.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ue.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ue.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ue.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ue.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Ue.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ue.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ue.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ue.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ue.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ue.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ue.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ue.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ue.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ue.errToObj(t)})}nonempty(e){return this.min(1,Ue.errToObj(e))}trim(){return new xi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new xi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new xi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}xi.create=r=>{var e;return new xi({checks:[],typeName:Ge.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ye(r)})};function r$(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class Xo extends ot{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ke.number){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:ke.number,received:s.parsedType}),Ke}let n;const i=new fn;for(const s of this._def.checks)s.kind==="int"?yt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:we.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?r$(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_finite,message:s.message}),i.dirty()):yt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ue.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ue.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ue.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ue.toString(t))}setLimit(e,t,n,i){return new Xo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ue.toString(i)}]})}_addCheck(e){return new Xo({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ue.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ue.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ue.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ue.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ue.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ue.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&yt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Xo.create=r=>new Xo({checks:[],typeName:Ge.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Ye(r)});class ea extends ot{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ke.bigint)return this._getInvalidInput(e);let n;const i=new fn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),xe(n,{code:we.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):yt.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return xe(t,{code:we.invalid_type,expected:ke.bigint,received:t.parsedType}),Ke}gte(e,t){return this.setLimit("min",e,!0,Ue.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ue.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ue.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ue.toString(t))}setLimit(e,t,n,i){return new ea({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ue.toString(i)}]})}_addCheck(e){return new ea({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ue.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ea.create=r=>{var e;return new ea({checks:[],typeName:Ge.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ye(r)})};class Zf extends ot{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ke.boolean){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.boolean,received:n.parsedType}),Ke}return An(e.data)}}Zf.create=r=>new Zf({typeName:Ge.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Ye(r)});class uc extends ot{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ke.date){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_type,expected:ke.date,received:s.parsedType}),Ke}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return xe(s,{code:we.invalid_date}),Ke}const n=new fn;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:we.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):yt.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new uc({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ue.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ue.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}uc.create=r=>new uc({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Ge.ZodDate,...Ye(r)});class S0 extends ot{_parse(e){if(this._getType(e)!==ke.symbol){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.symbol,received:n.parsedType}),Ke}return An(e.data)}}S0.create=r=>new S0({typeName:Ge.ZodSymbol,...Ye(r)});class Qf extends ot{_parse(e){if(this._getType(e)!==ke.undefined){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.undefined,received:n.parsedType}),Ke}return An(e.data)}}Qf.create=r=>new Qf({typeName:Ge.ZodUndefined,...Ye(r)});class Jf extends ot{_parse(e){if(this._getType(e)!==ke.null){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.null,received:n.parsedType}),Ke}return An(e.data)}}Jf.create=r=>new Jf({typeName:Ge.ZodNull,...Ye(r)});class al extends ot{constructor(){super(...arguments),this._any=!0}_parse(e){return An(e.data)}}al.create=r=>new al({typeName:Ge.ZodAny,...Ye(r)});class nc extends ot{constructor(){super(...arguments),this._unknown=!0}_parse(e){return An(e.data)}}nc.create=r=>new nc({typeName:Ge.ZodUnknown,...Ye(r)});class Xs extends ot{_parse(e){const t=this._getOrReturnCtx(e);return xe(t,{code:we.invalid_type,expected:ke.never,received:t.parsedType}),Ke}}Xs.create=r=>new Xs({typeName:Ge.ZodNever,...Ye(r)});class k0 extends ot{_parse(e){if(this._getType(e)!==ke.undefined){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.void,received:n.parsedType}),Ke}return An(e.data)}}k0.create=r=>new k0({typeName:Ge.ZodVoid,...Ye(r)});class Ii extends ot{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ke.array)return xe(t,{code:we.invalid_type,expected:ke.array,received:t.parsedType}),Ke;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(o||a)&&(xe(t,{code:o?we.too_big:we.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(xe(t,{code:we.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(xe(t,{code:we.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>i.type._parseAsync(new ls(t,o,t.path,a)))).then(o=>fn.mergeArray(n,o));const s=[...t.data].map((o,a)=>i.type._parseSync(new ls(t,o,t.path,a)));return fn.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Ii({...this._def,minLength:{value:e,message:Ue.toString(t)}})}max(e,t){return new Ii({...this._def,maxLength:{value:e,message:Ue.toString(t)}})}length(e,t){return new Ii({...this._def,exactLength:{value:e,message:Ue.toString(t)}})}nonempty(e){return this.min(1,e)}}Ii.create=(r,e)=>new Ii({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Ge.ZodArray,...Ye(e)});function Zc(r){if(r instanceof tr){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=ss.create(Zc(n))}return new tr({...r._def,shape:()=>e})}else return r instanceof Ii?new Ii({...r._def,type:Zc(r.element)}):r instanceof ss?ss.create(Zc(r.unwrap())):r instanceof ra?ra.create(Zc(r.unwrap())):r instanceof fs?fs.create(r.items.map(e=>Zc(e))):r}class tr extends ot{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=yt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ke.object){const l=this._getOrReturnCtx(e);return xe(l,{code:we.invalid_type,expected:ke.object,received:l.parsedType}),Ke}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Xs&&this._def.unknownKeys==="strip"))for(const l in i.data)o.includes(l)||a.push(l);const u=[];for(const l of o){const h=s[l],g=i.data[l];u.push({key:{status:"valid",value:l},value:h._parse(new ls(i,g,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof Xs){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of a)u.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(l==="strict")a.length>0&&(xe(i,{code:we.unrecognized_keys,keys:a}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of a){const g=i.data[h];u.push({key:{status:"valid",value:h},value:l._parse(new ls(i,g,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of u){const g=await h.key,b=await h.value;l.push({key:g,value:b,alwaysSet:h.alwaysSet})}return l}).then(l=>fn.mergeObjectSync(n,l)):fn.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Ue.errToObj,new tr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,a;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(a=Ue.errToObj(e).message)!==null&&a!==void 0?a:u}:{message:u}}}:{}})}strip(){return new tr({...this._def,unknownKeys:"strip"})}passthrough(){return new tr({...this._def,unknownKeys:"passthrough"})}extend(e){return new tr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new tr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ge.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new tr({...this._def,catchall:e})}pick(e){const t={};return yt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new tr({...this._def,shape:()=>t})}omit(e){const t={};return yt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new tr({...this._def,shape:()=>t})}deepPartial(){return Zc(this)}partial(e){const t={};return yt.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new tr({...this._def,shape:()=>t})}required(e){const t={};return yt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ss;)s=s._def.innerType;t[n]=s}}),new tr({...this._def,shape:()=>t})}keyof(){return rI(yt.objectKeys(this.shape))}}tr.create=(r,e)=>new tr({shape:()=>r,unknownKeys:"strip",catchall:Xs.create(),typeName:Ge.ZodObject,...Ye(e)});tr.strictCreate=(r,e)=>new tr({shape:()=>r,unknownKeys:"strict",catchall:Xs.create(),typeName:Ge.ZodObject,...Ye(e)});tr.lazycreate=(r,e)=>new tr({shape:r,unknownKeys:"strip",catchall:Xs.create(),typeName:Ge.ZodObject,...Ye(e)});class Yf extends ot{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new qn(a.ctx.common.issues));return xe(t,{code:we.invalid_union,unionErrors:o}),Ke}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(u=>new qn(u));return xe(t,{code:we.invalid_union,unionErrors:a}),Ke}}get options(){return this._def.options}}Yf.create=(r,e)=>new Yf({options:r,typeName:Ge.ZodUnion,...Ye(e)});const As=r=>r instanceof th?As(r.schema):r instanceof ki?As(r.innerType()):r instanceof rh?[r.value]:r instanceof ta?r.options:r instanceof nh?yt.objectValues(r.enum):r instanceof ih?As(r._def.innerType):r instanceof Qf?[void 0]:r instanceof Jf?[null]:r instanceof ss?[void 0,...As(r.unwrap())]:r instanceof ra?[null,...As(r.unwrap())]:r instanceof ib||r instanceof oh?As(r.unwrap()):r instanceof sh?As(r._def.innerType):[];class kp extends ot{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.object)return xe(t,{code:we.invalid_type,expected:ke.object,received:t.parsedType}),Ke;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(xe(t,{code:we.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Ke)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=As(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,s)}}return new kp({typeName:Ge.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Ye(n)})}}function $1(r,e){const t=Is(r),n=Is(e);if(r===e)return{valid:!0,data:r};if(t===ke.object&&n===ke.object){const i=yt.objectKeys(e),s=yt.objectKeys(r).filter(a=>i.indexOf(a)!==-1),o={...r,...e};for(const a of s){const u=$1(r[a],e[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(t===ke.array&&n===ke.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],a=e[s],u=$1(o,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ke.date&&n===ke.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Xf extends ot{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(U1(s)||U1(o))return Ke;const a=$1(s.value,o.value);return a.valid?((D1(s)||D1(o))&&t.dirty(),{status:t.value,value:a.data}):(xe(n,{code:we.invalid_intersection_types}),Ke)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Xf.create=(r,e,t)=>new Xf({left:r,right:e,typeName:Ge.ZodIntersection,...Ye(t)});class fs extends ot{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.array)return xe(n,{code:we.invalid_type,expected:ke.array,received:n.parsedType}),Ke;if(n.data.length<this._def.items.length)return xe(n,{code:we.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ke;!this._def.rest&&n.data.length>this._def.items.length&&(xe(n,{code:we.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,a)=>{const u=this._def.items[a]||this._def.rest;return u?u._parse(new ls(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>fn.mergeArray(t,o)):fn.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new fs({...this._def,rest:e})}}fs.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fs({items:r,typeName:Ge.ZodTuple,rest:null,...Ye(e)})};class eh extends ot{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.object)return xe(n,{code:we.invalid_type,expected:ke.object,received:n.parsedType}),Ke;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in n.data)i.push({key:s._parse(new ls(n,a,n.path,a)),value:o._parse(new ls(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?fn.mergeObjectAsync(t,i):fn.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof ot?new eh({keyType:e,valueType:t,typeName:Ge.ZodRecord,...Ye(n)}):new eh({keyType:xi.create(),valueType:e,typeName:Ge.ZodRecord,...Ye(t)})}}class T0 extends ot{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.map)return xe(n,{code:we.invalid_type,expected:ke.map,received:n.parsedType}),Ke;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([a,u],l)=>({key:i._parse(new ls(n,a,n.path,[l,"key"])),value:s._parse(new ls(n,u,n.path,[l,"value"]))}));if(n.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const u of o){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return Ke;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),a.set(l.value,h.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const u of o){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return Ke;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),a.set(l.value,h.value)}return{status:t.value,value:a}}}}T0.create=(r,e,t)=>new T0({valueType:e,keyType:r,typeName:Ge.ZodMap,...Ye(t)});class lc extends ot{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.set)return xe(n,{code:we.invalid_type,expected:ke.set,received:n.parsedType}),Ke;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(xe(n,{code:we.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(xe(n,{code:we.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const l=new Set;for(const h of u){if(h.status==="aborted")return Ke;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const a=[...n.data.values()].map((u,l)=>s._parse(new ls(n,u,n.path,l)));return n.common.async?Promise.all(a).then(u=>o(u)):o(a)}min(e,t){return new lc({...this._def,minSize:{value:e,message:Ue.toString(t)}})}max(e,t){return new lc({...this._def,maxSize:{value:e,message:Ue.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}lc.create=(r,e)=>new lc({valueType:r,minSize:null,maxSize:null,typeName:Ge.ZodSet,...Ye(e)});class fu extends ot{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.function)return xe(t,{code:we.invalid_type,expected:ke.function,received:t.parsedType}),Ke;function n(a,u){return R0({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,x0(),ol].filter(l=>!!l),issueData:{code:we.invalid_arguments,argumentsError:u}})}function i(a,u){return R0({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,x0(),ol].filter(l=>!!l),issueData:{code:we.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof cl){const a=this;return An(async function(...u){const l=new qn([]),h=await a._def.args.parseAsync(u,s).catch(w=>{throw l.addIssue(n(u,w)),l}),g=await Reflect.apply(o,this,h);return await a._def.returns._def.type.parseAsync(g,s).catch(w=>{throw l.addIssue(i(g,w)),l})})}else{const a=this;return An(function(...u){const l=a._def.args.safeParse(u,s);if(!l.success)throw new qn([n(u,l.error)]);const h=Reflect.apply(o,this,l.data),g=a._def.returns.safeParse(h,s);if(!g.success)throw new qn([i(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new fu({...this._def,args:fs.create(e).rest(nc.create())})}returns(e){return new fu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new fu({args:e||fs.create([]).rest(nc.create()),returns:t||nc.create(),typeName:Ge.ZodFunction,...Ye(n)})}}class th extends ot{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}th.create=(r,e)=>new th({getter:r,typeName:Ge.ZodLazy,...Ye(e)});class rh extends ot{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return xe(t,{received:t.data,code:we.invalid_literal,expected:this._def.value}),Ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}rh.create=(r,e)=>new rh({value:r,typeName:Ge.ZodLiteral,...Ye(e)});function rI(r,e){return new ta({values:r,typeName:Ge.ZodEnum,...Ye(e)})}class ta extends ot{constructor(){super(...arguments),Tf.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return xe(t,{expected:yt.joinValues(n),received:t.parsedType,code:we.invalid_type}),Ke}if(I0(this,Tf)||YR(this,Tf,new Set(this._def.values)),!I0(this,Tf).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return xe(t,{received:t.data,code:we.invalid_enum_value,options:n}),Ke}return An(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ta.create(e,{...this._def,...t})}exclude(e,t=this._def){return ta.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Tf=new WeakMap;ta.create=rI;class nh extends ot{constructor(){super(...arguments),Of.set(this,void 0)}_parse(e){const t=yt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ke.string&&n.parsedType!==ke.number){const i=yt.objectValues(t);return xe(n,{expected:yt.joinValues(i),received:n.parsedType,code:we.invalid_type}),Ke}if(I0(this,Of)||YR(this,Of,new Set(yt.getValidEnumValues(this._def.values))),!I0(this,Of).has(e.data)){const i=yt.objectValues(t);return xe(n,{received:n.data,code:we.invalid_enum_value,options:i}),Ke}return An(e.data)}get enum(){return this._def.values}}Of=new WeakMap;nh.create=(r,e)=>new nh({values:r,typeName:Ge.ZodNativeEnum,...Ye(e)});class cl extends ot{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.promise&&t.common.async===!1)return xe(t,{code:we.invalid_type,expected:ke.promise,received:t.parsedType}),Ke;const n=t.parsedType===ke.promise?t.data:Promise.resolve(t.data);return An(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}cl.create=(r,e)=>new cl({type:r,typeName:Ge.ZodPromise,...Ye(e)});class ki extends ot{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ge.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{xe(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return Ke;const u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?Ke:u.status==="dirty"||t.value==="dirty"?tu(u.value):u});{if(t.value==="aborted")return Ke;const a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?Ke:a.status==="dirty"||t.value==="dirty"?tu(a.value):a}}if(i.type==="refinement"){const o=a=>{const u=i.refinement(a,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Ke:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?Ke:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!cc(o))return o;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>cc(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:t.value,value:a})):o);yt.assertNever(i)}}ki.create=(r,e,t)=>new ki({schema:r,typeName:Ge.ZodEffects,effect:e,...Ye(t)});ki.createWithPreprocess=(r,e,t)=>new ki({schema:e,effect:{type:"preprocess",transform:r},typeName:Ge.ZodEffects,...Ye(t)});class ss extends ot{_parse(e){return this._getType(e)===ke.undefined?An(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ss.create=(r,e)=>new ss({innerType:r,typeName:Ge.ZodOptional,...Ye(e)});class ra extends ot{_parse(e){return this._getType(e)===ke.null?An(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ra.create=(r,e)=>new ra({innerType:r,typeName:Ge.ZodNullable,...Ye(e)});class ih extends ot{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ke.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ih.create=(r,e)=>new ih({innerType:r,typeName:Ge.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ye(e)});class sh extends ot{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qf(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new qn(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new qn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}sh.create=(r,e)=>new sh({innerType:r,typeName:Ge.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ye(e)});class O0 extends ot{_parse(e){if(this._getType(e)!==ke.nan){const n=this._getOrReturnCtx(e);return xe(n,{code:we.invalid_type,expected:ke.nan,received:n.parsedType}),Ke}return{status:"valid",value:e.data}}}O0.create=r=>new O0({typeName:Ge.ZodNaN,...Ye(r)});const n$=Symbol("zod_brand");class ib extends ot{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class qh extends ot{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Ke:s.status==="dirty"?(t.dirty(),tu(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Ke:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new qh({in:e,out:t,typeName:Ge.ZodPipeline})}}class oh extends ot{_parse(e){const t=this._def.innerType._parse(e),n=i=>(cc(i)&&(i.value=Object.freeze(i.value)),i);return qf(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}oh.create=(r,e)=>new oh({innerType:r,typeName:Ge.ZodReadonly,...Ye(e)});function nI(r,e={},t){return r?al.create().superRefine((n,i)=>{var s,o;if(!r(n)){const a=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=a.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,l=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...l,fatal:u})}}):al.create()}const i$={object:tr.lazycreate};var Ge;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Ge||(Ge={}));const s$=(r,e={message:`Input not instance of ${r.name}`})=>nI(t=>t instanceof r,e),iI=xi.create,sI=Xo.create,o$=O0.create,a$=ea.create,oI=Zf.create,c$=uc.create,u$=S0.create,l$=Qf.create,f$=Jf.create,h$=al.create,d$=nc.create,p$=Xs.create,g$=k0.create,y$=Ii.create,m$=tr.create,w$=tr.strictCreate,b$=Yf.create,_$=kp.create,A$=Xf.create,v$=fs.create,E$=eh.create,x$=T0.create,R$=lc.create,I$=fu.create,S$=th.create,k$=rh.create,T$=ta.create,O$=nh.create,N$=cl.create,Sv=ki.create,C$=ss.create,B$=ra.create,P$=ki.createWithPreprocess,M$=qh.create,L$=()=>iI().optional(),U$=()=>sI().optional(),D$=()=>oI().optional(),$$={string:r=>xi.create({...r,coerce:!0}),number:r=>Xo.create({...r,coerce:!0}),boolean:r=>Zf.create({...r,coerce:!0}),bigint:r=>ea.create({...r,coerce:!0}),date:r=>uc.create({...r,coerce:!0})},F$=Ke;var rr=Object.freeze({__proto__:null,defaultErrorMap:ol,setErrorMap:PD,getErrorMap:x0,makeIssue:R0,EMPTY_PATH:MD,addIssueToContext:xe,ParseStatus:fn,INVALID:Ke,DIRTY:tu,OK:An,isAborted:U1,isDirty:D1,isValid:cc,isAsync:qf,get util(){return yt},get objectUtil(){return L1},ZodParsedType:ke,getParsedType:Is,ZodType:ot,datetimeRegex:tI,ZodString:xi,ZodNumber:Xo,ZodBigInt:ea,ZodBoolean:Zf,ZodDate:uc,ZodSymbol:S0,ZodUndefined:Qf,ZodNull:Jf,ZodAny:al,ZodUnknown:nc,ZodNever:Xs,ZodVoid:k0,ZodArray:Ii,ZodObject:tr,ZodUnion:Yf,ZodDiscriminatedUnion:kp,ZodIntersection:Xf,ZodTuple:fs,ZodRecord:eh,ZodMap:T0,ZodSet:lc,ZodFunction:fu,ZodLazy:th,ZodLiteral:rh,ZodEnum:ta,ZodNativeEnum:nh,ZodPromise:cl,ZodEffects:ki,ZodTransformer:ki,ZodOptional:ss,ZodNullable:ra,ZodDefault:ih,ZodCatch:sh,ZodNaN:O0,BRAND:n$,ZodBranded:ib,ZodPipeline:qh,ZodReadonly:oh,custom:nI,Schema:ot,ZodSchema:ot,late:i$,get ZodFirstPartyTypeKind(){return Ge},coerce:$$,any:h$,array:y$,bigint:a$,boolean:oI,date:c$,discriminatedUnion:_$,effect:Sv,enum:T$,function:I$,instanceof:s$,intersection:A$,lazy:S$,literal:k$,map:x$,nan:o$,nativeEnum:O$,never:p$,null:f$,nullable:B$,number:sI,object:m$,oboolean:D$,onumber:U$,optional:C$,ostring:L$,pipeline:M$,preprocess:P$,promise:N$,record:E$,set:R$,strictObject:w$,string:iI,symbol:u$,transformer:Sv,tuple:v$,undefined:l$,union:b$,unknown:d$,void:g$,NEVER:F$,ZodIssueCode:we,quotelessJson:BD,ZodError:qn});const Zh=ns.getInstance(),aI=rr.object({username:rr.string(),address:rr.string(),timestamp:rr.number(),index:rr.number(),signature:rr.string()}),cI=rr.object({id:rr.number(),ref:rr.string(),updater:rr.string(),timestamp:rr.number()}),H$=rr.object({messageSender:aI.optional(),historyEntry:cI}),z$=rr.object({events:rr.array(rr.object({type:rr.string(),timestamp:rr.number()})),messageEntries:rr.array(rr.object({index:rr.number(),timestamp:rr.number()}))}),G$=rr.object({allTimeUsers:rr.record(z$)});function uI(r){const e=H$.safeParse(r);return e.success?r.messageSender&&!W$(r.messageSender)?(console.warn("Invalid messageSender"),!1):K$(r.historyEntry)?!0:(console.warn("Invalid historyEntry"),!1):(Zh.warn(e.error.format()),!1)}function K$(r){const e=cI.safeParse(r);return e.success?!0:(Zh.warn(e.error.format()),!1)}function j$(r){const e=G$.safeParse(r);return e.success?!0:(Zh.warn(e.error.format()),!1)}function W$(r){const e=aI.safeParse(r);return e.success?V$(r):(Zh.warn(e.error.format()),!1)}function V$(r){try{const e={username:r.username,address:r.address,timestamp:r.timestamp},t=new TextEncoder,n=un.concatBytes(t.encode(`Ethereum Signed Message:
11
+ 32`),un.keccak256(t.encode(JSON.stringify(e))));if(new nt.Signature(r.signature).isValid(n,r.address))throw new Error("Signature verification failed!");return!0}catch(e){return Zh.warn("Error in validateUserSignature",e),!1}}async function lI(r){const{condition:e,broadcast:t,maxRetries:n=2,initialDelayMs:i=2e3,checkIntervalMs:s=1e3,checkCount:o=10}=r;return new Promise((a,u)=>{let l=0;const h=async()=>{await B1(i);for(let g=0;g<o;g++){if(await Promise.resolve(e()))return a();await B1(s)}if(++l>=n)return u(new Error("Broadcast wait timeout"));console.warn(`Retrying broadcast... Attempt ${l} of ${n}`),await t(),h()};console.log("Starting broadcast..."),t().then(()=>h()).catch(u)})}const Yn={LOADING_INIT:"loadingInit",LOADING_PREVIOUS_MESSAGES:"loadingPreviousMessages",MESSAGE_RECEIVED:"messageReceived",MESSAGE_REQUEST_INITIATED:"messageRequestInitiated",MESSAGE_REQUEST_UPLOADED:"messageRequestUploaded",MESSAGE_REQUEST_ERROR:"messageRequestError",CRITICAL_ERROR:"criticalError"},q$=1e3,Z$=new Error("request for lock canceled");var Q$=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{l(n.next(h))}catch(g){o(g)}}function u(h){try{l(n.throw(h))}catch(g){o(g)}}function l(h){h.done?s(h.value):i(h.value).then(a,u)}l((n=n.apply(r,e||[])).next())})};class J${constructor(e,t=Z$){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,i)=>{const s={resolve:n,reject:i,weight:e,priority:t},o=fI(this._queue,a=>t<=a.priority);o===-1&&e<=this._value?this._dispatchItem(s):this._queue.splice(o+1,0,s)})}runExclusive(e){return Q$(this,arguments,void 0,function*(t,n=1,i=0){const[s,o]=yield this.acquire(n,i);try{return yield t(s)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Y$(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const i=n.findIndex(s=>s.priority<=e);(i===-1?n:n.splice(0,i)).forEach(s=>s.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Y$(r,e){const t=fI(r,n=>e.priority<=n.priority);r.splice(t+1,0,e)}function fI(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var X$=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{l(n.next(h))}catch(g){o(g)}}function u(h){try{l(n.throw(h))}catch(g){o(g)}}function l(h){h.done?s(h.value):i(h.value).then(a,u)}l((n=n.apply(r,e||[])).next())})};class eF{constructor(e){this._semaphore=new J$(1,e)}acquire(){return X$(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}var hI={};(function(r){r.aliasToReal={each:"forEach",eachRight:"forEachRight",entries:"toPairs",entriesIn:"toPairsIn",extend:"assignIn",extendAll:"assignInAll",extendAllWith:"assignInAllWith",extendWith:"assignInWith",first:"head",conforms:"conformsTo",matches:"isMatch",property:"get",__:"placeholder",F:"stubFalse",T:"stubTrue",all:"every",allPass:"overEvery",always:"constant",any:"some",anyPass:"overSome",apply:"spread",assoc:"set",assocPath:"set",complement:"negate",compose:"flowRight",contains:"includes",dissoc:"unset",dissocPath:"unset",dropLast:"dropRight",dropLastWhile:"dropRightWhile",equals:"isEqual",identical:"eq",indexBy:"keyBy",init:"initial",invertObj:"invert",juxt:"over",omitAll:"omit",nAry:"ary",path:"get",pathEq:"matchesProperty",pathOr:"getOr",paths:"at",pickAll:"pick",pipe:"flow",pluck:"map",prop:"get",propEq:"matchesProperty",propOr:"getOr",props:"at",symmetricDifference:"xor",symmetricDifferenceBy:"xorBy",symmetricDifferenceWith:"xorWith",takeLast:"takeRight",takeLastWhile:"takeRightWhile",unapply:"rest",unnest:"flatten",useWith:"overArgs",where:"conformsTo",whereEq:"isMatch",zipObj:"zipObject"},r.aryMethod={1:["assignAll","assignInAll","attempt","castArray","ceil","create","curry","curryRight","defaultsAll","defaultsDeepAll","floor","flow","flowRight","fromPairs","invert","iteratee","memoize","method","mergeAll","methodOf","mixin","nthArg","over","overEvery","overSome","rest","reverse","round","runInContext","spread","template","trim","trimEnd","trimStart","uniqueId","words","zipAll"],2:["add","after","ary","assign","assignAllWith","assignIn","assignInAllWith","at","before","bind","bindAll","bindKey","chunk","cloneDeepWith","cloneWith","concat","conformsTo","countBy","curryN","curryRightN","debounce","defaults","defaultsDeep","defaultTo","delay","difference","divide","drop","dropRight","dropRightWhile","dropWhile","endsWith","eq","every","filter","find","findIndex","findKey","findLast","findLastIndex","findLastKey","flatMap","flatMapDeep","flattenDepth","forEach","forEachRight","forIn","forInRight","forOwn","forOwnRight","get","groupBy","gt","gte","has","hasIn","includes","indexOf","intersection","invertBy","invoke","invokeMap","isEqual","isMatch","join","keyBy","lastIndexOf","lt","lte","map","mapKeys","mapValues","matchesProperty","maxBy","meanBy","merge","mergeAllWith","minBy","multiply","nth","omit","omitBy","overArgs","pad","padEnd","padStart","parseInt","partial","partialRight","partition","pick","pickBy","propertyOf","pull","pullAll","pullAt","random","range","rangeRight","rearg","reject","remove","repeat","restFrom","result","sampleSize","some","sortBy","sortedIndex","sortedIndexOf","sortedLastIndex","sortedLastIndexOf","sortedUniqBy","split","spreadFrom","startsWith","subtract","sumBy","take","takeRight","takeRightWhile","takeWhile","tap","throttle","thru","times","trimChars","trimCharsEnd","trimCharsStart","truncate","union","uniqBy","uniqWith","unset","unzipWith","without","wrap","xor","zip","zipObject","zipObjectDeep"],3:["assignInWith","assignWith","clamp","differenceBy","differenceWith","findFrom","findIndexFrom","findLastFrom","findLastIndexFrom","getOr","includesFrom","indexOfFrom","inRange","intersectionBy","intersectionWith","invokeArgs","invokeArgsMap","isEqualWith","isMatchWith","flatMapDepth","lastIndexOfFrom","mergeWith","orderBy","padChars","padCharsEnd","padCharsStart","pullAllBy","pullAllWith","rangeStep","rangeStepRight","reduce","reduceRight","replace","set","slice","sortedIndexBy","sortedLastIndexBy","transform","unionBy","unionWith","update","xorBy","xorWith","zipWith"],4:["fill","setWith","updateWith"]},r.aryRearg={2:[1,0],3:[2,0,1],4:[3,2,0,1]},r.iterateeAry={dropRightWhile:1,dropWhile:1,every:1,filter:1,find:1,findFrom:1,findIndex:1,findIndexFrom:1,findKey:1,findLast:1,findLastFrom:1,findLastIndex:1,findLastIndexFrom:1,findLastKey:1,flatMap:1,flatMapDeep:1,flatMapDepth:1,forEach:1,forEachRight:1,forIn:1,forInRight:1,forOwn:1,forOwnRight:1,map:1,mapKeys:1,mapValues:1,partition:1,reduce:2,reduceRight:2,reject:1,remove:1,some:1,takeRightWhile:1,takeWhile:1,times:1,transform:2},r.iterateeRearg={mapKeys:[1],reduceRight:[1,0]},r.methodRearg={assignInAllWith:[1,0],assignInWith:[1,2,0],assignAllWith:[1,0],assignWith:[1,2,0],differenceBy:[1,2,0],differenceWith:[1,2,0],getOr:[2,1,0],intersectionBy:[1,2,0],intersectionWith:[1,2,0],isEqualWith:[1,2,0],isMatchWith:[2,1,0],mergeAllWith:[1,0],mergeWith:[1,2,0],padChars:[2,1,0],padCharsEnd:[2,1,0],padCharsStart:[2,1,0],pullAllBy:[2,1,0],pullAllWith:[2,1,0],rangeStep:[1,2,0],rangeStepRight:[1,2,0],setWith:[3,1,2,0],sortedIndexBy:[2,1,0],sortedLastIndexBy:[2,1,0],unionBy:[1,2,0],unionWith:[1,2,0],updateWith:[3,1,2,0],xorBy:[1,2,0],xorWith:[1,2,0],zipWith:[1,2,0]},r.methodSpread={assignAll:{start:0},assignAllWith:{start:0},assignInAll:{start:0},assignInAllWith:{start:0},defaultsAll:{start:0},defaultsDeepAll:{start:0},invokeArgs:{start:2},invokeArgsMap:{start:2},mergeAll:{start:0},mergeAllWith:{start:0},partial:{start:1},partialRight:{start:1},without:{start:1},zipAll:{start:0}},r.mutate={array:{fill:!0,pull:!0,pullAll:!0,pullAllBy:!0,pullAllWith:!0,pullAt:!0,remove:!0,reverse:!0},object:{assign:!0,assignAll:!0,assignAllWith:!0,assignIn:!0,assignInAll:!0,assignInAllWith:!0,assignInWith:!0,assignWith:!0,defaults:!0,defaultsAll:!0,defaultsDeep:!0,defaultsDeepAll:!0,merge:!0,mergeAll:!0,mergeAllWith:!0,mergeWith:!0},set:{set:!0,setWith:!0,unset:!0,update:!0,updateWith:!0}},r.realToAlias=function(){var e=Object.prototype.hasOwnProperty,t=r.aliasToReal,n={};for(var i in t){var s=t[i];e.call(n,s)?n[s].push(i):n[s]=[i]}return n}(),r.remap={assignAll:"assign",assignAllWith:"assignWith",assignInAll:"assignIn",assignInAllWith:"assignInWith",curryN:"curry",curryRightN:"curryRight",defaultsAll:"defaults",defaultsDeepAll:"defaultsDeep",findFrom:"find",findIndexFrom:"findIndex",findLastFrom:"findLast",findLastIndexFrom:"findLastIndex",getOr:"get",includesFrom:"includes",indexOfFrom:"indexOf",invokeArgs:"invoke",invokeArgsMap:"invokeMap",lastIndexOfFrom:"lastIndexOf",mergeAll:"merge",mergeAllWith:"mergeWith",padChars:"pad",padCharsEnd:"padEnd",padCharsStart:"padStart",propertyOf:"get",rangeStep:"range",rangeStepRight:"rangeRight",restFrom:"rest",spreadFrom:"spread",trimChars:"trim",trimCharsEnd:"trimEnd",trimCharsStart:"trimStart",zipAll:"zip"},r.skipFixed={castArray:!0,flow:!0,flowRight:!0,iteratee:!0,mixin:!0,rearg:!0,runInContext:!0},r.skipRearg={add:!0,assign:!0,assignIn:!0,bind:!0,bindKey:!0,concat:!0,difference:!0,divide:!0,eq:!0,gt:!0,gte:!0,isEqual:!0,lt:!0,lte:!0,matchesProperty:!0,merge:!0,multiply:!0,overArgs:!0,partial:!0,partialRight:!0,propertyOf:!0,random:!0,range:!0,rangeRight:!0,subtract:!0,zip:!0,zipObject:!0,zipObjectDeep:!0}})(hI);var jy,kv;function dI(){return kv||(kv=1,jy={}),jy}var Or=hI,tF=dI(),Tv=Array.prototype.push;function rF(r,e){return e==2?function(t,n){return r.apply(void 0,arguments)}:function(t){return r.apply(void 0,arguments)}}function Wy(r,e){return e==2?function(t,n){return r(t,n)}:function(t){return r(t)}}function Ov(r){for(var e=r?r.length:0,t=Array(e);e--;)t[e]=r[e];return t}function nF(r){return function(e){return r({},e)}}function iF(r,e){return function(){for(var t=arguments.length,n=t-1,i=Array(t);t--;)i[t]=arguments[t];var s=i[e],o=i.slice(0,e);return s&&Tv.apply(o,s),e!=n&&Tv.apply(o,i.slice(e+1)),r.apply(this,o)}}function Vy(r,e){return function(){var t=arguments.length;if(t){for(var n=Array(t);t--;)n[t]=arguments[t];var i=n[0]=e.apply(void 0,n);return r.apply(void 0,n),i}}}function F1(r,e,t,n){var i=typeof e=="function",s=e===Object(e);if(s&&(n=t,t=e,e=void 0),t==null)throw new TypeError;n||(n={});var o={cap:"cap"in n?n.cap:!0,curry:"curry"in n?n.curry:!0,fixed:"fixed"in n?n.fixed:!0,immutable:"immutable"in n?n.immutable:!0,rearg:"rearg"in n?n.rearg:!0},a=i?t:tF,u="curry"in n&&n.curry,l="fixed"in n&&n.fixed,h="rearg"in n&&n.rearg,g=i?t.runInContext():void 0,b=i?t:{ary:r.ary,assign:r.assign,clone:r.clone,curry:r.curry,forEach:r.forEach,isArray:r.isArray,isError:r.isError,isFunction:r.isFunction,isWeakMap:r.isWeakMap,iteratee:r.iteratee,keys:r.keys,rearg:r.rearg,toInteger:r.toInteger,toPath:r.toPath},w=b.ary,I=b.assign,S=b.clone,x=b.curry,C=b.forEach,H=b.isArray,D=b.isError,z=b.isFunction,V=b.isWeakMap,Z=b.keys,K=b.rearg,W=b.toInteger,oe=b.toPath,ce=Z(Or.aryMethod),ne={castArray:function(ee){return function(){var re=arguments[0];return H(re)?ee(Ov(re)):ee.apply(void 0,arguments)}},iteratee:function(ee){return function(){var re=arguments[0],he=arguments[1],ye=ee(re,he),be=ye.length;return o.cap&&typeof he=="number"?(he=he>2?he-2:1,be&&be<=he?ye:Wy(ye,he)):ye}},mixin:function(ee){return function(re){var he=this;if(!z(he))return ee(he,Object(re));var ye=[];return C(Z(re),function(be){z(re[be])&&ye.push([be,he.prototype[be]])}),ee(he,Object(re)),C(ye,function(be){var je=be[1];z(je)?he.prototype[be[0]]=je:delete he.prototype[be[0]]}),he}},nthArg:function(ee){return function(re){var he=re<0?1:W(re)+1;return x(ee(re),he)}},rearg:function(ee){return function(re,he){var ye=he?he.length:0;return x(ee(re,he),ye)}},runInContext:function(ee){return function(re){return F1(r,ee(re),n)}}};function ue(ee,re){if(o.cap){var he=Or.iterateeRearg[ee];if(he)return G(re,he);var ye=!i&&Or.iterateeAry[ee];if(ye)return M(re,ye)}return re}function B(ee,re,he){return u||o.curry&&he>1?x(re,he):re}function p(ee,re,he){if(o.fixed&&(l||!Or.skipFixed[ee])){var ye=Or.methodSpread[ee],be=ye&&ye.start;return be===void 0?w(re,he):iF(re,be)}return re}function m(ee,re,he){return o.rearg&&he>1&&(h||!Or.skipRearg[ee])?K(re,Or.methodRearg[ee]||Or.aryRearg[he]):re}function E(ee,re){re=oe(re);for(var he=-1,ye=re.length,be=ye-1,je=S(Object(ee)),$e=je;$e!=null&&++he<ye;){var Oe=re[he],Xe=$e[Oe];Xe!=null&&!(z(Xe)||D(Xe)||V(Xe))&&($e[Oe]=S(he==be?Xe:Object(Xe))),$e=$e[Oe]}return je}function k(ee){return U.runInContext.convert(ee)(void 0)}function O(ee,re){var he=Or.aliasToReal[ee]||ee,ye=Or.remap[he]||he,be=n;return function(je){var $e=i?g:b,Oe=i?g[ye]:re,Xe=I(I({},be),je);return F1($e,he,Oe,Xe)}}function M(ee,re){return P(ee,function(he){return typeof he=="function"?Wy(he,re):he})}function G(ee,re){return P(ee,function(he){var ye=re.length;return rF(K(Wy(he,ye),re),ye)})}function P(ee,re){return function(){var he=arguments.length;if(!he)return ee();for(var ye=Array(he);he--;)ye[he]=arguments[he];var be=o.rearg?0:he-1;return ye[be]=re(ye[be]),ee.apply(void 0,ye)}}function A(ee,re,he){var ye,be=Or.aliasToReal[ee]||ee,je=re,$e=ne[be];return $e?je=$e(re):o.immutable&&(Or.mutate.array[be]?je=Vy(re,Ov):Or.mutate.object[be]?je=Vy(re,nF(re)):Or.mutate.set[be]&&(je=Vy(re,E))),C(ce,function(Oe){return C(Or.aryMethod[Oe],function(Xe){if(be==Xe){var qe=Or.methodSpread[be],et=qe&&qe.afterRearg;return ye=et?p(be,m(be,je,Oe),Oe):m(be,p(be,je,Oe),Oe),ye=ue(be,ye),ye=B(be,ye,Oe),!1}}),!ye}),ye||(ye=je),ye==re&&(ye=u?x(ye,1):function(){return re.apply(this,arguments)}),ye.convert=O(be,re),ye.placeholder=re.placeholder=he,ye}if(!s)return A(e,t,a);var U=t,le=[];return C(ce,function(ee){C(Or.aryMethod[ee],function(re){var he=U[Or.remap[re]||re];he&&le.push([re,A(re,he,U)])})}),C(Z(U),function(ee){var re=U[ee];if(typeof re=="function"){for(var he=le.length;he--;)if(le[he][0]==ee)return;re.convert=O(ee,re),le.push([ee,re])}}),C(le,function(ee){U[ee[0]]=ee[1]}),U.convert=k,U.placeholder=U,C(Z(U),function(ee){C(Or.realToAlias[ee]||[],function(re){U[re]=U[ee]})}),U}var sF=F1,qy,Nv;function Tp(){if(Nv)return qy;Nv=1;function r(e){return e}return qy=r,qy}var Cv=VR,oF=Cv&&new Cv,pI=oF,aF=Tp(),Bv=pI,cF=Bv?function(r,e){return Bv.set(r,e),r}:aF,gI=cF,Zy,Pv;function Op(){if(Pv)return Zy;Pv=1;var r=Bi,e=Object.create,t=function(){function n(){}return function(i){if(!r(i))return{};if(e)return e(i);n.prototype=i;var s=new n;return n.prototype=void 0,s}}();return Zy=t,Zy}var uF=Op(),lF=Bi;function fF(r){return function(){var e=arguments;switch(e.length){case 0:return new r;case 1:return new r(e[0]);case 2:return new r(e[0],e[1]);case 3:return new r(e[0],e[1],e[2]);case 4:return new r(e[0],e[1],e[2],e[3]);case 5:return new r(e[0],e[1],e[2],e[3],e[4]);case 6:return new r(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new r(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var t=uF(r.prototype),n=r.apply(t,e);return lF(n)?n:t}}var Np=fF,hF=Np,dF=Mn,pF=1;function gF(r,e,t){var n=e&pF,i=hF(r);function s(){var o=this&&this!==dF&&this instanceof s?i:r;return o.apply(n?t:this,arguments)}return s}var yF=gF,Qy,Mv;function sb(){if(Mv)return Qy;Mv=1;function r(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}return Qy=r,Qy}var mF=Math.max;function wF(r,e,t,n){for(var i=-1,s=r.length,o=t.length,a=-1,u=e.length,l=mF(s-o,0),h=Array(u+l),g=!n;++a<u;)h[a]=e[a];for(;++i<o;)(g||i<s)&&(h[t[i]]=r[i]);for(;l--;)h[a++]=r[i++];return h}var yI=wF,bF=Math.max;function _F(r,e,t,n){for(var i=-1,s=r.length,o=-1,a=t.length,u=-1,l=e.length,h=bF(s-a,0),g=Array(h+l),b=!n;++i<h;)g[i]=r[i];for(var w=i;++u<l;)g[w+u]=e[u];for(;++o<a;)(b||i<s)&&(g[w+t[o]]=r[i++]);return g}var mI=_F;function AF(r,e){for(var t=r.length,n=0;t--;)r[t]===e&&++n;return n}var vF=AF;function EF(){}var ob=EF,xF=Op(),RF=ob,IF=4294967295;function N0(r){this.__wrapped__=r,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=IF,this.__views__=[]}N0.prototype=xF(RF.prototype);N0.prototype.constructor=N0;var ab=N0;function SF(){}var kF=SF,Lv=pI,TF=kF,OF=Lv?function(r){return Lv.get(r)}:TF,wI=OF,NF={},CF=NF,Uv=CF,BF=Object.prototype,PF=BF.hasOwnProperty;function MF(r){for(var e=r.name+"",t=Uv[e],n=PF.call(Uv,e)?t.length:0;n--;){var i=t[n],s=i.func;if(s==null||s==r)return i.name}return e}var LF=MF,UF=Op(),DF=ob;function C0(r,e){this.__wrapped__=r,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}C0.prototype=UF(DF.prototype);C0.prototype.constructor=C0;var bI=C0;function $F(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var Qh=$F,FF=ab,HF=bI,zF=Qh;function GF(r){if(r instanceof FF)return r.clone();var e=new HF(r.__wrapped__,r.__chain__);return e.__actions__=zF(r.__actions__),e.__index__=r.__index__,e.__values__=r.__values__,e}var KF=GF,jF=ab,Dv=bI,WF=ob,VF=Ln,qF=di,ZF=KF,QF=Object.prototype,JF=QF.hasOwnProperty;function B0(r){if(qF(r)&&!VF(r)&&!(r instanceof jF)){if(r instanceof Dv)return r;if(JF.call(r,"__wrapped__"))return ZF(r)}return new Dv(r)}B0.prototype=WF.prototype;B0.prototype.constructor=B0;var YF=B0,XF=ab,e9=wI,t9=LF,r9=YF;function n9(r){var e=t9(r),t=r9[e];if(typeof t!="function"||!(e in XF.prototype))return!1;if(r===t)return!0;var n=e9(t);return!!n&&r===n[0]}var i9=n9,Jy,$v;function _I(){if($v)return Jy;$v=1;var r=800,e=16,t=Date.now;function n(i){var s=0,o=0;return function(){var a=t(),u=e-(a-o);if(o=a,u>0){if(++s>=r)return arguments[0]}else s=0;return i.apply(void 0,arguments)}}return Jy=n,Jy}var s9=gI,o9=_I(),a9=o9(s9),AI=a9,c9=/\{\n\/\* \[wrapped with (.+)\] \*/,u9=/,? & /;function l9(r){var e=r.match(c9);return e?e[1].split(u9):[]}var f9=l9,h9=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function d9(r,e){var t=e.length;if(!t)return r;var n=t-1;return e[n]=(t>1?"& ":"")+e[n],e=e.join(t>2?", ":" "),r.replace(h9,`{
12
+ /* [wrapped with `+e+`] */
13
+ `)}var p9=d9,Yy,Fv;function g9(){if(Fv)return Yy;Fv=1;function r(e){return function(){return e}}return Yy=r,Yy}var Xy,Hv;function vI(){if(Hv)return Xy;Hv=1;var r=Ic,e=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch{}}();return Xy=e,Xy}var em,zv;function y9(){if(zv)return em;zv=1;var r=g9(),e=vI(),t=Tp(),n=e?function(i,s){return e(i,"toString",{configurable:!0,enumerable:!1,value:r(s),writable:!0})}:t;return em=n,em}var tm,Gv;function cb(){if(Gv)return tm;Gv=1;var r=y9(),e=_I(),t=e(r);return tm=t,tm}function m9(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var ub=m9;function w9(r,e,t,n){for(var i=r.length,s=t+(n?1:-1);n?s--:++s<i;)if(e(r[s],s,r))return s;return-1}var b9=w9;function _9(r){return r!==r}var A9=_9;function v9(r,e,t){for(var n=t-1,i=r.length;++n<i;)if(r[n]===e)return n;return-1}var E9=v9,x9=b9,R9=A9,I9=E9;function S9(r,e,t){return e===e?I9(r,e,t):x9(r,R9,t)}var k9=S9,T9=k9;function O9(r,e){var t=r==null?0:r.length;return!!t&&T9(r,e,0)>-1}var N9=O9,C9=ub,B9=N9,P9=1,M9=2,L9=8,U9=16,D9=32,$9=64,F9=128,H9=256,z9=512,G9=[["ary",F9],["bind",P9],["bindKey",M9],["curry",L9],["curryRight",U9],["flip",z9],["partial",D9],["partialRight",$9],["rearg",H9]];function K9(r,e){return C9(G9,function(t){var n="_."+t[0];e&t[1]&&!B9(r,n)&&r.push(n)}),r.sort()}var j9=K9,W9=f9,V9=p9,q9=cb(),Z9=j9;function Q9(r,e,t){var n=e+"";return q9(r,V9(n,Z9(W9(n),t)))}var EI=Q9,J9=i9,Y9=AI,X9=EI,eH=1,tH=2,rH=4,nH=8,Kv=32,jv=64;function iH(r,e,t,n,i,s,o,a,u,l){var h=e&nH,g=h?o:void 0,b=h?void 0:o,w=h?s:void 0,I=h?void 0:s;e|=h?Kv:jv,e&=~(h?jv:Kv),e&rH||(e&=~(eH|tH));var S=[r,e,i,w,g,I,b,a,u,l],x=t.apply(void 0,S);return J9(r)&&Y9(x,S),x.placeholder=n,X9(x,r,e)}var xI=iH;function sH(r){var e=r;return e.placeholder}var RI=sH,oH=Qh,aH=xp,cH=Math.min;function uH(r,e){for(var t=r.length,n=cH(e.length,t),i=oH(r);n--;){var s=e[n];r[n]=aH(s,t)?i[s]:void 0}return r}var lH=uH,Wv="__lodash_placeholder__";function fH(r,e){for(var t=-1,n=r.length,i=0,s=[];++t<n;){var o=r[t];(o===e||o===Wv)&&(r[t]=Wv,s[i++]=t)}return s}var lb=fH,hH=yI,dH=mI,pH=vF,Vv=Np,gH=xI,yH=RI,mH=lH,wH=lb,bH=Mn,_H=1,AH=2,vH=8,EH=16,xH=128,RH=512;function II(r,e,t,n,i,s,o,a,u,l){var h=e&xH,g=e&_H,b=e&AH,w=e&(vH|EH),I=e&RH,S=b?void 0:Vv(r);function x(){for(var C=arguments.length,H=Array(C),D=C;D--;)H[D]=arguments[D];if(w)var z=yH(x),V=pH(H,z);if(n&&(H=hH(H,n,i,w)),s&&(H=dH(H,s,o,w)),C-=V,w&&C<l){var Z=wH(H,z);return gH(r,e,II,x.placeholder,t,H,Z,a,u,l-C)}var K=g?t:this,W=b?K[r]:r;return C=H.length,a?H=mH(H,a):I&&C>1&&H.reverse(),h&&u<C&&(H.length=u),this&&this!==bH&&this instanceof x&&(W=S||Vv(W)),W.apply(K,H)}return x}var SI=II,IH=sb(),SH=Np,kH=SI,TH=xI,OH=RI,NH=lb,CH=Mn;function BH(r,e,t){var n=SH(r);function i(){for(var s=arguments.length,o=Array(s),a=s,u=OH(i);a--;)o[a]=arguments[a];var l=s<3&&o[0]!==u&&o[s-1]!==u?[]:NH(o,u);if(s-=l.length,s<t)return TH(r,e,kH,i.placeholder,void 0,o,l,void 0,void 0,t-s);var h=this&&this!==CH&&this instanceof i?n:r;return IH(h,this,o)}return i}var PH=BH,MH=sb(),LH=Np,UH=Mn,DH=1;function $H(r,e,t,n){var i=e&DH,s=LH(r);function o(){for(var a=-1,u=arguments.length,l=-1,h=n.length,g=Array(h+u),b=this&&this!==UH&&this instanceof o?s:r;++l<h;)g[l]=n[l];for(;u--;)g[l++]=arguments[++a];return MH(b,i?t:this,g)}return o}var FH=$H,HH=yI,zH=mI,qv=lb,Zv="__lodash_placeholder__",rm=1,GH=2,KH=4,Qv=8,vf=128,Jv=256,jH=Math.min;function WH(r,e){var t=r[1],n=e[1],i=t|n,s=i<(rm|GH|vf),o=n==vf&&t==Qv||n==vf&&t==Jv&&r[7].length<=e[8]||n==(vf|Jv)&&e[7].length<=e[8]&&t==Qv;if(!(s||o))return r;n&rm&&(r[2]=e[2],i|=t&rm?0:KH);var a=e[3];if(a){var u=r[3];r[3]=u?HH(u,a,e[4]):a,r[4]=u?qv(r[3],Zv):e[4]}return a=e[5],a&&(u=r[5],r[5]=u?zH(u,a,e[6]):a,r[6]=u?qv(r[5],Zv):e[6]),a=e[7],a&&(r[7]=a),n&vf&&(r[8]=r[8]==null?e[8]:jH(r[8],e[8])),r[9]==null&&(r[9]=e[9]),r[0]=e[0],r[1]=i,r}var VH=WH,qH=/\s/;function ZH(r){for(var e=r.length;e--&&qH.test(r.charAt(e)););return e}var QH=ZH,JH=QH,YH=/^\s+/;function XH(r){return r&&r.slice(0,JH(r)+1).replace(YH,"")}var e7=XH,t7=Rc,r7=di,n7="[object Symbol]";function i7(r){return typeof r=="symbol"||r7(r)&&t7(r)==n7}var Jh=i7,s7=e7,Yv=Bi,o7=Jh,Xv=NaN,a7=/^[-+]0x[0-9a-f]+$/i,c7=/^0b[01]+$/i,u7=/^0o[0-7]+$/i,l7=parseInt;function f7(r){if(typeof r=="number")return r;if(o7(r))return Xv;if(Yv(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Yv(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=s7(r);var t=c7.test(r);return t||u7.test(r)?l7(r.slice(2),t?2:8):a7.test(r)?Xv:+r}var h7=f7,d7=h7,eE=1/0,p7=17976931348623157e292;function g7(r){if(!r)return r===0?r:0;if(r=d7(r),r===eE||r===-eE){var e=r<0?-1:1;return e*p7}return r===r?r:0}var y7=g7,m7=y7;function w7(r){var e=m7(r),t=e%1;return e===e?t?e-t:e:0}var kI=w7,b7=gI,_7=yF,A7=PH,v7=SI,E7=FH,x7=wI,R7=VH,I7=AI,S7=EI,tE=kI,k7="Expected a function",rE=1,T7=2,nm=8,im=16,sm=32,nE=64,iE=Math.max;function O7(r,e,t,n,i,s,o,a){var u=e&T7;if(!u&&typeof r!="function")throw new TypeError(k7);var l=n?n.length:0;if(l||(e&=~(sm|nE),n=i=void 0),o=o===void 0?o:iE(tE(o),0),a=a===void 0?a:tE(a),l-=i?i.length:0,e&nE){var h=n,g=i;n=i=void 0}var b=u?void 0:x7(r),w=[r,e,t,n,i,h,g,s,o,a];if(b&&R7(w,b),r=w[0],e=w[1],t=w[2],n=w[3],i=w[4],a=w[9]=w[9]===void 0?u?0:r.length:iE(w[9]-l,0),!a&&e&(nm|im)&&(e&=~(nm|im)),!e||e==rE)var I=_7(r,e,t);else e==nm||e==im?I=A7(r,e,a):(e==sm||e==(rE|sm))&&!i.length?I=E7(r,e,t,n):I=v7.apply(void 0,w);var S=b?b7:I7;return S7(S(I,w),r,e)}var fb=O7,N7=fb,C7=128;function B7(r,e,t){return e=t?void 0:e,e=r&&e==null?r.length:e,N7(r,C7,void 0,void 0,void 0,void 0,e)}var P7=B7,om,sE;function hb(){if(sE)return om;sE=1;var r=vI();function e(t,n,i){n=="__proto__"&&r?r(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return om=e,om}var M7=hb(),L7=Wh,U7=Object.prototype,D7=U7.hasOwnProperty;function $7(r,e,t){var n=r[e];(!(D7.call(r,e)&&L7(n,t))||t===void 0&&!(e in r))&&M7(r,e,t)}var TI=$7,F7=TI,H7=hb();function z7(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],u=n?n(t[a],r[a],a,t,r):void 0;u===void 0&&(u=r[a]),i?H7(t,a,u):F7(t,a,u)}return t}var Yh=z7,G7=Yh,K7=Ip;function j7(r,e){return r&&G7(e,K7(e),r)}var OI=j7,am,oE;function W7(){if(oE)return am;oE=1;function r(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return am=r,am}var cm,aE;function V7(){if(aE)return cm;aE=1;var r=Bi,e=rb,t=W7(),n=Object.prototype,i=n.hasOwnProperty;function s(o){if(!r(o))return t(o);var a=e(o),u=[];for(var l in o)l=="constructor"&&(a||!i.call(o,l))||u.push(l);return u}return cm=s,cm}var um,cE;function Xh(){if(cE)return um;cE=1;var r=GR,e=V7(),t=Rp;function n(i){return t(i)?r(i,!0):e(i)}return um=n,um}var q7=Yh,Z7=Xh();function Q7(r,e){return r&&q7(e,Z7(e),r)}var J7=Q7,Nf={exports:{}};Nf.exports;var uE;function NI(){return uE||(uE=1,function(r,e){var t=Mn,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,s=i&&i.exports===n,o=s?t.Buffer:void 0,a=o?o.allocUnsafe:void 0;function u(l,h){if(h)return l.slice();var g=l.length,b=a?a(g):new l.constructor(g);return l.copy(b),b}r.exports=u}(Nf,Nf.exports)),Nf.exports}var Y7=Yh,X7=Jw;function ez(r,e){return Y7(r,X7(r),e)}var tz=ez,rz=KR,nz=rz(Object.getPrototypeOf,Object),db=nz,iz=Qw,sz=db,oz=Jw,az=HR,cz=Object.getOwnPropertySymbols,uz=cz?function(r){for(var e=[];r;)iz(e,oz(r)),r=sz(r);return e}:az,CI=uz,lz=Yh,fz=CI;function hz(r,e){return lz(r,fz(r),e)}var dz=hz,pz=FR,gz=CI,yz=Xh();function mz(r){return pz(r,yz,gz)}var wz=mz,bz=Object.prototype,_z=bz.hasOwnProperty;function Az(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&_z.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var vz=Az,lm,lE;function pb(){if(lE)return lm;lE=1;var r=$R;function e(t){var n=new t.constructor(t.byteLength);return new r(n).set(new r(t)),n}return lm=e,lm}var Ez=pb();function xz(r,e){var t=e?Ez(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var Rz=xz,Iz=/\w*$/;function Sz(r){var e=new r.constructor(r.source,Iz.exec(r));return e.lastIndex=r.lastIndex,e}var kz=Sz,fE=Tl,hE=fE?fE.prototype:void 0,dE=hE?hE.valueOf:void 0;function Tz(r){return dE?Object(dE.call(r)):{}}var Oz=Tz,fm,pE;function BI(){if(pE)return fm;pE=1;var r=pb();function e(t,n){var i=n?r(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return fm=e,fm}var Nz=pb(),Cz=Rz,Bz=kz,Pz=Oz,Mz=BI(),Lz="[object Boolean]",Uz="[object Date]",Dz="[object Map]",$z="[object Number]",Fz="[object RegExp]",Hz="[object Set]",zz="[object String]",Gz="[object Symbol]",Kz="[object ArrayBuffer]",jz="[object DataView]",Wz="[object Float32Array]",Vz="[object Float64Array]",qz="[object Int8Array]",Zz="[object Int16Array]",Qz="[object Int32Array]",Jz="[object Uint8Array]",Yz="[object Uint8ClampedArray]",Xz="[object Uint16Array]",eG="[object Uint32Array]";function tG(r,e,t){var n=r.constructor;switch(e){case Kz:return Nz(r);case Lz:case Uz:return new n(+r);case jz:return Cz(r,t);case Wz:case Vz:case qz:case Zz:case Qz:case Jz:case Yz:case Xz:case eG:return Mz(r,t);case Dz:return new n;case $z:case zz:return new n(r);case Fz:return Bz(r);case Hz:return new n;case Gz:return Pz(r)}}var rG=tG,hm,gE;function PI(){if(gE)return hm;gE=1;var r=Op(),e=db,t=rb;function n(i){return typeof i.constructor=="function"&&!t(i)?r(e(i)):{}}return hm=n,hm}var nG=Vh,iG=di,sG="[object Map]";function oG(r){return iG(r)&&nG(r)==sG}var aG=oG,cG=aG,uG=Xw,yE=eb,mE=yE&&yE.isMap,lG=mE?uG(mE):cG,fG=lG,hG=Vh,dG=di,pG="[object Set]";function gG(r){return dG(r)&&hG(r)==pG}var yG=gG,mG=yG,wG=Xw,wE=eb,bE=wE&&wE.isSet,bG=bE?wG(bE):mG,_G=bG,AG=Ap,vG=ub,EG=TI,xG=OI,RG=J7,IG=NI(),SG=Qh,kG=tz,TG=dz,OG=WR,NG=wz,CG=Vh,BG=vz,PG=rG,MG=PI(),LG=Ln,UG=Ep,DG=fG,$G=Bi,FG=_G,HG=Ip,zG=Xh(),GG=1,KG=2,jG=4,MI="[object Arguments]",WG="[object Array]",VG="[object Boolean]",qG="[object Date]",ZG="[object Error]",LI="[object Function]",QG="[object GeneratorFunction]",JG="[object Map]",YG="[object Number]",UI="[object Object]",XG="[object RegExp]",eK="[object Set]",tK="[object String]",rK="[object Symbol]",nK="[object WeakMap]",iK="[object ArrayBuffer]",sK="[object DataView]",oK="[object Float32Array]",aK="[object Float64Array]",cK="[object Int8Array]",uK="[object Int16Array]",lK="[object Int32Array]",fK="[object Uint8Array]",hK="[object Uint8ClampedArray]",dK="[object Uint16Array]",pK="[object Uint32Array]",Ft={};Ft[MI]=Ft[WG]=Ft[iK]=Ft[sK]=Ft[VG]=Ft[qG]=Ft[oK]=Ft[aK]=Ft[cK]=Ft[uK]=Ft[lK]=Ft[JG]=Ft[YG]=Ft[UI]=Ft[XG]=Ft[eK]=Ft[tK]=Ft[rK]=Ft[fK]=Ft[hK]=Ft[dK]=Ft[pK]=!0;Ft[ZG]=Ft[LI]=Ft[nK]=!1;function s0(r,e,t,n,i,s){var o,a=e&GG,u=e&KG,l=e&jG;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!$G(r))return r;var h=LG(r);if(h){if(o=BG(r),!a)return SG(r,o)}else{var g=CG(r),b=g==LI||g==QG;if(UG(r))return IG(r,a);if(g==UI||g==MI||b&&!i){if(o=u||b?{}:MG(r),!a)return u?TG(r,RG(o,r)):kG(r,xG(o,r))}else{if(!Ft[g])return i?r:{};o=PG(r,g,a)}}s||(s=new AG);var w=s.get(r);if(w)return w;s.set(r,o),FG(r)?r.forEach(function(x){o.add(s0(x,e,t,x,r,s))}):DG(r)&&r.forEach(function(x,C){o.set(C,s0(x,e,t,C,r,s))});var I=l?u?NG:OG:u?zG:HG,S=h?void 0:I(r);return vG(S||r,function(x,C){S&&(C=x,x=r[C]),EG(o,C,s0(x,e,t,C,r,s))}),o}var DI=s0,gK=DI,yK=4;function mK(r){return gK(r,yK)}var wK=mK,bK=fb,_K=8;function gb(r,e,t){e=t?void 0:e;var n=bK(r,_K,void 0,void 0,void 0,void 0,void 0,e);return n.placeholder=gb.placeholder,n}gb.placeholder={};var AK=gb,vK=Rc,EK=db,xK=di,RK="[object Object]",IK=Function.prototype,SK=Object.prototype,$I=IK.toString,kK=SK.hasOwnProperty,TK=$I.call(Object);function OK(r){if(!xK(r)||vK(r)!=RK)return!1;var e=EK(r);if(e===null)return!0;var t=kK.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&$I.call(t)==TK}var FI=OK,NK=Rc,CK=di,BK=FI,PK="[object DOMException]",MK="[object Error]";function LK(r){if(!CK(r))return!1;var e=NK(r);return e==MK||e==PK||typeof r.message=="string"&&typeof r.name=="string"&&!BK(r)}var UK=LK,DK=Vh,$K=di,FK="[object WeakMap]";function HK(r){return $K(r)&&DK(r)==FK}var zK=HK,GK=Ap,KK=nb,jK=1,WK=2;function VK(r,e,t,n){var i=t.length,s=i,o=!n;if(r==null)return!s;for(r=Object(r);i--;){var a=t[i];if(o&&a[2]?a[1]!==r[a[0]]:!(a[0]in r))return!1}for(;++i<s;){a=t[i];var u=a[0],l=r[u],h=a[1];if(o&&a[2]){if(l===void 0&&!(u in r))return!1}else{var g=new GK;if(n)var b=n(l,h,u,r,e,g);if(!(b===void 0?KK(h,l,jK|WK,n,g):b))return!1}}return!0}var qK=VK,ZK=Bi;function QK(r){return r===r&&!ZK(r)}var HI=QK,JK=HI,YK=Ip;function XK(r){for(var e=YK(r),t=e.length;t--;){var n=e[t],i=r[n];e[t]=[n,i,JK(i)]}return e}var ej=XK;function tj(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var zI=tj,rj=qK,nj=ej,ij=zI;function sj(r){var e=nj(r);return e.length==1&&e[0][2]?ij(e[0][0],e[0][1]):function(t){return t===r||rj(t,r,e)}}var oj=sj,aj=Ln,cj=Jh,uj=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,lj=/^\w*$/;function fj(r,e){if(aj(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||cj(r)?!0:lj.test(r)||!uj.test(r)||e!=null&&r in Object(e)}var yb=fj,GI=Zw,hj="Expected a function";function mb(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(hj);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new(mb.Cache||GI),t}mb.Cache=GI;var dj=mb,pj=dj,gj=500;function yj(r){var e=pj(r,function(n){return t.size===gj&&t.clear(),n}),t=e.cache;return e}var mj=yj,wj=mj,bj=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,_j=/\\(\\)?/g,Aj=wj(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(bj,function(t,n,i,s){e.push(i?s.replace(_j,"$1"):n||t)}),e}),KI=Aj;function vj(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var jI=vj,_E=Tl,Ej=jI,xj=Ln,Rj=Jh,Ij=1/0,AE=_E?_E.prototype:void 0,vE=AE?AE.toString:void 0;function WI(r){if(typeof r=="string")return r;if(xj(r))return Ej(r,WI)+"";if(Rj(r))return vE?vE.call(r):"";var e=r+"";return e=="0"&&1/r==-Ij?"-0":e}var Sj=WI,kj=Sj;function Tj(r){return r==null?"":kj(r)}var VI=Tj,Oj=Ln,Nj=yb,Cj=KI,Bj=VI;function Pj(r,e){return Oj(r)?r:Nj(r,e)?[r]:Cj(Bj(r))}var qI=Pj,Mj=Jh,Lj=1/0;function Uj(r){if(typeof r=="string"||Mj(r))return r;var e=r+"";return e=="0"&&1/r==-Lj?"-0":e}var ed=Uj,Dj=qI,$j=ed;function Fj(r,e){e=Dj(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[$j(e[t++])];return t&&t==n?r:void 0}var ZI=Fj,Hj=ZI;function zj(r,e,t){var n=r==null?void 0:Hj(r,e);return n===void 0?t:n}var Gj=zj;function Kj(r,e){return r!=null&&e in Object(r)}var jj=Kj,Wj=qI,Vj=vp,qj=Ln,Zj=xp,Qj=Yw,Jj=ed;function Yj(r,e,t){e=Wj(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=Jj(e[n]);if(!(s=r!=null&&t(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&Qj(i)&&Zj(o,i)&&(qj(r)||Vj(r)))}var Xj=Yj,eW=jj,tW=Xj;function rW(r,e){return r!=null&&tW(r,e,eW)}var nW=rW,iW=nb,sW=Gj,oW=nW,aW=yb,cW=HI,uW=zI,lW=ed,fW=1,hW=2;function dW(r,e){return aW(r)&&cW(e)?uW(lW(r),e):function(t){var n=sW(t,r);return n===void 0&&n===e?oW(t,r):iW(e,n,fW|hW)}}var pW=dW;function gW(r){return function(e){return e==null?void 0:e[r]}}var yW=gW,mW=ZI;function wW(r){return function(e){return mW(e,r)}}var bW=wW,_W=yW,AW=bW,vW=yb,EW=ed;function xW(r){return vW(r)?_W(EW(r)):AW(r)}var RW=xW,IW=oj,SW=pW,kW=Tp(),TW=Ln,OW=RW;function NW(r){return typeof r=="function"?r:r==null?kW:typeof r=="object"?TW(r)?SW(r[0],r[1]):IW(r):OW(r)}var CW=NW,BW=DI,PW=CW,MW=1;function LW(r){return PW(typeof r=="function"?r:BW(r,MW))}var UW=LW,EE=Tl,DW=vp,$W=Ln,xE=EE?EE.isConcatSpreadable:void 0;function FW(r){return $W(r)||DW(r)||!!(xE&&r&&r[xE])}var HW=FW,zW=Qw,GW=HW;function QI(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=GW),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?QI(a,e-1,t,n,i):zW(i,a):n||(i[i.length]=a)}return i}var KW=QI,jW=KW;function WW(r){var e=r==null?0:r.length;return e?jW(r,1):[]}var VW=WW,dm,RE;function JI(){if(RE)return dm;RE=1;var r=sb(),e=Math.max;function t(n,i,s){return i=e(i===void 0?n.length-1:i,0),function(){for(var o=arguments,a=-1,u=e(o.length-i,0),l=Array(u);++a<u;)l[a]=o[i+a];a=-1;for(var h=Array(i+1);++a<i;)h[a]=o[a];return h[i]=s(l),r(n,this,h)}}return dm=t,dm}var qW=VW,ZW=JI(),QW=cb();function JW(r){return QW(ZW(r,void 0,qW),r+"")}var YW=JW,XW=fb,eV=YW,tV=256,rV=eV(function(r,e){return XW(r,tV,void 0,void 0,void 0,e)}),nV=rV,iV=jI,sV=Qh,oV=Ln,aV=Jh,cV=KI,uV=ed,lV=VI;function fV(r){return oV(r)?iV(r,uV):aV(r)?[r]:sV(cV(lV(r)))}var hV=fV,dV={ary:P7,assign:OI,clone:wK,curry:AK,forEach:ub,isArray:Ln,isError:UK,isFunction:wp,isWeakMap:zK,iteratee:UW,keys:jR,rearg:nV,toInteger:kI,toPath:hV},pV=sF,gV=dV;function yV(r,e,t){return pV(gV,r,e,t)}var mV=yV,pm,IE;function YI(){if(IE)return pm;IE=1;var r=hb(),e=Wh;function t(n,i,s){(s!==void 0&&!e(n[i],s)||s===void 0&&!(i in n))&&r(n,i,s)}return pm=t,pm}var gm,SE;function wV(){if(SE)return gm;SE=1;function r(e){return function(t,n,i){for(var s=-1,o=Object(t),a=i(t),u=a.length;u--;){var l=a[e?u:++s];if(n(o[l],l,o)===!1)break}return t}}return gm=r,gm}var ym,kE;function bV(){if(kE)return ym;kE=1;var r=wV(),e=r();return ym=e,ym}var mm,TE;function _V(){if(TE)return mm;TE=1;var r=Rp,e=di;function t(n){return e(n)&&r(n)}return mm=t,mm}var wm,OE;function XI(){if(OE)return wm;OE=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return wm=r,wm}var bm,NE;function AV(){if(NE)return bm;NE=1;var r=Yh,e=Xh();function t(n){return r(n,e(n))}return bm=t,bm}var _m,CE;function vV(){if(CE)return _m;CE=1;var r=YI(),e=NI(),t=BI(),n=Qh,i=PI(),s=vp,o=Ln,a=_V(),u=Ep,l=wp,h=Bi,g=FI,b=tb,w=XI(),I=AV();function S(x,C,H,D,z,V,Z){var K=w(x,H),W=w(C,H),oe=Z.get(W);if(oe){r(x,H,oe);return}var ce=V?V(K,W,H+"",x,C,Z):void 0,ne=ce===void 0;if(ne){var ue=o(W),B=!ue&&u(W),p=!ue&&!B&&b(W);ce=W,ue||B||p?o(K)?ce=K:a(K)?ce=n(K):B?(ne=!1,ce=e(W,!0)):p?(ne=!1,ce=t(W,!0)):ce=[]:g(W)||s(W)?(ce=K,s(K)?ce=I(K):(!h(K)||l(K))&&(ce=i(W))):ne=!1}ne&&(Z.set(W,ce),z(ce,W,D,V,Z),Z.delete(W)),r(x,H,ce)}return _m=S,_m}var Am,BE;function EV(){if(BE)return Am;BE=1;var r=Ap,e=YI(),t=bV(),n=vV(),i=Bi,s=Xh(),o=XI();function a(u,l,h,g,b){u!==l&&t(l,function(w,I){if(b||(b=new r),i(w))n(u,l,I,h,a,g,b);else{var S=g?g(o(u,I),w,I+"",u,l,b):void 0;S===void 0&&(S=w),e(u,I,S)}},s)}return Am=a,Am}var vm,PE;function xV(){if(PE)return vm;PE=1;var r=Tp(),e=JI(),t=cb();function n(i,s){return t(e(i,s,r),i+"")}return vm=n,vm}var Em,ME;function RV(){if(ME)return Em;ME=1;var r=Wh,e=Rp,t=xp,n=Bi;function i(s,o,a){if(!n(a))return!1;var u=typeof o;return(u=="number"?e(a)&&t(o,a.length):u=="string"&&o in a)?r(a[o],s):!1}return Em=i,Em}var xm,LE;function IV(){if(LE)return xm;LE=1;var r=xV(),e=RV();function t(n){return r(function(i,s){var o=-1,a=s.length,u=a>1?s[a-1]:void 0,l=a>2?s[2]:void 0;for(u=n.length>3&&typeof u=="function"?(a--,u):void 0,l&&e(s[0],s[1],l)&&(u=a<3?void 0:u,a=1),i=Object(i);++o<a;){var h=s[o];h&&n(i,h,o,u)}return i})}return xm=t,xm}var Rm,UE;function SV(){if(UE)return Rm;UE=1;var r=EV(),e=IV(),t=e(function(n,i,s,o){r(n,i,s,o)});return Rm=t,Rm}var kV=mV,eS=kV("mergeWith",SV());eS.placeholder=dI();var TV=eS;const OV=no(TV);class NV{constructor(e,t,n){this.userDetails=e,this.utils=t,this.emitter=n,this.mutex=new eF,this.logger=ns.getInstance(),this.errorHandler=new Sp,this.messagesQueue=new M1({clearWaitTime:200}),this.history={allTimeUsers:{}},this.processedUpdaterRefs=new Set,this.loadedMessagesCache=new Set,this.updaterEntryBuffer=[],this.historyUpdateTimer=null,this.HISTORY_UPDATE_INTERVAL_TIME=5e3,this.MAX_LOADED_MESSAGES_CACHE_SIZE=10}async init(){const e=await this.fetchLatestHistoryEntry();if(!this.historyEntry&&!e){this.initializeDefaultEntry();return}if(e!=null&&e.ref){this.setHistoryEntry(e);const t=await this.fetchHistory(e);this.history=t||this.history,this.trimHistory(),await this.fetchPreviousMessages({preDownloadHistory:!1})}}startHistoryUpdateProcess(){if(this.historyUpdateTimer){this.logger.warn("History update process is already running.");return}this.historyUpdateTimer=setInterval(this.createHistoryEntry.bind(this),this.HISTORY_UPDATE_INTERVAL_TIME)}stopHistoryUpdateProcess(){this.historyUpdateTimer&&(clearInterval(this.historyUpdateTimer),this.historyUpdateTimer=null)}getHistoryEntryWithNewUpdater(e){return{...this.historyEntry,updater:this.chooseNewUpdater(e)}}setHistoryEntry(e){this.historyEntry=e}async processHistoryUpdaterEntry(e,t){const n=await this.mutex.acquire();try{this.updateLocalHistory(e),t.updater===this.userDetails.ownAddress&&this.updaterEntryBuffer.push(t)}catch(i){this.errorHandler.handleError(i,"Chat.processHistoryUpdaterEntry")}finally{n()}}async fetchPreviousMessages(e){const t=await this.mutex.acquire();try{const n=e.preDownloadHistory?await this.fetchHistory(this.historyEntry):null,{allTimeUsers:i}=n?this.mergeChatHistory(n,this.history):this.history,s=this.selectLatestMessages(i);s.length>0&&await this.readAllMessageEntry(s)}finally{t()}}async createHistoryEntry(){const e=await this.mutex.acquire();try{const t=this.selectBestEntryForUpdate([...this.updaterEntryBuffer]);if(!t||this.processedUpdaterRefs.has(t.ref)){this.cleanupUpdaterEntryBuffer(t==null?void 0:t.id);return}const n=t.ref?await this.fetchHistory(this.historyEntry):null,i=n?this.mergeChatHistory(n,this.history):this.history,s=await this.uploadHistory(i),o=this.createNewHistoryEntry(s);await this.waitForHistoryEntryBroadcast(o),this.cleanupUpdaterEntryBuffer(t.id),this.processedUpdaterRefs.add(t.ref)}catch(t){this.errorHandler.handleError(t,"Chat.updateHistory")}finally{e()}}async waitForHistoryEntryBroadcast(e){return lI({condition:()=>this.historyEntry.ref===e.ref,broadcast:()=>this.broadcastHistoryEntry(e)})}async broadcastHistoryEntry(e){try{await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({historyEntry:e}))),this.logger.debug("NEW history entry broadcast CALLED")}catch(t){this.errorHandler.handleError(t,"Chat.broadcastNewAppState")}}async uploadHistory(e){const t=await this.utils.uploadObjectToBee(e);if(!t)throw new Error("History reference is null");return t}async fetchHistory(e){const t=e||await this.fetchLatestHistoryEntry();if(!t)return null;const n=await this.utils.downloadObjectFromBee(t.ref);return j$(n)?n:(this.logger.warn("Could not fetch remote history: invalid history data"),null)}async fetchLatestHistoryEntry(){try{const e=await this.utils.fetchLatestChatMessage();return this.logger.debug("Init GSOC message:",e),uI(e)?e.historyEntry:(this.logger.warn("Invalid GSOC message during latest history entry fetch"),null)}catch(e){return this.errorHandler.handleError(e,"Chat.fetchLatestHistoryEntry"),null}}async readAllMessageEntry(e){e.forEach(t=>{this.messagesQueue.enqueue(()=>this.readMessage(t))}),await this.messagesQueue.waitForProcessing()}async readMessage(e){try{const t=await this.utils.fetchUserFeedDataByIndex(e.address,e.entry.index);this.emitter.emit(Yn.MESSAGE_RECEIVED,t)}catch(t){this.errorHandler.handleError(t,"SwarmHistory.readMessage")}}updateLocalHistory(e){const t={};Object.entries(e).forEach(([n,i])=>{t[n]={events:[],messageEntries:[{index:i.index,timestamp:i.timestamp}]}}),this.history={allTimeUsers:this.mergeUserHistory(t,this.history.allTimeUsers)}}mergeChatHistory(e,t){return{allTimeUsers:this.mergeUserHistory(e.allTimeUsers,t.allTimeUsers)}}mergeUserHistory(e,t){return OV((n,i)=>{if(!n)return i;if(!i)return n;const s=Rv(n.events,i.events,a=>`${a.type}-${a.timestamp}`,(a,u)=>a.timestamp-u.timestamp),o=Rv(n.messageEntries,i.messageEntries,a=>a.index,(a,u)=>a.timestamp-u.timestamp);return{events:s,messageEntries:o}},e,t)}trimHistory(e=2,t=1e4){try{const n=JSON.stringify(this.history);if(new Blob([n]).size/(1024*1024)<=e)return;const o=[];for(const l in this.history.allTimeUsers)this.history.allTimeUsers[l].messageEntries.forEach(g=>{o.push({address:l,entry:g})});o.sort((l,h)=>l.entry.timestamp-h.entry.timestamp);const a=o.slice(t),u={allTimeUsers:{}};for(const{address:l,entry:h}of a)u.allTimeUsers[l]||(u.allTimeUsers[l]={events:[],messageEntries:[]}),u.allTimeUsers[l].messageEntries.push(h);this.history=u}catch(n){this.errorHandler.handleError(n,"SwarmHistory.trimHistory")}}chooseNewUpdater(e){const t=Object.values(e);if(t.length===0)return this.userDetails.ownAddress;let n;if(window.crypto&&window.crypto.getRandomValues){const i=new Uint32Array(1);window.crypto.getRandomValues(i),n=i[0]%t.length}else n=Math.floor(Math.random()*t.length);return t[n].address}selectLatestMessages(e){const t=[];for(const[i,s]of Object.entries(e))for(const o of s.messageEntries)t.push({address:i,entry:o});t.sort((i,s)=>s.entry.timestamp-i.entry.timestamp);const n=[];for(const{address:i,entry:s}of t){const o=`${i}:${s.index}`;if(!this.loadedMessagesCache.has(o)&&(n.push({address:i,entry:s}),this.loadedMessagesCache.add(o),n.length===this.MAX_LOADED_MESSAGES_CACHE_SIZE))break}return n}selectBestEntryForUpdate(e){return e.filter(t=>t.updater===this.userDetails.ownAddress).reduce((t,n)=>!t||n.id>t.id||n.id===t.id&&n.timestamp>t.timestamp?n:t,null)}cleanupUpdaterEntryBuffer(e){e!==void 0&&(this.updaterEntryBuffer=this.updaterEntryBuffer.filter(t=>t.id!==e))}createNewHistoryEntry(e){return{id:this.historyEntry.id+1,ref:e,updater:this.userDetails.ownAddress,timestamp:Date.now()}}initializeDefaultEntry(){this.historyEntry={id:0,ref:"",updater:this.userDetails.ownAddress,timestamp:Date.now()}}}const ul=globalThis||void 0||self;var wb={},Cp={};Cp.byteLength=PV;Cp.toByteArray=LV;Cp.fromByteArray=$V;var Qi=[],ti=[],CV=typeof Uint8Array<"u"?Uint8Array:Array,Im="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var zc=0,BV=Im.length;zc<BV;++zc)Qi[zc]=Im[zc],ti[Im.charCodeAt(zc)]=zc;ti[45]=62;ti[95]=63;function tS(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function PV(r){var e=tS(r),t=e[0],n=e[1];return(t+n)*3/4-n}function MV(r,e,t){return(e+t)*3/4-t}function LV(r){var e,t=tS(r),n=t[0],i=t[1],s=new CV(MV(r,n,i)),o=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)e=ti[r.charCodeAt(u)]<<18|ti[r.charCodeAt(u+1)]<<12|ti[r.charCodeAt(u+2)]<<6|ti[r.charCodeAt(u+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=ti[r.charCodeAt(u)]<<2|ti[r.charCodeAt(u+1)]>>4,s[o++]=e&255),i===1&&(e=ti[r.charCodeAt(u)]<<10|ti[r.charCodeAt(u+1)]<<4|ti[r.charCodeAt(u+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function UV(r){return Qi[r>>18&63]+Qi[r>>12&63]+Qi[r>>6&63]+Qi[r&63]}function DV(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(UV(n));return i.join("")}function $V(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,a=t-n;o<a;o+=s)i.push(DV(r,o,o+s>a?a:o+s));return n===1?(e=r[t-1],i.push(Qi[e>>2]+Qi[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(Qi[e>>10]+Qi[e>>4&63]+Qi[e<<2&63]+"=")),i.join("")}var bb={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */bb.read=function(r,e,t,n,i){var s,o,a=i*8-n-1,u=(1<<a)-1,l=u>>1,h=-7,g=t?i-1:0,b=t?-1:1,w=r[e+g];for(g+=b,s=w&(1<<-h)-1,w>>=-h,h+=a;h>0;s=s*256+r[e+g],g+=b,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+r[e+g],g+=b,h-=8);if(s===0)s=1-l;else{if(s===u)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(w?-1:1)*o*Math.pow(2,s-n)};bb.write=function(r,e,t,n,i,s){var o,a,u,l=s*8-i-1,h=(1<<l)-1,g=h>>1,b=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,I=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+g>=1?e+=b/u:e+=b*Math.pow(2,1-g),e*u>=2&&(o++,u/=2),o+g>=h?(a=0,o=h):o+g>=1?(a=(e*u-1)*Math.pow(2,i),o=o+g):(a=e*Math.pow(2,g-1)*Math.pow(2,i),o=0));i>=8;r[t+w]=a&255,w+=I,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;r[t+w]=o&255,w+=I,o/=256,l-=8);r[t+w-I]|=S*128};/*!
5
14
  * The buffer module from node.js, for the browser.
6
15
  *
7
16
  * @author Feross Aboukhadijeh <https://feross.org>
8
17
  * @license MIT
9
- */(function(t){const e=base64Js,n=ieee754,a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=d,t.SlowBuffer=W,t.INSPECT_MAX_BYTES=50;const c=2147483647;t.kMaxLength=c;const{Uint8Array:o,ArrayBuffer:u,SharedArrayBuffer:h}=globalThis;d.TYPED_ARRAY_SUPPORT=l(),!d.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 l(){try{const V=new o(1),T={foo:function(){return 42}};return Object.setPrototypeOf(T,o.prototype),Object.setPrototypeOf(V,T),V.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function b(V){if(V>c)throw new RangeError('The value "'+V+'" is invalid for option "size"');const T=new o(V);return Object.setPrototypeOf(T,d.prototype),T}function d(V,T,O){if(typeof V=="number"){if(typeof T=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(V)}return p(V,T,O)}d.poolSize=8192;function p(V,T,O){if(typeof V=="string")return g(V,T);if(u.isView(V))return B(V);if(V==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof V);if(Be(V,u)||V&&Be(V.buffer,u)||typeof h<"u"&&(Be(V,h)||V&&Be(V.buffer,h)))return C(V,T,O);if(typeof V=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const X=V.valueOf&&V.valueOf();if(X!=null&&X!==V)return d.from(X,T,O);const ne=F(V);if(ne)return ne;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof V[Symbol.toPrimitive]=="function")return d.from(V[Symbol.toPrimitive]("string"),T,O);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof V)}d.from=function(V,T,O){return p(V,T,O)},Object.setPrototypeOf(d.prototype,o.prototype),Object.setPrototypeOf(d,o);function x(V){if(typeof V!="number")throw new TypeError('"size" argument must be of type number');if(V<0)throw new RangeError('The value "'+V+'" is invalid for option "size"')}function m(V,T,O){return x(V),V<=0?b(V):T!==void 0?typeof O=="string"?b(V).fill(T,O):b(V).fill(T):b(V)}d.alloc=function(V,T,O){return m(V,T,O)};function v(V){return x(V),b(V<0?0:H(V)|0)}d.allocUnsafe=function(V){return v(V)},d.allocUnsafeSlow=function(V){return v(V)};function g(V,T){if((typeof T!="string"||T==="")&&(T="utf8"),!d.isEncoding(T))throw new TypeError("Unknown encoding: "+T);const O=Z(V,T)|0;let X=b(O);const ne=X.write(V,T);return ne!==O&&(X=X.slice(0,ne)),X}function $(V){const T=V.length<0?0:H(V.length)|0,O=b(T);for(let X=0;X<T;X+=1)O[X]=V[X]&255;return O}function B(V){if(Be(V,o)){const T=new o(V);return C(T.buffer,T.byteOffset,T.byteLength)}return $(V)}function C(V,T,O){if(T<0||V.byteLength<T)throw new RangeError('"offset" is outside of buffer bounds');if(V.byteLength<T+(O||0))throw new RangeError('"length" is outside of buffer bounds');let X;return T===void 0&&O===void 0?X=new o(V):O===void 0?X=new o(V,T):X=new o(V,T,O),Object.setPrototypeOf(X,d.prototype),X}function F(V){if(d.isBuffer(V)){const T=H(V.length)|0,O=b(T);return O.length===0||V.copy(O,0,0,T),O}if(V.length!==void 0)return typeof V.length!="number"||De(V.length)?b(0):$(V);if(V.type==="Buffer"&&Array.isArray(V.data))return $(V.data)}function H(V){if(V>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return V|0}function W(V){return+V!=V&&(V=0),d.alloc(+V)}d.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==d.prototype},d.compare=function(T,O){if(Be(T,o)&&(T=d.from(T,T.offset,T.byteLength)),Be(O,o)&&(O=d.from(O,O.offset,O.byteLength)),!d.isBuffer(T)||!d.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===O)return 0;let X=T.length,ne=O.length;for(let ce=0,ue=Math.min(X,ne);ce<ue;++ce)if(T[ce]!==O[ce]){X=T[ce],ne=O[ce];break}return X<ne?-1:ne<X?1:0},d.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}},d.concat=function(T,O){if(!Array.isArray(T))throw new TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return d.alloc(0);let X;if(O===void 0)for(O=0,X=0;X<T.length;++X)O+=T[X].length;const ne=d.allocUnsafe(O);let ce=0;for(X=0;X<T.length;++X){let ue=T[X];if(Be(ue,o))ce+ue.length>ne.length?(d.isBuffer(ue)||(ue=d.from(ue)),ue.copy(ne,ce)):o.prototype.set.call(ne,ue,ce);else if(d.isBuffer(ue))ue.copy(ne,ce);else throw new TypeError('"list" argument must be an Array of Buffers');ce+=ue.length}return ne};function Z(V,T){if(d.isBuffer(V))return V.length;if(u.isView(V)||Be(V,u))return V.byteLength;if(typeof V!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof V);const O=V.length,X=arguments.length>2&&arguments[2]===!0;if(!X&&O===0)return 0;let ne=!1;for(;;)switch(T){case"ascii":case"latin1":case"binary":return O;case"utf8":case"utf-8":return ge(V).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O*2;case"hex":return O>>>1;case"base64":return Ne(V).length;default:if(ne)return X?-1:ge(V).length;T=(""+T).toLowerCase(),ne=!0}}d.byteLength=Z;function ie(V,T,O){let X=!1;if((T===void 0||T<0)&&(T=0),T>this.length||((O===void 0||O>this.length)&&(O=this.length),O<=0)||(O>>>=0,T>>>=0,O<=T))return"";for(V||(V="utf8");;)switch(V){case"hex":return E(this,T,O);case"utf8":case"utf-8":return M(this,T,O);case"ascii":return _(this,T,O);case"latin1":case"binary":return q(this,T,O);case"base64":return I(this,T,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,T,O);default:if(X)throw new TypeError("Unknown encoding: "+V);V=(V+"").toLowerCase(),X=!0}}d.prototype._isBuffer=!0;function te(V,T,O){const X=V[T];V[T]=V[O],V[O]=X}d.prototype.swap16=function(){const T=this.length;if(T%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<T;O+=2)te(this,O,O+1);return this},d.prototype.swap32=function(){const T=this.length;if(T%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<T;O+=4)te(this,O,O+3),te(this,O+1,O+2);return this},d.prototype.swap64=function(){const T=this.length;if(T%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<T;O+=8)te(this,O,O+7),te(this,O+1,O+6),te(this,O+2,O+5),te(this,O+3,O+4);return this},d.prototype.toString=function(){const T=this.length;return T===0?"":arguments.length===0?M(this,0,T):ie.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(T){if(!d.isBuffer(T))throw new TypeError("Argument must be a Buffer");return this===T?!0:d.compare(this,T)===0},d.prototype.inspect=function(){let T="";const O=t.INSPECT_MAX_BYTES;return T=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(T+=" ... "),"<Buffer "+T+">"},a&&(d.prototype[a]=d.prototype.inspect),d.prototype.compare=function(T,O,X,ne,ce){if(Be(T,o)&&(T=d.from(T,T.offset,T.byteLength)),!d.isBuffer(T))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(O===void 0&&(O=0),X===void 0&&(X=T?T.length:0),ne===void 0&&(ne=0),ce===void 0&&(ce=this.length),O<0||X>T.length||ne<0||ce>this.length)throw new RangeError("out of range index");if(ne>=ce&&O>=X)return 0;if(ne>=ce)return-1;if(O>=X)return 1;if(O>>>=0,X>>>=0,ne>>>=0,ce>>>=0,this===T)return 0;let ue=ce-ne,me=X-O;const Ee=Math.min(ue,me),xe=this.slice(ne,ce),Ae=T.slice(O,X);for(let _e=0;_e<Ee;++_e)if(xe[_e]!==Ae[_e]){ue=xe[_e],me=Ae[_e];break}return ue<me?-1:me<ue?1:0};function ae(V,T,O,X,ne){if(V.length===0)return-1;if(typeof O=="string"?(X=O,O=0):O>2147483647?O=2147483647:O<-2147483648&&(O=-2147483648),O=+O,De(O)&&(O=ne?0:V.length-1),O<0&&(O=V.length+O),O>=V.length){if(ne)return-1;O=V.length-1}else if(O<0)if(ne)O=0;else return-1;if(typeof T=="string"&&(T=d.from(T,X)),d.isBuffer(T))return T.length===0?-1:de(V,T,O,X,ne);if(typeof T=="number")return T=T&255,typeof o.prototype.indexOf=="function"?ne?o.prototype.indexOf.call(V,T,O):o.prototype.lastIndexOf.call(V,T,O):de(V,[T],O,X,ne);throw new TypeError("val must be string, number or Buffer")}function de(V,T,O,X,ne){let ce=1,ue=V.length,me=T.length;if(X!==void 0&&(X=String(X).toLowerCase(),X==="ucs2"||X==="ucs-2"||X==="utf16le"||X==="utf-16le")){if(V.length<2||T.length<2)return-1;ce=2,ue/=2,me/=2,O/=2}function Ee(Ae,_e){return ce===1?Ae[_e]:Ae.readUInt16BE(_e*ce)}let xe;if(ne){let Ae=-1;for(xe=O;xe<ue;xe++)if(Ee(V,xe)===Ee(T,Ae===-1?0:xe-Ae)){if(Ae===-1&&(Ae=xe),xe-Ae+1===me)return Ae*ce}else Ae!==-1&&(xe-=xe-Ae),Ae=-1}else for(O+me>ue&&(O=ue-me),xe=O;xe>=0;xe--){let Ae=!0;for(let _e=0;_e<me;_e++)if(Ee(V,xe+_e)!==Ee(T,_e)){Ae=!1;break}if(Ae)return xe}return-1}d.prototype.includes=function(T,O,X){return this.indexOf(T,O,X)!==-1},d.prototype.indexOf=function(T,O,X){return ae(this,T,O,X,!0)},d.prototype.lastIndexOf=function(T,O,X){return ae(this,T,O,X,!1)};function J(V,T,O,X){O=Number(O)||0;const ne=V.length-O;X?(X=Number(X),X>ne&&(X=ne)):X=ne;const ce=T.length;X>ce/2&&(X=ce/2);let ue;for(ue=0;ue<X;++ue){const me=parseInt(T.substr(ue*2,2),16);if(De(me))return ue;V[O+ue]=me}return ue}function R(V,T,O,X){return ve(ge(T,V.length-O),V,O,X)}function A(V,T,O,X){return ve(ye(T),V,O,X)}function y(V,T,O,X){return ve(Ne(T),V,O,X)}function w(V,T,O,X){return ve($e(T,V.length-O),V,O,X)}d.prototype.write=function(T,O,X,ne){if(O===void 0)ne="utf8",X=this.length,O=0;else if(X===void 0&&typeof O=="string")ne=O,X=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite(X)?(X=X>>>0,ne===void 0&&(ne="utf8")):(ne=X,X=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ce=this.length-O;if((X===void 0||X>ce)&&(X=ce),T.length>0&&(X<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");ne||(ne="utf8");let ue=!1;for(;;)switch(ne){case"hex":return J(this,T,O,X);case"utf8":case"utf-8":return R(this,T,O,X);case"ascii":case"latin1":case"binary":return A(this,T,O,X);case"base64":return y(this,T,O,X);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,T,O,X);default:if(ue)throw new TypeError("Unknown encoding: "+ne);ne=(""+ne).toLowerCase(),ue=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(V,T,O){return T===0&&O===V.length?e.fromByteArray(V):e.fromByteArray(V.slice(T,O))}function M(V,T,O){O=Math.min(V.length,O);const X=[];let ne=T;for(;ne<O;){const ce=V[ne];let ue=null,me=ce>239?4:ce>223?3:ce>191?2:1;if(ne+me<=O){let Ee,xe,Ae,_e;switch(me){case 1:ce<128&&(ue=ce);break;case 2:Ee=V[ne+1],(Ee&192)===128&&(_e=(ce&31)<<6|Ee&63,_e>127&&(ue=_e));break;case 3:Ee=V[ne+1],xe=V[ne+2],(Ee&192)===128&&(xe&192)===128&&(_e=(ce&15)<<12|(Ee&63)<<6|xe&63,_e>2047&&(_e<55296||_e>57343)&&(ue=_e));break;case 4:Ee=V[ne+1],xe=V[ne+2],Ae=V[ne+3],(Ee&192)===128&&(xe&192)===128&&(Ae&192)===128&&(_e=(ce&15)<<18|(Ee&63)<<12|(xe&63)<<6|Ae&63,_e>65535&&_e<1114112&&(ue=_e))}}ue===null?(ue=65533,me=1):ue>65535&&(ue-=65536,X.push(ue>>>10&1023|55296),ue=56320|ue&1023),X.push(ue),ne+=me}return P(X)}const k=4096;function P(V){const T=V.length;if(T<=k)return String.fromCharCode.apply(String,V);let O="",X=0;for(;X<T;)O+=String.fromCharCode.apply(String,V.slice(X,X+=k));return O}function _(V,T,O){let X="";O=Math.min(V.length,O);for(let ne=T;ne<O;++ne)X+=String.fromCharCode(V[ne]&127);return X}function q(V,T,O){let X="";O=Math.min(V.length,O);for(let ne=T;ne<O;++ne)X+=String.fromCharCode(V[ne]);return X}function E(V,T,O){const X=V.length;(!T||T<0)&&(T=0),(!O||O<0||O>X)&&(O=X);let ne="";for(let ce=T;ce<O;++ce)ne+=Se[V[ce]];return ne}function j(V,T,O){const X=V.slice(T,O);let ne="";for(let ce=0;ce<X.length-1;ce+=2)ne+=String.fromCharCode(X[ce]+X[ce+1]*256);return ne}d.prototype.slice=function(T,O){const X=this.length;T=~~T,O=O===void 0?X:~~O,T<0?(T+=X,T<0&&(T=0)):T>X&&(T=X),O<0?(O+=X,O<0&&(O=0)):O>X&&(O=X),O<T&&(O=T);const ne=this.subarray(T,O);return Object.setPrototypeOf(ne,d.prototype),ne};function ee(V,T,O){if(V%1!==0||V<0)throw new RangeError("offset is not uint");if(V+T>O)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(T,O,X){T=T>>>0,O=O>>>0,X||ee(T,O,this.length);let ne=this[T],ce=1,ue=0;for(;++ue<O&&(ce*=256);)ne+=this[T+ue]*ce;return ne},d.prototype.readUintBE=d.prototype.readUIntBE=function(T,O,X){T=T>>>0,O=O>>>0,X||ee(T,O,this.length);let ne=this[T+--O],ce=1;for(;O>0&&(ce*=256);)ne+=this[T+--O]*ce;return ne},d.prototype.readUint8=d.prototype.readUInt8=function(T,O){return T=T>>>0,O||ee(T,1,this.length),this[T]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(T,O){return T=T>>>0,O||ee(T,2,this.length),this[T]|this[T+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(T,O){return T=T>>>0,O||ee(T,2,this.length),this[T]<<8|this[T+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])},d.prototype.readBigUInt64LE=Oe(function(T){T=T>>>0,le(T,"offset");const O=this[T],X=this[T+7];(O===void 0||X===void 0)&&pe(T,this.length-8);const ne=O+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24,ce=this[++T]+this[++T]*2**8+this[++T]*2**16+X*2**24;return BigInt(ne)+(BigInt(ce)<<BigInt(32))}),d.prototype.readBigUInt64BE=Oe(function(T){T=T>>>0,le(T,"offset");const O=this[T],X=this[T+7];(O===void 0||X===void 0)&&pe(T,this.length-8);const ne=O*2**24+this[++T]*2**16+this[++T]*2**8+this[++T],ce=this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+X;return(BigInt(ne)<<BigInt(32))+BigInt(ce)}),d.prototype.readIntLE=function(T,O,X){T=T>>>0,O=O>>>0,X||ee(T,O,this.length);let ne=this[T],ce=1,ue=0;for(;++ue<O&&(ce*=256);)ne+=this[T+ue]*ce;return ce*=128,ne>=ce&&(ne-=Math.pow(2,8*O)),ne},d.prototype.readIntBE=function(T,O,X){T=T>>>0,O=O>>>0,X||ee(T,O,this.length);let ne=O,ce=1,ue=this[T+--ne];for(;ne>0&&(ce*=256);)ue+=this[T+--ne]*ce;return ce*=128,ue>=ce&&(ue-=Math.pow(2,8*O)),ue},d.prototype.readInt8=function(T,O){return T=T>>>0,O||ee(T,1,this.length),this[T]&128?(255-this[T]+1)*-1:this[T]},d.prototype.readInt16LE=function(T,O){T=T>>>0,O||ee(T,2,this.length);const X=this[T]|this[T+1]<<8;return X&32768?X|4294901760:X},d.prototype.readInt16BE=function(T,O){T=T>>>0,O||ee(T,2,this.length);const X=this[T+1]|this[T]<<8;return X&32768?X|4294901760:X},d.prototype.readInt32LE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24},d.prototype.readInt32BE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]},d.prototype.readBigInt64LE=Oe(function(T){T=T>>>0,le(T,"offset");const O=this[T],X=this[T+7];(O===void 0||X===void 0)&&pe(T,this.length-8);const ne=this[T+4]+this[T+5]*2**8+this[T+6]*2**16+(X<<24);return(BigInt(ne)<<BigInt(32))+BigInt(O+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24)}),d.prototype.readBigInt64BE=Oe(function(T){T=T>>>0,le(T,"offset");const O=this[T],X=this[T+7];(O===void 0||X===void 0)&&pe(T,this.length-8);const ne=(O<<24)+this[++T]*2**16+this[++T]*2**8+this[++T];return(BigInt(ne)<<BigInt(32))+BigInt(this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+X)}),d.prototype.readFloatLE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),n.read(this,T,!0,23,4)},d.prototype.readFloatBE=function(T,O){return T=T>>>0,O||ee(T,4,this.length),n.read(this,T,!1,23,4)},d.prototype.readDoubleLE=function(T,O){return T=T>>>0,O||ee(T,8,this.length),n.read(this,T,!0,52,8)},d.prototype.readDoubleBE=function(T,O){return T=T>>>0,O||ee(T,8,this.length),n.read(this,T,!1,52,8)};function oe(V,T,O,X,ne,ce){if(!d.isBuffer(V))throw new TypeError('"buffer" argument must be a Buffer instance');if(T>ne||T<ce)throw new RangeError('"value" argument is out of bounds');if(O+X>V.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(T,O,X,ne){if(T=+T,O=O>>>0,X=X>>>0,!ne){const me=Math.pow(2,8*X)-1;oe(this,T,O,X,me,0)}let ce=1,ue=0;for(this[O]=T&255;++ue<X&&(ce*=256);)this[O+ue]=T/ce&255;return O+X},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(T,O,X,ne){if(T=+T,O=O>>>0,X=X>>>0,!ne){const me=Math.pow(2,8*X)-1;oe(this,T,O,X,me,0)}let ce=X-1,ue=1;for(this[O+ce]=T&255;--ce>=0&&(ue*=256);)this[O+ce]=T/ue&255;return O+X},d.prototype.writeUint8=d.prototype.writeUInt8=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,1,255,0),this[O]=T&255,O+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,2,65535,0),this[O]=T&255,this[O+1]=T>>>8,O+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,2,65535,0),this[O]=T>>>8,this[O+1]=T&255,O+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,4,4294967295,0),this[O+3]=T>>>24,this[O+2]=T>>>16,this[O+1]=T>>>8,this[O]=T&255,O+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,4,4294967295,0),this[O]=T>>>24,this[O+1]=T>>>16,this[O+2]=T>>>8,this[O+3]=T&255,O+4};function Y(V,T,O,X,ne){he(T,X,ne,V,O,7);let ce=Number(T&BigInt(4294967295));V[O++]=ce,ce=ce>>8,V[O++]=ce,ce=ce>>8,V[O++]=ce,ce=ce>>8,V[O++]=ce;let ue=Number(T>>BigInt(32)&BigInt(4294967295));return V[O++]=ue,ue=ue>>8,V[O++]=ue,ue=ue>>8,V[O++]=ue,ue=ue>>8,V[O++]=ue,O}function L(V,T,O,X,ne){he(T,X,ne,V,O,7);let ce=Number(T&BigInt(4294967295));V[O+7]=ce,ce=ce>>8,V[O+6]=ce,ce=ce>>8,V[O+5]=ce,ce=ce>>8,V[O+4]=ce;let ue=Number(T>>BigInt(32)&BigInt(4294967295));return V[O+3]=ue,ue=ue>>8,V[O+2]=ue,ue=ue>>8,V[O+1]=ue,ue=ue>>8,V[O]=ue,O+8}d.prototype.writeBigUInt64LE=Oe(function(T,O=0){return Y(this,T,O,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=Oe(function(T,O=0){return L(this,T,O,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(T,O,X,ne){if(T=+T,O=O>>>0,!ne){const Ee=Math.pow(2,8*X-1);oe(this,T,O,X,Ee-1,-Ee)}let ce=0,ue=1,me=0;for(this[O]=T&255;++ce<X&&(ue*=256);)T<0&&me===0&&this[O+ce-1]!==0&&(me=1),this[O+ce]=(T/ue>>0)-me&255;return O+X},d.prototype.writeIntBE=function(T,O,X,ne){if(T=+T,O=O>>>0,!ne){const Ee=Math.pow(2,8*X-1);oe(this,T,O,X,Ee-1,-Ee)}let ce=X-1,ue=1,me=0;for(this[O+ce]=T&255;--ce>=0&&(ue*=256);)T<0&&me===0&&this[O+ce+1]!==0&&(me=1),this[O+ce]=(T/ue>>0)-me&255;return O+X},d.prototype.writeInt8=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,1,127,-128),T<0&&(T=255+T+1),this[O]=T&255,O+1},d.prototype.writeInt16LE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,2,32767,-32768),this[O]=T&255,this[O+1]=T>>>8,O+2},d.prototype.writeInt16BE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,2,32767,-32768),this[O]=T>>>8,this[O+1]=T&255,O+2},d.prototype.writeInt32LE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,4,2147483647,-2147483648),this[O]=T&255,this[O+1]=T>>>8,this[O+2]=T>>>16,this[O+3]=T>>>24,O+4},d.prototype.writeInt32BE=function(T,O,X){return T=+T,O=O>>>0,X||oe(this,T,O,4,2147483647,-2147483648),T<0&&(T=4294967295+T+1),this[O]=T>>>24,this[O+1]=T>>>16,this[O+2]=T>>>8,this[O+3]=T&255,O+4},d.prototype.writeBigInt64LE=Oe(function(T,O=0){return Y(this,T,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=Oe(function(T,O=0){return L(this,T,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function z(V,T,O,X,ne,ce){if(O+X>V.length)throw new RangeError("Index out of range");if(O<0)throw new RangeError("Index out of range")}function re(V,T,O,X,ne){return T=+T,O=O>>>0,ne||z(V,T,O,4),n.write(V,T,O,X,23,4),O+4}d.prototype.writeFloatLE=function(T,O,X){return re(this,T,O,!0,X)},d.prototype.writeFloatBE=function(T,O,X){return re(this,T,O,!1,X)};function D(V,T,O,X,ne){return T=+T,O=O>>>0,ne||z(V,T,O,8),n.write(V,T,O,X,52,8),O+8}d.prototype.writeDoubleLE=function(T,O,X){return D(this,T,O,!0,X)},d.prototype.writeDoubleBE=function(T,O,X){return D(this,T,O,!1,X)},d.prototype.copy=function(T,O,X,ne){if(!d.isBuffer(T))throw new TypeError("argument should be a Buffer");if(X||(X=0),!ne&&ne!==0&&(ne=this.length),O>=T.length&&(O=T.length),O||(O=0),ne>0&&ne<X&&(ne=X),ne===X||T.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if(X<0||X>=this.length)throw new RangeError("Index out of range");if(ne<0)throw new RangeError("sourceEnd out of bounds");ne>this.length&&(ne=this.length),T.length-O<ne-X&&(ne=T.length-O+X);const ce=ne-X;return this===T&&typeof o.prototype.copyWithin=="function"?this.copyWithin(O,X,ne):o.prototype.set.call(T,this.subarray(X,ne),O),ce},d.prototype.fill=function(T,O,X,ne){if(typeof T=="string"){if(typeof O=="string"?(ne=O,O=0,X=this.length):typeof X=="string"&&(ne=X,X=this.length),ne!==void 0&&typeof ne!="string")throw new TypeError("encoding must be a string");if(typeof ne=="string"&&!d.isEncoding(ne))throw new TypeError("Unknown encoding: "+ne);if(T.length===1){const ue=T.charCodeAt(0);(ne==="utf8"&&ue<128||ne==="latin1")&&(T=ue)}}else typeof T=="number"?T=T&255:typeof T=="boolean"&&(T=Number(T));if(O<0||this.length<O||this.length<X)throw new RangeError("Out of range index");if(X<=O)return this;O=O>>>0,X=X===void 0?this.length:X>>>0,T||(T=0);let ce;if(typeof T=="number")for(ce=O;ce<X;++ce)this[ce]=T;else{const ue=d.isBuffer(T)?T:d.from(T,ne),me=ue.length;if(me===0)throw new TypeError('The value "'+T+'" is invalid for argument "value"');for(ce=0;ce<X-O;++ce)this[ce+O]=ue[ce%me]}return this};const G={};function U(V,T,O){G[V]=class extends O{constructor(){super(),Object.defineProperty(this,"message",{value:T.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${V}]`,this.stack,delete this.name}get code(){return V}set code(ne){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:ne,writable:!0})}toString(){return`${this.name} [${V}]: ${this.message}`}}}U("ERR_BUFFER_OUT_OF_BOUNDS",function(V){return V?`${V} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(V,T){return`The "${V}" argument must be of type number. Received type ${typeof T}`},TypeError),U("ERR_OUT_OF_RANGE",function(V,T,O){let X=`The value of "${V}" is out of range.`,ne=O;return Number.isInteger(O)&&Math.abs(O)>2**32?ne=Q(String(O)):typeof O=="bigint"&&(ne=String(O),(O>BigInt(2)**BigInt(32)||O<-(BigInt(2)**BigInt(32)))&&(ne=Q(ne)),ne+="n"),X+=` It must be ${T}. Received ${ne}`,X},RangeError);function Q(V){let T="",O=V.length;const X=V[0]==="-"?1:0;for(;O>=X+4;O-=3)T=`_${V.slice(O-3,O)}${T}`;return`${V.slice(0,O)}${T}`}function fe(V,T,O){le(T,"offset"),(V[T]===void 0||V[T+O]===void 0)&&pe(T,V.length-(O+1))}function he(V,T,O,X,ne,ce){if(V>O||V<T){const ue=typeof T=="bigint"?"n":"";let me;throw T===0||T===BigInt(0)?me=`>= 0${ue} and < 2${ue} ** ${(ce+1)*8}${ue}`:me=`>= -(2${ue} ** ${(ce+1)*8-1}${ue}) and < 2 ** ${(ce+1)*8-1}${ue}`,new G.ERR_OUT_OF_RANGE("value",me,V)}fe(X,ne,ce)}function le(V,T){if(typeof V!="number")throw new G.ERR_INVALID_ARG_TYPE(T,"number",V)}function pe(V,T,O){throw Math.floor(V)!==V?(le(V,O),new G.ERR_OUT_OF_RANGE("offset","an integer",V)):T<0?new G.ERR_BUFFER_OUT_OF_BOUNDS:new G.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${T}`,V)}const be=/[^+/0-9A-Za-z-_]/g;function se(V){if(V=V.split("=")[0],V=V.trim().replace(be,""),V.length<2)return"";for(;V.length%4!==0;)V=V+"=";return V}function ge(V,T){T=T||1/0;let O;const X=V.length;let ne=null;const ce=[];for(let ue=0;ue<X;++ue){if(O=V.charCodeAt(ue),O>55295&&O<57344){if(!ne){if(O>56319){(T-=3)>-1&&ce.push(239,191,189);continue}else if(ue+1===X){(T-=3)>-1&&ce.push(239,191,189);continue}ne=O;continue}if(O<56320){(T-=3)>-1&&ce.push(239,191,189),ne=O;continue}O=(ne-55296<<10|O-56320)+65536}else ne&&(T-=3)>-1&&ce.push(239,191,189);if(ne=null,O<128){if((T-=1)<0)break;ce.push(O)}else if(O<2048){if((T-=2)<0)break;ce.push(O>>6|192,O&63|128)}else if(O<65536){if((T-=3)<0)break;ce.push(O>>12|224,O>>6&63|128,O&63|128)}else if(O<1114112){if((T-=4)<0)break;ce.push(O>>18|240,O>>12&63|128,O>>6&63|128,O&63|128)}else throw new Error("Invalid code point")}return ce}function ye(V){const T=[];for(let O=0;O<V.length;++O)T.push(V.charCodeAt(O)&255);return T}function $e(V,T){let O,X,ne;const ce=[];for(let ue=0;ue<V.length&&!((T-=2)<0);++ue)O=V.charCodeAt(ue),X=O>>8,ne=O%256,ce.push(ne),ce.push(X);return ce}function Ne(V){return e.toByteArray(se(V))}function ve(V,T,O,X){let ne;for(ne=0;ne<X&&!(ne+O>=T.length||ne>=V.length);++ne)T[ne+O]=V[ne];return ne}function Be(V,T){return V instanceof T||V!=null&&V.constructor!=null&&V.constructor.name!=null&&V.constructor.name===T.name}function De(V){return V!==V}const Se=function(){const V="0123456789abcdef",T=new Array(256);for(let O=0;O<16;++O){const X=O*16;for(let ne=0;ne<16;++ne)T[X+ne]=V[O]+V[ne]}return T}();function Oe(V){return typeof BigInt>"u"?Ue:V}function Ue(){throw new Error("BigInt not supported")}})(buffer$1);const Buffer=buffer$1.Buffer,Buffer$1=buffer$1.Buffer,dist$1=Object.freeze(Object.defineProperty({__proto__:null,Buffer:Buffer$1,default:Buffer},Symbol.toStringTag,{value:"Module"}));var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs$1(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function getAugmentedNamespace(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function a(){return this instanceof a?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(a){var c=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,c.get?c:{enumerable:!0,get:function(){return t[a]}})}),n}var dist={},file={},chunk={},span={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_SPAN_LENGTH=t.DEFAULT_SPAN_SIZE=void 0,t.makeSpan=e,t.getSpanValue=n,t.DEFAULT_SPAN_SIZE=8,t.MAX_SPAN_LENGTH=Math.pow(2,32)-1;function e(a,c){const o=c||t.DEFAULT_SPAN_SIZE;if(a<0)throw new Error(`invalid length for span: ${a}`);if(a>t.MAX_SPAN_LENGTH)throw new Error(`invalid length (> ${t.MAX_SPAN_LENGTH}) ${a}`);const u=new Uint8Array(o),h=new DataView(u.buffer),l=!0,b=a&4294967295;return h.setUint32(0,b,l),u}function n(a){return new DataView(a.buffer).getUint32(0,!0)}})(span);var utils$p={};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var browser$c={exports:{}},process=browser$c.exports={},cachedSetTimeout,cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?cachedSetTimeout=setTimeout:cachedSetTimeout=defaultSetTimout}catch{cachedSetTimeout=defaultSetTimout}try{typeof clearTimeout=="function"?cachedClearTimeout=clearTimeout:cachedClearTimeout=defaultClearTimeout}catch{cachedClearTimeout=defaultClearTimeout}})();function runTimeout(t){if(cachedSetTimeout===setTimeout)return setTimeout(t,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(t,0);try{return cachedSetTimeout(t,0)}catch{try{return cachedSetTimeout.call(null,t,0)}catch{return cachedSetTimeout.call(this,t,0)}}}function runClearTimeout(t){if(cachedClearTimeout===clearTimeout)return clearTimeout(t);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(t);try{return cachedClearTimeout(t)}catch{try{return cachedClearTimeout.call(null,t)}catch{return cachedClearTimeout.call(this,t)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var t=runTimeout(cleanUpNextTick);draining=!0;for(var e=queue.length;e;){for(currentQueue=queue,queue=[];++queueIndex<e;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,e=queue.length}currentQueue=null,draining=!1,runClearTimeout(t)}}process.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];queue.push(new Item(t,e)),queue.length===1&&!draining&&runTimeout(drainQueue)};function Item(t,e){this.fun=t,this.array=e}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=!0;process.env={};process.argv=[];process.version="";process.versions={};function noop$1(){}process.on=noop$1;process.addListener=noop$1;process.once=noop$1;process.off=noop$1;process.removeListener=noop$1;process.removeAllListeners=noop$1;process.emit=noop$1;process.prependListener=noop$1;process.prependOnceListener=noop$1;process.listeners=function(t){return[]};process.binding=function(t){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(t){throw new Error("process.chdir is not supported")};process.umask=function(){return 0};var browserExports=browser$c.exports;const process$1=getDefaultExportFromCjs(browserExports);var sha3={exports:{}};(function(t){(function(){var e="input is invalid type",n="finalize already called",a=typeof window=="object",c=a?window:{};c.JS_SHA3_NO_WINDOW&&(a=!1);var o=!a&&typeof self=="object",u=!c.JS_SHA3_NO_NODE_JS&&typeof process$1=="object"&&process$1.versions&&process$1.versions.node;u?c=commonjsGlobal:o&&(c=self);for(var h=!c.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,l=!c.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",b="0123456789abcdef".split(""),d=[31,7936,2031616,520093696],p=[4,1024,262144,67108864],x=[1,256,65536,16777216],m=[6,1536,393216,100663296],v=[0,8,16,24],g=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],$=[224,256,384,512],B=[128,256],C=["hex","buffer","arrayBuffer","array","digest"],F={128:168,256:136},H=c.JS_SHA3_NO_NODE_JS||!Array.isArray?function(D){return Object.prototype.toString.call(D)==="[object Array]"}:Array.isArray,W=l&&(c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(D){return typeof D=="object"&&D.buffer&&D.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Z=function(D){var G=typeof D;if(G==="string")return[D,!0];if(G!=="object"||D===null)throw new Error(e);if(l&&D.constructor===ArrayBuffer)return[new Uint8Array(D),!1];if(!H(D)&&!W(D))throw new Error(e);return[D,!1]},ie=function(D){return Z(D)[0].length===0},te=function(D){for(var G=[],U=0;U<D.length;++U)G[U]=D[U];return G},ae=function(D,G,U){return function(Q){return new L(D,G,D).update(Q)[U]()}},de=function(D,G,U){return function(Q,fe){return new L(D,G,fe).update(Q)[U]()}},J=function(D,G,U){return function(Q,fe,he,le){return P["cshake"+D].update(Q,fe,he,le)[U]()}},R=function(D,G,U){return function(Q,fe,he,le){return P["kmac"+D].update(Q,fe,he,le)[U]()}},A=function(D,G,U,Q){for(var fe=0;fe<C.length;++fe){var he=C[fe];D[he]=G(U,Q,he)}return D},y=function(D,G){var U=ae(D,G,"hex");return U.create=function(){return new L(D,G,D)},U.update=function(Q){return U.create().update(Q)},A(U,ae,D,G)},w=function(D,G){var U=de(D,G,"hex");return U.create=function(Q){return new L(D,G,Q)},U.update=function(Q,fe){return U.create(fe).update(Q)},A(U,de,D,G)},I=function(D,G){var U=F[D],Q=J(D,G,"hex");return Q.create=function(fe,he,le){return ie(he)&&ie(le)?P["shake"+D].create(fe):new L(D,G,fe).bytepad([he,le],U)},Q.update=function(fe,he,le,pe){return Q.create(he,le,pe).update(fe)},A(Q,J,D,G)},M=function(D,G){var U=F[D],Q=R(D,G,"hex");return Q.create=function(fe,he,le){return new z(D,G,he).bytepad(["KMAC",le],U).bytepad([fe],U)},Q.update=function(fe,he,le,pe){return Q.create(fe,le,pe).update(he)},A(Q,R,D,G)},k=[{name:"keccak",padding:x,bits:$,createMethod:y},{name:"sha3",padding:m,bits:$,createMethod:y},{name:"shake",padding:d,bits:B,createMethod:w},{name:"cshake",padding:p,bits:B,createMethod:I},{name:"kmac",padding:p,bits:B,createMethod:M}],P={},_=[],q=0;q<k.length;++q)for(var E=k[q],j=E.bits,ee=0;ee<j.length;++ee){var oe=E.name+"_"+j[ee];if(_.push(oe),P[oe]=E.createMethod(j[ee],E.padding),E.name!=="sha3"){var Y=E.name+j[ee];_.push(Y),P[Y]=P[oe]}}function L(D,G,U){this.blocks=[],this.s=[],this.padding=G,this.outputBits=U,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(D<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=U>>5,this.extraBytes=(U&31)>>3;for(var Q=0;Q<50;++Q)this.s[Q]=0}L.prototype.update=function(D){if(this.finalized)throw new Error(n);var G=Z(D);D=G[0];for(var U=G[1],Q=this.blocks,fe=this.byteCount,he=D.length,le=this.blockCount,pe=0,be=this.s,se,ge;pe<he;){if(this.reset)for(this.reset=!1,Q[0]=this.block,se=1;se<le+1;++se)Q[se]=0;if(U)for(se=this.start;pe<he&&se<fe;++pe)ge=D.charCodeAt(pe),ge<128?Q[se>>2]|=ge<<v[se++&3]:ge<2048?(Q[se>>2]|=(192|ge>>6)<<v[se++&3],Q[se>>2]|=(128|ge&63)<<v[se++&3]):ge<55296||ge>=57344?(Q[se>>2]|=(224|ge>>12)<<v[se++&3],Q[se>>2]|=(128|ge>>6&63)<<v[se++&3],Q[se>>2]|=(128|ge&63)<<v[se++&3]):(ge=65536+((ge&1023)<<10|D.charCodeAt(++pe)&1023),Q[se>>2]|=(240|ge>>18)<<v[se++&3],Q[se>>2]|=(128|ge>>12&63)<<v[se++&3],Q[se>>2]|=(128|ge>>6&63)<<v[se++&3],Q[se>>2]|=(128|ge&63)<<v[se++&3]);else for(se=this.start;pe<he&&se<fe;++pe)Q[se>>2]|=D[pe]<<v[se++&3];if(this.lastByteIndex=se,se>=fe){for(this.start=se-fe,this.block=Q[le],se=0;se<le;++se)be[se]^=Q[se];re(be),this.reset=!0}else this.start=se}return this},L.prototype.encode=function(D,G){var U=D&255,Q=1,fe=[U];for(D=D>>8,U=D&255;U>0;)fe.unshift(U),D=D>>8,U=D&255,++Q;return G?fe.push(Q):fe.unshift(Q),this.update(fe),fe.length},L.prototype.encodeString=function(D){var G=Z(D);D=G[0];var U=G[1],Q=0,fe=D.length;if(U)for(var he=0;he<D.length;++he){var le=D.charCodeAt(he);le<128?Q+=1:le<2048?Q+=2:le<55296||le>=57344?Q+=3:(le=65536+((le&1023)<<10|D.charCodeAt(++he)&1023),Q+=4)}else Q=fe;return Q+=this.encode(Q*8),this.update(D),Q},L.prototype.bytepad=function(D,G){for(var U=this.encode(G),Q=0;Q<D.length;++Q)U+=this.encodeString(D[Q]);var fe=(G-U%G)%G,he=[];return he.length=fe,this.update(he),this},L.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var D=this.blocks,G=this.lastByteIndex,U=this.blockCount,Q=this.s;if(D[G>>2]|=this.padding[G&3],this.lastByteIndex===this.byteCount)for(D[0]=D[U],G=1;G<U+1;++G)D[G]=0;for(D[U-1]|=2147483648,G=0;G<U;++G)Q[G]^=D[G];re(Q)}},L.prototype.toString=L.prototype.hex=function(){this.finalize();for(var D=this.blockCount,G=this.s,U=this.outputBlocks,Q=this.extraBytes,fe=0,he=0,le="",pe;he<U;){for(fe=0;fe<D&&he<U;++fe,++he)pe=G[fe],le+=b[pe>>4&15]+b[pe&15]+b[pe>>12&15]+b[pe>>8&15]+b[pe>>20&15]+b[pe>>16&15]+b[pe>>28&15]+b[pe>>24&15];he%D===0&&(G=te(G),re(G),fe=0)}return Q&&(pe=G[fe],le+=b[pe>>4&15]+b[pe&15],Q>1&&(le+=b[pe>>12&15]+b[pe>>8&15]),Q>2&&(le+=b[pe>>20&15]+b[pe>>16&15])),le},L.prototype.arrayBuffer=function(){this.finalize();var D=this.blockCount,G=this.s,U=this.outputBlocks,Q=this.extraBytes,fe=0,he=0,le=this.outputBits>>3,pe;Q?pe=new ArrayBuffer(U+1<<2):pe=new ArrayBuffer(le);for(var be=new Uint32Array(pe);he<U;){for(fe=0;fe<D&&he<U;++fe,++he)be[he]=G[fe];he%D===0&&(G=te(G),re(G))}return Q&&(be[he]=G[fe],pe=pe.slice(0,le)),pe},L.prototype.buffer=L.prototype.arrayBuffer,L.prototype.digest=L.prototype.array=function(){this.finalize();for(var D=this.blockCount,G=this.s,U=this.outputBlocks,Q=this.extraBytes,fe=0,he=0,le=[],pe,be;he<U;){for(fe=0;fe<D&&he<U;++fe,++he)pe=he<<2,be=G[fe],le[pe]=be&255,le[pe+1]=be>>8&255,le[pe+2]=be>>16&255,le[pe+3]=be>>24&255;he%D===0&&(G=te(G),re(G))}return Q&&(pe=he<<2,be=G[fe],le[pe]=be&255,Q>1&&(le[pe+1]=be>>8&255),Q>2&&(le[pe+2]=be>>16&255)),le};function z(D,G,U){L.call(this,D,G,U)}z.prototype=new L,z.prototype.finalize=function(){return this.encode(this.outputBits,!0),L.prototype.finalize.call(this)};var re=function(D){var G,U,Q,fe,he,le,pe,be,se,ge,ye,$e,Ne,ve,Be,De,Se,Oe,Ue,V,T,O,X,ne,ce,ue,me,Ee,xe,Ae,_e,Me,Ge,Ke,Ie,ze,Ve,Pe,We,Je,Te,Ze,Xe,ke,Ye,Qe,qe,et,tt,Ce,rt,He,je,at,st,ot,ft,ct,dt,ht,lt,pt,bt;for(Q=0;Q<48;Q+=2)fe=D[0]^D[10]^D[20]^D[30]^D[40],he=D[1]^D[11]^D[21]^D[31]^D[41],le=D[2]^D[12]^D[22]^D[32]^D[42],pe=D[3]^D[13]^D[23]^D[33]^D[43],be=D[4]^D[14]^D[24]^D[34]^D[44],se=D[5]^D[15]^D[25]^D[35]^D[45],ge=D[6]^D[16]^D[26]^D[36]^D[46],ye=D[7]^D[17]^D[27]^D[37]^D[47],$e=D[8]^D[18]^D[28]^D[38]^D[48],Ne=D[9]^D[19]^D[29]^D[39]^D[49],G=$e^(le<<1|pe>>>31),U=Ne^(pe<<1|le>>>31),D[0]^=G,D[1]^=U,D[10]^=G,D[11]^=U,D[20]^=G,D[21]^=U,D[30]^=G,D[31]^=U,D[40]^=G,D[41]^=U,G=fe^(be<<1|se>>>31),U=he^(se<<1|be>>>31),D[2]^=G,D[3]^=U,D[12]^=G,D[13]^=U,D[22]^=G,D[23]^=U,D[32]^=G,D[33]^=U,D[42]^=G,D[43]^=U,G=le^(ge<<1|ye>>>31),U=pe^(ye<<1|ge>>>31),D[4]^=G,D[5]^=U,D[14]^=G,D[15]^=U,D[24]^=G,D[25]^=U,D[34]^=G,D[35]^=U,D[44]^=G,D[45]^=U,G=be^($e<<1|Ne>>>31),U=se^(Ne<<1|$e>>>31),D[6]^=G,D[7]^=U,D[16]^=G,D[17]^=U,D[26]^=G,D[27]^=U,D[36]^=G,D[37]^=U,D[46]^=G,D[47]^=U,G=ge^(fe<<1|he>>>31),U=ye^(he<<1|fe>>>31),D[8]^=G,D[9]^=U,D[18]^=G,D[19]^=U,D[28]^=G,D[29]^=U,D[38]^=G,D[39]^=U,D[48]^=G,D[49]^=U,ve=D[0],Be=D[1],Qe=D[11]<<4|D[10]>>>28,qe=D[10]<<4|D[11]>>>28,Ee=D[20]<<3|D[21]>>>29,xe=D[21]<<3|D[20]>>>29,ht=D[31]<<9|D[30]>>>23,lt=D[30]<<9|D[31]>>>23,Ze=D[40]<<18|D[41]>>>14,Xe=D[41]<<18|D[40]>>>14,Ke=D[2]<<1|D[3]>>>31,Ie=D[3]<<1|D[2]>>>31,De=D[13]<<12|D[12]>>>20,Se=D[12]<<12|D[13]>>>20,et=D[22]<<10|D[23]>>>22,tt=D[23]<<10|D[22]>>>22,Ae=D[33]<<13|D[32]>>>19,_e=D[32]<<13|D[33]>>>19,pt=D[42]<<2|D[43]>>>30,bt=D[43]<<2|D[42]>>>30,at=D[5]<<30|D[4]>>>2,st=D[4]<<30|D[5]>>>2,ze=D[14]<<6|D[15]>>>26,Ve=D[15]<<6|D[14]>>>26,Oe=D[25]<<11|D[24]>>>21,Ue=D[24]<<11|D[25]>>>21,Ce=D[34]<<15|D[35]>>>17,rt=D[35]<<15|D[34]>>>17,Me=D[45]<<29|D[44]>>>3,Ge=D[44]<<29|D[45]>>>3,ne=D[6]<<28|D[7]>>>4,ce=D[7]<<28|D[6]>>>4,ot=D[17]<<23|D[16]>>>9,ft=D[16]<<23|D[17]>>>9,Pe=D[26]<<25|D[27]>>>7,We=D[27]<<25|D[26]>>>7,V=D[36]<<21|D[37]>>>11,T=D[37]<<21|D[36]>>>11,He=D[47]<<24|D[46]>>>8,je=D[46]<<24|D[47]>>>8,ke=D[8]<<27|D[9]>>>5,Ye=D[9]<<27|D[8]>>>5,ue=D[18]<<20|D[19]>>>12,me=D[19]<<20|D[18]>>>12,ct=D[29]<<7|D[28]>>>25,dt=D[28]<<7|D[29]>>>25,Je=D[38]<<8|D[39]>>>24,Te=D[39]<<8|D[38]>>>24,O=D[48]<<14|D[49]>>>18,X=D[49]<<14|D[48]>>>18,D[0]=ve^~De&Oe,D[1]=Be^~Se&Ue,D[10]=ne^~ue&Ee,D[11]=ce^~me&xe,D[20]=Ke^~ze&Pe,D[21]=Ie^~Ve&We,D[30]=ke^~Qe&et,D[31]=Ye^~qe&tt,D[40]=at^~ot&ct,D[41]=st^~ft&dt,D[2]=De^~Oe&V,D[3]=Se^~Ue&T,D[12]=ue^~Ee&Ae,D[13]=me^~xe&_e,D[22]=ze^~Pe&Je,D[23]=Ve^~We&Te,D[32]=Qe^~et&Ce,D[33]=qe^~tt&rt,D[42]=ot^~ct&ht,D[43]=ft^~dt&lt,D[4]=Oe^~V&O,D[5]=Ue^~T&X,D[14]=Ee^~Ae&Me,D[15]=xe^~_e&Ge,D[24]=Pe^~Je&Ze,D[25]=We^~Te&Xe,D[34]=et^~Ce&He,D[35]=tt^~rt&je,D[44]=ct^~ht&pt,D[45]=dt^~lt&bt,D[6]=V^~O&ve,D[7]=T^~X&Be,D[16]=Ae^~Me&ne,D[17]=_e^~Ge&ce,D[26]=Je^~Ze&Ke,D[27]=Te^~Xe&Ie,D[36]=Ce^~He&ke,D[37]=rt^~je&Ye,D[46]=ht^~pt&at,D[47]=lt^~bt&st,D[8]=O^~ve&De,D[9]=X^~Be&Se,D[18]=Me^~ne&ue,D[19]=Ge^~ce&me,D[28]=Ze^~Ke&ze,D[29]=Xe^~Ie&Ve,D[38]=He^~ke&Qe,D[39]=je^~Ye&qe,D[48]=pt^~at&ot,D[49]=bt^~st&ft,D[0]^=g[Q],D[1]^=g[Q+1]};if(h)t.exports=P;else for(q=0;q<_.length;++q)c[_[q]]=P[_[q]]})()})(sha3);var sha3Exports=sha3.exports;Object.defineProperty(utils$p,"__esModule",{value:!0});utils$p.isFlexBytes=isFlexBytes;utils$p.assertFlexBytes=assertFlexBytes;utils$p.serializeBytes=serializeBytes$1;utils$p.keccak256Hash=keccak256Hash$1;utils$p.bytesToHex=bytesToHex$1;utils$p.equalBytes=equalBytes;const js_sha3_1=sha3Exports;function isFlexBytes(t,e,n){return t instanceof Uint8Array&&t.length>=e&&t.length<=n}function assertFlexBytes(t,e,n){if(!isFlexBytes(t,e,n))throw new TypeError(`Parameter is not valid FlexBytes of min: ${e}, max: ${n}, length: ${t.length}`)}function serializeBytes$1(...t){const e=t.reduce((c,o)=>c+o.length,0),n=new Uint8Array(e);let a=0;return t.forEach(c=>{n.set(c,a),a+=c.length}),n}function keccak256Hash$1(...t){const e=js_sha3_1.keccak256.create();return t.forEach(n=>e.update(n)),Uint8Array.from(e.digest())}function bytesToHex$1(t,e){const n=c=>c.toString(16).padStart(2,"0"),a=Array.from(t,n).join("");if(a.length!==e)throw new TypeError(`Resulting HexString does not have expected length ${e}: ${a}`);return a}function equalBytes(t,e){return t.length!==e.length?!1:t.every((n,a)=>e[a]===n)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_MIN_PAYLOAD_SIZE=t.DEFAULT_MAX_PAYLOAD_SIZE=t.SEGMENT_SIZE=void 0,t.makeChunk=o,t.bmtRootHash=u,t.inclusionProofBottomUp=h,t.rootHashFromInclusionProof=l;const e=span,n=utils$p;t.SEGMENT_SIZE=32;const a=2*t.SEGMENT_SIZE;t.DEFAULT_MAX_PAYLOAD_SIZE=4096;const c=32;t.DEFAULT_MIN_PAYLOAD_SIZE=1;function o(p,x){const m=(x==null?void 0:x.maxPayloadSize)||t.DEFAULT_MAX_PAYLOAD_SIZE,v=(x==null?void 0:x.spanLength)||e.DEFAULT_SPAN_SIZE,g=(x==null?void 0:x.startingSpanValue)||p.length,$=x!=null&&x.hashFn?x.hashFn:n.keccak256Hash;(0,n.assertFlexBytes)(p,0,m);const B=new Uint8Array(m-p.length),C=()=>(0,e.makeSpan)(g,v),F=()=>(0,n.serializeBytes)(p,new Uint8Array(B));return{payload:p,spanLength:v,maxPayloadLength:m,data:F,span:C,address:()=>d(p,v,C(),{hashFn:$}),inclusionProof:ie=>h(F(),ie,{hashFn:$}),bmt:()=>b(F(),{hashFn:$})}}function u(p,x=t.DEFAULT_MAX_PAYLOAD_SIZE,m){if(p.length>x)throw new Error(`invalid data length ${p}`);const v=m!=null&&m.hashFn?m.hashFn:n.keccak256Hash;let g=new Uint8Array([...p,...new Uint8Array(x-p.length)]);for(;g.length!==c;){const $=new Uint8Array(g.length/2);for(let B=0;B<g.length;B+=a){const C=v(g.slice(B,B+a));$.set(C,B/2)}g=$}return g}function h(p,x,m){if(x*t.SEGMENT_SIZE>=p.length)throw new Error(`The given segment index ${x} is greater than ${Math.floor(p.length/t.SEGMENT_SIZE)}`);const v=b(p,m),g=[],$=v.length-1;for(let B=0;B<$;B++){const C=x%2===0?1:-1,F=x+C,H=v[B].slice(F*t.SEGMENT_SIZE,(F+1)*t.SEGMENT_SIZE);g.push(H),x>>>=1}return g}function l(p,x,m,v){const g=v!=null&&v.hashFn?v.hashFn:n.keccak256Hash;let $=x;for(const B of p)$=m%2===0?g($,B):g(B,$),m>>>=1;return $}function b(p,x){if(p.length>t.DEFAULT_MAX_PAYLOAD_SIZE)throw new Error(`invalid data length ${p.length}`);const m=x!=null&&x.hashFn?x.hashFn:n.keccak256Hash;let v=new Uint8Array([...p,...new Uint8Array(t.DEFAULT_MAX_PAYLOAD_SIZE-p.length)]);const g=[];for(;v.length!==c;){g.push(v);const $=new Uint8Array(v.length/2);for(let B=0;B<v.length;B+=a){const C=m(v.slice(B,B+a));$.set(C,B/2)}v=$}return g.push(v),g}function d(p,x,m,v){const g=v!=null&&v.hashFn?v.hashFn:n.keccak256Hash,$=m||(0,e.makeSpan)(p.length,x),B=u(p,t.DEFAULT_MAX_PAYLOAD_SIZE,v),C=new Uint8Array([...$,...B]);return g(C)}})(chunk);var hasRequiredFile;function requireFile(){if(hasRequiredFile)return file;hasRequiredFile=1,Object.defineProperty(file,"__esModule",{value:!0}),file.makeChunkedFile=c,file.fileInclusionProofBottomUp=o,file.fileAddressFromInclusionProof=u,file.getBmtIndexOfSegment=h;const t=requireDist(),e=chunk,n=span,a=utils$p;function c(m,v){const g=(v==null?void 0:v.maxPayloadLength)||e.DEFAULT_MAX_PAYLOAD_SIZE,$=(v==null?void 0:v.spanLength)||n.DEFAULT_SPAN_SIZE,B=()=>{const Z=[];if(m.length===0)Z.push((0,t.makeChunk)(new Uint8Array,v));else for(let ie=0;ie<m.length;ie+=g)Z.push((0,t.makeChunk)(m.slice(ie,ie+g),v));return Z};return{payload:m,span:()=>(0,t.makeSpan)(m.length,$),leafChunks:B,address:()=>b(B()).address(),rootChunk:()=>b(B()),bmt:()=>l(B())}}function o(m,v){if(v*e.SEGMENT_SIZE>=(0,t.getSpanValue)(m.span()))throw new Error(`The given segment index ${v} is greater than ${Math.floor((0,t.getSpanValue)(m.span())/e.SEGMENT_SIZE)}`);let g=m.leafChunks();const B=g[0].maxPayloadLength/e.SEGMENT_SIZE,C=Math.log2(B);let F=x(g);const H=[];for(;g.length!==1||F;){const Z=v%B;let ie=Math.floor(v/B);if(ie===g.length){if(!F)throw new Error("Impossible");v>>>=C;do{const{nextLevelChunks:R,nextLevelCarrierChunk:A}=d(g,F);g=R,F=A,v>>>=C}while(v%B===0);ie=g.length-1}const te=g[ie],ae=te.inclusionProof(Z);H.push({sisterSegments:ae,span:te.span()}),v=ie;const{nextLevelChunks:de,nextLevelCarrierChunk:J}=d(g,F);g=de,F=J}const W=g[0].inclusionProof(v);return H.push({sisterSegments:W,span:g[0].span()}),H}function u(m,v,g,$=4096){const B=Math.floor($/e.SEGMENT_SIZE),C=Math.log2(B),F=(0,t.getSpanValue)(m[m.length-1].span);let H=Math.floor((F-1)/$),W=v;for(const Z of m){const{chunkIndex:ie,level:te}=h(g,H,$);for(const ae of Z.sisterSegments)W=g%2===0?(0,a.keccak256Hash)(W,ae):(0,a.keccak256Hash)(ae,W),g=Math.floor(g/2);W=(0,a.keccak256Hash)(Z.span,W),g=ie,H>>>=C+te*C}return W}function h(m,v,g=4096){const $=Math.floor(g/e.SEGMENT_SIZE),B=Math.log2($);let C=0;if(Math.floor(m/$)===v&&v%$===0&&v!==0)for(m>>>=B;m%e.SEGMENT_SIZE===0;)C++,m>>>=B;else m>>>=B;return{chunkIndex:m,level:C}}function l(m){if(m.length===0)throw new Error("given chunk array is empty");const v=[m];let g=x(m);for(;v[v.length-1].length!==1;){const{nextLevelChunks:$,nextLevelCarrierChunk:B}=d(v[v.length-1],g);g=B,v.push($)}return v}function b(m){if(m.length===0)throw new Error("given chunk array is empty");let v=m,g=x(v);for(;v.length!==1||g;){const{nextLevelChunks:$,nextLevelCarrierChunk:B}=d(v,g);v=$,g=B}return v[0]}function d(m,v){if(m.length===0)throw new Error("The given chunk array is empty");const g=m[0].maxPayloadLength,$=m[0].spanLength,B=g/e.SEGMENT_SIZE,C=[];for(let H=0;H<m.length;H+=B){const W=m.slice(H,H+B);C.push(p(W,$,g))}let F=v;return v?C.length%B!==0&&(C.push(v),F=null):F=x(C),{nextLevelChunks:C,nextLevelCarrierChunk:F}}function p(m,v,g){const $=m.map(F=>F.address()),B=m.map(F=>(0,t.getSpanValue)(F.span())).reduce((F,H)=>F+H),C=(0,a.serializeBytes)(...$);return(0,t.makeChunk)(C,{spanLength:v,startingSpanValue:B,maxPayloadSize:g})}function x(m){if(m.length<=1)return null;const g=m[0].maxPayloadLength/e.SEGMENT_SIZE;return m.length%g===1&&m.pop()||null}return file}var hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,function(t){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(h,l,b,d){d===void 0&&(d=b);var p=Object.getOwnPropertyDescriptor(l,b);(!p||("get"in p?!l.__esModule:p.writable||p.configurable))&&(p={enumerable:!0,get:function(){return l[b]}}),Object.defineProperty(h,d,p)}:function(h,l,b,d){d===void 0&&(d=b),h[d]=l[b]}),n=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(h,l){Object.defineProperty(h,"default",{enumerable:!0,value:l})}:function(h,l){h.default=l}),a=commonjsGlobal&&commonjsGlobal.__importStar||function(h){if(h&&h.__esModule)return h;var l={};if(h!=null)for(var b in h)b!=="default"&&Object.prototype.hasOwnProperty.call(h,b)&&e(l,h,b);return n(l,h),l};Object.defineProperty(t,"__esModule",{value:!0}),t.Utils=t.getSpanValue=t.makeSpan=t.rootHashFromInclusionProof=t.makeChunk=t.getBmtIndexOfSegment=t.fileAddressFromInclusionProof=t.fileInclusionProofBottomUp=t.makeChunkedFile=void 0;var c=requireFile();Object.defineProperty(t,"makeChunkedFile",{enumerable:!0,get:function(){return c.makeChunkedFile}}),Object.defineProperty(t,"fileInclusionProofBottomUp",{enumerable:!0,get:function(){return c.fileInclusionProofBottomUp}}),Object.defineProperty(t,"fileAddressFromInclusionProof",{enumerable:!0,get:function(){return c.fileAddressFromInclusionProof}}),Object.defineProperty(t,"getBmtIndexOfSegment",{enumerable:!0,get:function(){return c.getBmtIndexOfSegment}});var o=chunk;Object.defineProperty(t,"makeChunk",{enumerable:!0,get:function(){return o.makeChunk}}),Object.defineProperty(t,"rootHashFromInclusionProof",{enumerable:!0,get:function(){return o.rootHashFromInclusionProof}});var u=span;Object.defineProperty(t,"makeSpan",{enumerable:!0,get:function(){return u.makeSpan}}),Object.defineProperty(t,"getSpanValue",{enumerable:!0,get:function(){return u.getSpanValue}}),t.Utils=a(utils$p)}(dist)),dist}var distExports=requireDist(),ws=null;typeof WebSocket<"u"?ws=WebSocket:typeof MozWebSocket<"u"?ws=MozWebSocket:typeof global$1<"u"?ws=global$1.WebSocket||global$1.MozWebSocket:typeof window<"u"?ws=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(ws=self.WebSocket||self.MozWebSocket);const WebSocket$1=ws;var elliptic={};const name="elliptic",version="6.5.7",description="EC cryptography",main="lib/elliptic.js",files=["lib"],scripts={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository={type:"git",url:"git@github.com:indutny/elliptic"},keywords=["EC","Elliptic","curve","Cryptography"],author="Fedor Indutny <fedor@indutny.com>",license="MIT",bugs={url:"https://github.com/indutny/elliptic/issues"},homepage="https://github.com/indutny/elliptic",devDependencies={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},require$$0={name,version,description,main,files,scripts,repository,keywords,author,license,bugs,homepage,devDependencies,dependencies};var utils$o={},bn$1={exports:{}};const require$$1$2=getAugmentedNamespace(dist$1);bn$1.exports;(function(t){(function(e,n){function a(J,R){if(!J)throw new Error(R||"Assertion failed")}function c(J,R){J.super_=R;var A=function(){};A.prototype=R.prototype,J.prototype=new A,J.prototype.constructor=J}function o(J,R,A){if(o.isBN(J))return J;this.negative=0,this.words=null,this.length=0,this.red=null,J!==null&&((R==="le"||R==="be")&&(A=R,R=10),this._init(J||0,R||10,A||"be"))}typeof e=="object"?e.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var u;try{typeof window<"u"&&typeof window.Buffer<"u"?u=window.Buffer:u=require$$1$2.Buffer}catch{}o.isBN=function(R){return R instanceof o?!0:R!==null&&typeof R=="object"&&R.constructor.wordSize===o.wordSize&&Array.isArray(R.words)},o.max=function(R,A){return R.cmp(A)>0?R:A},o.min=function(R,A){return R.cmp(A)<0?R:A},o.prototype._init=function(R,A,y){if(typeof R=="number")return this._initNumber(R,A,y);if(typeof R=="object")return this._initArray(R,A,y);A==="hex"&&(A=16),a(A===(A|0)&&A>=2&&A<=36),R=R.toString().replace(/\s+/g,"");var w=0;R[0]==="-"&&(w++,this.negative=1),w<R.length&&(A===16?this._parseHex(R,w,y):(this._parseBase(R,A,w),y==="le"&&this._initArray(this.toArray(),A,y)))},o.prototype._initNumber=function(R,A,y){R<0&&(this.negative=1,R=-R),R<67108864?(this.words=[R&67108863],this.length=1):R<4503599627370496?(this.words=[R&67108863,R/67108864&67108863],this.length=2):(a(R<9007199254740992),this.words=[R&67108863,R/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),A,y)},o.prototype._initArray=function(R,A,y){if(a(typeof R.length=="number"),R.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(R.length/3),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var I,M,k=0;if(y==="be")for(w=R.length-1,I=0;w>=0;w-=3)M=R[w]|R[w-1]<<8|R[w-2]<<16,this.words[I]|=M<<k&67108863,this.words[I+1]=M>>>26-k&67108863,k+=24,k>=26&&(k-=26,I++);else if(y==="le")for(w=0,I=0;w<R.length;w+=3)M=R[w]|R[w+1]<<8|R[w+2]<<16,this.words[I]|=M<<k&67108863,this.words[I+1]=M>>>26-k&67108863,k+=24,k>=26&&(k-=26,I++);return this.strip()};function h(J,R){var A=J.charCodeAt(R);return A>=65&&A<=70?A-55:A>=97&&A<=102?A-87:A-48&15}function l(J,R,A){var y=h(J,A);return A-1>=R&&(y|=h(J,A-1)<<4),y}o.prototype._parseHex=function(R,A,y){this.length=Math.ceil((R.length-A)/6),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var I=0,M=0,k;if(y==="be")for(w=R.length-1;w>=A;w-=2)k=l(R,A,w)<<I,this.words[M]|=k&67108863,I>=18?(I-=18,M+=1,this.words[M]|=k>>>26):I+=8;else{var P=R.length-A;for(w=P%2===0?A+1:A;w<R.length;w+=2)k=l(R,A,w)<<I,this.words[M]|=k&67108863,I>=18?(I-=18,M+=1,this.words[M]|=k>>>26):I+=8}this.strip()};function b(J,R,A,y){for(var w=0,I=Math.min(J.length,A),M=R;M<I;M++){var k=J.charCodeAt(M)-48;w*=y,k>=49?w+=k-49+10:k>=17?w+=k-17+10:w+=k}return w}o.prototype._parseBase=function(R,A,y){this.words=[0],this.length=1;for(var w=0,I=1;I<=67108863;I*=A)w++;w--,I=I/A|0;for(var M=R.length-y,k=M%w,P=Math.min(M,M-k)+y,_=0,q=y;q<P;q+=w)_=b(R,q,q+w,A),this.imuln(I),this.words[0]+_<67108864?this.words[0]+=_:this._iaddn(_);if(k!==0){var E=1;for(_=b(R,q,R.length,A),q=0;q<k;q++)E*=A;this.imuln(E),this.words[0]+_<67108864?this.words[0]+=_:this._iaddn(_)}this.strip()},o.prototype.copy=function(R){R.words=new Array(this.length);for(var A=0;A<this.length;A++)R.words[A]=this.words[A];R.length=this.length,R.negative=this.negative,R.red=this.red},o.prototype.clone=function(){var R=new o(null);return this.copy(R),R},o.prototype._expand=function(R){for(;this.length<R;)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},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],x=[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(R,A){R=R||10,A=A|0||1;var y;if(R===16||R==="hex"){y="";for(var w=0,I=0,M=0;M<this.length;M++){var k=this.words[M],P=((k<<w|I)&16777215).toString(16);I=k>>>24-w&16777215,I!==0||M!==this.length-1?y=d[6-P.length]+P+y:y=P+y,w+=2,w>=26&&(w-=26,M--)}for(I!==0&&(y=I.toString(16)+y);y.length%A!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(R===(R|0)&&R>=2&&R<=36){var _=p[R],q=x[R];y="";var E=this.clone();for(E.negative=0;!E.isZero();){var j=E.modn(q).toString(R);E=E.idivn(q),E.isZero()?y=j+y:y=d[_-j.length]+j+y}for(this.isZero()&&(y="0"+y);y.length%A!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}a(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var R=this.words[0];return this.length===2?R+=this.words[1]*67108864:this.length===3&&this.words[2]===1?R+=4503599627370496+this.words[1]*67108864:this.length>2&&a(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-R:R},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(R,A){return a(typeof u<"u"),this.toArrayLike(u,R,A)},o.prototype.toArray=function(R,A){return this.toArrayLike(Array,R,A)},o.prototype.toArrayLike=function(R,A,y){var w=this.byteLength(),I=y||Math.max(1,w);a(w<=I,"byte array longer than desired length"),a(I>0,"Requested array length <= 0"),this.strip();var M=A==="le",k=new R(I),P,_,q=this.clone();if(M){for(_=0;!q.isZero();_++)P=q.andln(255),q.iushrn(8),k[_]=P;for(;_<I;_++)k[_]=0}else{for(_=0;_<I-w;_++)k[_]=0;for(_=0;!q.isZero();_++)P=q.andln(255),q.iushrn(8),k[I-_-1]=P}return k},Math.clz32?o.prototype._countBits=function(R){return 32-Math.clz32(R)}:o.prototype._countBits=function(R){var A=R,y=0;return A>=4096&&(y+=13,A>>>=13),A>=64&&(y+=7,A>>>=7),A>=8&&(y+=4,A>>>=4),A>=2&&(y+=2,A>>>=2),y+A},o.prototype._zeroBits=function(R){if(R===0)return 26;var A=R,y=0;return A&8191||(y+=13,A>>>=13),A&127||(y+=7,A>>>=7),A&15||(y+=4,A>>>=4),A&3||(y+=2,A>>>=2),A&1||y++,y},o.prototype.bitLength=function(){var R=this.words[this.length-1],A=this._countBits(R);return(this.length-1)*26+A};function m(J){for(var R=new Array(J.bitLength()),A=0;A<R.length;A++){var y=A/26|0,w=A%26;R[A]=(J.words[y]&1<<w)>>>w}return R}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var R=0,A=0;A<this.length;A++){var y=this._zeroBits(this.words[A]);if(R+=y,y!==26)break}return R},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(R){return this.negative!==0?this.abs().inotn(R).iaddn(1):this.clone()},o.prototype.fromTwos=function(R){return this.testn(R-1)?this.notn(R).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(R){for(;this.length<R.length;)this.words[this.length++]=0;for(var A=0;A<R.length;A++)this.words[A]=this.words[A]|R.words[A];return this.strip()},o.prototype.ior=function(R){return a((this.negative|R.negative)===0),this.iuor(R)},o.prototype.or=function(R){return this.length>R.length?this.clone().ior(R):R.clone().ior(this)},o.prototype.uor=function(R){return this.length>R.length?this.clone().iuor(R):R.clone().iuor(this)},o.prototype.iuand=function(R){var A;this.length>R.length?A=R:A=this;for(var y=0;y<A.length;y++)this.words[y]=this.words[y]&R.words[y];return this.length=A.length,this.strip()},o.prototype.iand=function(R){return a((this.negative|R.negative)===0),this.iuand(R)},o.prototype.and=function(R){return this.length>R.length?this.clone().iand(R):R.clone().iand(this)},o.prototype.uand=function(R){return this.length>R.length?this.clone().iuand(R):R.clone().iuand(this)},o.prototype.iuxor=function(R){var A,y;this.length>R.length?(A=this,y=R):(A=R,y=this);for(var w=0;w<y.length;w++)this.words[w]=A.words[w]^y.words[w];if(this!==A)for(;w<A.length;w++)this.words[w]=A.words[w];return this.length=A.length,this.strip()},o.prototype.ixor=function(R){return a((this.negative|R.negative)===0),this.iuxor(R)},o.prototype.xor=function(R){return this.length>R.length?this.clone().ixor(R):R.clone().ixor(this)},o.prototype.uxor=function(R){return this.length>R.length?this.clone().iuxor(R):R.clone().iuxor(this)},o.prototype.inotn=function(R){a(typeof R=="number"&&R>=0);var A=Math.ceil(R/26)|0,y=R%26;this._expand(A),y>0&&A--;for(var w=0;w<A;w++)this.words[w]=~this.words[w]&67108863;return y>0&&(this.words[w]=~this.words[w]&67108863>>26-y),this.strip()},o.prototype.notn=function(R){return this.clone().inotn(R)},o.prototype.setn=function(R,A){a(typeof R=="number"&&R>=0);var y=R/26|0,w=R%26;return this._expand(y+1),A?this.words[y]=this.words[y]|1<<w:this.words[y]=this.words[y]&~(1<<w),this.strip()},o.prototype.iadd=function(R){var A;if(this.negative!==0&&R.negative===0)return this.negative=0,A=this.isub(R),this.negative^=1,this._normSign();if(this.negative===0&&R.negative!==0)return R.negative=0,A=this.isub(R),R.negative=1,A._normSign();var y,w;this.length>R.length?(y=this,w=R):(y=R,w=this);for(var I=0,M=0;M<w.length;M++)A=(y.words[M]|0)+(w.words[M]|0)+I,this.words[M]=A&67108863,I=A>>>26;for(;I!==0&&M<y.length;M++)A=(y.words[M]|0)+I,this.words[M]=A&67108863,I=A>>>26;if(this.length=y.length,I!==0)this.words[this.length]=I,this.length++;else if(y!==this)for(;M<y.length;M++)this.words[M]=y.words[M];return this},o.prototype.add=function(R){var A;return R.negative!==0&&this.negative===0?(R.negative=0,A=this.sub(R),R.negative^=1,A):R.negative===0&&this.negative!==0?(this.negative=0,A=R.sub(this),this.negative=1,A):this.length>R.length?this.clone().iadd(R):R.clone().iadd(this)},o.prototype.isub=function(R){if(R.negative!==0){R.negative=0;var A=this.iadd(R);return R.negative=1,A._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(R),this.negative=1,this._normSign();var y=this.cmp(R);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var w,I;y>0?(w=this,I=R):(w=R,I=this);for(var M=0,k=0;k<I.length;k++)A=(w.words[k]|0)-(I.words[k]|0)+M,M=A>>26,this.words[k]=A&67108863;for(;M!==0&&k<w.length;k++)A=(w.words[k]|0)+M,M=A>>26,this.words[k]=A&67108863;if(M===0&&k<w.length&&w!==this)for(;k<w.length;k++)this.words[k]=w.words[k];return this.length=Math.max(this.length,k),w!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(R){return this.clone().isub(R)};function v(J,R,A){A.negative=R.negative^J.negative;var y=J.length+R.length|0;A.length=y,y=y-1|0;var w=J.words[0]|0,I=R.words[0]|0,M=w*I,k=M&67108863,P=M/67108864|0;A.words[0]=k;for(var _=1;_<y;_++){for(var q=P>>>26,E=P&67108863,j=Math.min(_,R.length-1),ee=Math.max(0,_-J.length+1);ee<=j;ee++){var oe=_-ee|0;w=J.words[oe]|0,I=R.words[ee]|0,M=w*I+E,q+=M/67108864|0,E=M&67108863}A.words[_]=E|0,P=q|0}return P!==0?A.words[_]=P|0:A.length--,A.strip()}var g=function(R,A,y){var w=R.words,I=A.words,M=y.words,k=0,P,_,q,E=w[0]|0,j=E&8191,ee=E>>>13,oe=w[1]|0,Y=oe&8191,L=oe>>>13,z=w[2]|0,re=z&8191,D=z>>>13,G=w[3]|0,U=G&8191,Q=G>>>13,fe=w[4]|0,he=fe&8191,le=fe>>>13,pe=w[5]|0,be=pe&8191,se=pe>>>13,ge=w[6]|0,ye=ge&8191,$e=ge>>>13,Ne=w[7]|0,ve=Ne&8191,Be=Ne>>>13,De=w[8]|0,Se=De&8191,Oe=De>>>13,Ue=w[9]|0,V=Ue&8191,T=Ue>>>13,O=I[0]|0,X=O&8191,ne=O>>>13,ce=I[1]|0,ue=ce&8191,me=ce>>>13,Ee=I[2]|0,xe=Ee&8191,Ae=Ee>>>13,_e=I[3]|0,Me=_e&8191,Ge=_e>>>13,Ke=I[4]|0,Ie=Ke&8191,ze=Ke>>>13,Ve=I[5]|0,Pe=Ve&8191,We=Ve>>>13,Je=I[6]|0,Te=Je&8191,Ze=Je>>>13,Xe=I[7]|0,ke=Xe&8191,Ye=Xe>>>13,Qe=I[8]|0,qe=Qe&8191,et=Qe>>>13,tt=I[9]|0,Ce=tt&8191,rt=tt>>>13;y.negative=R.negative^A.negative,y.length=19,P=Math.imul(j,X),_=Math.imul(j,ne),_=_+Math.imul(ee,X)|0,q=Math.imul(ee,ne);var He=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(He>>>26)|0,He&=67108863,P=Math.imul(Y,X),_=Math.imul(Y,ne),_=_+Math.imul(L,X)|0,q=Math.imul(L,ne),P=P+Math.imul(j,ue)|0,_=_+Math.imul(j,me)|0,_=_+Math.imul(ee,ue)|0,q=q+Math.imul(ee,me)|0;var je=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(je>>>26)|0,je&=67108863,P=Math.imul(re,X),_=Math.imul(re,ne),_=_+Math.imul(D,X)|0,q=Math.imul(D,ne),P=P+Math.imul(Y,ue)|0,_=_+Math.imul(Y,me)|0,_=_+Math.imul(L,ue)|0,q=q+Math.imul(L,me)|0,P=P+Math.imul(j,xe)|0,_=_+Math.imul(j,Ae)|0,_=_+Math.imul(ee,xe)|0,q=q+Math.imul(ee,Ae)|0;var at=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(at>>>26)|0,at&=67108863,P=Math.imul(U,X),_=Math.imul(U,ne),_=_+Math.imul(Q,X)|0,q=Math.imul(Q,ne),P=P+Math.imul(re,ue)|0,_=_+Math.imul(re,me)|0,_=_+Math.imul(D,ue)|0,q=q+Math.imul(D,me)|0,P=P+Math.imul(Y,xe)|0,_=_+Math.imul(Y,Ae)|0,_=_+Math.imul(L,xe)|0,q=q+Math.imul(L,Ae)|0,P=P+Math.imul(j,Me)|0,_=_+Math.imul(j,Ge)|0,_=_+Math.imul(ee,Me)|0,q=q+Math.imul(ee,Ge)|0;var st=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(st>>>26)|0,st&=67108863,P=Math.imul(he,X),_=Math.imul(he,ne),_=_+Math.imul(le,X)|0,q=Math.imul(le,ne),P=P+Math.imul(U,ue)|0,_=_+Math.imul(U,me)|0,_=_+Math.imul(Q,ue)|0,q=q+Math.imul(Q,me)|0,P=P+Math.imul(re,xe)|0,_=_+Math.imul(re,Ae)|0,_=_+Math.imul(D,xe)|0,q=q+Math.imul(D,Ae)|0,P=P+Math.imul(Y,Me)|0,_=_+Math.imul(Y,Ge)|0,_=_+Math.imul(L,Me)|0,q=q+Math.imul(L,Ge)|0,P=P+Math.imul(j,Ie)|0,_=_+Math.imul(j,ze)|0,_=_+Math.imul(ee,Ie)|0,q=q+Math.imul(ee,ze)|0;var ot=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(ot>>>26)|0,ot&=67108863,P=Math.imul(be,X),_=Math.imul(be,ne),_=_+Math.imul(se,X)|0,q=Math.imul(se,ne),P=P+Math.imul(he,ue)|0,_=_+Math.imul(he,me)|0,_=_+Math.imul(le,ue)|0,q=q+Math.imul(le,me)|0,P=P+Math.imul(U,xe)|0,_=_+Math.imul(U,Ae)|0,_=_+Math.imul(Q,xe)|0,q=q+Math.imul(Q,Ae)|0,P=P+Math.imul(re,Me)|0,_=_+Math.imul(re,Ge)|0,_=_+Math.imul(D,Me)|0,q=q+Math.imul(D,Ge)|0,P=P+Math.imul(Y,Ie)|0,_=_+Math.imul(Y,ze)|0,_=_+Math.imul(L,Ie)|0,q=q+Math.imul(L,ze)|0,P=P+Math.imul(j,Pe)|0,_=_+Math.imul(j,We)|0,_=_+Math.imul(ee,Pe)|0,q=q+Math.imul(ee,We)|0;var ft=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(ft>>>26)|0,ft&=67108863,P=Math.imul(ye,X),_=Math.imul(ye,ne),_=_+Math.imul($e,X)|0,q=Math.imul($e,ne),P=P+Math.imul(be,ue)|0,_=_+Math.imul(be,me)|0,_=_+Math.imul(se,ue)|0,q=q+Math.imul(se,me)|0,P=P+Math.imul(he,xe)|0,_=_+Math.imul(he,Ae)|0,_=_+Math.imul(le,xe)|0,q=q+Math.imul(le,Ae)|0,P=P+Math.imul(U,Me)|0,_=_+Math.imul(U,Ge)|0,_=_+Math.imul(Q,Me)|0,q=q+Math.imul(Q,Ge)|0,P=P+Math.imul(re,Ie)|0,_=_+Math.imul(re,ze)|0,_=_+Math.imul(D,Ie)|0,q=q+Math.imul(D,ze)|0,P=P+Math.imul(Y,Pe)|0,_=_+Math.imul(Y,We)|0,_=_+Math.imul(L,Pe)|0,q=q+Math.imul(L,We)|0,P=P+Math.imul(j,Te)|0,_=_+Math.imul(j,Ze)|0,_=_+Math.imul(ee,Te)|0,q=q+Math.imul(ee,Ze)|0;var ct=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(ct>>>26)|0,ct&=67108863,P=Math.imul(ve,X),_=Math.imul(ve,ne),_=_+Math.imul(Be,X)|0,q=Math.imul(Be,ne),P=P+Math.imul(ye,ue)|0,_=_+Math.imul(ye,me)|0,_=_+Math.imul($e,ue)|0,q=q+Math.imul($e,me)|0,P=P+Math.imul(be,xe)|0,_=_+Math.imul(be,Ae)|0,_=_+Math.imul(se,xe)|0,q=q+Math.imul(se,Ae)|0,P=P+Math.imul(he,Me)|0,_=_+Math.imul(he,Ge)|0,_=_+Math.imul(le,Me)|0,q=q+Math.imul(le,Ge)|0,P=P+Math.imul(U,Ie)|0,_=_+Math.imul(U,ze)|0,_=_+Math.imul(Q,Ie)|0,q=q+Math.imul(Q,ze)|0,P=P+Math.imul(re,Pe)|0,_=_+Math.imul(re,We)|0,_=_+Math.imul(D,Pe)|0,q=q+Math.imul(D,We)|0,P=P+Math.imul(Y,Te)|0,_=_+Math.imul(Y,Ze)|0,_=_+Math.imul(L,Te)|0,q=q+Math.imul(L,Ze)|0,P=P+Math.imul(j,ke)|0,_=_+Math.imul(j,Ye)|0,_=_+Math.imul(ee,ke)|0,q=q+Math.imul(ee,Ye)|0;var dt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(dt>>>26)|0,dt&=67108863,P=Math.imul(Se,X),_=Math.imul(Se,ne),_=_+Math.imul(Oe,X)|0,q=Math.imul(Oe,ne),P=P+Math.imul(ve,ue)|0,_=_+Math.imul(ve,me)|0,_=_+Math.imul(Be,ue)|0,q=q+Math.imul(Be,me)|0,P=P+Math.imul(ye,xe)|0,_=_+Math.imul(ye,Ae)|0,_=_+Math.imul($e,xe)|0,q=q+Math.imul($e,Ae)|0,P=P+Math.imul(be,Me)|0,_=_+Math.imul(be,Ge)|0,_=_+Math.imul(se,Me)|0,q=q+Math.imul(se,Ge)|0,P=P+Math.imul(he,Ie)|0,_=_+Math.imul(he,ze)|0,_=_+Math.imul(le,Ie)|0,q=q+Math.imul(le,ze)|0,P=P+Math.imul(U,Pe)|0,_=_+Math.imul(U,We)|0,_=_+Math.imul(Q,Pe)|0,q=q+Math.imul(Q,We)|0,P=P+Math.imul(re,Te)|0,_=_+Math.imul(re,Ze)|0,_=_+Math.imul(D,Te)|0,q=q+Math.imul(D,Ze)|0,P=P+Math.imul(Y,ke)|0,_=_+Math.imul(Y,Ye)|0,_=_+Math.imul(L,ke)|0,q=q+Math.imul(L,Ye)|0,P=P+Math.imul(j,qe)|0,_=_+Math.imul(j,et)|0,_=_+Math.imul(ee,qe)|0,q=q+Math.imul(ee,et)|0;var ht=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(ht>>>26)|0,ht&=67108863,P=Math.imul(V,X),_=Math.imul(V,ne),_=_+Math.imul(T,X)|0,q=Math.imul(T,ne),P=P+Math.imul(Se,ue)|0,_=_+Math.imul(Se,me)|0,_=_+Math.imul(Oe,ue)|0,q=q+Math.imul(Oe,me)|0,P=P+Math.imul(ve,xe)|0,_=_+Math.imul(ve,Ae)|0,_=_+Math.imul(Be,xe)|0,q=q+Math.imul(Be,Ae)|0,P=P+Math.imul(ye,Me)|0,_=_+Math.imul(ye,Ge)|0,_=_+Math.imul($e,Me)|0,q=q+Math.imul($e,Ge)|0,P=P+Math.imul(be,Ie)|0,_=_+Math.imul(be,ze)|0,_=_+Math.imul(se,Ie)|0,q=q+Math.imul(se,ze)|0,P=P+Math.imul(he,Pe)|0,_=_+Math.imul(he,We)|0,_=_+Math.imul(le,Pe)|0,q=q+Math.imul(le,We)|0,P=P+Math.imul(U,Te)|0,_=_+Math.imul(U,Ze)|0,_=_+Math.imul(Q,Te)|0,q=q+Math.imul(Q,Ze)|0,P=P+Math.imul(re,ke)|0,_=_+Math.imul(re,Ye)|0,_=_+Math.imul(D,ke)|0,q=q+Math.imul(D,Ye)|0,P=P+Math.imul(Y,qe)|0,_=_+Math.imul(Y,et)|0,_=_+Math.imul(L,qe)|0,q=q+Math.imul(L,et)|0,P=P+Math.imul(j,Ce)|0,_=_+Math.imul(j,rt)|0,_=_+Math.imul(ee,Ce)|0,q=q+Math.imul(ee,rt)|0;var lt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(lt>>>26)|0,lt&=67108863,P=Math.imul(V,ue),_=Math.imul(V,me),_=_+Math.imul(T,ue)|0,q=Math.imul(T,me),P=P+Math.imul(Se,xe)|0,_=_+Math.imul(Se,Ae)|0,_=_+Math.imul(Oe,xe)|0,q=q+Math.imul(Oe,Ae)|0,P=P+Math.imul(ve,Me)|0,_=_+Math.imul(ve,Ge)|0,_=_+Math.imul(Be,Me)|0,q=q+Math.imul(Be,Ge)|0,P=P+Math.imul(ye,Ie)|0,_=_+Math.imul(ye,ze)|0,_=_+Math.imul($e,Ie)|0,q=q+Math.imul($e,ze)|0,P=P+Math.imul(be,Pe)|0,_=_+Math.imul(be,We)|0,_=_+Math.imul(se,Pe)|0,q=q+Math.imul(se,We)|0,P=P+Math.imul(he,Te)|0,_=_+Math.imul(he,Ze)|0,_=_+Math.imul(le,Te)|0,q=q+Math.imul(le,Ze)|0,P=P+Math.imul(U,ke)|0,_=_+Math.imul(U,Ye)|0,_=_+Math.imul(Q,ke)|0,q=q+Math.imul(Q,Ye)|0,P=P+Math.imul(re,qe)|0,_=_+Math.imul(re,et)|0,_=_+Math.imul(D,qe)|0,q=q+Math.imul(D,et)|0,P=P+Math.imul(Y,Ce)|0,_=_+Math.imul(Y,rt)|0,_=_+Math.imul(L,Ce)|0,q=q+Math.imul(L,rt)|0;var pt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(pt>>>26)|0,pt&=67108863,P=Math.imul(V,xe),_=Math.imul(V,Ae),_=_+Math.imul(T,xe)|0,q=Math.imul(T,Ae),P=P+Math.imul(Se,Me)|0,_=_+Math.imul(Se,Ge)|0,_=_+Math.imul(Oe,Me)|0,q=q+Math.imul(Oe,Ge)|0,P=P+Math.imul(ve,Ie)|0,_=_+Math.imul(ve,ze)|0,_=_+Math.imul(Be,Ie)|0,q=q+Math.imul(Be,ze)|0,P=P+Math.imul(ye,Pe)|0,_=_+Math.imul(ye,We)|0,_=_+Math.imul($e,Pe)|0,q=q+Math.imul($e,We)|0,P=P+Math.imul(be,Te)|0,_=_+Math.imul(be,Ze)|0,_=_+Math.imul(se,Te)|0,q=q+Math.imul(se,Ze)|0,P=P+Math.imul(he,ke)|0,_=_+Math.imul(he,Ye)|0,_=_+Math.imul(le,ke)|0,q=q+Math.imul(le,Ye)|0,P=P+Math.imul(U,qe)|0,_=_+Math.imul(U,et)|0,_=_+Math.imul(Q,qe)|0,q=q+Math.imul(Q,et)|0,P=P+Math.imul(re,Ce)|0,_=_+Math.imul(re,rt)|0,_=_+Math.imul(D,Ce)|0,q=q+Math.imul(D,rt)|0;var bt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(bt>>>26)|0,bt&=67108863,P=Math.imul(V,Me),_=Math.imul(V,Ge),_=_+Math.imul(T,Me)|0,q=Math.imul(T,Ge),P=P+Math.imul(Se,Ie)|0,_=_+Math.imul(Se,ze)|0,_=_+Math.imul(Oe,Ie)|0,q=q+Math.imul(Oe,ze)|0,P=P+Math.imul(ve,Pe)|0,_=_+Math.imul(ve,We)|0,_=_+Math.imul(Be,Pe)|0,q=q+Math.imul(Be,We)|0,P=P+Math.imul(ye,Te)|0,_=_+Math.imul(ye,Ze)|0,_=_+Math.imul($e,Te)|0,q=q+Math.imul($e,Ze)|0,P=P+Math.imul(be,ke)|0,_=_+Math.imul(be,Ye)|0,_=_+Math.imul(se,ke)|0,q=q+Math.imul(se,Ye)|0,P=P+Math.imul(he,qe)|0,_=_+Math.imul(he,et)|0,_=_+Math.imul(le,qe)|0,q=q+Math.imul(le,et)|0,P=P+Math.imul(U,Ce)|0,_=_+Math.imul(U,rt)|0,_=_+Math.imul(Q,Ce)|0,q=q+Math.imul(Q,rt)|0;var At=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(At>>>26)|0,At&=67108863,P=Math.imul(V,Ie),_=Math.imul(V,ze),_=_+Math.imul(T,Ie)|0,q=Math.imul(T,ze),P=P+Math.imul(Se,Pe)|0,_=_+Math.imul(Se,We)|0,_=_+Math.imul(Oe,Pe)|0,q=q+Math.imul(Oe,We)|0,P=P+Math.imul(ve,Te)|0,_=_+Math.imul(ve,Ze)|0,_=_+Math.imul(Be,Te)|0,q=q+Math.imul(Be,Ze)|0,P=P+Math.imul(ye,ke)|0,_=_+Math.imul(ye,Ye)|0,_=_+Math.imul($e,ke)|0,q=q+Math.imul($e,Ye)|0,P=P+Math.imul(be,qe)|0,_=_+Math.imul(be,et)|0,_=_+Math.imul(se,qe)|0,q=q+Math.imul(se,et)|0,P=P+Math.imul(he,Ce)|0,_=_+Math.imul(he,rt)|0,_=_+Math.imul(le,Ce)|0,q=q+Math.imul(le,rt)|0;var Bt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,P=Math.imul(V,Pe),_=Math.imul(V,We),_=_+Math.imul(T,Pe)|0,q=Math.imul(T,We),P=P+Math.imul(Se,Te)|0,_=_+Math.imul(Se,Ze)|0,_=_+Math.imul(Oe,Te)|0,q=q+Math.imul(Oe,Ze)|0,P=P+Math.imul(ve,ke)|0,_=_+Math.imul(ve,Ye)|0,_=_+Math.imul(Be,ke)|0,q=q+Math.imul(Be,Ye)|0,P=P+Math.imul(ye,qe)|0,_=_+Math.imul(ye,et)|0,_=_+Math.imul($e,qe)|0,q=q+Math.imul($e,et)|0,P=P+Math.imul(be,Ce)|0,_=_+Math.imul(be,rt)|0,_=_+Math.imul(se,Ce)|0,q=q+Math.imul(se,rt)|0;var Rt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,P=Math.imul(V,Te),_=Math.imul(V,Ze),_=_+Math.imul(T,Te)|0,q=Math.imul(T,Ze),P=P+Math.imul(Se,ke)|0,_=_+Math.imul(Se,Ye)|0,_=_+Math.imul(Oe,ke)|0,q=q+Math.imul(Oe,Ye)|0,P=P+Math.imul(ve,qe)|0,_=_+Math.imul(ve,et)|0,_=_+Math.imul(Be,qe)|0,q=q+Math.imul(Be,et)|0,P=P+Math.imul(ye,Ce)|0,_=_+Math.imul(ye,rt)|0,_=_+Math.imul($e,Ce)|0,q=q+Math.imul($e,rt)|0;var $t=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+($t>>>26)|0,$t&=67108863,P=Math.imul(V,ke),_=Math.imul(V,Ye),_=_+Math.imul(T,ke)|0,q=Math.imul(T,Ye),P=P+Math.imul(Se,qe)|0,_=_+Math.imul(Se,et)|0,_=_+Math.imul(Oe,qe)|0,q=q+Math.imul(Oe,et)|0,P=P+Math.imul(ve,Ce)|0,_=_+Math.imul(ve,rt)|0,_=_+Math.imul(Be,Ce)|0,q=q+Math.imul(Be,rt)|0;var Mt=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,P=Math.imul(V,qe),_=Math.imul(V,et),_=_+Math.imul(T,qe)|0,q=Math.imul(T,et),P=P+Math.imul(Se,Ce)|0,_=_+Math.imul(Se,rt)|0,_=_+Math.imul(Oe,Ce)|0,q=q+Math.imul(Oe,rt)|0;var It=(k+P|0)+((_&8191)<<13)|0;k=(q+(_>>>13)|0)+(It>>>26)|0,It&=67108863,P=Math.imul(V,Ce),_=Math.imul(V,rt),_=_+Math.imul(T,Ce)|0,q=Math.imul(T,rt);var Pt=(k+P|0)+((_&8191)<<13)|0;return k=(q+(_>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,M[0]=He,M[1]=je,M[2]=at,M[3]=st,M[4]=ot,M[5]=ft,M[6]=ct,M[7]=dt,M[8]=ht,M[9]=lt,M[10]=pt,M[11]=bt,M[12]=At,M[13]=Bt,M[14]=Rt,M[15]=$t,M[16]=Mt,M[17]=It,M[18]=Pt,k!==0&&(M[19]=k,y.length++),y};Math.imul||(g=v);function $(J,R,A){A.negative=R.negative^J.negative,A.length=J.length+R.length;for(var y=0,w=0,I=0;I<A.length-1;I++){var M=w;w=0;for(var k=y&67108863,P=Math.min(I,R.length-1),_=Math.max(0,I-J.length+1);_<=P;_++){var q=I-_,E=J.words[q]|0,j=R.words[_]|0,ee=E*j,oe=ee&67108863;M=M+(ee/67108864|0)|0,oe=oe+k|0,k=oe&67108863,M=M+(oe>>>26)|0,w+=M>>>26,M&=67108863}A.words[I]=k,y=M,M=w}return y!==0?A.words[I]=y:A.length--,A.strip()}function B(J,R,A){var y=new C;return y.mulp(J,R,A)}o.prototype.mulTo=function(R,A){var y,w=this.length+R.length;return this.length===10&&R.length===10?y=g(this,R,A):w<63?y=v(this,R,A):w<1024?y=$(this,R,A):y=B(this,R,A),y};function C(J,R){this.x=J,this.y=R}C.prototype.makeRBT=function(R){for(var A=new Array(R),y=o.prototype._countBits(R)-1,w=0;w<R;w++)A[w]=this.revBin(w,y,R);return A},C.prototype.revBin=function(R,A,y){if(R===0||R===y-1)return R;for(var w=0,I=0;I<A;I++)w|=(R&1)<<A-I-1,R>>=1;return w},C.prototype.permute=function(R,A,y,w,I,M){for(var k=0;k<M;k++)w[k]=A[R[k]],I[k]=y[R[k]]},C.prototype.transform=function(R,A,y,w,I,M){this.permute(M,R,A,y,w,I);for(var k=1;k<I;k<<=1)for(var P=k<<1,_=Math.cos(2*Math.PI/P),q=Math.sin(2*Math.PI/P),E=0;E<I;E+=P)for(var j=_,ee=q,oe=0;oe<k;oe++){var Y=y[E+oe],L=w[E+oe],z=y[E+oe+k],re=w[E+oe+k],D=j*z-ee*re;re=j*re+ee*z,z=D,y[E+oe]=Y+z,w[E+oe]=L+re,y[E+oe+k]=Y-z,w[E+oe+k]=L-re,oe!==P&&(D=_*j-q*ee,ee=_*ee+q*j,j=D)}},C.prototype.guessLen13b=function(R,A){var y=Math.max(A,R)|1,w=y&1,I=0;for(y=y/2|0;y;y=y>>>1)I++;return 1<<I+1+w},C.prototype.conjugate=function(R,A,y){if(!(y<=1))for(var w=0;w<y/2;w++){var I=R[w];R[w]=R[y-w-1],R[y-w-1]=I,I=A[w],A[w]=-A[y-w-1],A[y-w-1]=-I}},C.prototype.normalize13b=function(R,A){for(var y=0,w=0;w<A/2;w++){var I=Math.round(R[2*w+1]/A)*8192+Math.round(R[2*w]/A)+y;R[w]=I&67108863,I<67108864?y=0:y=I/67108864|0}return R},C.prototype.convert13b=function(R,A,y,w){for(var I=0,M=0;M<A;M++)I=I+(R[M]|0),y[2*M]=I&8191,I=I>>>13,y[2*M+1]=I&8191,I=I>>>13;for(M=2*A;M<w;++M)y[M]=0;a(I===0),a((I&-8192)===0)},C.prototype.stub=function(R){for(var A=new Array(R),y=0;y<R;y++)A[y]=0;return A},C.prototype.mulp=function(R,A,y){var w=2*this.guessLen13b(R.length,A.length),I=this.makeRBT(w),M=this.stub(w),k=new Array(w),P=new Array(w),_=new Array(w),q=new Array(w),E=new Array(w),j=new Array(w),ee=y.words;ee.length=w,this.convert13b(R.words,R.length,k,w),this.convert13b(A.words,A.length,q,w),this.transform(k,M,P,_,w,I),this.transform(q,M,E,j,w,I);for(var oe=0;oe<w;oe++){var Y=P[oe]*E[oe]-_[oe]*j[oe];_[oe]=P[oe]*j[oe]+_[oe]*E[oe],P[oe]=Y}return this.conjugate(P,_,w),this.transform(P,_,ee,M,w,I),this.conjugate(ee,M,w),this.normalize13b(ee,w),y.negative=R.negative^A.negative,y.length=R.length+A.length,y.strip()},o.prototype.mul=function(R){var A=new o(null);return A.words=new Array(this.length+R.length),this.mulTo(R,A)},o.prototype.mulf=function(R){var A=new o(null);return A.words=new Array(this.length+R.length),B(this,R,A)},o.prototype.imul=function(R){return this.clone().mulTo(R,this)},o.prototype.imuln=function(R){a(typeof R=="number"),a(R<67108864);for(var A=0,y=0;y<this.length;y++){var w=(this.words[y]|0)*R,I=(w&67108863)+(A&67108863);A>>=26,A+=w/67108864|0,A+=I>>>26,this.words[y]=I&67108863}return A!==0&&(this.words[y]=A,this.length++),this},o.prototype.muln=function(R){return this.clone().imuln(R)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(R){var A=m(R);if(A.length===0)return new o(1);for(var y=this,w=0;w<A.length&&A[w]===0;w++,y=y.sqr());if(++w<A.length)for(var I=y.sqr();w<A.length;w++,I=I.sqr())A[w]!==0&&(y=y.mul(I));return y},o.prototype.iushln=function(R){a(typeof R=="number"&&R>=0);var A=R%26,y=(R-A)/26,w=67108863>>>26-A<<26-A,I;if(A!==0){var M=0;for(I=0;I<this.length;I++){var k=this.words[I]&w,P=(this.words[I]|0)-k<<A;this.words[I]=P|M,M=k>>>26-A}M&&(this.words[I]=M,this.length++)}if(y!==0){for(I=this.length-1;I>=0;I--)this.words[I+y]=this.words[I];for(I=0;I<y;I++)this.words[I]=0;this.length+=y}return this.strip()},o.prototype.ishln=function(R){return a(this.negative===0),this.iushln(R)},o.prototype.iushrn=function(R,A,y){a(typeof R=="number"&&R>=0);var w;A?w=(A-A%26)/26:w=0;var I=R%26,M=Math.min((R-I)/26,this.length),k=67108863^67108863>>>I<<I,P=y;if(w-=M,w=Math.max(0,w),P){for(var _=0;_<M;_++)P.words[_]=this.words[_];P.length=M}if(M!==0)if(this.length>M)for(this.length-=M,_=0;_<this.length;_++)this.words[_]=this.words[_+M];else this.words[0]=0,this.length=1;var q=0;for(_=this.length-1;_>=0&&(q!==0||_>=w);_--){var E=this.words[_]|0;this.words[_]=q<<26-I|E>>>I,q=E&k}return P&&q!==0&&(P.words[P.length++]=q),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(R,A,y){return a(this.negative===0),this.iushrn(R,A,y)},o.prototype.shln=function(R){return this.clone().ishln(R)},o.prototype.ushln=function(R){return this.clone().iushln(R)},o.prototype.shrn=function(R){return this.clone().ishrn(R)},o.prototype.ushrn=function(R){return this.clone().iushrn(R)},o.prototype.testn=function(R){a(typeof R=="number"&&R>=0);var A=R%26,y=(R-A)/26,w=1<<A;if(this.length<=y)return!1;var I=this.words[y];return!!(I&w)},o.prototype.imaskn=function(R){a(typeof R=="number"&&R>=0);var A=R%26,y=(R-A)/26;if(a(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(A!==0&&y++,this.length=Math.min(y,this.length),A!==0){var w=67108863^67108863>>>A<<A;this.words[this.length-1]&=w}return this.strip()},o.prototype.maskn=function(R){return this.clone().imaskn(R)},o.prototype.iaddn=function(R){return a(typeof R=="number"),a(R<67108864),R<0?this.isubn(-R):this.negative!==0?this.length===1&&(this.words[0]|0)<R?(this.words[0]=R-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(R),this.negative=1,this):this._iaddn(R)},o.prototype._iaddn=function(R){this.words[0]+=R;for(var A=0;A<this.length&&this.words[A]>=67108864;A++)this.words[A]-=67108864,A===this.length-1?this.words[A+1]=1:this.words[A+1]++;return this.length=Math.max(this.length,A+1),this},o.prototype.isubn=function(R){if(a(typeof R=="number"),a(R<67108864),R<0)return this.iaddn(-R);if(this.negative!==0)return this.negative=0,this.iaddn(R),this.negative=1,this;if(this.words[0]-=R,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var A=0;A<this.length&&this.words[A]<0;A++)this.words[A]+=67108864,this.words[A+1]-=1;return this.strip()},o.prototype.addn=function(R){return this.clone().iaddn(R)},o.prototype.subn=function(R){return this.clone().isubn(R)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(R,A,y){var w=R.length+y,I;this._expand(w);var M,k=0;for(I=0;I<R.length;I++){M=(this.words[I+y]|0)+k;var P=(R.words[I]|0)*A;M-=P&67108863,k=(M>>26)-(P/67108864|0),this.words[I+y]=M&67108863}for(;I<this.length-y;I++)M=(this.words[I+y]|0)+k,k=M>>26,this.words[I+y]=M&67108863;if(k===0)return this.strip();for(a(k===-1),k=0,I=0;I<this.length;I++)M=-(this.words[I]|0)+k,k=M>>26,this.words[I]=M&67108863;return this.negative=1,this.strip()},o.prototype._wordDiv=function(R,A){var y=this.length-R.length,w=this.clone(),I=R,M=I.words[I.length-1]|0,k=this._countBits(M);y=26-k,y!==0&&(I=I.ushln(y),w.iushln(y),M=I.words[I.length-1]|0);var P=w.length-I.length,_;if(A!=="mod"){_=new o(null),_.length=P+1,_.words=new Array(_.length);for(var q=0;q<_.length;q++)_.words[q]=0}var E=w.clone()._ishlnsubmul(I,1,P);E.negative===0&&(w=E,_&&(_.words[P]=1));for(var j=P-1;j>=0;j--){var ee=(w.words[I.length+j]|0)*67108864+(w.words[I.length+j-1]|0);for(ee=Math.min(ee/M|0,67108863),w._ishlnsubmul(I,ee,j);w.negative!==0;)ee--,w.negative=0,w._ishlnsubmul(I,1,j),w.isZero()||(w.negative^=1);_&&(_.words[j]=ee)}return _&&_.strip(),w.strip(),A!=="div"&&y!==0&&w.iushrn(y),{div:_||null,mod:w}},o.prototype.divmod=function(R,A,y){if(a(!R.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var w,I,M;return this.negative!==0&&R.negative===0?(M=this.neg().divmod(R,A),A!=="mod"&&(w=M.div.neg()),A!=="div"&&(I=M.mod.neg(),y&&I.negative!==0&&I.iadd(R)),{div:w,mod:I}):this.negative===0&&R.negative!==0?(M=this.divmod(R.neg(),A),A!=="mod"&&(w=M.div.neg()),{div:w,mod:M.mod}):this.negative&R.negative?(M=this.neg().divmod(R.neg(),A),A!=="div"&&(I=M.mod.neg(),y&&I.negative!==0&&I.isub(R)),{div:M.div,mod:I}):R.length>this.length||this.cmp(R)<0?{div:new o(0),mod:this}:R.length===1?A==="div"?{div:this.divn(R.words[0]),mod:null}:A==="mod"?{div:null,mod:new o(this.modn(R.words[0]))}:{div:this.divn(R.words[0]),mod:new o(this.modn(R.words[0]))}:this._wordDiv(R,A)},o.prototype.div=function(R){return this.divmod(R,"div",!1).div},o.prototype.mod=function(R){return this.divmod(R,"mod",!1).mod},o.prototype.umod=function(R){return this.divmod(R,"mod",!0).mod},o.prototype.divRound=function(R){var A=this.divmod(R);if(A.mod.isZero())return A.div;var y=A.div.negative!==0?A.mod.isub(R):A.mod,w=R.ushrn(1),I=R.andln(1),M=y.cmp(w);return M<0||I===1&&M===0?A.div:A.div.negative!==0?A.div.isubn(1):A.div.iaddn(1)},o.prototype.modn=function(R){a(R<=67108863);for(var A=(1<<26)%R,y=0,w=this.length-1;w>=0;w--)y=(A*y+(this.words[w]|0))%R;return y},o.prototype.idivn=function(R){a(R<=67108863);for(var A=0,y=this.length-1;y>=0;y--){var w=(this.words[y]|0)+A*67108864;this.words[y]=w/R|0,A=w%R}return this.strip()},o.prototype.divn=function(R){return this.clone().idivn(R)},o.prototype.egcd=function(R){a(R.negative===0),a(!R.isZero());var A=this,y=R.clone();A.negative!==0?A=A.umod(R):A=A.clone();for(var w=new o(1),I=new o(0),M=new o(0),k=new o(1),P=0;A.isEven()&&y.isEven();)A.iushrn(1),y.iushrn(1),++P;for(var _=y.clone(),q=A.clone();!A.isZero();){for(var E=0,j=1;!(A.words[0]&j)&&E<26;++E,j<<=1);if(E>0)for(A.iushrn(E);E-- >0;)(w.isOdd()||I.isOdd())&&(w.iadd(_),I.isub(q)),w.iushrn(1),I.iushrn(1);for(var ee=0,oe=1;!(y.words[0]&oe)&&ee<26;++ee,oe<<=1);if(ee>0)for(y.iushrn(ee);ee-- >0;)(M.isOdd()||k.isOdd())&&(M.iadd(_),k.isub(q)),M.iushrn(1),k.iushrn(1);A.cmp(y)>=0?(A.isub(y),w.isub(M),I.isub(k)):(y.isub(A),M.isub(w),k.isub(I))}return{a:M,b:k,gcd:y.iushln(P)}},o.prototype._invmp=function(R){a(R.negative===0),a(!R.isZero());var A=this,y=R.clone();A.negative!==0?A=A.umod(R):A=A.clone();for(var w=new o(1),I=new o(0),M=y.clone();A.cmpn(1)>0&&y.cmpn(1)>0;){for(var k=0,P=1;!(A.words[0]&P)&&k<26;++k,P<<=1);if(k>0)for(A.iushrn(k);k-- >0;)w.isOdd()&&w.iadd(M),w.iushrn(1);for(var _=0,q=1;!(y.words[0]&q)&&_<26;++_,q<<=1);if(_>0)for(y.iushrn(_);_-- >0;)I.isOdd()&&I.iadd(M),I.iushrn(1);A.cmp(y)>=0?(A.isub(y),w.isub(I)):(y.isub(A),I.isub(w))}var E;return A.cmpn(1)===0?E=w:E=I,E.cmpn(0)<0&&E.iadd(R),E},o.prototype.gcd=function(R){if(this.isZero())return R.abs();if(R.isZero())return this.abs();var A=this.clone(),y=R.clone();A.negative=0,y.negative=0;for(var w=0;A.isEven()&&y.isEven();w++)A.iushrn(1),y.iushrn(1);do{for(;A.isEven();)A.iushrn(1);for(;y.isEven();)y.iushrn(1);var I=A.cmp(y);if(I<0){var M=A;A=y,y=M}else if(I===0||y.cmpn(1)===0)break;A.isub(y)}while(!0);return y.iushln(w)},o.prototype.invm=function(R){return this.egcd(R).a.umod(R)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(R){return this.words[0]&R},o.prototype.bincn=function(R){a(typeof R=="number");var A=R%26,y=(R-A)/26,w=1<<A;if(this.length<=y)return this._expand(y+1),this.words[y]|=w,this;for(var I=w,M=y;I!==0&&M<this.length;M++){var k=this.words[M]|0;k+=I,I=k>>>26,k&=67108863,this.words[M]=k}return I!==0&&(this.words[M]=I,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(R){var A=R<0;if(this.negative!==0&&!A)return-1;if(this.negative===0&&A)return 1;this.strip();var y;if(this.length>1)y=1;else{A&&(R=-R),a(R<=67108863,"Number is too big");var w=this.words[0]|0;y=w===R?0:w<R?-1:1}return this.negative!==0?-y|0:y},o.prototype.cmp=function(R){if(this.negative!==0&&R.negative===0)return-1;if(this.negative===0&&R.negative!==0)return 1;var A=this.ucmp(R);return this.negative!==0?-A|0:A},o.prototype.ucmp=function(R){if(this.length>R.length)return 1;if(this.length<R.length)return-1;for(var A=0,y=this.length-1;y>=0;y--){var w=this.words[y]|0,I=R.words[y]|0;if(w!==I){w<I?A=-1:w>I&&(A=1);break}}return A},o.prototype.gtn=function(R){return this.cmpn(R)===1},o.prototype.gt=function(R){return this.cmp(R)===1},o.prototype.gten=function(R){return this.cmpn(R)>=0},o.prototype.gte=function(R){return this.cmp(R)>=0},o.prototype.ltn=function(R){return this.cmpn(R)===-1},o.prototype.lt=function(R){return this.cmp(R)===-1},o.prototype.lten=function(R){return this.cmpn(R)<=0},o.prototype.lte=function(R){return this.cmp(R)<=0},o.prototype.eqn=function(R){return this.cmpn(R)===0},o.prototype.eq=function(R){return this.cmp(R)===0},o.red=function(R){return new ae(R)},o.prototype.toRed=function(R){return a(!this.red,"Already a number in reduction context"),a(this.negative===0,"red works only with positives"),R.convertTo(this)._forceRed(R)},o.prototype.fromRed=function(){return a(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(R){return this.red=R,this},o.prototype.forceRed=function(R){return a(!this.red,"Already a number in reduction context"),this._forceRed(R)},o.prototype.redAdd=function(R){return a(this.red,"redAdd works only with red numbers"),this.red.add(this,R)},o.prototype.redIAdd=function(R){return a(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,R)},o.prototype.redSub=function(R){return a(this.red,"redSub works only with red numbers"),this.red.sub(this,R)},o.prototype.redISub=function(R){return a(this.red,"redISub works only with red numbers"),this.red.isub(this,R)},o.prototype.redShl=function(R){return a(this.red,"redShl works only with red numbers"),this.red.shl(this,R)},o.prototype.redMul=function(R){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,R),this.red.mul(this,R)},o.prototype.redIMul=function(R){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,R),this.red.imul(this,R)},o.prototype.redSqr=function(){return a(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return a(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return a(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return a(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return a(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(R){return a(this.red&&!R.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,R)};var F={k256:null,p224:null,p192:null,p25519:null};function H(J,R){this.name=J,this.p=new o(R,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var R=new o(null);return R.words=new Array(Math.ceil(this.n/13)),R},H.prototype.ireduce=function(R){var A=R,y;do this.split(A,this.tmp),A=this.imulK(A),A=A.iadd(this.tmp),y=A.bitLength();while(y>this.n);var w=y<this.n?-1:A.ucmp(this.p);return w===0?(A.words[0]=0,A.length=1):w>0?A.isub(this.p):A.strip!==void 0?A.strip():A._strip(),A},H.prototype.split=function(R,A){R.iushrn(this.n,0,A)},H.prototype.imulK=function(R){return R.imul(this.k)};function W(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}c(W,H),W.prototype.split=function(R,A){for(var y=4194303,w=Math.min(R.length,9),I=0;I<w;I++)A.words[I]=R.words[I];if(A.length=w,R.length<=9){R.words[0]=0,R.length=1;return}var M=R.words[9];for(A.words[A.length++]=M&y,I=10;I<R.length;I++){var k=R.words[I]|0;R.words[I-10]=(k&y)<<4|M>>>22,M=k}M>>>=22,R.words[I-10]=M,M===0&&R.length>10?R.length-=10:R.length-=9},W.prototype.imulK=function(R){R.words[R.length]=0,R.words[R.length+1]=0,R.length+=2;for(var A=0,y=0;y<R.length;y++){var w=R.words[y]|0;A+=w*977,R.words[y]=A&67108863,A=w*64+(A/67108864|0)}return R.words[R.length-1]===0&&(R.length--,R.words[R.length-1]===0&&R.length--),R};function Z(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}c(Z,H);function ie(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}c(ie,H);function te(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}c(te,H),te.prototype.imulK=function(R){for(var A=0,y=0;y<R.length;y++){var w=(R.words[y]|0)*19+A,I=w&67108863;w>>>=26,R.words[y]=I,A=w}return A!==0&&(R.words[R.length++]=A),R},o._prime=function(R){if(F[R])return F[R];var A;if(R==="k256")A=new W;else if(R==="p224")A=new Z;else if(R==="p192")A=new ie;else if(R==="p25519")A=new te;else throw new Error("Unknown prime "+R);return F[R]=A,A};function ae(J){if(typeof J=="string"){var R=o._prime(J);this.m=R.p,this.prime=R}else a(J.gtn(1),"modulus must be greater than 1"),this.m=J,this.prime=null}ae.prototype._verify1=function(R){a(R.negative===0,"red works only with positives"),a(R.red,"red works only with red numbers")},ae.prototype._verify2=function(R,A){a((R.negative|A.negative)===0,"red works only with positives"),a(R.red&&R.red===A.red,"red works only with red numbers")},ae.prototype.imod=function(R){return this.prime?this.prime.ireduce(R)._forceRed(this):R.umod(this.m)._forceRed(this)},ae.prototype.neg=function(R){return R.isZero()?R.clone():this.m.sub(R)._forceRed(this)},ae.prototype.add=function(R,A){this._verify2(R,A);var y=R.add(A);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},ae.prototype.iadd=function(R,A){this._verify2(R,A);var y=R.iadd(A);return y.cmp(this.m)>=0&&y.isub(this.m),y},ae.prototype.sub=function(R,A){this._verify2(R,A);var y=R.sub(A);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},ae.prototype.isub=function(R,A){this._verify2(R,A);var y=R.isub(A);return y.cmpn(0)<0&&y.iadd(this.m),y},ae.prototype.shl=function(R,A){return this._verify1(R),this.imod(R.ushln(A))},ae.prototype.imul=function(R,A){return this._verify2(R,A),this.imod(R.imul(A))},ae.prototype.mul=function(R,A){return this._verify2(R,A),this.imod(R.mul(A))},ae.prototype.isqr=function(R){return this.imul(R,R.clone())},ae.prototype.sqr=function(R){return this.mul(R,R)},ae.prototype.sqrt=function(R){if(R.isZero())return R.clone();var A=this.m.andln(3);if(a(A%2===1),A===3){var y=this.m.add(new o(1)).iushrn(2);return this.pow(R,y)}for(var w=this.m.subn(1),I=0;!w.isZero()&&w.andln(1)===0;)I++,w.iushrn(1);a(!w.isZero());var M=new o(1).toRed(this),k=M.redNeg(),P=this.m.subn(1).iushrn(1),_=this.m.bitLength();for(_=new o(2*_*_).toRed(this);this.pow(_,P).cmp(k)!==0;)_.redIAdd(k);for(var q=this.pow(_,w),E=this.pow(R,w.addn(1).iushrn(1)),j=this.pow(R,w),ee=I;j.cmp(M)!==0;){for(var oe=j,Y=0;oe.cmp(M)!==0;Y++)oe=oe.redSqr();a(Y<ee);var L=this.pow(q,new o(1).iushln(ee-Y-1));E=E.redMul(L),q=L.redSqr(),j=j.redMul(q),ee=Y}return E},ae.prototype.invm=function(R){var A=R._invmp(this.m);return A.negative!==0?(A.negative=0,this.imod(A).redNeg()):this.imod(A)},ae.prototype.pow=function(R,A){if(A.isZero())return new o(1).toRed(this);if(A.cmpn(1)===0)return R.clone();var y=4,w=new Array(1<<y);w[0]=new o(1).toRed(this),w[1]=R;for(var I=2;I<w.length;I++)w[I]=this.mul(w[I-1],R);var M=w[0],k=0,P=0,_=A.bitLength()%26;for(_===0&&(_=26),I=A.length-1;I>=0;I--){for(var q=A.words[I],E=_-1;E>=0;E--){var j=q>>E&1;if(M!==w[0]&&(M=this.sqr(M)),j===0&&k===0){P=0;continue}k<<=1,k|=j,P++,!(P!==y&&(I!==0||E!==0))&&(M=this.mul(M,w[k]),P=0,k=0)}_=26}return M},ae.prototype.convertTo=function(R){var A=R.umod(this.m);return A===R?A.clone():A},ae.prototype.convertFrom=function(R){var A=R.clone();return A.red=null,A},o.mont=function(R){return new de(R)};function de(J){ae.call(this,J),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)}c(de,ae),de.prototype.convertTo=function(R){return this.imod(R.ushln(this.shift))},de.prototype.convertFrom=function(R){var A=this.imod(R.mul(this.rinv));return A.red=null,A},de.prototype.imul=function(R,A){if(R.isZero()||A.isZero())return R.words[0]=0,R.length=1,R;var y=R.imul(A),w=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=y.isub(w).iushrn(this.shift),M=I;return I.cmp(this.m)>=0?M=I.isub(this.m):I.cmpn(0)<0&&(M=I.iadd(this.m)),M._forceRed(this)},de.prototype.mul=function(R,A){if(R.isZero()||A.isZero())return new o(0)._forceRed(this);var y=R.mul(A),w=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=y.isub(w).iushrn(this.shift),M=I;return I.cmp(this.m)>=0?M=I.isub(this.m):I.cmpn(0)<0&&(M=I.iadd(this.m)),M._forceRed(this)},de.prototype.invm=function(R){var A=this.imod(R._invmp(this.m).mul(this.r2));return A._forceRed(this)}})(t,commonjsGlobal)})(bn$1);var bnExports=bn$1.exports,minimalisticAssert=assert$e;function assert$e(t,e){if(!t)throw new Error(e||"Assertion failed")}assert$e.equal=function(e,n,a){if(e!=n)throw new Error(a||"Assertion failed: "+e+" != "+n)};var utils$n={};(function(t){var e=t;function n(o,u){if(Array.isArray(o))return o.slice();if(!o)return[];var h=[];if(typeof o!="string"){for(var l=0;l<o.length;l++)h[l]=o[l]|0;return h}if(u==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var l=0;l<o.length;l+=2)h.push(parseInt(o[l]+o[l+1],16))}else for(var l=0;l<o.length;l++){var b=o.charCodeAt(l),d=b>>8,p=b&255;d?h.push(d,p):h.push(p)}return h}e.toArray=n;function a(o){return o.length===1?"0"+o:o}e.zero2=a;function c(o){for(var u="",h=0;h<o.length;h++)u+=a(o[h].toString(16));return u}e.toHex=c,e.encode=function(u,h){return h==="hex"?c(u):u}})(utils$n);(function(t){var e=t,n=bnExports,a=minimalisticAssert,c=utils$n;e.assert=a,e.toArray=c.toArray,e.zero2=c.zero2,e.toHex=c.toHex,e.encode=c.encode;function o(d,p,x){var m=new Array(Math.max(d.bitLength(),x)+1),v;for(v=0;v<m.length;v+=1)m[v]=0;var g=1<<p+1,$=d.clone();for(v=0;v<m.length;v++){var B,C=$.andln(g-1);$.isOdd()?(C>(g>>1)-1?B=(g>>1)-C:B=C,$.isubn(B)):B=0,m[v]=B,$.iushrn(1)}return m}e.getNAF=o;function u(d,p){var x=[[],[]];d=d.clone(),p=p.clone();for(var m=0,v=0,g;d.cmpn(-m)>0||p.cmpn(-v)>0;){var $=d.andln(3)+m&3,B=p.andln(3)+v&3;$===3&&($=-1),B===3&&(B=-1);var C;$&1?(g=d.andln(7)+m&7,(g===3||g===5)&&B===2?C=-$:C=$):C=0,x[0].push(C);var F;B&1?(g=p.andln(7)+v&7,(g===3||g===5)&&$===2?F=-B:F=B):F=0,x[1].push(F),2*m===C+1&&(m=1-m),2*v===F+1&&(v=1-v),d.iushrn(1),p.iushrn(1)}return x}e.getJSF=u;function h(d,p,x){var m="_"+p;d.prototype[p]=function(){return this[m]!==void 0?this[m]:this[m]=x.call(this)}}e.cachedProperty=h;function l(d){return typeof d=="string"?e.toArray(d,"hex"):d}e.parseBytes=l;function b(d){return new n(d,"hex","le")}e.intFromLE=b})(utils$o);var brorand={exports:{}},cryptoBrowserify={},browser$b={exports:{}},safeBuffer$1={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var hasRequiredSafeBuffer$1;function requireSafeBuffer$1(){return hasRequiredSafeBuffer$1||(hasRequiredSafeBuffer$1=1,function(t,e){var n=require$$1$2,a=n.Buffer;function c(u,h){for(var l in u)h[l]=u[l]}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?t.exports=n:(c(n,e),e.Buffer=o);function o(u,h,l){return a(u,h,l)}o.prototype=Object.create(a.prototype),c(a,o),o.from=function(u,h,l){if(typeof u=="number")throw new TypeError("Argument must not be a number");return a(u,h,l)},o.alloc=function(u,h,l){if(typeof u!="number")throw new TypeError("Argument must be a number");var b=a(u);return h!==void 0?typeof l=="string"?b.fill(h,l):b.fill(h):b.fill(0),b},o.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return a(u)},o.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(u)}}(safeBuffer$1,safeBuffer$1.exports)),safeBuffer$1.exports}var hasRequiredBrowser$b;function requireBrowser$b(){if(hasRequiredBrowser$b)return browser$b.exports;hasRequiredBrowser$b=1;var t=65536,e=4294967295;function n(){throw new Error(`Secure random number generation is not supported by this browser.
10
- Use Chrome, Firefox or Internet Explorer 11`)}var a=requireSafeBuffer$1().Buffer,c=commonjsGlobal.crypto||commonjsGlobal.msCrypto;c&&c.getRandomValues?browser$b.exports=o:browser$b.exports=n;function o(u,h){if(u>e)throw new RangeError("requested too many random bytes");var l=a.allocUnsafe(u);if(u>0)if(u>t)for(var b=0;b<u;b+=t)c.getRandomValues(l.slice(b,b+t));else c.getRandomValues(l);return typeof h=="function"?process$1.nextTick(function(){h(null,l)}):l}return browser$b.exports}var inherits_browser={exports:{}};typeof Object.create=="function"?inherits_browser.exports=function(e,n){n&&(e.super_=n,e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:inherits_browser.exports=function(e,n){if(n){e.super_=n;var a=function(){};a.prototype=n.prototype,e.prototype=new a,e.prototype.constructor=e}};var inherits_browserExports=inherits_browser.exports,readableBrowser$1={exports:{}},events={exports:{}},hasRequiredEvents;function requireEvents(){if(hasRequiredEvents)return events.exports;hasRequiredEvents=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(W,Z,ie){return Function.prototype.apply.call(W,Z,ie)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(W){return Object.getOwnPropertyNames(W).concat(Object.getOwnPropertySymbols(W))}:n=function(W){return Object.getOwnPropertyNames(W)};function a(H){console&&console.warn&&console.warn(H)}var c=Number.isNaN||function(W){return W!==W};function o(){o.init.call(this)}events.exports=o,events.exports.once=B,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var u=10;function h(H){if(typeof H!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof H)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(H){if(typeof H!="number"||H<0||c(H))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+H+".");u=H}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(W){if(typeof W!="number"||W<0||c(W))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+W+".");return this._maxListeners=W,this};function l(H){return H._maxListeners===void 0?o.defaultMaxListeners:H._maxListeners}o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(W){for(var Z=[],ie=1;ie<arguments.length;ie++)Z.push(arguments[ie]);var te=W==="error",ae=this._events;if(ae!==void 0)te=te&&ae.error===void 0;else if(!te)return!1;if(te){var de;if(Z.length>0&&(de=Z[0]),de instanceof Error)throw de;var J=new Error("Unhandled error."+(de?" ("+de.message+")":""));throw J.context=de,J}var R=ae[W];if(R===void 0)return!1;if(typeof R=="function")e(R,this,Z);else for(var A=R.length,y=v(R,A),ie=0;ie<A;++ie)e(y[ie],this,Z);return!0};function b(H,W,Z,ie){var te,ae,de;if(h(Z),ae=H._events,ae===void 0?(ae=H._events=Object.create(null),H._eventsCount=0):(ae.newListener!==void 0&&(H.emit("newListener",W,Z.listener?Z.listener:Z),ae=H._events),de=ae[W]),de===void 0)de=ae[W]=Z,++H._eventsCount;else if(typeof de=="function"?de=ae[W]=ie?[Z,de]:[de,Z]:ie?de.unshift(Z):de.push(Z),te=l(H),te>0&&de.length>te&&!de.warned){de.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+de.length+" "+String(W)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=H,J.type=W,J.count=de.length,a(J)}return H}o.prototype.addListener=function(W,Z){return b(this,W,Z,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(W,Z){return b(this,W,Z,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(H,W,Z){var ie={fired:!1,wrapFn:void 0,target:H,type:W,listener:Z},te=d.bind(ie);return te.listener=Z,ie.wrapFn=te,te}o.prototype.once=function(W,Z){return h(Z),this.on(W,p(this,W,Z)),this},o.prototype.prependOnceListener=function(W,Z){return h(Z),this.prependListener(W,p(this,W,Z)),this},o.prototype.removeListener=function(W,Z){var ie,te,ae,de,J;if(h(Z),te=this._events,te===void 0)return this;if(ie=te[W],ie===void 0)return this;if(ie===Z||ie.listener===Z)--this._eventsCount===0?this._events=Object.create(null):(delete te[W],te.removeListener&&this.emit("removeListener",W,ie.listener||Z));else if(typeof ie!="function"){for(ae=-1,de=ie.length-1;de>=0;de--)if(ie[de]===Z||ie[de].listener===Z){J=ie[de].listener,ae=de;break}if(ae<0)return this;ae===0?ie.shift():g(ie,ae),ie.length===1&&(te[W]=ie[0]),te.removeListener!==void 0&&this.emit("removeListener",W,J||Z)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(W){var Z,ie,te;if(ie=this._events,ie===void 0)return this;if(ie.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):ie[W]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete ie[W]),this;if(arguments.length===0){var ae=Object.keys(ie),de;for(te=0;te<ae.length;++te)de=ae[te],de!=="removeListener"&&this.removeAllListeners(de);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(Z=ie[W],typeof Z=="function")this.removeListener(W,Z);else if(Z!==void 0)for(te=Z.length-1;te>=0;te--)this.removeListener(W,Z[te]);return this};function x(H,W,Z){var ie=H._events;if(ie===void 0)return[];var te=ie[W];return te===void 0?[]:typeof te=="function"?Z?[te.listener||te]:[te]:Z?$(te):v(te,te.length)}o.prototype.listeners=function(W){return x(this,W,!0)},o.prototype.rawListeners=function(W){return x(this,W,!1)},o.listenerCount=function(H,W){return typeof H.listenerCount=="function"?H.listenerCount(W):m.call(H,W)},o.prototype.listenerCount=m;function m(H){var W=this._events;if(W!==void 0){var Z=W[H];if(typeof Z=="function")return 1;if(Z!==void 0)return Z.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function v(H,W){for(var Z=new Array(W),ie=0;ie<W;++ie)Z[ie]=H[ie];return Z}function g(H,W){for(;W+1<H.length;W++)H[W]=H[W+1];H.pop()}function $(H){for(var W=new Array(H.length),Z=0;Z<W.length;++Z)W[Z]=H[Z].listener||H[Z];return W}function B(H,W){return new Promise(function(Z,ie){function te(de){H.removeListener(W,ae),ie(de)}function ae(){typeof H.removeListener=="function"&&H.removeListener("error",te),Z([].slice.call(arguments))}F(H,W,ae,{once:!0}),W!=="error"&&C(H,te,{once:!0})})}function C(H,W,Z){typeof H.on=="function"&&F(H,"error",W,Z)}function F(H,W,Z,ie){if(typeof H.on=="function")ie.once?H.once(W,Z):H.on(W,Z);else if(typeof H.addEventListener=="function")H.addEventListener(W,function te(ae){ie.once&&H.removeEventListener(W,te),Z(ae)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof H)}return events.exports}var streamBrowser$1,hasRequiredStreamBrowser$1;function requireStreamBrowser$1(){return hasRequiredStreamBrowser$1||(hasRequiredStreamBrowser$1=1,streamBrowser$1=requireEvents().EventEmitter),streamBrowser$1}var util$1={},types={},shams$1,hasRequiredShams$1;function requireShams$1(){return hasRequiredShams$1||(hasRequiredShams$1=1,shams$1=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),a=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(a)!=="[object Symbol]")return!1;var c=42;e[n]=c;for(n in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var u=Object.getOwnPropertyDescriptor(e,n);if(u.value!==c||u.enumerable!==!0)return!1}return!0}),shams$1}var shams,hasRequiredShams;function requireShams(){if(hasRequiredShams)return shams;hasRequiredShams=1;var t=requireShams$1();return shams=function(){return t()&&!!Symbol.toStringTag},shams}var esErrors,hasRequiredEsErrors;function requireEsErrors(){return hasRequiredEsErrors||(hasRequiredEsErrors=1,esErrors=Error),esErrors}var _eval,hasRequired_eval;function require_eval(){return hasRequired_eval||(hasRequired_eval=1,_eval=EvalError),_eval}var range,hasRequiredRange;function requireRange(){return hasRequiredRange||(hasRequiredRange=1,range=RangeError),range}var ref,hasRequiredRef;function requireRef(){return hasRequiredRef||(hasRequiredRef=1,ref=ReferenceError),ref}var syntax,hasRequiredSyntax;function requireSyntax(){return hasRequiredSyntax||(hasRequiredSyntax=1,syntax=SyntaxError),syntax}var type,hasRequiredType;function requireType(){return hasRequiredType||(hasRequiredType=1,type=TypeError),type}var uri,hasRequiredUri;function requireUri(){return hasRequiredUri||(hasRequiredUri=1,uri=URIError),uri}var hasSymbols,hasRequiredHasSymbols;function requireHasSymbols(){if(hasRequiredHasSymbols)return hasSymbols;hasRequiredHasSymbols=1;var t=typeof Symbol<"u"&&Symbol,e=requireShams$1();return hasSymbols=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},hasSymbols}var hasProto,hasRequiredHasProto;function requireHasProto(){if(hasRequiredHasProto)return hasProto;hasRequiredHasProto=1;var t={__proto__:null,foo:{}},e=Object;return hasProto=function(){return{__proto__:t}.foo===t.foo&&!(t instanceof e)},hasProto}var implementation,hasRequiredImplementation;function requireImplementation(){if(hasRequiredImplementation)return implementation;hasRequiredImplementation=1;var t="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,n=Math.max,a="[object Function]",c=function(l,b){for(var d=[],p=0;p<l.length;p+=1)d[p]=l[p];for(var x=0;x<b.length;x+=1)d[x+l.length]=b[x];return d},o=function(l,b){for(var d=[],p=b,x=0;p<l.length;p+=1,x+=1)d[x]=l[p];return d},u=function(h,l){for(var b="",d=0;d<h.length;d+=1)b+=h[d],d+1<h.length&&(b+=l);return b};return implementation=function(l){var b=this;if(typeof b!="function"||e.apply(b)!==a)throw new TypeError(t+b);for(var d=o(arguments,1),p,x=function(){if(this instanceof p){var B=b.apply(this,c(d,arguments));return Object(B)===B?B:this}return b.apply(l,c(d,arguments))},m=n(0,b.length-d.length),v=[],g=0;g<m;g++)v[g]="$"+g;if(p=Function("binder","return function ("+u(v,",")+"){ return binder.apply(this,arguments); }")(x),b.prototype){var $=function(){};$.prototype=b.prototype,p.prototype=new $,$.prototype=null}return p},implementation}var functionBind,hasRequiredFunctionBind;function requireFunctionBind(){if(hasRequiredFunctionBind)return functionBind;hasRequiredFunctionBind=1;var t=requireImplementation();return functionBind=Function.prototype.bind||t,functionBind}var hasown,hasRequiredHasown;function requireHasown(){if(hasRequiredHasown)return hasown;hasRequiredHasown=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,n=requireFunctionBind();return hasown=n.call(t,e),hasown}var getIntrinsic,hasRequiredGetIntrinsic;function requireGetIntrinsic(){if(hasRequiredGetIntrinsic)return getIntrinsic;hasRequiredGetIntrinsic=1;var t,e=requireEsErrors(),n=require_eval(),a=requireRange(),c=requireRef(),o=requireSyntax(),u=requireType(),h=requireUri(),l=Function,b=function(M){try{return l('"use strict"; return ('+M+").constructor;")()}catch{}},d=Object.getOwnPropertyDescriptor;if(d)try{d({},"")}catch{d=null}var p=function(){throw new u},x=d?function(){try{return arguments.callee,p}catch{try{return d(arguments,"callee").get}catch{return p}}}():p,m=requireHasSymbols()(),v=requireHasProto()(),g=Object.getPrototypeOf||(v?function(M){return M.__proto__}:null),$={},B=typeof Uint8Array>"u"||!g?t:g(Uint8Array),C={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":m&&g?g([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":$,"%AsyncGenerator%":$,"%AsyncGeneratorFunction%":$,"%AsyncIteratorPrototype%":$,"%Atomics%":typeof Atomics>"u"?t:Atomics,"%BigInt%":typeof BigInt>"u"?t:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?t:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":e,"%eval%":eval,"%EvalError%":n,"%Float32Array%":typeof Float32Array>"u"?t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?t:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":$,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":m&&g?g(g([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!m||!g?t:g(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?t:Promise,"%Proxy%":typeof Proxy>"u"?t:Proxy,"%RangeError%":a,"%ReferenceError%":c,"%Reflect%":typeof Reflect>"u"?t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!m||!g?t:g(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":m&&g?g(""[Symbol.iterator]()):t,"%Symbol%":m?Symbol:t,"%SyntaxError%":o,"%ThrowTypeError%":x,"%TypedArray%":B,"%TypeError%":u,"%Uint8Array%":typeof Uint8Array>"u"?t:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?t:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?t:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?t:Uint32Array,"%URIError%":h,"%WeakMap%":typeof WeakMap>"u"?t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?t:WeakSet};if(g)try{null.error}catch(M){var F=g(g(M));C["%Error.prototype%"]=F}var H=function M(k){var P;if(k==="%AsyncFunction%")P=b("async function () {}");else if(k==="%GeneratorFunction%")P=b("function* () {}");else if(k==="%AsyncGeneratorFunction%")P=b("async function* () {}");else if(k==="%AsyncGenerator%"){var _=M("%AsyncGeneratorFunction%");_&&(P=_.prototype)}else if(k==="%AsyncIteratorPrototype%"){var q=M("%AsyncGenerator%");q&&g&&(P=g(q.prototype))}return C[k]=P,P},W={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Z=requireFunctionBind(),ie=requireHasown(),te=Z.call(Function.call,Array.prototype.concat),ae=Z.call(Function.apply,Array.prototype.splice),de=Z.call(Function.call,String.prototype.replace),J=Z.call(Function.call,String.prototype.slice),R=Z.call(Function.call,RegExp.prototype.exec),A=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,y=/\\(\\)?/g,w=function(k){var P=J(k,0,1),_=J(k,-1);if(P==="%"&&_!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(_==="%"&&P!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var q=[];return de(k,A,function(E,j,ee,oe){q[q.length]=ee?de(oe,y,"$1"):j||E}),q},I=function(k,P){var _=k,q;if(ie(W,_)&&(q=W[_],_="%"+q[0]+"%"),ie(C,_)){var E=C[_];if(E===$&&(E=H(_)),typeof E>"u"&&!P)throw new u("intrinsic "+k+" exists, but is not available. Please file an issue!");return{alias:q,name:_,value:E}}throw new o("intrinsic "+k+" does not exist!")};return getIntrinsic=function(k,P){if(typeof k!="string"||k.length===0)throw new u("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof P!="boolean")throw new u('"allowMissing" argument must be a boolean');if(R(/^%?[^%]*%?$/,k)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var _=w(k),q=_.length>0?_[0]:"",E=I("%"+q+"%",P),j=E.name,ee=E.value,oe=!1,Y=E.alias;Y&&(q=Y[0],ae(_,te([0,1],Y)));for(var L=1,z=!0;L<_.length;L+=1){var re=_[L],D=J(re,0,1),G=J(re,-1);if((D==='"'||D==="'"||D==="`"||G==='"'||G==="'"||G==="`")&&D!==G)throw new o("property names with quotes must have matching quotes");if((re==="constructor"||!z)&&(oe=!0),q+="."+re,j="%"+q+"%",ie(C,j))ee=C[j];else if(ee!=null){if(!(re in ee)){if(!P)throw new u("base intrinsic for "+k+" exists, but the property is not available.");return}if(d&&L+1>=_.length){var U=d(ee,re);z=!!U,z&&"get"in U&&!("originalValue"in U.get)?ee=U.get:ee=ee[re]}else z=ie(ee,re),ee=ee[re];z&&!oe&&(C[j]=ee)}}return ee},getIntrinsic}var callBind={exports:{}},esDefineProperty,hasRequiredEsDefineProperty;function requireEsDefineProperty(){if(hasRequiredEsDefineProperty)return esDefineProperty;hasRequiredEsDefineProperty=1;var t=requireGetIntrinsic(),e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return esDefineProperty=e,esDefineProperty}var gopd,hasRequiredGopd;function requireGopd(){if(hasRequiredGopd)return gopd;hasRequiredGopd=1;var t=requireGetIntrinsic(),e=t("%Object.getOwnPropertyDescriptor%",!0);if(e)try{e([],"length")}catch{e=null}return gopd=e,gopd}var defineDataProperty,hasRequiredDefineDataProperty;function requireDefineDataProperty(){if(hasRequiredDefineDataProperty)return defineDataProperty;hasRequiredDefineDataProperty=1;var t=requireEsDefineProperty(),e=requireSyntax(),n=requireType(),a=requireGopd();return defineDataProperty=function(o,u,h){if(!o||typeof o!="object"&&typeof o!="function")throw new n("`obj` must be an object or a function`");if(typeof u!="string"&&typeof u!="symbol")throw new n("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new n("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new n("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new n("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new n("`loose`, if provided, must be a boolean");var l=arguments.length>3?arguments[3]:null,b=arguments.length>4?arguments[4]:null,d=arguments.length>5?arguments[5]:null,p=arguments.length>6?arguments[6]:!1,x=!!a&&a(o,u);if(t)t(o,u,{configurable:d===null&&x?x.configurable:!d,enumerable:l===null&&x?x.enumerable:!l,value:h,writable:b===null&&x?x.writable:!b});else if(p||!l&&!b&&!d)o[u]=h;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},defineDataProperty}var hasPropertyDescriptors_1,hasRequiredHasPropertyDescriptors;function requireHasPropertyDescriptors(){if(hasRequiredHasPropertyDescriptors)return hasPropertyDescriptors_1;hasRequiredHasPropertyDescriptors=1;var t=requireEsDefineProperty(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},hasPropertyDescriptors_1=e,hasPropertyDescriptors_1}var setFunctionLength,hasRequiredSetFunctionLength;function requireSetFunctionLength(){if(hasRequiredSetFunctionLength)return setFunctionLength;hasRequiredSetFunctionLength=1;var t=requireGetIntrinsic(),e=requireDefineDataProperty(),n=requireHasPropertyDescriptors()(),a=requireGopd(),c=requireType(),o=t("%Math.floor%");return setFunctionLength=function(h,l){if(typeof h!="function")throw new c("`fn` is not a function");if(typeof l!="number"||l<0||l>4294967295||o(l)!==l)throw new c("`length` must be a positive 32-bit integer");var b=arguments.length>2&&!!arguments[2],d=!0,p=!0;if("length"in h&&a){var x=a(h,"length");x&&!x.configurable&&(d=!1),x&&!x.writable&&(p=!1)}return(d||p||!b)&&(n?e(h,"length",l,!0,!0):e(h,"length",l)),h},setFunctionLength}var hasRequiredCallBind;function requireCallBind(){return hasRequiredCallBind||(hasRequiredCallBind=1,function(t){var e=requireFunctionBind(),n=requireGetIntrinsic(),a=requireSetFunctionLength(),c=requireType(),o=n("%Function.prototype.apply%"),u=n("%Function.prototype.call%"),h=n("%Reflect.apply%",!0)||e.call(u,o),l=requireEsDefineProperty(),b=n("%Math.max%");t.exports=function(x){if(typeof x!="function")throw new c("a function is required");var m=h(e,u,arguments);return a(m,1+b(0,x.length-(arguments.length-1)),!0)};var d=function(){return h(e,o,arguments)};l?l(t.exports,"apply",{value:d}):t.exports.apply=d}(callBind)),callBind.exports}var callBound,hasRequiredCallBound;function requireCallBound(){if(hasRequiredCallBound)return callBound;hasRequiredCallBound=1;var t=requireGetIntrinsic(),e=requireCallBind(),n=e(t("String.prototype.indexOf"));return callBound=function(c,o){var u=t(c,!!o);return typeof u=="function"&&n(c,".prototype.")>-1?e(u):u},callBound}var isArguments,hasRequiredIsArguments;function requireIsArguments(){if(hasRequiredIsArguments)return isArguments;hasRequiredIsArguments=1;var t=requireShams()(),e=requireCallBound(),n=e("Object.prototype.toString"),a=function(h){return t&&h&&typeof h=="object"&&Symbol.toStringTag in h?!1:n(h)==="[object Arguments]"},c=function(h){return a(h)?!0:h!==null&&typeof h=="object"&&typeof h.length=="number"&&h.length>=0&&n(h)!=="[object Array]"&&n(h.callee)==="[object Function]"},o=function(){return a(arguments)}();return a.isLegacyArguments=c,isArguments=o?a:c,isArguments}var isGeneratorFunction,hasRequiredIsGeneratorFunction;function requireIsGeneratorFunction(){if(hasRequiredIsGeneratorFunction)return isGeneratorFunction;hasRequiredIsGeneratorFunction=1;var t=Object.prototype.toString,e=Function.prototype.toString,n=/^\s*(?:function)?\*/,a=requireShams()(),c=Object.getPrototypeOf,o=function(){if(!a)return!1;try{return Function("return function*() {}")()}catch{}},u;return isGeneratorFunction=function(l){if(typeof l!="function")return!1;if(n.test(e.call(l)))return!0;if(!a){var b=t.call(l);return b==="[object GeneratorFunction]"}if(!c)return!1;if(typeof u>"u"){var d=o();u=d?c(d):!1}return c(l)===u},isGeneratorFunction}var isCallable,hasRequiredIsCallable;function requireIsCallable(){if(hasRequiredIsCallable)return isCallable;hasRequiredIsCallable=1;var t=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,n,a;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{n=Object.defineProperty({},"length",{get:function(){throw a}}),a={},e(function(){throw 42},null,n)}catch(C){C!==a&&(e=null)}else e=null;var c=/^\s*class\b/,o=function(F){try{var H=t.call(F);return c.test(H)}catch{return!1}},u=function(F){try{return o(F)?!1:(t.call(F),!0)}catch{return!1}},h=Object.prototype.toString,l="[object Object]",b="[object Function]",d="[object GeneratorFunction]",p="[object HTMLAllCollection]",x="[object HTML document.all class]",m="[object HTMLCollection]",v=typeof Symbol=="function"&&!!Symbol.toStringTag,g=!(0 in[,]),$=function(){return!1};if(typeof document=="object"){var B=document.all;h.call(B)===h.call(document.all)&&($=function(F){if((g||!F)&&(typeof F>"u"||typeof F=="object"))try{var H=h.call(F);return(H===p||H===x||H===m||H===l)&&F("")==null}catch{}return!1})}return isCallable=e?function(F){if($(F))return!0;if(!F||typeof F!="function"&&typeof F!="object")return!1;try{e(F,null,n)}catch(H){if(H!==a)return!1}return!o(F)&&u(F)}:function(F){if($(F))return!0;if(!F||typeof F!="function"&&typeof F!="object")return!1;if(v)return u(F);if(o(F))return!1;var H=h.call(F);return H!==b&&H!==d&&!/^\[object HTML/.test(H)?!1:u(F)},isCallable}var forEach_1,hasRequiredForEach;function requireForEach(){if(hasRequiredForEach)return forEach_1;hasRequiredForEach=1;var t=requireIsCallable(),e=Object.prototype.toString,n=Object.prototype.hasOwnProperty,a=function(l,b,d){for(var p=0,x=l.length;p<x;p++)n.call(l,p)&&(d==null?b(l[p],p,l):b.call(d,l[p],p,l))},c=function(l,b,d){for(var p=0,x=l.length;p<x;p++)d==null?b(l.charAt(p),p,l):b.call(d,l.charAt(p),p,l)},o=function(l,b,d){for(var p in l)n.call(l,p)&&(d==null?b(l[p],p,l):b.call(d,l[p],p,l))},u=function(l,b,d){if(!t(b))throw new TypeError("iterator must be a function");var p;arguments.length>=3&&(p=d),e.call(l)==="[object Array]"?a(l,b,p):typeof l=="string"?c(l,b,p):o(l,b,p)};return forEach_1=u,forEach_1}var possibleTypedArrayNames,hasRequiredPossibleTypedArrayNames;function requirePossibleTypedArrayNames(){return hasRequiredPossibleTypedArrayNames||(hasRequiredPossibleTypedArrayNames=1,possibleTypedArrayNames=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),possibleTypedArrayNames}var availableTypedArrays,hasRequiredAvailableTypedArrays;function requireAvailableTypedArrays(){if(hasRequiredAvailableTypedArrays)return availableTypedArrays;hasRequiredAvailableTypedArrays=1;var t=requirePossibleTypedArrayNames(),e=typeof globalThis>"u"?commonjsGlobal:globalThis;return availableTypedArrays=function(){for(var a=[],c=0;c<t.length;c++)typeof e[t[c]]=="function"&&(a[a.length]=t[c]);return a},availableTypedArrays}var whichTypedArray,hasRequiredWhichTypedArray;function requireWhichTypedArray(){if(hasRequiredWhichTypedArray)return whichTypedArray;hasRequiredWhichTypedArray=1;var t=requireForEach(),e=requireAvailableTypedArrays(),n=requireCallBind(),a=requireCallBound(),c=requireGopd(),o=a("Object.prototype.toString"),u=requireShams()(),h=typeof globalThis>"u"?commonjsGlobal:globalThis,l=e(),b=a("String.prototype.slice"),d=Object.getPrototypeOf,p=a("Array.prototype.indexOf",!0)||function($,B){for(var C=0;C<$.length;C+=1)if($[C]===B)return C;return-1},x={__proto__:null};u&&c&&d?t(l,function(g){var $=new h[g];if(Symbol.toStringTag in $){var B=d($),C=c(B,Symbol.toStringTag);if(!C){var F=d(B);C=c(F,Symbol.toStringTag)}x["$"+g]=n(C.get)}}):t(l,function(g){var $=new h[g],B=$.slice||$.set;B&&(x["$"+g]=n(B))});var m=function($){var B=!1;return t(x,function(C,F){if(!B)try{"$"+C($)===F&&(B=b(F,1))}catch{}}),B},v=function($){var B=!1;return t(x,function(C,F){if(!B)try{C($),B=b(F,1)}catch{}}),B};return whichTypedArray=function($){if(!$||typeof $!="object")return!1;if(!u){var B=b(o($),8,-1);return p(l,B)>-1?B:B!=="Object"?!1:v($)}return c?m($):null},whichTypedArray}var isTypedArray$1,hasRequiredIsTypedArray;function requireIsTypedArray(){if(hasRequiredIsTypedArray)return isTypedArray$1;hasRequiredIsTypedArray=1;var t=requireWhichTypedArray();return isTypedArray$1=function(n){return!!t(n)},isTypedArray$1}var hasRequiredTypes;function requireTypes(){return hasRequiredTypes||(hasRequiredTypes=1,function(t){var e=requireIsArguments(),n=requireIsGeneratorFunction(),a=requireWhichTypedArray(),c=requireIsTypedArray();function o(se){return se.call.bind(se)}var u=typeof BigInt<"u",h=typeof Symbol<"u",l=o(Object.prototype.toString),b=o(Number.prototype.valueOf),d=o(String.prototype.valueOf),p=o(Boolean.prototype.valueOf);if(u)var x=o(BigInt.prototype.valueOf);if(h)var m=o(Symbol.prototype.valueOf);function v(se,ge){if(typeof se!="object")return!1;try{return ge(se),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=n,t.isTypedArray=c;function g(se){return typeof Promise<"u"&&se instanceof Promise||se!==null&&typeof se=="object"&&typeof se.then=="function"&&typeof se.catch=="function"}t.isPromise=g;function $(se){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(se):c(se)||j(se)}t.isArrayBufferView=$;function B(se){return a(se)==="Uint8Array"}t.isUint8Array=B;function C(se){return a(se)==="Uint8ClampedArray"}t.isUint8ClampedArray=C;function F(se){return a(se)==="Uint16Array"}t.isUint16Array=F;function H(se){return a(se)==="Uint32Array"}t.isUint32Array=H;function W(se){return a(se)==="Int8Array"}t.isInt8Array=W;function Z(se){return a(se)==="Int16Array"}t.isInt16Array=Z;function ie(se){return a(se)==="Int32Array"}t.isInt32Array=ie;function te(se){return a(se)==="Float32Array"}t.isFloat32Array=te;function ae(se){return a(se)==="Float64Array"}t.isFloat64Array=ae;function de(se){return a(se)==="BigInt64Array"}t.isBigInt64Array=de;function J(se){return a(se)==="BigUint64Array"}t.isBigUint64Array=J;function R(se){return l(se)==="[object Map]"}R.working=typeof Map<"u"&&R(new Map);function A(se){return typeof Map>"u"?!1:R.working?R(se):se instanceof Map}t.isMap=A;function y(se){return l(se)==="[object Set]"}y.working=typeof Set<"u"&&y(new Set);function w(se){return typeof Set>"u"?!1:y.working?y(se):se instanceof Set}t.isSet=w;function I(se){return l(se)==="[object WeakMap]"}I.working=typeof WeakMap<"u"&&I(new WeakMap);function M(se){return typeof WeakMap>"u"?!1:I.working?I(se):se instanceof WeakMap}t.isWeakMap=M;function k(se){return l(se)==="[object WeakSet]"}k.working=typeof WeakSet<"u"&&k(new WeakSet);function P(se){return k(se)}t.isWeakSet=P;function _(se){return l(se)==="[object ArrayBuffer]"}_.working=typeof ArrayBuffer<"u"&&_(new ArrayBuffer);function q(se){return typeof ArrayBuffer>"u"?!1:_.working?_(se):se instanceof ArrayBuffer}t.isArrayBuffer=q;function E(se){return l(se)==="[object DataView]"}E.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&E(new DataView(new ArrayBuffer(1),0,1));function j(se){return typeof DataView>"u"?!1:E.working?E(se):se instanceof DataView}t.isDataView=j;var ee=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function oe(se){return l(se)==="[object SharedArrayBuffer]"}function Y(se){return typeof ee>"u"?!1:(typeof oe.working>"u"&&(oe.working=oe(new ee)),oe.working?oe(se):se instanceof ee)}t.isSharedArrayBuffer=Y;function L(se){return l(se)==="[object AsyncFunction]"}t.isAsyncFunction=L;function z(se){return l(se)==="[object Map Iterator]"}t.isMapIterator=z;function re(se){return l(se)==="[object Set Iterator]"}t.isSetIterator=re;function D(se){return l(se)==="[object Generator]"}t.isGeneratorObject=D;function G(se){return l(se)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=G;function U(se){return v(se,b)}t.isNumberObject=U;function Q(se){return v(se,d)}t.isStringObject=Q;function fe(se){return v(se,p)}t.isBooleanObject=fe;function he(se){return u&&v(se,x)}t.isBigIntObject=he;function le(se){return h&&v(se,m)}t.isSymbolObject=le;function pe(se){return U(se)||Q(se)||fe(se)||he(se)||le(se)}t.isBoxedPrimitive=pe;function be(se){return typeof Uint8Array<"u"&&(q(se)||Y(se))}t.isAnyArrayBuffer=be,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(se){Object.defineProperty(t,se,{enumerable:!1,value:function(){throw new Error(se+" is not supported in userland")}})})}(types)),types}var isBufferBrowser,hasRequiredIsBufferBrowser;function requireIsBufferBrowser(){return hasRequiredIsBufferBrowser||(hasRequiredIsBufferBrowser=1,isBufferBrowser=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),isBufferBrowser}var hasRequiredUtil$1;function requireUtil$1(){return hasRequiredUtil$1||(hasRequiredUtil$1=1,function(t){var e=Object.getOwnPropertyDescriptors||function(j){for(var ee=Object.keys(j),oe={},Y=0;Y<ee.length;Y++)oe[ee[Y]]=Object.getOwnPropertyDescriptor(j,ee[Y]);return oe},n=/%[sdj%]/g;t.format=function(E){if(!W(E)){for(var j=[],ee=0;ee<arguments.length;ee++)j.push(u(arguments[ee]));return j.join(" ")}for(var ee=1,oe=arguments,Y=oe.length,L=String(E).replace(n,function(re){if(re==="%%")return"%";if(ee>=Y)return re;switch(re){case"%s":return String(oe[ee++]);case"%d":return Number(oe[ee++]);case"%j":try{return JSON.stringify(oe[ee++])}catch{return"[Circular]"}default:return re}}),z=oe[ee];ee<Y;z=oe[++ee])C(z)||!ae(z)?L+=" "+z:L+=" "+u(z);return L},t.deprecate=function(E,j){if(typeof process$1<"u"&&process$1.noDeprecation===!0)return E;if(typeof process$1>"u")return function(){return t.deprecate(E,j).apply(this,arguments)};var ee=!1;function oe(){if(!ee){if(process$1.throwDeprecation)throw new Error(j);process$1.traceDeprecation?console.trace(j):console.error(j),ee=!0}return E.apply(this,arguments)}return oe};var a={},c=/^$/;if(process$1.env.NODE_DEBUG){var o=process$1.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),c=new RegExp("^"+o+"$","i")}t.debuglog=function(E){if(E=E.toUpperCase(),!a[E])if(c.test(E)){var j=process$1.pid;a[E]=function(){var ee=t.format.apply(t,arguments);console.error("%s %d: %s",E,j,ee)}}else a[E]=function(){};return a[E]};function u(E,j){var ee={seen:[],stylize:l};return arguments.length>=3&&(ee.depth=arguments[2]),arguments.length>=4&&(ee.colors=arguments[3]),B(j)?ee.showHidden=j:j&&t._extend(ee,j),ie(ee.showHidden)&&(ee.showHidden=!1),ie(ee.depth)&&(ee.depth=2),ie(ee.colors)&&(ee.colors=!1),ie(ee.customInspect)&&(ee.customInspect=!0),ee.colors&&(ee.stylize=h),d(ee,E,ee.depth)}t.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function h(E,j){var ee=u.styles[j];return ee?"\x1B["+u.colors[ee][0]+"m"+E+"\x1B["+u.colors[ee][1]+"m":E}function l(E,j){return E}function b(E){var j={};return E.forEach(function(ee,oe){j[ee]=!0}),j}function d(E,j,ee){if(E.customInspect&&j&&R(j.inspect)&&j.inspect!==t.inspect&&!(j.constructor&&j.constructor.prototype===j)){var oe=j.inspect(ee,E);return W(oe)||(oe=d(E,oe,ee)),oe}var Y=p(E,j);if(Y)return Y;var L=Object.keys(j),z=b(L);if(E.showHidden&&(L=Object.getOwnPropertyNames(j)),J(j)&&(L.indexOf("message")>=0||L.indexOf("description")>=0))return x(j);if(L.length===0){if(R(j)){var re=j.name?": "+j.name:"";return E.stylize("[Function"+re+"]","special")}if(te(j))return E.stylize(RegExp.prototype.toString.call(j),"regexp");if(de(j))return E.stylize(Date.prototype.toString.call(j),"date");if(J(j))return x(j)}var D="",G=!1,U=["{","}"];if($(j)&&(G=!0,U=["[","]"]),R(j)){var Q=j.name?": "+j.name:"";D=" [Function"+Q+"]"}if(te(j)&&(D=" "+RegExp.prototype.toString.call(j)),de(j)&&(D=" "+Date.prototype.toUTCString.call(j)),J(j)&&(D=" "+x(j)),L.length===0&&(!G||j.length==0))return U[0]+D+U[1];if(ee<0)return te(j)?E.stylize(RegExp.prototype.toString.call(j),"regexp"):E.stylize("[Object]","special");E.seen.push(j);var fe;return G?fe=m(E,j,ee,z,L):fe=L.map(function(he){return v(E,j,ee,z,he,G)}),E.seen.pop(),g(fe,D,U)}function p(E,j){if(ie(j))return E.stylize("undefined","undefined");if(W(j)){var ee="'"+JSON.stringify(j).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return E.stylize(ee,"string")}if(H(j))return E.stylize(""+j,"number");if(B(j))return E.stylize(""+j,"boolean");if(C(j))return E.stylize("null","null")}function x(E){return"["+Error.prototype.toString.call(E)+"]"}function m(E,j,ee,oe,Y){for(var L=[],z=0,re=j.length;z<re;++z)k(j,String(z))?L.push(v(E,j,ee,oe,String(z),!0)):L.push("");return Y.forEach(function(D){D.match(/^\d+$/)||L.push(v(E,j,ee,oe,D,!0))}),L}function v(E,j,ee,oe,Y,L){var z,re,D;if(D=Object.getOwnPropertyDescriptor(j,Y)||{value:j[Y]},D.get?D.set?re=E.stylize("[Getter/Setter]","special"):re=E.stylize("[Getter]","special"):D.set&&(re=E.stylize("[Setter]","special")),k(oe,Y)||(z="["+Y+"]"),re||(E.seen.indexOf(D.value)<0?(C(ee)?re=d(E,D.value,null):re=d(E,D.value,ee-1),re.indexOf(`
11
- `)>-1&&(L?re=re.split(`
12
- `).map(function(G){return" "+G}).join(`
13
- `).slice(2):re=`
14
- `+re.split(`
15
- `).map(function(G){return" "+G}).join(`
16
- `))):re=E.stylize("[Circular]","special")),ie(z)){if(L&&Y.match(/^\d+$/))return re;z=JSON.stringify(""+Y),z.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(z=z.slice(1,-1),z=E.stylize(z,"name")):(z=z.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),z=E.stylize(z,"string"))}return z+": "+re}function g(E,j,ee){var oe=E.reduce(function(Y,L){return L.indexOf(`
17
- `)>=0,Y+L.replace(/\u001b\[\d\d?m/g,"").length+1},0);return oe>60?ee[0]+(j===""?"":j+`
18
- `)+" "+E.join(`,
19
- `)+" "+ee[1]:ee[0]+j+" "+E.join(", ")+" "+ee[1]}t.types=requireTypes();function $(E){return Array.isArray(E)}t.isArray=$;function B(E){return typeof E=="boolean"}t.isBoolean=B;function C(E){return E===null}t.isNull=C;function F(E){return E==null}t.isNullOrUndefined=F;function H(E){return typeof E=="number"}t.isNumber=H;function W(E){return typeof E=="string"}t.isString=W;function Z(E){return typeof E=="symbol"}t.isSymbol=Z;function ie(E){return E===void 0}t.isUndefined=ie;function te(E){return ae(E)&&y(E)==="[object RegExp]"}t.isRegExp=te,t.types.isRegExp=te;function ae(E){return typeof E=="object"&&E!==null}t.isObject=ae;function de(E){return ae(E)&&y(E)==="[object Date]"}t.isDate=de,t.types.isDate=de;function J(E){return ae(E)&&(y(E)==="[object Error]"||E instanceof Error)}t.isError=J,t.types.isNativeError=J;function R(E){return typeof E=="function"}t.isFunction=R;function A(E){return E===null||typeof E=="boolean"||typeof E=="number"||typeof E=="string"||typeof E=="symbol"||typeof E>"u"}t.isPrimitive=A,t.isBuffer=requireIsBufferBrowser();function y(E){return Object.prototype.toString.call(E)}function w(E){return E<10?"0"+E.toString(10):E.toString(10)}var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(){var E=new Date,j=[w(E.getHours()),w(E.getMinutes()),w(E.getSeconds())].join(":");return[E.getDate(),I[E.getMonth()],j].join(" ")}t.log=function(){console.log("%s - %s",M(),t.format.apply(t,arguments))},t.inherits=inherits_browserExports,t._extend=function(E,j){if(!j||!ae(j))return E;for(var ee=Object.keys(j),oe=ee.length;oe--;)E[ee[oe]]=j[ee[oe]];return E};function k(E,j){return Object.prototype.hasOwnProperty.call(E,j)}var P=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');if(P&&j[P]){var ee=j[P];if(typeof ee!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(ee,P,{value:ee,enumerable:!1,writable:!1,configurable:!0}),ee}function ee(){for(var oe,Y,L=new Promise(function(D,G){oe=D,Y=G}),z=[],re=0;re<arguments.length;re++)z.push(arguments[re]);z.push(function(D,G){D?Y(D):oe(G)});try{j.apply(this,z)}catch(D){Y(D)}return L}return Object.setPrototypeOf(ee,Object.getPrototypeOf(j)),P&&Object.defineProperty(ee,P,{value:ee,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(ee,e(j))},t.promisify.custom=P;function _(E,j){if(!E){var ee=new Error("Promise was rejected with a falsy value");ee.reason=E,E=ee}return j(E)}function q(E){if(typeof E!="function")throw new TypeError('The "original" argument must be of type Function');function j(){for(var ee=[],oe=0;oe<arguments.length;oe++)ee.push(arguments[oe]);var Y=ee.pop();if(typeof Y!="function")throw new TypeError("The last argument must be of type Function");var L=this,z=function(){return Y.apply(L,arguments)};E.apply(this,ee).then(function(re){process$1.nextTick(z.bind(null,null,re))},function(re){process$1.nextTick(_.bind(null,re,z))})}return Object.setPrototypeOf(j,Object.getPrototypeOf(E)),Object.defineProperties(j,e(E)),j}t.callbackify=q}(util$1)),util$1}var buffer_list,hasRequiredBuffer_list;function requireBuffer_list(){if(hasRequiredBuffer_list)return buffer_list;hasRequiredBuffer_list=1;function t(v,g){var $=Object.keys(v);if(Object.getOwnPropertySymbols){var B=Object.getOwnPropertySymbols(v);g&&(B=B.filter(function(C){return Object.getOwnPropertyDescriptor(v,C).enumerable})),$.push.apply($,B)}return $}function e(v){for(var g=1;g<arguments.length;g++){var $=arguments[g]!=null?arguments[g]:{};g%2?t(Object($),!0).forEach(function(B){n(v,B,$[B])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors($)):t(Object($)).forEach(function(B){Object.defineProperty(v,B,Object.getOwnPropertyDescriptor($,B))})}return v}function n(v,g,$){return g=u(g),g in v?Object.defineProperty(v,g,{value:$,enumerable:!0,configurable:!0,writable:!0}):v[g]=$,v}function a(v,g){if(!(v instanceof g))throw new TypeError("Cannot call a class as a function")}function c(v,g){for(var $=0;$<g.length;$++){var B=g[$];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(v,u(B.key),B)}}function o(v,g,$){return g&&c(v.prototype,g),Object.defineProperty(v,"prototype",{writable:!1}),v}function u(v){var g=h(v,"string");return typeof g=="symbol"?g:String(g)}function h(v,g){if(typeof v!="object"||v===null)return v;var $=v[Symbol.toPrimitive];if($!==void 0){var B=$.call(v,g||"default");if(typeof B!="object")return B;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(v)}var l=require$$1$2,b=l.Buffer,d=requireUtil$1(),p=d.inspect,x=p&&p.custom||"inspect";function m(v,g,$){b.prototype.copy.call(v,g,$)}return buffer_list=function(){function v(){a(this,v),this.head=null,this.tail=null,this.length=0}return o(v,[{key:"push",value:function($){var B={data:$,next:null};this.length>0?this.tail.next=B:this.head=B,this.tail=B,++this.length}},{key:"unshift",value:function($){var B={data:$,next:this.head};this.length===0&&(this.tail=B),this.head=B,++this.length}},{key:"shift",value:function(){if(this.length!==0){var $=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,$}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function($){if(this.length===0)return"";for(var B=this.head,C=""+B.data;B=B.next;)C+=$+B.data;return C}},{key:"concat",value:function($){if(this.length===0)return b.alloc(0);for(var B=b.allocUnsafe($>>>0),C=this.head,F=0;C;)m(C.data,B,F),F+=C.data.length,C=C.next;return B}},{key:"consume",value:function($,B){var C;return $<this.head.data.length?(C=this.head.data.slice(0,$),this.head.data=this.head.data.slice($)):$===this.head.data.length?C=this.shift():C=B?this._getString($):this._getBuffer($),C}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function($){var B=this.head,C=1,F=B.data;for($-=F.length;B=B.next;){var H=B.data,W=$>H.length?H.length:$;if(W===H.length?F+=H:F+=H.slice(0,$),$-=W,$===0){W===H.length?(++C,B.next?this.head=B.next:this.head=this.tail=null):(this.head=B,B.data=H.slice(W));break}++C}return this.length-=C,F}},{key:"_getBuffer",value:function($){var B=b.allocUnsafe($),C=this.head,F=1;for(C.data.copy(B),$-=C.data.length;C=C.next;){var H=C.data,W=$>H.length?H.length:$;if(H.copy(B,B.length-$,0,W),$-=W,$===0){W===H.length?(++F,C.next?this.head=C.next:this.head=this.tail=null):(this.head=C,C.data=H.slice(W));break}++F}return this.length-=F,B}},{key:x,value:function($,B){return p(this,e(e({},B),{},{depth:0,customInspect:!1}))}}]),v}(),buffer_list}var destroy_1$1,hasRequiredDestroy$1;function requireDestroy$1(){if(hasRequiredDestroy$1)return destroy_1$1;hasRequiredDestroy$1=1;function t(u,h){var l=this,b=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return b||d?(h?h(u):u&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process$1.nextTick(c,this,u)):process$1.nextTick(c,this,u)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(u||null,function(p){!h&&p?l._writableState?l._writableState.errorEmitted?process$1.nextTick(n,l):(l._writableState.errorEmitted=!0,process$1.nextTick(e,l,p)):process$1.nextTick(e,l,p):h?(process$1.nextTick(n,l),h(p)):process$1.nextTick(n,l)}),this)}function e(u,h){c(u,h),n(u)}function n(u){u._writableState&&!u._writableState.emitClose||u._readableState&&!u._readableState.emitClose||u.emit("close")}function a(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function c(u,h){u.emit("error",h)}function o(u,h){var l=u._readableState,b=u._writableState;l&&l.autoDestroy||b&&b.autoDestroy?u.destroy(h):u.emit("error",h)}return destroy_1$1={destroy:t,undestroy:a,errorOrDestroy:o},destroy_1$1}var errorsBrowser={},hasRequiredErrorsBrowser;function requireErrorsBrowser(){if(hasRequiredErrorsBrowser)return errorsBrowser;hasRequiredErrorsBrowser=1;function t(h,l){h.prototype=Object.create(l.prototype),h.prototype.constructor=h,h.__proto__=l}var e={};function n(h,l,b){b||(b=Error);function d(x,m,v){return typeof l=="string"?l:l(x,m,v)}var p=function(x){t(m,x);function m(v,g,$){return x.call(this,d(v,g,$))||this}return m}(b);p.prototype.name=b.name,p.prototype.code=h,e[h]=p}function a(h,l){if(Array.isArray(h)){var b=h.length;return h=h.map(function(d){return String(d)}),b>2?"one of ".concat(l," ").concat(h.slice(0,b-1).join(", "),", or ")+h[b-1]:b===2?"one of ".concat(l," ").concat(h[0]," or ").concat(h[1]):"of ".concat(l," ").concat(h[0])}else return"of ".concat(l," ").concat(String(h))}function c(h,l,b){return h.substr(0,l.length)===l}function o(h,l,b){return(b===void 0||b>h.length)&&(b=h.length),h.substring(b-l.length,b)===l}function u(h,l,b){return typeof b!="number"&&(b=0),b+l.length>h.length?!1:h.indexOf(l,b)!==-1}return n("ERR_INVALID_OPT_VALUE",function(h,l){return'The value "'+l+'" is invalid for option "'+h+'"'},TypeError),n("ERR_INVALID_ARG_TYPE",function(h,l,b){var d;typeof l=="string"&&c(l,"not ")?(d="must not be",l=l.replace(/^not /,"")):d="must be";var p;if(o(h," argument"))p="The ".concat(h," ").concat(d," ").concat(a(l,"type"));else{var x=u(h,".")?"property":"argument";p='The "'.concat(h,'" ').concat(x," ").concat(d," ").concat(a(l,"type"))}return p+=". Received type ".concat(typeof b),p},TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",function(h){return"The "+h+" method is not implemented"}),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",function(h){return"Cannot call "+h+" after a stream was destroyed"}),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",function(h){return"Unknown encoding: "+h},TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),errorsBrowser.codes=e,errorsBrowser}var state,hasRequiredState;function requireState(){if(hasRequiredState)return state;hasRequiredState=1;var t=requireErrorsBrowser().codes.ERR_INVALID_OPT_VALUE;function e(a,c,o){return a.highWaterMark!=null?a.highWaterMark:c?a[o]:null}function n(a,c,o,u){var h=e(c,u,o);if(h!=null){if(!(isFinite(h)&&Math.floor(h)===h)||h<0){var l=u?o:"highWaterMark";throw new t(l,h)}return Math.floor(h)}return a.objectMode?16:16*1024}return state={getHighWaterMark:n},state}var browser$a,hasRequiredBrowser$a;function requireBrowser$a(){if(hasRequiredBrowser$a)return browser$a;hasRequiredBrowser$a=1,browser$a=t;function t(n,a){if(e("noDeprecation"))return n;var c=!1;function o(){if(!c){if(e("throwDeprecation"))throw new Error(a);e("traceDeprecation")?console.trace(a):console.warn(a),c=!0}return n.apply(this,arguments)}return o}function e(n){try{if(!commonjsGlobal.localStorage)return!1}catch{return!1}var a=commonjsGlobal.localStorage[n];return a==null?!1:String(a).toLowerCase()==="true"}return browser$a}var _stream_writable$1,hasRequired_stream_writable$1;function require_stream_writable$1(){if(hasRequired_stream_writable$1)return _stream_writable$1;hasRequired_stream_writable$1=1,_stream_writable$1=te;function t(Y){var L=this;this.next=null,this.entry=null,this.finish=function(){oe(L,Y)}}var e;te.WritableState=Z;var n={deprecate:requireBrowser$a()},a=requireStreamBrowser$1(),c=require$$1$2.Buffer,o=(typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function u(Y){return c.from(Y)}function h(Y){return c.isBuffer(Y)||Y instanceof o}var l=requireDestroy$1(),b=requireState(),d=b.getHighWaterMark,p=requireErrorsBrowser().codes,x=p.ERR_INVALID_ARG_TYPE,m=p.ERR_METHOD_NOT_IMPLEMENTED,v=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,$=p.ERR_STREAM_DESTROYED,B=p.ERR_STREAM_NULL_VALUES,C=p.ERR_STREAM_WRITE_AFTER_END,F=p.ERR_UNKNOWN_ENCODING,H=l.errorOrDestroy;inherits_browserExports(te,a);function W(){}function Z(Y,L,z){e=e||require_stream_duplex$1(),Y=Y||{},typeof z!="boolean"&&(z=L instanceof e),this.objectMode=!!Y.objectMode,z&&(this.objectMode=this.objectMode||!!Y.writableObjectMode),this.highWaterMark=d(this,Y,"writableHighWaterMark",z),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var re=Y.decodeStrings===!1;this.decodeStrings=!re,this.defaultEncoding=Y.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(D){I(L,D)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=Y.emitClose!==!1,this.autoDestroy=!!Y.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}Z.prototype.getBuffer=function(){for(var L=this.bufferedRequest,z=[];L;)z.push(L),L=L.next;return z},function(){try{Object.defineProperty(Z.prototype,"buffer",{get:n.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var ie;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(ie=Function.prototype[Symbol.hasInstance],Object.defineProperty(te,Symbol.hasInstance,{value:function(L){return ie.call(this,L)?!0:this!==te?!1:L&&L._writableState instanceof Z}})):ie=function(L){return L instanceof this};function te(Y){e=e||require_stream_duplex$1();var L=this instanceof e;if(!L&&!ie.call(te,this))return new te(Y);this._writableState=new Z(Y,this,L),this.writable=!0,Y&&(typeof Y.write=="function"&&(this._write=Y.write),typeof Y.writev=="function"&&(this._writev=Y.writev),typeof Y.destroy=="function"&&(this._destroy=Y.destroy),typeof Y.final=="function"&&(this._final=Y.final)),a.call(this)}te.prototype.pipe=function(){H(this,new g)};function ae(Y,L){var z=new C;H(Y,z),process$1.nextTick(L,z)}function de(Y,L,z,re){var D;return z===null?D=new B:typeof z!="string"&&!L.objectMode&&(D=new x("chunk",["string","Buffer"],z)),D?(H(Y,D),process$1.nextTick(re,D),!1):!0}te.prototype.write=function(Y,L,z){var re=this._writableState,D=!1,G=!re.objectMode&&h(Y);return G&&!c.isBuffer(Y)&&(Y=u(Y)),typeof L=="function"&&(z=L,L=null),G?L="buffer":L||(L=re.defaultEncoding),typeof z!="function"&&(z=W),re.ending?ae(this,z):(G||de(this,re,Y,z))&&(re.pendingcb++,D=R(this,re,G,Y,L,z)),D},te.prototype.cork=function(){this._writableState.corked++},te.prototype.uncork=function(){var Y=this._writableState;Y.corked&&(Y.corked--,!Y.writing&&!Y.corked&&!Y.bufferProcessing&&Y.bufferedRequest&&P(this,Y))},te.prototype.setDefaultEncoding=function(L){if(typeof L=="string"&&(L=L.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((L+"").toLowerCase())>-1))throw new F(L);return this._writableState.defaultEncoding=L,this},Object.defineProperty(te.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function J(Y,L,z){return!Y.objectMode&&Y.decodeStrings!==!1&&typeof L=="string"&&(L=c.from(L,z)),L}Object.defineProperty(te.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function R(Y,L,z,re,D,G){if(!z){var U=J(L,re,D);re!==U&&(z=!0,D="buffer",re=U)}var Q=L.objectMode?1:re.length;L.length+=Q;var fe=L.length<L.highWaterMark;if(fe||(L.needDrain=!0),L.writing||L.corked){var he=L.lastBufferedRequest;L.lastBufferedRequest={chunk:re,encoding:D,isBuf:z,callback:G,next:null},he?he.next=L.lastBufferedRequest:L.bufferedRequest=L.lastBufferedRequest,L.bufferedRequestCount+=1}else A(Y,L,!1,Q,re,D,G);return fe}function A(Y,L,z,re,D,G,U){L.writelen=re,L.writecb=U,L.writing=!0,L.sync=!0,L.destroyed?L.onwrite(new $("write")):z?Y._writev(D,L.onwrite):Y._write(D,G,L.onwrite),L.sync=!1}function y(Y,L,z,re,D){--L.pendingcb,z?(process$1.nextTick(D,re),process$1.nextTick(j,Y,L),Y._writableState.errorEmitted=!0,H(Y,re)):(D(re),Y._writableState.errorEmitted=!0,H(Y,re),j(Y,L))}function w(Y){Y.writing=!1,Y.writecb=null,Y.length-=Y.writelen,Y.writelen=0}function I(Y,L){var z=Y._writableState,re=z.sync,D=z.writecb;if(typeof D!="function")throw new v;if(w(z),L)y(Y,z,re,L,D);else{var G=_(z)||Y.destroyed;!G&&!z.corked&&!z.bufferProcessing&&z.bufferedRequest&&P(Y,z),re?process$1.nextTick(M,Y,z,G,D):M(Y,z,G,D)}}function M(Y,L,z,re){z||k(Y,L),L.pendingcb--,re(),j(Y,L)}function k(Y,L){L.length===0&&L.needDrain&&(L.needDrain=!1,Y.emit("drain"))}function P(Y,L){L.bufferProcessing=!0;var z=L.bufferedRequest;if(Y._writev&&z&&z.next){var re=L.bufferedRequestCount,D=new Array(re),G=L.corkedRequestsFree;G.entry=z;for(var U=0,Q=!0;z;)D[U]=z,z.isBuf||(Q=!1),z=z.next,U+=1;D.allBuffers=Q,A(Y,L,!0,L.length,D,"",G.finish),L.pendingcb++,L.lastBufferedRequest=null,G.next?(L.corkedRequestsFree=G.next,G.next=null):L.corkedRequestsFree=new t(L),L.bufferedRequestCount=0}else{for(;z;){var fe=z.chunk,he=z.encoding,le=z.callback,pe=L.objectMode?1:fe.length;if(A(Y,L,!1,pe,fe,he,le),z=z.next,L.bufferedRequestCount--,L.writing)break}z===null&&(L.lastBufferedRequest=null)}L.bufferedRequest=z,L.bufferProcessing=!1}te.prototype._write=function(Y,L,z){z(new m("_write()"))},te.prototype._writev=null,te.prototype.end=function(Y,L,z){var re=this._writableState;return typeof Y=="function"?(z=Y,Y=null,L=null):typeof L=="function"&&(z=L,L=null),Y!=null&&this.write(Y,L),re.corked&&(re.corked=1,this.uncork()),re.ending||ee(this,re,z),this},Object.defineProperty(te.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function _(Y){return Y.ending&&Y.length===0&&Y.bufferedRequest===null&&!Y.finished&&!Y.writing}function q(Y,L){Y._final(function(z){L.pendingcb--,z&&H(Y,z),L.prefinished=!0,Y.emit("prefinish"),j(Y,L)})}function E(Y,L){!L.prefinished&&!L.finalCalled&&(typeof Y._final=="function"&&!L.destroyed?(L.pendingcb++,L.finalCalled=!0,process$1.nextTick(q,Y,L)):(L.prefinished=!0,Y.emit("prefinish")))}function j(Y,L){var z=_(L);if(z&&(E(Y,L),L.pendingcb===0&&(L.finished=!0,Y.emit("finish"),L.autoDestroy))){var re=Y._readableState;(!re||re.autoDestroy&&re.endEmitted)&&Y.destroy()}return z}function ee(Y,L,z){L.ending=!0,j(Y,L),z&&(L.finished?process$1.nextTick(z):Y.once("finish",z)),L.ended=!0,Y.writable=!1}function oe(Y,L,z){var re=Y.entry;for(Y.entry=null;re;){var D=re.callback;L.pendingcb--,D(z),re=re.next}L.corkedRequestsFree.next=Y}return Object.defineProperty(te.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(L){this._writableState&&(this._writableState.destroyed=L)}}),te.prototype.destroy=l.destroy,te.prototype._undestroy=l.undestroy,te.prototype._destroy=function(Y,L){L(Y)},_stream_writable$1}var _stream_duplex$1,hasRequired_stream_duplex$1;function require_stream_duplex$1(){if(hasRequired_stream_duplex$1)return _stream_duplex$1;hasRequired_stream_duplex$1=1;var t=Object.keys||function(b){var d=[];for(var p in b)d.push(p);return d};_stream_duplex$1=u;var e=require_stream_readable$1(),n=require_stream_writable$1();inherits_browserExports(u,e);for(var a=t(n.prototype),c=0;c<a.length;c++){var o=a[c];u.prototype[o]||(u.prototype[o]=n.prototype[o])}function u(b){if(!(this instanceof u))return new u(b);e.call(this,b),n.call(this,b),this.allowHalfOpen=!0,b&&(b.readable===!1&&(this.readable=!1),b.writable===!1&&(this.writable=!1),b.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",h)))}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function h(){this._writableState.ended||process$1.nextTick(l,this)}function l(b){b.end()}return Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(d){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=d,this._writableState.destroyed=d)}}),_stream_duplex$1}var string_decoder={},hasRequiredString_decoder;function requireString_decoder(){if(hasRequiredString_decoder)return string_decoder;hasRequiredString_decoder=1;var t=requireSafeBuffer$1().Buffer,e=t.isEncoding||function(B){switch(B=""+B,B&&B.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function n(B){if(!B)return"utf8";for(var C;;)switch(B){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return B;default:if(C)return;B=(""+B).toLowerCase(),C=!0}}function a(B){var C=n(B);if(typeof C!="string"&&(t.isEncoding===e||!e(B)))throw new Error("Unknown encoding: "+B);return C||B}string_decoder.StringDecoder=c;function c(B){this.encoding=a(B);var C;switch(this.encoding){case"utf16le":this.text=p,this.end=x,C=4;break;case"utf8":this.fillLast=l,C=4;break;case"base64":this.text=m,this.end=v,C=3;break;default:this.write=g,this.end=$;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(C)}c.prototype.write=function(B){if(B.length===0)return"";var C,F;if(this.lastNeed){if(C=this.fillLast(B),C===void 0)return"";F=this.lastNeed,this.lastNeed=0}else F=0;return F<B.length?C?C+this.text(B,F):this.text(B,F):C||""},c.prototype.end=d,c.prototype.text=b,c.prototype.fillLast=function(B){if(this.lastNeed<=B.length)return B.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);B.copy(this.lastChar,this.lastTotal-this.lastNeed,0,B.length),this.lastNeed-=B.length};function o(B){return B<=127?0:B>>5===6?2:B>>4===14?3:B>>3===30?4:B>>6===2?-1:-2}function u(B,C,F){var H=C.length-1;if(H<F)return 0;var W=o(C[H]);return W>=0?(W>0&&(B.lastNeed=W-1),W):--H<F||W===-2?0:(W=o(C[H]),W>=0?(W>0&&(B.lastNeed=W-2),W):--H<F||W===-2?0:(W=o(C[H]),W>=0?(W>0&&(W===2?W=0:B.lastNeed=W-3),W):0))}function h(B,C,F){if((C[0]&192)!==128)return B.lastNeed=0,"�";if(B.lastNeed>1&&C.length>1){if((C[1]&192)!==128)return B.lastNeed=1,"�";if(B.lastNeed>2&&C.length>2&&(C[2]&192)!==128)return B.lastNeed=2,"�"}}function l(B){var C=this.lastTotal-this.lastNeed,F=h(this,B);if(F!==void 0)return F;if(this.lastNeed<=B.length)return B.copy(this.lastChar,C,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);B.copy(this.lastChar,C,0,B.length),this.lastNeed-=B.length}function b(B,C){var F=u(this,B,C);if(!this.lastNeed)return B.toString("utf8",C);this.lastTotal=F;var H=B.length-(F-this.lastNeed);return B.copy(this.lastChar,0,H),B.toString("utf8",C,H)}function d(B){var C=B&&B.length?this.write(B):"";return this.lastNeed?C+"�":C}function p(B,C){if((B.length-C)%2===0){var F=B.toString("utf16le",C);if(F){var H=F.charCodeAt(F.length-1);if(H>=55296&&H<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=B[B.length-2],this.lastChar[1]=B[B.length-1],F.slice(0,-1)}return F}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=B[B.length-1],B.toString("utf16le",C,B.length-1)}function x(B){var C=B&&B.length?this.write(B):"";if(this.lastNeed){var F=this.lastTotal-this.lastNeed;return C+this.lastChar.toString("utf16le",0,F)}return C}function m(B,C){var F=(B.length-C)%3;return F===0?B.toString("base64",C):(this.lastNeed=3-F,this.lastTotal=3,F===1?this.lastChar[0]=B[B.length-1]:(this.lastChar[0]=B[B.length-2],this.lastChar[1]=B[B.length-1]),B.toString("base64",C,B.length-F))}function v(B){var C=B&&B.length?this.write(B):"";return this.lastNeed?C+this.lastChar.toString("base64",0,3-this.lastNeed):C}function g(B){return B.toString(this.encoding)}function $(B){return B&&B.length?this.write(B):""}return string_decoder}var endOfStream,hasRequiredEndOfStream;function requireEndOfStream(){if(hasRequiredEndOfStream)return endOfStream;hasRequiredEndOfStream=1;var t=requireErrorsBrowser().codes.ERR_STREAM_PREMATURE_CLOSE;function e(o){var u=!1;return function(){if(!u){u=!0;for(var h=arguments.length,l=new Array(h),b=0;b<h;b++)l[b]=arguments[b];o.apply(this,l)}}}function n(){}function a(o){return o.setHeader&&typeof o.abort=="function"}function c(o,u,h){if(typeof u=="function")return c(o,null,u);u||(u={}),h=e(h||n);var l=u.readable||u.readable!==!1&&o.readable,b=u.writable||u.writable!==!1&&o.writable,d=function(){o.writable||x()},p=o._writableState&&o._writableState.finished,x=function(){b=!1,p=!0,l||h.call(o)},m=o._readableState&&o._readableState.endEmitted,v=function(){l=!1,m=!0,b||h.call(o)},g=function(F){h.call(o,F)},$=function(){var F;if(l&&!m)return(!o._readableState||!o._readableState.ended)&&(F=new t),h.call(o,F);if(b&&!p)return(!o._writableState||!o._writableState.ended)&&(F=new t),h.call(o,F)},B=function(){o.req.on("finish",x)};return a(o)?(o.on("complete",x),o.on("abort",$),o.req?B():o.on("request",B)):b&&!o._writableState&&(o.on("end",d),o.on("close",d)),o.on("end",v),o.on("finish",x),u.error!==!1&&o.on("error",g),o.on("close",$),function(){o.removeListener("complete",x),o.removeListener("abort",$),o.removeListener("request",B),o.req&&o.req.removeListener("finish",x),o.removeListener("end",d),o.removeListener("close",d),o.removeListener("finish",x),o.removeListener("end",v),o.removeListener("error",g),o.removeListener("close",$)}}return endOfStream=c,endOfStream}var async_iterator,hasRequiredAsync_iterator;function requireAsync_iterator(){if(hasRequiredAsync_iterator)return async_iterator;hasRequiredAsync_iterator=1;var t;function e(F,H,W){return H=n(H),H in F?Object.defineProperty(F,H,{value:W,enumerable:!0,configurable:!0,writable:!0}):F[H]=W,F}function n(F){var H=a(F,"string");return typeof H=="symbol"?H:String(H)}function a(F,H){if(typeof F!="object"||F===null)return F;var W=F[Symbol.toPrimitive];if(W!==void 0){var Z=W.call(F,H||"default");if(typeof Z!="object")return Z;throw new TypeError("@@toPrimitive must return a primitive value.")}return(H==="string"?String:Number)(F)}var c=requireEndOfStream(),o=Symbol("lastResolve"),u=Symbol("lastReject"),h=Symbol("error"),l=Symbol("ended"),b=Symbol("lastPromise"),d=Symbol("handlePromise"),p=Symbol("stream");function x(F,H){return{value:F,done:H}}function m(F){var H=F[o];if(H!==null){var W=F[p].read();W!==null&&(F[b]=null,F[o]=null,F[u]=null,H(x(W,!1)))}}function v(F){process$1.nextTick(m,F)}function g(F,H){return function(W,Z){F.then(function(){if(H[l]){W(x(void 0,!0));return}H[d](W,Z)},Z)}}var $=Object.getPrototypeOf(function(){}),B=Object.setPrototypeOf((t={get stream(){return this[p]},next:function(){var H=this,W=this[h];if(W!==null)return Promise.reject(W);if(this[l])return Promise.resolve(x(void 0,!0));if(this[p].destroyed)return new Promise(function(ae,de){process$1.nextTick(function(){H[h]?de(H[h]):ae(x(void 0,!0))})});var Z=this[b],ie;if(Z)ie=new Promise(g(Z,this));else{var te=this[p].read();if(te!==null)return Promise.resolve(x(te,!1));ie=new Promise(this[d])}return this[b]=ie,ie}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var H=this;return new Promise(function(W,Z){H[p].destroy(null,function(ie){if(ie){Z(ie);return}W(x(void 0,!0))})})}),t),$),C=function(H){var W,Z=Object.create(B,(W={},e(W,p,{value:H,writable:!0}),e(W,o,{value:null,writable:!0}),e(W,u,{value:null,writable:!0}),e(W,h,{value:null,writable:!0}),e(W,l,{value:H._readableState.endEmitted,writable:!0}),e(W,d,{value:function(te,ae){var de=Z[p].read();de?(Z[b]=null,Z[o]=null,Z[u]=null,te(x(de,!1))):(Z[o]=te,Z[u]=ae)},writable:!0}),W));return Z[b]=null,c(H,function(ie){if(ie&&ie.code!=="ERR_STREAM_PREMATURE_CLOSE"){var te=Z[u];te!==null&&(Z[b]=null,Z[o]=null,Z[u]=null,te(ie)),Z[h]=ie;return}var ae=Z[o];ae!==null&&(Z[b]=null,Z[o]=null,Z[u]=null,ae(x(void 0,!0))),Z[l]=!0}),H.on("readable",v.bind(null,Z)),Z};return async_iterator=C,async_iterator}var fromBrowser,hasRequiredFromBrowser;function requireFromBrowser(){return hasRequiredFromBrowser||(hasRequiredFromBrowser=1,fromBrowser=function(){throw new Error("Readable.from is not available in the browser")}),fromBrowser}var _stream_readable$1,hasRequired_stream_readable$1;function require_stream_readable$1(){if(hasRequired_stream_readable$1)return _stream_readable$1;hasRequired_stream_readable$1=1,_stream_readable$1=ae;var t;ae.ReadableState=te,requireEvents().EventEmitter;var e=function(U,Q){return U.listeners(Q).length},n=requireStreamBrowser$1(),a=require$$1$2.Buffer,c=(typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function o(G){return a.from(G)}function u(G){return a.isBuffer(G)||G instanceof c}var h=requireUtil$1(),l;h&&h.debuglog?l=h.debuglog("stream"):l=function(){};var b=requireBuffer_list(),d=requireDestroy$1(),p=requireState(),x=p.getHighWaterMark,m=requireErrorsBrowser().codes,v=m.ERR_INVALID_ARG_TYPE,g=m.ERR_STREAM_PUSH_AFTER_EOF,$=m.ERR_METHOD_NOT_IMPLEMENTED,B=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,C,F,H;inherits_browserExports(ae,n);var W=d.errorOrDestroy,Z=["error","close","destroy","pause","resume"];function ie(G,U,Q){if(typeof G.prependListener=="function")return G.prependListener(U,Q);!G._events||!G._events[U]?G.on(U,Q):Array.isArray(G._events[U])?G._events[U].unshift(Q):G._events[U]=[Q,G._events[U]]}function te(G,U,Q){t=t||require_stream_duplex$1(),G=G||{},typeof Q!="boolean"&&(Q=U instanceof t),this.objectMode=!!G.objectMode,Q&&(this.objectMode=this.objectMode||!!G.readableObjectMode),this.highWaterMark=x(this,G,"readableHighWaterMark",Q),this.buffer=new b,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=G.emitClose!==!1,this.autoDestroy=!!G.autoDestroy,this.destroyed=!1,this.defaultEncoding=G.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,G.encoding&&(C||(C=requireString_decoder().StringDecoder),this.decoder=new C(G.encoding),this.encoding=G.encoding)}function ae(G){if(t=t||require_stream_duplex$1(),!(this instanceof ae))return new ae(G);var U=this instanceof t;this._readableState=new te(G,this,U),this.readable=!0,G&&(typeof G.read=="function"&&(this._read=G.read),typeof G.destroy=="function"&&(this._destroy=G.destroy)),n.call(this)}Object.defineProperty(ae.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(U){this._readableState&&(this._readableState.destroyed=U)}}),ae.prototype.destroy=d.destroy,ae.prototype._undestroy=d.undestroy,ae.prototype._destroy=function(G,U){U(G)},ae.prototype.push=function(G,U){var Q=this._readableState,fe;return Q.objectMode?fe=!0:typeof G=="string"&&(U=U||Q.defaultEncoding,U!==Q.encoding&&(G=a.from(G,U),U=""),fe=!0),de(this,G,U,!1,fe)},ae.prototype.unshift=function(G){return de(this,G,null,!0,!1)};function de(G,U,Q,fe,he){l("readableAddChunk",U);var le=G._readableState;if(U===null)le.reading=!1,I(G,le);else{var pe;if(he||(pe=R(le,U)),pe)W(G,pe);else if(le.objectMode||U&&U.length>0)if(typeof U!="string"&&!le.objectMode&&Object.getPrototypeOf(U)!==a.prototype&&(U=o(U)),fe)le.endEmitted?W(G,new B):J(G,le,U,!0);else if(le.ended)W(G,new g);else{if(le.destroyed)return!1;le.reading=!1,le.decoder&&!Q?(U=le.decoder.write(U),le.objectMode||U.length!==0?J(G,le,U,!1):P(G,le)):J(G,le,U,!1)}else fe||(le.reading=!1,P(G,le))}return!le.ended&&(le.length<le.highWaterMark||le.length===0)}function J(G,U,Q,fe){U.flowing&&U.length===0&&!U.sync?(U.awaitDrain=0,G.emit("data",Q)):(U.length+=U.objectMode?1:Q.length,fe?U.buffer.unshift(Q):U.buffer.push(Q),U.needReadable&&M(G)),P(G,U)}function R(G,U){var Q;return!u(U)&&typeof U!="string"&&U!==void 0&&!G.objectMode&&(Q=new v("chunk",["string","Buffer","Uint8Array"],U)),Q}ae.prototype.isPaused=function(){return this._readableState.flowing===!1},ae.prototype.setEncoding=function(G){C||(C=requireString_decoder().StringDecoder);var U=new C(G);this._readableState.decoder=U,this._readableState.encoding=this._readableState.decoder.encoding;for(var Q=this._readableState.buffer.head,fe="";Q!==null;)fe+=U.write(Q.data),Q=Q.next;return this._readableState.buffer.clear(),fe!==""&&this._readableState.buffer.push(fe),this._readableState.length=fe.length,this};var A=1073741824;function y(G){return G>=A?G=A:(G--,G|=G>>>1,G|=G>>>2,G|=G>>>4,G|=G>>>8,G|=G>>>16,G++),G}function w(G,U){return G<=0||U.length===0&&U.ended?0:U.objectMode?1:G!==G?U.flowing&&U.length?U.buffer.head.data.length:U.length:(G>U.highWaterMark&&(U.highWaterMark=y(G)),G<=U.length?G:U.ended?U.length:(U.needReadable=!0,0))}ae.prototype.read=function(G){l("read",G),G=parseInt(G,10);var U=this._readableState,Q=G;if(G!==0&&(U.emittedReadable=!1),G===0&&U.needReadable&&((U.highWaterMark!==0?U.length>=U.highWaterMark:U.length>0)||U.ended))return l("read: emitReadable",U.length,U.ended),U.length===0&&U.ended?z(this):M(this),null;if(G=w(G,U),G===0&&U.ended)return U.length===0&&z(this),null;var fe=U.needReadable;l("need readable",fe),(U.length===0||U.length-G<U.highWaterMark)&&(fe=!0,l("length less than watermark",fe)),U.ended||U.reading?(fe=!1,l("reading or ended",fe)):fe&&(l("do read"),U.reading=!0,U.sync=!0,U.length===0&&(U.needReadable=!0),this._read(U.highWaterMark),U.sync=!1,U.reading||(G=w(Q,U)));var he;return G>0?he=L(G,U):he=null,he===null?(U.needReadable=U.length<=U.highWaterMark,G=0):(U.length-=G,U.awaitDrain=0),U.length===0&&(U.ended||(U.needReadable=!0),Q!==G&&U.ended&&z(this)),he!==null&&this.emit("data",he),he};function I(G,U){if(l("onEofChunk"),!U.ended){if(U.decoder){var Q=U.decoder.end();Q&&Q.length&&(U.buffer.push(Q),U.length+=U.objectMode?1:Q.length)}U.ended=!0,U.sync?M(G):(U.needReadable=!1,U.emittedReadable||(U.emittedReadable=!0,k(G)))}}function M(G){var U=G._readableState;l("emitReadable",U.needReadable,U.emittedReadable),U.needReadable=!1,U.emittedReadable||(l("emitReadable",U.flowing),U.emittedReadable=!0,process$1.nextTick(k,G))}function k(G){var U=G._readableState;l("emitReadable_",U.destroyed,U.length,U.ended),!U.destroyed&&(U.length||U.ended)&&(G.emit("readable"),U.emittedReadable=!1),U.needReadable=!U.flowing&&!U.ended&&U.length<=U.highWaterMark,Y(G)}function P(G,U){U.readingMore||(U.readingMore=!0,process$1.nextTick(_,G,U))}function _(G,U){for(;!U.reading&&!U.ended&&(U.length<U.highWaterMark||U.flowing&&U.length===0);){var Q=U.length;if(l("maybeReadMore read 0"),G.read(0),Q===U.length)break}U.readingMore=!1}ae.prototype._read=function(G){W(this,new $("_read()"))},ae.prototype.pipe=function(G,U){var Q=this,fe=this._readableState;switch(fe.pipesCount){case 0:fe.pipes=G;break;case 1:fe.pipes=[fe.pipes,G];break;default:fe.pipes.push(G);break}fe.pipesCount+=1,l("pipe count=%d opts=%j",fe.pipesCount,U);var he=(!U||U.end!==!1)&&G!==process$1.stdout&&G!==process$1.stderr,le=he?be:De;fe.endEmitted?process$1.nextTick(le):Q.once("end",le),G.on("unpipe",pe);function pe(Se,Oe){l("onunpipe"),Se===Q&&Oe&&Oe.hasUnpiped===!1&&(Oe.hasUnpiped=!0,ye())}function be(){l("onend"),G.end()}var se=q(Q);G.on("drain",se);var ge=!1;function ye(){l("cleanup"),G.removeListener("close",ve),G.removeListener("finish",Be),G.removeListener("drain",se),G.removeListener("error",Ne),G.removeListener("unpipe",pe),Q.removeListener("end",be),Q.removeListener("end",De),Q.removeListener("data",$e),ge=!0,fe.awaitDrain&&(!G._writableState||G._writableState.needDrain)&&se()}Q.on("data",$e);function $e(Se){l("ondata");var Oe=G.write(Se);l("dest.write",Oe),Oe===!1&&((fe.pipesCount===1&&fe.pipes===G||fe.pipesCount>1&&D(fe.pipes,G)!==-1)&&!ge&&(l("false write response, pause",fe.awaitDrain),fe.awaitDrain++),Q.pause())}function Ne(Se){l("onerror",Se),De(),G.removeListener("error",Ne),e(G,"error")===0&&W(G,Se)}ie(G,"error",Ne);function ve(){G.removeListener("finish",Be),De()}G.once("close",ve);function Be(){l("onfinish"),G.removeListener("close",ve),De()}G.once("finish",Be);function De(){l("unpipe"),Q.unpipe(G)}return G.emit("pipe",Q),fe.flowing||(l("pipe resume"),Q.resume()),G};function q(G){return function(){var Q=G._readableState;l("pipeOnDrain",Q.awaitDrain),Q.awaitDrain&&Q.awaitDrain--,Q.awaitDrain===0&&e(G,"data")&&(Q.flowing=!0,Y(G))}}ae.prototype.unpipe=function(G){var U=this._readableState,Q={hasUnpiped:!1};if(U.pipesCount===0)return this;if(U.pipesCount===1)return G&&G!==U.pipes?this:(G||(G=U.pipes),U.pipes=null,U.pipesCount=0,U.flowing=!1,G&&G.emit("unpipe",this,Q),this);if(!G){var fe=U.pipes,he=U.pipesCount;U.pipes=null,U.pipesCount=0,U.flowing=!1;for(var le=0;le<he;le++)fe[le].emit("unpipe",this,{hasUnpiped:!1});return this}var pe=D(U.pipes,G);return pe===-1?this:(U.pipes.splice(pe,1),U.pipesCount-=1,U.pipesCount===1&&(U.pipes=U.pipes[0]),G.emit("unpipe",this,Q),this)},ae.prototype.on=function(G,U){var Q=n.prototype.on.call(this,G,U),fe=this._readableState;return G==="data"?(fe.readableListening=this.listenerCount("readable")>0,fe.flowing!==!1&&this.resume()):G==="readable"&&!fe.endEmitted&&!fe.readableListening&&(fe.readableListening=fe.needReadable=!0,fe.flowing=!1,fe.emittedReadable=!1,l("on readable",fe.length,fe.reading),fe.length?M(this):fe.reading||process$1.nextTick(j,this)),Q},ae.prototype.addListener=ae.prototype.on,ae.prototype.removeListener=function(G,U){var Q=n.prototype.removeListener.call(this,G,U);return G==="readable"&&process$1.nextTick(E,this),Q},ae.prototype.removeAllListeners=function(G){var U=n.prototype.removeAllListeners.apply(this,arguments);return(G==="readable"||G===void 0)&&process$1.nextTick(E,this),U};function E(G){var U=G._readableState;U.readableListening=G.listenerCount("readable")>0,U.resumeScheduled&&!U.paused?U.flowing=!0:G.listenerCount("data")>0&&G.resume()}function j(G){l("readable nexttick read 0"),G.read(0)}ae.prototype.resume=function(){var G=this._readableState;return G.flowing||(l("resume"),G.flowing=!G.readableListening,ee(this,G)),G.paused=!1,this};function ee(G,U){U.resumeScheduled||(U.resumeScheduled=!0,process$1.nextTick(oe,G,U))}function oe(G,U){l("resume",U.reading),U.reading||G.read(0),U.resumeScheduled=!1,G.emit("resume"),Y(G),U.flowing&&!U.reading&&G.read(0)}ae.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Y(G){var U=G._readableState;for(l("flow",U.flowing);U.flowing&&G.read()!==null;);}ae.prototype.wrap=function(G){var U=this,Q=this._readableState,fe=!1;G.on("end",function(){if(l("wrapped end"),Q.decoder&&!Q.ended){var pe=Q.decoder.end();pe&&pe.length&&U.push(pe)}U.push(null)}),G.on("data",function(pe){if(l("wrapped data"),Q.decoder&&(pe=Q.decoder.write(pe)),!(Q.objectMode&&pe==null)&&!(!Q.objectMode&&(!pe||!pe.length))){var be=U.push(pe);be||(fe=!0,G.pause())}});for(var he in G)this[he]===void 0&&typeof G[he]=="function"&&(this[he]=function(be){return function(){return G[be].apply(G,arguments)}}(he));for(var le=0;le<Z.length;le++)G.on(Z[le],this.emit.bind(this,Z[le]));return this._read=function(pe){l("wrapped _read",pe),fe&&(fe=!1,G.resume())},this},typeof Symbol=="function"&&(ae.prototype[Symbol.asyncIterator]=function(){return F===void 0&&(F=requireAsync_iterator()),F(this)}),Object.defineProperty(ae.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(ae.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(ae.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(U){this._readableState&&(this._readableState.flowing=U)}}),ae._fromList=L,Object.defineProperty(ae.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function L(G,U){if(U.length===0)return null;var Q;return U.objectMode?Q=U.buffer.shift():!G||G>=U.length?(U.decoder?Q=U.buffer.join(""):U.buffer.length===1?Q=U.buffer.first():Q=U.buffer.concat(U.length),U.buffer.clear()):Q=U.buffer.consume(G,U.decoder),Q}function z(G){var U=G._readableState;l("endReadable",U.endEmitted),U.endEmitted||(U.ended=!0,process$1.nextTick(re,U,G))}function re(G,U){if(l("endReadableNT",G.endEmitted,G.length),!G.endEmitted&&G.length===0&&(G.endEmitted=!0,U.readable=!1,U.emit("end"),G.autoDestroy)){var Q=U._writableState;(!Q||Q.autoDestroy&&Q.finished)&&U.destroy()}}typeof Symbol=="function"&&(ae.from=function(G,U){return H===void 0&&(H=requireFromBrowser()),H(ae,G,U)});function D(G,U){for(var Q=0,fe=G.length;Q<fe;Q++)if(G[Q]===U)return Q;return-1}return _stream_readable$1}var _stream_transform$1,hasRequired_stream_transform$1;function require_stream_transform$1(){if(hasRequired_stream_transform$1)return _stream_transform$1;hasRequired_stream_transform$1=1,_stream_transform$1=h;var t=requireErrorsBrowser().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,n=t.ERR_MULTIPLE_CALLBACK,a=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,c=t.ERR_TRANSFORM_WITH_LENGTH_0,o=require_stream_duplex$1();inherits_browserExports(h,o);function u(d,p){var x=this._transformState;x.transforming=!1;var m=x.writecb;if(m===null)return this.emit("error",new n);x.writechunk=null,x.writecb=null,p!=null&&this.push(p),m(d);var v=this._readableState;v.reading=!1,(v.needReadable||v.length<v.highWaterMark)&&this._read(v.highWaterMark)}function h(d){if(!(this instanceof h))return new h(d);o.call(this,d),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",l)}function l(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(p,x){b(d,p,x)}):b(this,null,null)}h.prototype.push=function(d,p){return this._transformState.needTransform=!1,o.prototype.push.call(this,d,p)},h.prototype._transform=function(d,p,x){x(new e("_transform()"))},h.prototype._write=function(d,p,x){var m=this._transformState;if(m.writecb=x,m.writechunk=d,m.writeencoding=p,!m.transforming){var v=this._readableState;(m.needTransform||v.needReadable||v.length<v.highWaterMark)&&this._read(v.highWaterMark)}},h.prototype._read=function(d){var p=this._transformState;p.writechunk!==null&&!p.transforming?(p.transforming=!0,this._transform(p.writechunk,p.writeencoding,p.afterTransform)):p.needTransform=!0},h.prototype._destroy=function(d,p){o.prototype._destroy.call(this,d,function(x){p(x)})};function b(d,p,x){if(p)return d.emit("error",p);if(x!=null&&d.push(x),d._writableState.length)throw new c;if(d._transformState.transforming)throw new a;return d.push(null)}return _stream_transform$1}var _stream_passthrough$1,hasRequired_stream_passthrough$1;function require_stream_passthrough$1(){if(hasRequired_stream_passthrough$1)return _stream_passthrough$1;hasRequired_stream_passthrough$1=1,_stream_passthrough$1=e;var t=require_stream_transform$1();inherits_browserExports(e,t);function e(n){if(!(this instanceof e))return new e(n);t.call(this,n)}return e.prototype._transform=function(n,a,c){c(null,n)},_stream_passthrough$1}var pipeline_1,hasRequiredPipeline;function requirePipeline(){if(hasRequiredPipeline)return pipeline_1;hasRequiredPipeline=1;var t;function e(x){var m=!1;return function(){m||(m=!0,x.apply(void 0,arguments))}}var n=requireErrorsBrowser().codes,a=n.ERR_MISSING_ARGS,c=n.ERR_STREAM_DESTROYED;function o(x){if(x)throw x}function u(x){return x.setHeader&&typeof x.abort=="function"}function h(x,m,v,g){g=e(g);var $=!1;x.on("close",function(){$=!0}),t===void 0&&(t=requireEndOfStream()),t(x,{readable:m,writable:v},function(C){if(C)return g(C);$=!0,g()});var B=!1;return function(C){if(!$&&!B){if(B=!0,u(x))return x.abort();if(typeof x.destroy=="function")return x.destroy();g(C||new c("pipe"))}}}function l(x){x()}function b(x,m){return x.pipe(m)}function d(x){return!x.length||typeof x[x.length-1]!="function"?o:x.pop()}function p(){for(var x=arguments.length,m=new Array(x),v=0;v<x;v++)m[v]=arguments[v];var g=d(m);if(Array.isArray(m[0])&&(m=m[0]),m.length<2)throw new a("streams");var $,B=m.map(function(C,F){var H=F<m.length-1,W=F>0;return h(C,H,W,function(Z){$||($=Z),Z&&B.forEach(l),!H&&(B.forEach(l),g($))})});return m.reduce(b)}return pipeline_1=p,pipeline_1}var hasRequiredReadableBrowser$1;function requireReadableBrowser$1(){return hasRequiredReadableBrowser$1||(hasRequiredReadableBrowser$1=1,function(t,e){e=t.exports=require_stream_readable$1(),e.Stream=e,e.Readable=e,e.Writable=require_stream_writable$1(),e.Duplex=require_stream_duplex$1(),e.Transform=require_stream_transform$1(),e.PassThrough=require_stream_passthrough$1(),e.finished=requireEndOfStream(),e.pipeline=requirePipeline()}(readableBrowser$1,readableBrowser$1.exports)),readableBrowser$1.exports}var hashBase,hasRequiredHashBase;function requireHashBase(){if(hasRequiredHashBase)return hashBase;hasRequiredHashBase=1;var t=requireSafeBuffer$1().Buffer,e=requireReadableBrowser$1().Transform,n=inherits_browserExports;function a(o,u){if(!t.isBuffer(o)&&typeof o!="string")throw new TypeError(u+" must be a string or a buffer")}function c(o){e.call(this),this._block=t.allocUnsafe(o),this._blockSize=o,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}return n(c,e),c.prototype._transform=function(o,u,h){var l=null;try{this.update(o,u)}catch(b){l=b}h(l)},c.prototype._flush=function(o){var u=null;try{this.push(this.digest())}catch(h){u=h}o(u)},c.prototype.update=function(o,u){if(a(o,"Data"),this._finalized)throw new Error("Digest already called");t.isBuffer(o)||(o=t.from(o,u));for(var h=this._block,l=0;this._blockOffset+o.length-l>=this._blockSize;){for(var b=this._blockOffset;b<this._blockSize;)h[b++]=o[l++];this._update(),this._blockOffset=0}for(;l<o.length;)h[this._blockOffset++]=o[l++];for(var d=0,p=o.length*8;p>0;++d)this._length[d]+=p,p=this._length[d]/4294967296|0,p>0&&(this._length[d]-=4294967296*p);return this},c.prototype._update=function(){throw new Error("_update is not implemented")},c.prototype.digest=function(o){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var u=this._digest();o!==void 0&&(u=u.toString(o)),this._block.fill(0),this._blockOffset=0;for(var h=0;h<4;++h)this._length[h]=0;return u},c.prototype._digest=function(){throw new Error("_digest is not implemented")},hashBase=c,hashBase}var md5_js,hasRequiredMd5_js;function requireMd5_js(){if(hasRequiredMd5_js)return md5_js;hasRequiredMd5_js=1;var t=inherits_browserExports,e=requireHashBase(),n=requireSafeBuffer$1().Buffer,a=new Array(16);function c(){e.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}t(c,e),c.prototype._update=function(){for(var d=a,p=0;p<16;++p)d[p]=this._block.readInt32LE(p*4);var x=this._a,m=this._b,v=this._c,g=this._d;x=u(x,m,v,g,d[0],3614090360,7),g=u(g,x,m,v,d[1],3905402710,12),v=u(v,g,x,m,d[2],606105819,17),m=u(m,v,g,x,d[3],3250441966,22),x=u(x,m,v,g,d[4],4118548399,7),g=u(g,x,m,v,d[5],1200080426,12),v=u(v,g,x,m,d[6],2821735955,17),m=u(m,v,g,x,d[7],4249261313,22),x=u(x,m,v,g,d[8],1770035416,7),g=u(g,x,m,v,d[9],2336552879,12),v=u(v,g,x,m,d[10],4294925233,17),m=u(m,v,g,x,d[11],2304563134,22),x=u(x,m,v,g,d[12],1804603682,7),g=u(g,x,m,v,d[13],4254626195,12),v=u(v,g,x,m,d[14],2792965006,17),m=u(m,v,g,x,d[15],1236535329,22),x=h(x,m,v,g,d[1],4129170786,5),g=h(g,x,m,v,d[6],3225465664,9),v=h(v,g,x,m,d[11],643717713,14),m=h(m,v,g,x,d[0],3921069994,20),x=h(x,m,v,g,d[5],3593408605,5),g=h(g,x,m,v,d[10],38016083,9),v=h(v,g,x,m,d[15],3634488961,14),m=h(m,v,g,x,d[4],3889429448,20),x=h(x,m,v,g,d[9],568446438,5),g=h(g,x,m,v,d[14],3275163606,9),v=h(v,g,x,m,d[3],4107603335,14),m=h(m,v,g,x,d[8],1163531501,20),x=h(x,m,v,g,d[13],2850285829,5),g=h(g,x,m,v,d[2],4243563512,9),v=h(v,g,x,m,d[7],1735328473,14),m=h(m,v,g,x,d[12],2368359562,20),x=l(x,m,v,g,d[5],4294588738,4),g=l(g,x,m,v,d[8],2272392833,11),v=l(v,g,x,m,d[11],1839030562,16),m=l(m,v,g,x,d[14],4259657740,23),x=l(x,m,v,g,d[1],2763975236,4),g=l(g,x,m,v,d[4],1272893353,11),v=l(v,g,x,m,d[7],4139469664,16),m=l(m,v,g,x,d[10],3200236656,23),x=l(x,m,v,g,d[13],681279174,4),g=l(g,x,m,v,d[0],3936430074,11),v=l(v,g,x,m,d[3],3572445317,16),m=l(m,v,g,x,d[6],76029189,23),x=l(x,m,v,g,d[9],3654602809,4),g=l(g,x,m,v,d[12],3873151461,11),v=l(v,g,x,m,d[15],530742520,16),m=l(m,v,g,x,d[2],3299628645,23),x=b(x,m,v,g,d[0],4096336452,6),g=b(g,x,m,v,d[7],1126891415,10),v=b(v,g,x,m,d[14],2878612391,15),m=b(m,v,g,x,d[5],4237533241,21),x=b(x,m,v,g,d[12],1700485571,6),g=b(g,x,m,v,d[3],2399980690,10),v=b(v,g,x,m,d[10],4293915773,15),m=b(m,v,g,x,d[1],2240044497,21),x=b(x,m,v,g,d[8],1873313359,6),g=b(g,x,m,v,d[15],4264355552,10),v=b(v,g,x,m,d[6],2734768916,15),m=b(m,v,g,x,d[13],1309151649,21),x=b(x,m,v,g,d[4],4149444226,6),g=b(g,x,m,v,d[11],3174756917,10),v=b(v,g,x,m,d[2],718787259,15),m=b(m,v,g,x,d[9],3951481745,21),this._a=this._a+x|0,this._b=this._b+m|0,this._c=this._c+v|0,this._d=this._d+g|0},c.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var d=n.allocUnsafe(16);return d.writeInt32LE(this._a,0),d.writeInt32LE(this._b,4),d.writeInt32LE(this._c,8),d.writeInt32LE(this._d,12),d};function o(d,p){return d<<p|d>>>32-p}function u(d,p,x,m,v,g,$){return o(d+(p&x|~p&m)+v+g|0,$)+p|0}function h(d,p,x,m,v,g,$){return o(d+(p&m|x&~m)+v+g|0,$)+p|0}function l(d,p,x,m,v,g,$){return o(d+(p^x^m)+v+g|0,$)+p|0}function b(d,p,x,m,v,g,$){return o(d+(x^(p|~m))+v+g|0,$)+p|0}return md5_js=c,md5_js}var ripemd160,hasRequiredRipemd160;function requireRipemd160(){if(hasRequiredRipemd160)return ripemd160;hasRequiredRipemd160=1;var t=require$$1$2.Buffer,e=inherits_browserExports,n=requireHashBase(),a=new Array(16),c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],h=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],b=[1352829926,1548603684,1836072691,2053994217,0];function d(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}e(d,n),d.prototype._update=function(){for(var B=a,C=0;C<16;++C)B[C]=this._block.readInt32LE(C*4);for(var F=this._a|0,H=this._b|0,W=this._c|0,Z=this._d|0,ie=this._e|0,te=this._a|0,ae=this._b|0,de=this._c|0,J=this._d|0,R=this._e|0,A=0;A<80;A+=1){var y,w;A<16?(y=x(F,H,W,Z,ie,B[c[A]],l[0],u[A]),w=$(te,ae,de,J,R,B[o[A]],b[0],h[A])):A<32?(y=m(F,H,W,Z,ie,B[c[A]],l[1],u[A]),w=g(te,ae,de,J,R,B[o[A]],b[1],h[A])):A<48?(y=v(F,H,W,Z,ie,B[c[A]],l[2],u[A]),w=v(te,ae,de,J,R,B[o[A]],b[2],h[A])):A<64?(y=g(F,H,W,Z,ie,B[c[A]],l[3],u[A]),w=m(te,ae,de,J,R,B[o[A]],b[3],h[A])):(y=$(F,H,W,Z,ie,B[c[A]],l[4],u[A]),w=x(te,ae,de,J,R,B[o[A]],b[4],h[A])),F=ie,ie=Z,Z=p(W,10),W=H,H=y,te=R,R=J,J=p(de,10),de=ae,ae=w}var I=this._b+W+J|0;this._b=this._c+Z+R|0,this._c=this._d+ie+te|0,this._d=this._e+F+ae|0,this._e=this._a+H+de|0,this._a=I},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var B=t.alloc?t.alloc(20):new t(20);return B.writeInt32LE(this._a,0),B.writeInt32LE(this._b,4),B.writeInt32LE(this._c,8),B.writeInt32LE(this._d,12),B.writeInt32LE(this._e,16),B};function p(B,C){return B<<C|B>>>32-C}function x(B,C,F,H,W,Z,ie,te){return p(B+(C^F^H)+Z+ie|0,te)+W|0}function m(B,C,F,H,W,Z,ie,te){return p(B+(C&F|~C&H)+Z+ie|0,te)+W|0}function v(B,C,F,H,W,Z,ie,te){return p(B+((C|~F)^H)+Z+ie|0,te)+W|0}function g(B,C,F,H,W,Z,ie,te){return p(B+(C&H|F&~H)+Z+ie|0,te)+W|0}function $(B,C,F,H,W,Z,ie,te){return p(B+(C^(F|~H))+Z+ie|0,te)+W|0}return ripemd160=d,ripemd160}var sha_js={exports:{}},hash$3,hasRequiredHash;function requireHash(){if(hasRequiredHash)return hash$3;hasRequiredHash=1;var t=requireSafeBuffer$1().Buffer;function e(n,a){this._block=t.alloc(n),this._finalSize=a,this._blockSize=n,this._len=0}return e.prototype.update=function(n,a){typeof n=="string"&&(a=a||"utf8",n=t.from(n,a));for(var c=this._block,o=this._blockSize,u=n.length,h=this._len,l=0;l<u;){for(var b=h%o,d=Math.min(u-l,o-b),p=0;p<d;p++)c[b+p]=n[l+p];h+=d,l+=d,h%o===0&&this._update(c)}return this._len+=u,this},e.prototype.digest=function(n){var a=this._len%this._blockSize;this._block[a]=128,this._block.fill(0,a+1),a>=this._finalSize&&(this._update(this._block),this._block.fill(0));var c=this._len*8;if(c<=4294967295)this._block.writeUInt32BE(c,this._blockSize-4);else{var o=(c&4294967295)>>>0,u=(c-o)/4294967296;this._block.writeUInt32BE(u,this._blockSize-8),this._block.writeUInt32BE(o,this._blockSize-4)}this._update(this._block);var h=this._hash();return n?h.toString(n):h},e.prototype._update=function(){throw new Error("_update must be implemented by subclass")},hash$3=e,hash$3}var sha$1,hasRequiredSha;function requireSha(){if(hasRequiredSha)return sha$1;hasRequiredSha=1;var t=inherits_browserExports,e=requireHash(),n=requireSafeBuffer$1().Buffer,a=[1518500249,1859775393,-1894007588,-899497514],c=new Array(80);function o(){this.init(),this._w=c,e.call(this,64,56)}t(o,e),o.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function u(b){return b<<5|b>>>27}function h(b){return b<<30|b>>>2}function l(b,d,p,x){return b===0?d&p|~d&x:b===2?d&p|d&x|p&x:d^p^x}return o.prototype._update=function(b){for(var d=this._w,p=this._a|0,x=this._b|0,m=this._c|0,v=this._d|0,g=this._e|0,$=0;$<16;++$)d[$]=b.readInt32BE($*4);for(;$<80;++$)d[$]=d[$-3]^d[$-8]^d[$-14]^d[$-16];for(var B=0;B<80;++B){var C=~~(B/20),F=u(p)+l(C,x,m,v)+g+d[B]+a[C]|0;g=v,v=m,m=h(x),x=p,p=F}this._a=p+this._a|0,this._b=x+this._b|0,this._c=m+this._c|0,this._d=v+this._d|0,this._e=g+this._e|0},o.prototype._hash=function(){var b=n.allocUnsafe(20);return b.writeInt32BE(this._a|0,0),b.writeInt32BE(this._b|0,4),b.writeInt32BE(this._c|0,8),b.writeInt32BE(this._d|0,12),b.writeInt32BE(this._e|0,16),b},sha$1=o,sha$1}var sha1,hasRequiredSha1;function requireSha1(){if(hasRequiredSha1)return sha1;hasRequiredSha1=1;var t=inherits_browserExports,e=requireHash(),n=requireSafeBuffer$1().Buffer,a=[1518500249,1859775393,-1894007588,-899497514],c=new Array(80);function o(){this.init(),this._w=c,e.call(this,64,56)}t(o,e),o.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function u(d){return d<<1|d>>>31}function h(d){return d<<5|d>>>27}function l(d){return d<<30|d>>>2}function b(d,p,x,m){return d===0?p&x|~p&m:d===2?p&x|p&m|x&m:p^x^m}return o.prototype._update=function(d){for(var p=this._w,x=this._a|0,m=this._b|0,v=this._c|0,g=this._d|0,$=this._e|0,B=0;B<16;++B)p[B]=d.readInt32BE(B*4);for(;B<80;++B)p[B]=u(p[B-3]^p[B-8]^p[B-14]^p[B-16]);for(var C=0;C<80;++C){var F=~~(C/20),H=h(x)+b(F,m,v,g)+$+p[C]+a[F]|0;$=g,g=v,v=l(m),m=x,x=H}this._a=x+this._a|0,this._b=m+this._b|0,this._c=v+this._c|0,this._d=g+this._d|0,this._e=$+this._e|0},o.prototype._hash=function(){var d=n.allocUnsafe(20);return d.writeInt32BE(this._a|0,0),d.writeInt32BE(this._b|0,4),d.writeInt32BE(this._c|0,8),d.writeInt32BE(this._d|0,12),d.writeInt32BE(this._e|0,16),d},sha1=o,sha1}var sha256$1,hasRequiredSha256;function requireSha256(){if(hasRequiredSha256)return sha256$1;hasRequiredSha256=1;var t=inherits_browserExports,e=requireHash(),n=requireSafeBuffer$1().Buffer,a=[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],c=new Array(64);function o(){this.init(),this._w=c,e.call(this,64,56)}t(o,e),o.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function u(x,m,v){return v^x&(m^v)}function h(x,m,v){return x&m|v&(x|m)}function l(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function b(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function d(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function p(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}return o.prototype._update=function(x){for(var m=this._w,v=this._a|0,g=this._b|0,$=this._c|0,B=this._d|0,C=this._e|0,F=this._f|0,H=this._g|0,W=this._h|0,Z=0;Z<16;++Z)m[Z]=x.readInt32BE(Z*4);for(;Z<64;++Z)m[Z]=p(m[Z-2])+m[Z-7]+d(m[Z-15])+m[Z-16]|0;for(var ie=0;ie<64;++ie){var te=W+b(C)+u(C,F,H)+a[ie]+m[ie]|0,ae=l(v)+h(v,g,$)|0;W=H,H=F,F=C,C=B+te|0,B=$,$=g,g=v,v=te+ae|0}this._a=v+this._a|0,this._b=g+this._b|0,this._c=$+this._c|0,this._d=B+this._d|0,this._e=C+this._e|0,this._f=F+this._f|0,this._g=H+this._g|0,this._h=W+this._h|0},o.prototype._hash=function(){var x=n.allocUnsafe(32);return x.writeInt32BE(this._a,0),x.writeInt32BE(this._b,4),x.writeInt32BE(this._c,8),x.writeInt32BE(this._d,12),x.writeInt32BE(this._e,16),x.writeInt32BE(this._f,20),x.writeInt32BE(this._g,24),x.writeInt32BE(this._h,28),x},sha256$1=o,sha256$1}var sha224$1,hasRequiredSha224;function requireSha224(){if(hasRequiredSha224)return sha224$1;hasRequiredSha224=1;var t=inherits_browserExports,e=requireSha256(),n=requireHash(),a=requireSafeBuffer$1().Buffer,c=new Array(64);function o(){this.init(),this._w=c,n.call(this,64,56)}return t(o,e),o.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},o.prototype._hash=function(){var u=a.allocUnsafe(28);return u.writeInt32BE(this._a,0),u.writeInt32BE(this._b,4),u.writeInt32BE(this._c,8),u.writeInt32BE(this._d,12),u.writeInt32BE(this._e,16),u.writeInt32BE(this._f,20),u.writeInt32BE(this._g,24),u},sha224$1=o,sha224$1}var sha512$1,hasRequiredSha512;function requireSha512(){if(hasRequiredSha512)return sha512$1;hasRequiredSha512=1;var t=inherits_browserExports,e=requireHash(),n=requireSafeBuffer$1().Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],c=new Array(160);function o(){this.init(),this._w=c,e.call(this,128,112)}t(o,e),o.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function u(g,$,B){return B^g&($^B)}function h(g,$,B){return g&$|B&(g|$)}function l(g,$){return(g>>>28|$<<4)^($>>>2|g<<30)^($>>>7|g<<25)}function b(g,$){return(g>>>14|$<<18)^(g>>>18|$<<14)^($>>>9|g<<23)}function d(g,$){return(g>>>1|$<<31)^(g>>>8|$<<24)^g>>>7}function p(g,$){return(g>>>1|$<<31)^(g>>>8|$<<24)^(g>>>7|$<<25)}function x(g,$){return(g>>>19|$<<13)^($>>>29|g<<3)^g>>>6}function m(g,$){return(g>>>19|$<<13)^($>>>29|g<<3)^(g>>>6|$<<26)}function v(g,$){return g>>>0<$>>>0?1:0}return o.prototype._update=function(g){for(var $=this._w,B=this._ah|0,C=this._bh|0,F=this._ch|0,H=this._dh|0,W=this._eh|0,Z=this._fh|0,ie=this._gh|0,te=this._hh|0,ae=this._al|0,de=this._bl|0,J=this._cl|0,R=this._dl|0,A=this._el|0,y=this._fl|0,w=this._gl|0,I=this._hl|0,M=0;M<32;M+=2)$[M]=g.readInt32BE(M*4),$[M+1]=g.readInt32BE(M*4+4);for(;M<160;M+=2){var k=$[M-30],P=$[M-15*2+1],_=d(k,P),q=p(P,k);k=$[M-2*2],P=$[M-2*2+1];var E=x(k,P),j=m(P,k),ee=$[M-7*2],oe=$[M-7*2+1],Y=$[M-16*2],L=$[M-16*2+1],z=q+oe|0,re=_+ee+v(z,q)|0;z=z+j|0,re=re+E+v(z,j)|0,z=z+L|0,re=re+Y+v(z,L)|0,$[M]=re,$[M+1]=z}for(var D=0;D<160;D+=2){re=$[D],z=$[D+1];var G=h(B,C,F),U=h(ae,de,J),Q=l(B,ae),fe=l(ae,B),he=b(W,A),le=b(A,W),pe=a[D],be=a[D+1],se=u(W,Z,ie),ge=u(A,y,w),ye=I+le|0,$e=te+he+v(ye,I)|0;ye=ye+ge|0,$e=$e+se+v(ye,ge)|0,ye=ye+be|0,$e=$e+pe+v(ye,be)|0,ye=ye+z|0,$e=$e+re+v(ye,z)|0;var Ne=fe+U|0,ve=Q+G+v(Ne,fe)|0;te=ie,I=w,ie=Z,w=y,Z=W,y=A,A=R+ye|0,W=H+$e+v(A,R)|0,H=F,R=J,F=C,J=de,C=B,de=ae,ae=ye+Ne|0,B=$e+ve+v(ae,ye)|0}this._al=this._al+ae|0,this._bl=this._bl+de|0,this._cl=this._cl+J|0,this._dl=this._dl+R|0,this._el=this._el+A|0,this._fl=this._fl+y|0,this._gl=this._gl+w|0,this._hl=this._hl+I|0,this._ah=this._ah+B+v(this._al,ae)|0,this._bh=this._bh+C+v(this._bl,de)|0,this._ch=this._ch+F+v(this._cl,J)|0,this._dh=this._dh+H+v(this._dl,R)|0,this._eh=this._eh+W+v(this._el,A)|0,this._fh=this._fh+Z+v(this._fl,y)|0,this._gh=this._gh+ie+v(this._gl,w)|0,this._hh=this._hh+te+v(this._hl,I)|0},o.prototype._hash=function(){var g=n.allocUnsafe(64);function $(B,C,F){g.writeInt32BE(B,F),g.writeInt32BE(C,F+4)}return $(this._ah,this._al,0),$(this._bh,this._bl,8),$(this._ch,this._cl,16),$(this._dh,this._dl,24),$(this._eh,this._el,32),$(this._fh,this._fl,40),$(this._gh,this._gl,48),$(this._hh,this._hl,56),g},sha512$1=o,sha512$1}var sha384$1,hasRequiredSha384;function requireSha384(){if(hasRequiredSha384)return sha384$1;hasRequiredSha384=1;var t=inherits_browserExports,e=requireSha512(),n=requireHash(),a=requireSafeBuffer$1().Buffer,c=new Array(160);function o(){this.init(),this._w=c,n.call(this,128,112)}return t(o,e),o.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},o.prototype._hash=function(){var u=a.allocUnsafe(48);function h(l,b,d){u.writeInt32BE(l,d),u.writeInt32BE(b,d+4)}return h(this._ah,this._al,0),h(this._bh,this._bl,8),h(this._ch,this._cl,16),h(this._dh,this._dl,24),h(this._eh,this._el,32),h(this._fh,this._fl,40),u},sha384$1=o,sha384$1}var hasRequiredSha_js;function requireSha_js(){if(hasRequiredSha_js)return sha_js.exports;hasRequiredSha_js=1;var t=sha_js.exports=function(n){n=n.toLowerCase();var a=t[n];if(!a)throw new Error(n+" is not supported (we accept pull requests)");return new a};return t.sha=requireSha(),t.sha1=requireSha1(),t.sha224=requireSha224(),t.sha256=requireSha256(),t.sha384=requireSha384(),t.sha512=requireSha512(),sha_js.exports}var streamBrowserify,hasRequiredStreamBrowserify;function requireStreamBrowserify(){if(hasRequiredStreamBrowserify)return streamBrowserify;hasRequiredStreamBrowserify=1,streamBrowserify=n;var t=requireEvents().EventEmitter,e=inherits_browserExports;e(n,t),n.Readable=require_stream_readable$1(),n.Writable=require_stream_writable$1(),n.Duplex=require_stream_duplex$1(),n.Transform=require_stream_transform$1(),n.PassThrough=require_stream_passthrough$1(),n.finished=requireEndOfStream(),n.pipeline=requirePipeline(),n.Stream=n;function n(){t.call(this)}return n.prototype.pipe=function(a,c){var o=this;function u(m){a.writable&&a.write(m)===!1&&o.pause&&o.pause()}o.on("data",u);function h(){o.readable&&o.resume&&o.resume()}a.on("drain",h),!a._isStdio&&(!c||c.end!==!1)&&(o.on("end",b),o.on("close",d));var l=!1;function b(){l||(l=!0,a.end())}function d(){l||(l=!0,typeof a.destroy=="function"&&a.destroy())}function p(m){if(x(),t.listenerCount(this,"error")===0)throw m}o.on("error",p),a.on("error",p);function x(){o.removeListener("data",u),a.removeListener("drain",h),o.removeListener("end",b),o.removeListener("close",d),o.removeListener("error",p),a.removeListener("error",p),o.removeListener("end",x),o.removeListener("close",x),a.removeListener("close",x)}return o.on("end",x),o.on("close",x),a.on("close",x),a.emit("pipe",o),a},streamBrowserify}var cipherBase,hasRequiredCipherBase;function requireCipherBase(){if(hasRequiredCipherBase)return cipherBase;hasRequiredCipherBase=1;var t=requireSafeBuffer$1().Buffer,e=requireStreamBrowserify().Transform,n=requireString_decoder().StringDecoder,a=inherits_browserExports;function c(o){e.call(this),this.hashMode=typeof o=="string",this.hashMode?this[o]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}return a(c,e),c.prototype.update=function(o,u,h){typeof o=="string"&&(o=t.from(o,u));var l=this._update(o);return this.hashMode?this:(h&&(l=this._toString(l,h)),l)},c.prototype.setAutoPadding=function(){},c.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},c.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},c.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},c.prototype._transform=function(o,u,h){var l;try{this.hashMode?this._update(o):this.push(this._update(o))}catch(b){l=b}finally{h(l)}},c.prototype._flush=function(o){var u;try{this.push(this.__final())}catch(h){u=h}o(u)},c.prototype._finalOrDigest=function(o){var u=this.__final()||t.alloc(0);return o&&(u=this._toString(u,o,!0)),u},c.prototype._toString=function(o,u,h){if(this._decoder||(this._decoder=new n(u),this._encoding=u),this._encoding!==u)throw new Error("can't switch encodings");var l=this._decoder.write(o);return h&&(l+=this._decoder.end()),l},cipherBase=c,cipherBase}var browser$9,hasRequiredBrowser$9;function requireBrowser$9(){if(hasRequiredBrowser$9)return browser$9;hasRequiredBrowser$9=1;var t=inherits_browserExports,e=requireMd5_js(),n=requireRipemd160(),a=requireSha_js(),c=requireCipherBase();function o(u){c.call(this,"digest"),this._hash=u}return t(o,c),o.prototype._update=function(u){this._hash.update(u)},o.prototype._final=function(){return this._hash.digest()},browser$9=function(h){return h=h.toLowerCase(),h==="md5"?new e:h==="rmd160"||h==="ripemd160"?new n:new o(a(h))},browser$9}var legacy,hasRequiredLegacy;function requireLegacy(){if(hasRequiredLegacy)return legacy;hasRequiredLegacy=1;var t=inherits_browserExports,e=requireSafeBuffer$1().Buffer,n=requireCipherBase(),a=e.alloc(128),c=64;function o(u,h){n.call(this,"digest"),typeof h=="string"&&(h=e.from(h)),this._alg=u,this._key=h,h.length>c?h=u(h):h.length<c&&(h=e.concat([h,a],c));for(var l=this._ipad=e.allocUnsafe(c),b=this._opad=e.allocUnsafe(c),d=0;d<c;d++)l[d]=h[d]^54,b[d]=h[d]^92;this._hash=[l]}return t(o,n),o.prototype._update=function(u){this._hash.push(u)},o.prototype._final=function(){var u=this._alg(e.concat(this._hash));return this._alg(e.concat([this._opad,u]))},legacy=o,legacy}var md5,hasRequiredMd5;function requireMd5(){if(hasRequiredMd5)return md5;hasRequiredMd5=1;var t=requireMd5_js();return md5=function(e){return new t().update(e).digest()},md5}var browser$8,hasRequiredBrowser$8;function requireBrowser$8(){if(hasRequiredBrowser$8)return browser$8;hasRequiredBrowser$8=1;var t=inherits_browserExports,e=requireLegacy(),n=requireCipherBase(),a=requireSafeBuffer$1().Buffer,c=requireMd5(),o=requireRipemd160(),u=requireSha_js(),h=a.alloc(128);function l(b,d){n.call(this,"digest"),typeof d=="string"&&(d=a.from(d));var p=b==="sha512"||b==="sha384"?128:64;if(this._alg=b,this._key=d,d.length>p){var x=b==="rmd160"?new o:u(b);d=x.update(d).digest()}else d.length<p&&(d=a.concat([d,h],p));for(var m=this._ipad=a.allocUnsafe(p),v=this._opad=a.allocUnsafe(p),g=0;g<p;g++)m[g]=d[g]^54,v[g]=d[g]^92;this._hash=b==="rmd160"?new o:u(b),this._hash.update(m)}return t(l,n),l.prototype._update=function(b){this._hash.update(b)},l.prototype._final=function(){var b=this._hash.digest(),d=this._alg==="rmd160"?new o:u(this._alg);return d.update(this._opad).update(b).digest()},browser$8=function(d,p){return d=d.toLowerCase(),d==="rmd160"||d==="ripemd160"?new l("rmd160",p):d==="md5"?new e(c,p):new l(d,p)},browser$8}const sha224WithRSAEncryption={sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption={sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption={sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption={sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},sha256={sign:"ecdsa",hash:"sha256",id:""},sha224={sign:"ecdsa",hash:"sha224",id:""},sha384={sign:"ecdsa",hash:"sha384",id:""},sha512={sign:"ecdsa",hash:"sha512",id:""},DSA={sign:"dsa",hash:"sha1",id:""},ripemd160WithRSA={sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption={sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},require$$6={sha224WithRSAEncryption,"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption,"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption,"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption,"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256,sha224,sha384,sha512,"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA,"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA,"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption,"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}};var algos,hasRequiredAlgos;function requireAlgos(){return hasRequiredAlgos||(hasRequiredAlgos=1,algos=require$$6),algos}var browser$7={},precondition,hasRequiredPrecondition;function requirePrecondition(){if(hasRequiredPrecondition)return precondition;hasRequiredPrecondition=1;var t=Math.pow(2,30)-1;return precondition=function(e,n){if(typeof e!="number")throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if(typeof n!="number")throw new TypeError("Key length not a number");if(n<0||n>t||n!==n)throw new TypeError("Bad key length")},precondition}var defaultEncoding_1,hasRequiredDefaultEncoding;function requireDefaultEncoding(){if(hasRequiredDefaultEncoding)return defaultEncoding_1;hasRequiredDefaultEncoding=1;var t;if(commonjsGlobal.process&&commonjsGlobal.process.browser)t="utf-8";else if(commonjsGlobal.process&&commonjsGlobal.process.version){var e=parseInt(process$1.version.split(".")[0].slice(1),10);t=e>=6?"utf-8":"binary"}else t="utf-8";return defaultEncoding_1=t,defaultEncoding_1}var toBuffer,hasRequiredToBuffer;function requireToBuffer(){if(hasRequiredToBuffer)return toBuffer;hasRequiredToBuffer=1;var t=requireSafeBuffer$1().Buffer;return toBuffer=function(e,n,a){if(t.isBuffer(e))return e;if(typeof e=="string")return t.from(e,n);if(ArrayBuffer.isView(e))return t.from(e.buffer);throw new TypeError(a+" must be a string, a Buffer, a typed array or a DataView")},toBuffer}var syncBrowser,hasRequiredSyncBrowser;function requireSyncBrowser(){if(hasRequiredSyncBrowser)return syncBrowser;hasRequiredSyncBrowser=1;var t=requireMd5(),e=requireRipemd160(),n=requireSha_js(),a=requireSafeBuffer$1().Buffer,c=requirePrecondition(),o=requireDefaultEncoding(),u=requireToBuffer(),h=a.alloc(128),l={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function b(x,m,v){var g=d(x),$=x==="sha512"||x==="sha384"?128:64;m.length>$?m=g(m):m.length<$&&(m=a.concat([m,h],$));for(var B=a.allocUnsafe($+l[x]),C=a.allocUnsafe($+l[x]),F=0;F<$;F++)B[F]=m[F]^54,C[F]=m[F]^92;var H=a.allocUnsafe($+v+4);B.copy(H,0,0,$),this.ipad1=H,this.ipad2=B,this.opad=C,this.alg=x,this.blocksize=$,this.hash=g,this.size=l[x]}b.prototype.run=function(x,m){x.copy(m,this.blocksize);var v=this.hash(m);return v.copy(this.opad,this.blocksize),this.hash(this.opad)};function d(x){function m(g){return n(x).update(g).digest()}function v(g){return new e().update(g).digest()}return x==="rmd160"||x==="ripemd160"?v:x==="md5"?t:m}function p(x,m,v,g,$){c(v,g),x=u(x,o,"Password"),m=u(m,o,"Salt"),$=$||"sha1";var B=new b($,x,m.length),C=a.allocUnsafe(g),F=a.allocUnsafe(m.length+4);m.copy(F,0,0,m.length);for(var H=0,W=l[$],Z=Math.ceil(g/W),ie=1;ie<=Z;ie++){F.writeUInt32BE(ie,m.length);for(var te=B.run(F,B.ipad1),ae=te,de=1;de<v;de++){ae=B.run(ae,B.ipad2);for(var J=0;J<W;J++)te[J]^=ae[J]}te.copy(C,H),H+=W}return C}return syncBrowser=p,syncBrowser}var async,hasRequiredAsync;function requireAsync(){if(hasRequiredAsync)return async;hasRequiredAsync=1;var t=requireSafeBuffer$1().Buffer,e=requirePrecondition(),n=requireDefaultEncoding(),a=requireSyncBrowser(),c=requireToBuffer(),o,u=commonjsGlobal.crypto&&commonjsGlobal.crypto.subtle,h={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},l=[];function b(v){if(commonjsGlobal.process&&!commonjsGlobal.process.browser||!u||!u.importKey||!u.deriveBits)return Promise.resolve(!1);if(l[v]!==void 0)return l[v];o=o||t.alloc(8);var g=x(o,o,10,128,v).then(function(){return!0}).catch(function(){return!1});return l[v]=g,g}var d;function p(){return d||(commonjsGlobal.process&&commonjsGlobal.process.nextTick?d=commonjsGlobal.process.nextTick:commonjsGlobal.queueMicrotask?d=commonjsGlobal.queueMicrotask:commonjsGlobal.setImmediate?d=commonjsGlobal.setImmediate:d=commonjsGlobal.setTimeout,d)}function x(v,g,$,B,C){return u.importKey("raw",v,{name:"PBKDF2"},!1,["deriveBits"]).then(function(F){return u.deriveBits({name:"PBKDF2",salt:g,iterations:$,hash:{name:C}},F,B<<3)}).then(function(F){return t.from(F)})}function m(v,g){v.then(function($){p()(function(){g(null,$)})},function($){p()(function(){g($)})})}return async=function(v,g,$,B,C,F){typeof C=="function"&&(F=C,C=void 0),C=C||"sha1";var H=h[C.toLowerCase()];if(!H||typeof commonjsGlobal.Promise!="function"){p()(function(){var W;try{W=a(v,g,$,B,C)}catch(Z){return F(Z)}F(null,W)});return}if(e($,B),v=c(v,n,"Password"),g=c(g,n,"Salt"),typeof F!="function")throw new Error("No callback provided to pbkdf2");m(b(H).then(function(W){return W?x(v,g,$,B,H):a(v,g,$,B,C)}),F)},async}var hasRequiredBrowser$7;function requireBrowser$7(){return hasRequiredBrowser$7||(hasRequiredBrowser$7=1,browser$7.pbkdf2=requireAsync(),browser$7.pbkdf2Sync=requireSyncBrowser()),browser$7}var browser$6={},des$1={},utils$m={},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils$m;hasRequiredUtils=1,utils$m.readUInt32BE=function(c,o){var u=c[0+o]<<24|c[1+o]<<16|c[2+o]<<8|c[3+o];return u>>>0},utils$m.writeUInt32BE=function(c,o,u){c[0+u]=o>>>24,c[1+u]=o>>>16&255,c[2+u]=o>>>8&255,c[3+u]=o&255},utils$m.ip=function(c,o,u,h){for(var l=0,b=0,d=6;d>=0;d-=2){for(var p=0;p<=24;p+=8)l<<=1,l|=o>>>p+d&1;for(var p=0;p<=24;p+=8)l<<=1,l|=c>>>p+d&1}for(var d=6;d>=0;d-=2){for(var p=1;p<=25;p+=8)b<<=1,b|=o>>>p+d&1;for(var p=1;p<=25;p+=8)b<<=1,b|=c>>>p+d&1}u[h+0]=l>>>0,u[h+1]=b>>>0},utils$m.rip=function(c,o,u,h){for(var l=0,b=0,d=0;d<4;d++)for(var p=24;p>=0;p-=8)l<<=1,l|=o>>>p+d&1,l<<=1,l|=c>>>p+d&1;for(var d=4;d<8;d++)for(var p=24;p>=0;p-=8)b<<=1,b|=o>>>p+d&1,b<<=1,b|=c>>>p+d&1;u[h+0]=l>>>0,u[h+1]=b>>>0},utils$m.pc1=function(c,o,u,h){for(var l=0,b=0,d=7;d>=5;d--){for(var p=0;p<=24;p+=8)l<<=1,l|=o>>p+d&1;for(var p=0;p<=24;p+=8)l<<=1,l|=c>>p+d&1}for(var p=0;p<=24;p+=8)l<<=1,l|=o>>p+d&1;for(var d=1;d<=3;d++){for(var p=0;p<=24;p+=8)b<<=1,b|=o>>p+d&1;for(var p=0;p<=24;p+=8)b<<=1,b|=c>>p+d&1}for(var p=0;p<=24;p+=8)b<<=1,b|=c>>p+d&1;u[h+0]=l>>>0,u[h+1]=b>>>0},utils$m.r28shl=function(c,o){return c<<o&268435455|c>>>28-o};var t=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];utils$m.pc2=function(c,o,u,h){for(var l=0,b=0,d=t.length>>>1,p=0;p<d;p++)l<<=1,l|=c>>>t[p]&1;for(var p=d;p<t.length;p++)b<<=1,b|=o>>>t[p]&1;u[h+0]=l>>>0,u[h+1]=b>>>0},utils$m.expand=function(c,o,u){var h=0,l=0;h=(c&1)<<5|c>>>27;for(var b=23;b>=15;b-=4)h<<=6,h|=c>>>b&63;for(var b=11;b>=3;b-=4)l|=c>>>b&63,l<<=6;l|=(c&31)<<1|c>>>31,o[u+0]=h>>>0,o[u+1]=l>>>0};var e=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];utils$m.substitute=function(c,o){for(var u=0,h=0;h<4;h++){var l=c>>>18-h*6&63,b=e[h*64+l];u<<=4,u|=b}for(var h=0;h<4;h++){var l=o>>>18-h*6&63,b=e[4*64+h*64+l];u<<=4,u|=b}return u>>>0};var n=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];return utils$m.permute=function(c){for(var o=0,u=0;u<n.length;u++)o<<=1,o|=c>>>n[u]&1;return o>>>0},utils$m.padSplit=function(c,o,u){for(var h=c.toString(2);h.length<o;)h="0"+h;for(var l=[],b=0;b<o;b+=u)l.push(h.slice(b,b+u));return l.join(" ")},utils$m}var cipher,hasRequiredCipher;function requireCipher(){if(hasRequiredCipher)return cipher;hasRequiredCipher=1;var t=minimalisticAssert;function e(n){this.options=n,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=n.padding!==!1}return cipher=e,e.prototype._init=function(){},e.prototype.update=function(a){return a.length===0?[]:this.type==="decrypt"?this._updateDecrypt(a):this._updateEncrypt(a)},e.prototype._buffer=function(a,c){for(var o=Math.min(this.buffer.length-this.bufferOff,a.length-c),u=0;u<o;u++)this.buffer[this.bufferOff+u]=a[c+u];return this.bufferOff+=o,o},e.prototype._flushBuffer=function(a,c){return this._update(this.buffer,0,a,c),this.bufferOff=0,this.blockSize},e.prototype._updateEncrypt=function(a){var c=0,o=0,u=(this.bufferOff+a.length)/this.blockSize|0,h=new Array(u*this.blockSize);this.bufferOff!==0&&(c+=this._buffer(a,c),this.bufferOff===this.buffer.length&&(o+=this._flushBuffer(h,o)));for(var l=a.length-(a.length-c)%this.blockSize;c<l;c+=this.blockSize)this._update(a,c,h,o),o+=this.blockSize;for(;c<a.length;c++,this.bufferOff++)this.buffer[this.bufferOff]=a[c];return h},e.prototype._updateDecrypt=function(a){for(var c=0,o=0,u=Math.ceil((this.bufferOff+a.length)/this.blockSize)-1,h=new Array(u*this.blockSize);u>0;u--)c+=this._buffer(a,c),o+=this._flushBuffer(h,o);return c+=this._buffer(a,c),h},e.prototype.final=function(a){var c;a&&(c=this.update(a));var o;return this.type==="encrypt"?o=this._finalEncrypt():o=this._finalDecrypt(),c?c.concat(o):o},e.prototype._pad=function(a,c){if(c===0)return!1;for(;c<a.length;)a[c++]=0;return!0},e.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var a=new Array(this.blockSize);return this._update(this.buffer,0,a,0),a},e.prototype._unpad=function(a){return a},e.prototype._finalDecrypt=function(){t.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var a=new Array(this.blockSize);return this._flushBuffer(a,0),this._unpad(a)},cipher}var des,hasRequiredDes$1;function requireDes$1(){if(hasRequiredDes$1)return des;hasRequiredDes$1=1;var t=minimalisticAssert,e=inherits_browserExports,n=requireUtils(),a=requireCipher();function c(){this.tmp=new Array(2),this.keys=null}function o(h){a.call(this,h);var l=new c;this._desState=l,this.deriveKeys(l,h.key)}e(o,a),des=o,o.create=function(l){return new o(l)};var u=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];return o.prototype.deriveKeys=function(l,b){l.keys=new Array(16*2),t.equal(b.length,this.blockSize,"Invalid key length");var d=n.readUInt32BE(b,0),p=n.readUInt32BE(b,4);n.pc1(d,p,l.tmp,0),d=l.tmp[0],p=l.tmp[1];for(var x=0;x<l.keys.length;x+=2){var m=u[x>>>1];d=n.r28shl(d,m),p=n.r28shl(p,m),n.pc2(d,p,l.keys,x)}},o.prototype._update=function(l,b,d,p){var x=this._desState,m=n.readUInt32BE(l,b),v=n.readUInt32BE(l,b+4);n.ip(m,v,x.tmp,0),m=x.tmp[0],v=x.tmp[1],this.type==="encrypt"?this._encrypt(x,m,v,x.tmp,0):this._decrypt(x,m,v,x.tmp,0),m=x.tmp[0],v=x.tmp[1],n.writeUInt32BE(d,m,p),n.writeUInt32BE(d,v,p+4)},o.prototype._pad=function(l,b){if(this.padding===!1)return!1;for(var d=l.length-b,p=b;p<l.length;p++)l[p]=d;return!0},o.prototype._unpad=function(l){if(this.padding===!1)return l;for(var b=l[l.length-1],d=l.length-b;d<l.length;d++)t.equal(l[d],b);return l.slice(0,l.length-b)},o.prototype._encrypt=function(l,b,d,p,x){for(var m=b,v=d,g=0;g<l.keys.length;g+=2){var $=l.keys[g],B=l.keys[g+1];n.expand(v,l.tmp,0),$^=l.tmp[0],B^=l.tmp[1];var C=n.substitute($,B),F=n.permute(C),H=v;v=(m^F)>>>0,m=H}n.rip(v,m,p,x)},o.prototype._decrypt=function(l,b,d,p,x){for(var m=d,v=b,g=l.keys.length-2;g>=0;g-=2){var $=l.keys[g],B=l.keys[g+1];n.expand(m,l.tmp,0),$^=l.tmp[0],B^=l.tmp[1];var C=n.substitute($,B),F=n.permute(C),H=m;m=(v^F)>>>0,v=H}n.rip(m,v,p,x)},des}var cbc$1={},hasRequiredCbc$1;function requireCbc$1(){if(hasRequiredCbc$1)return cbc$1;hasRequiredCbc$1=1;var t=minimalisticAssert,e=inherits_browserExports,n={};function a(o){t.equal(o.length,8,"Invalid IV length"),this.iv=new Array(8);for(var u=0;u<this.iv.length;u++)this.iv[u]=o[u]}function c(o){function u(d){o.call(this,d),this._cbcInit()}e(u,o);for(var h=Object.keys(n),l=0;l<h.length;l++){var b=h[l];u.prototype[b]=n[b]}return u.create=function(p){return new u(p)},u}return cbc$1.instantiate=c,n._cbcInit=function(){var u=new a(this.options.iv);this._cbcState=u},n._update=function(u,h,l,b){var d=this._cbcState,p=this.constructor.super_.prototype,x=d.iv;if(this.type==="encrypt"){for(var m=0;m<this.blockSize;m++)x[m]^=u[h+m];p._update.call(this,x,0,l,b);for(var m=0;m<this.blockSize;m++)x[m]=l[b+m]}else{p._update.call(this,u,h,l,b);for(var m=0;m<this.blockSize;m++)l[b+m]^=x[m];for(var m=0;m<this.blockSize;m++)x[m]=u[h+m]}},cbc$1}var ede,hasRequiredEde;function requireEde(){if(hasRequiredEde)return ede;hasRequiredEde=1;var t=minimalisticAssert,e=inherits_browserExports,n=requireCipher(),a=requireDes$1();function c(u,h){t.equal(h.length,24,"Invalid key length");var l=h.slice(0,8),b=h.slice(8,16),d=h.slice(16,24);u==="encrypt"?this.ciphers=[a.create({type:"encrypt",key:l}),a.create({type:"decrypt",key:b}),a.create({type:"encrypt",key:d})]:this.ciphers=[a.create({type:"decrypt",key:d}),a.create({type:"encrypt",key:b}),a.create({type:"decrypt",key:l})]}function o(u){n.call(this,u);var h=new c(this.type,this.options.key);this._edeState=h}return e(o,n),ede=o,o.create=function(h){return new o(h)},o.prototype._update=function(h,l,b,d){var p=this._edeState;p.ciphers[0]._update(h,l,b,d),p.ciphers[1]._update(b,d,b,d),p.ciphers[2]._update(b,d,b,d)},o.prototype._pad=a.prototype._pad,o.prototype._unpad=a.prototype._unpad,ede}var hasRequiredDes;function requireDes(){return hasRequiredDes||(hasRequiredDes=1,des$1.utils=requireUtils(),des$1.Cipher=requireCipher(),des$1.DES=requireDes$1(),des$1.CBC=requireCbc$1(),des$1.EDE=requireEde()),des$1}var browserifyDes,hasRequiredBrowserifyDes;function requireBrowserifyDes(){if(hasRequiredBrowserifyDes)return browserifyDes;hasRequiredBrowserifyDes=1;var t=requireCipherBase(),e=requireDes(),n=inherits_browserExports,a=requireSafeBuffer$1().Buffer,c={"des-ede3-cbc":e.CBC.instantiate(e.EDE),"des-ede3":e.EDE,"des-ede-cbc":e.CBC.instantiate(e.EDE),"des-ede":e.EDE,"des-cbc":e.CBC.instantiate(e.DES),"des-ecb":e.DES};c.des=c["des-cbc"],c.des3=c["des-ede3-cbc"],browserifyDes=o,n(o,t);function o(u){t.call(this);var h=u.mode.toLowerCase(),l=c[h],b;u.decrypt?b="decrypt":b="encrypt";var d=u.key;a.isBuffer(d)||(d=a.from(d)),(h==="des-ede"||h==="des-ede-cbc")&&(d=a.concat([d,d.slice(0,8)]));var p=u.iv;a.isBuffer(p)||(p=a.from(p)),this._des=l.create({key:d,iv:p,type:b})}return o.prototype._update=function(u){return a.from(this._des.update(u))},o.prototype._final=function(){return a.from(this._des.final())},browserifyDes}var browser$5={},encrypter={},ecb={},hasRequiredEcb;function requireEcb(){return hasRequiredEcb||(hasRequiredEcb=1,ecb.encrypt=function(t,e){return t._cipher.encryptBlock(e)},ecb.decrypt=function(t,e){return t._cipher.decryptBlock(e)}),ecb}var cbc={},bufferXor,hasRequiredBufferXor;function requireBufferXor(){return hasRequiredBufferXor||(hasRequiredBufferXor=1,bufferXor=function(e,n){for(var a=Math.min(e.length,n.length),c=new Buffer(a),o=0;o<a;++o)c[o]=e[o]^n[o];return c}),bufferXor}var hasRequiredCbc;function requireCbc(){if(hasRequiredCbc)return cbc;hasRequiredCbc=1;var t=requireBufferXor();return cbc.encrypt=function(e,n){var a=t(n,e._prev);return e._prev=e._cipher.encryptBlock(a),e._prev},cbc.decrypt=function(e,n){var a=e._prev;e._prev=n;var c=e._cipher.decryptBlock(n);return t(c,a)},cbc}var cfb={},hasRequiredCfb;function requireCfb(){if(hasRequiredCfb)return cfb;hasRequiredCfb=1;var t=requireSafeBuffer$1().Buffer,e=requireBufferXor();function n(a,c,o){var u=c.length,h=e(c,a._cache);return a._cache=a._cache.slice(u),a._prev=t.concat([a._prev,o?c:h]),h}return cfb.encrypt=function(a,c,o){for(var u=t.allocUnsafe(0),h;c.length;)if(a._cache.length===0&&(a._cache=a._cipher.encryptBlock(a._prev),a._prev=t.allocUnsafe(0)),a._cache.length<=c.length)h=a._cache.length,u=t.concat([u,n(a,c.slice(0,h),o)]),c=c.slice(h);else{u=t.concat([u,n(a,c,o)]);break}return u},cfb}var cfb8={},hasRequiredCfb8;function requireCfb8(){if(hasRequiredCfb8)return cfb8;hasRequiredCfb8=1;var t=requireSafeBuffer$1().Buffer;function e(n,a,c){var o=n._cipher.encryptBlock(n._prev),u=o[0]^a;return n._prev=t.concat([n._prev.slice(1),t.from([c?a:u])]),u}return cfb8.encrypt=function(n,a,c){for(var o=a.length,u=t.allocUnsafe(o),h=-1;++h<o;)u[h]=e(n,a[h],c);return u},cfb8}var cfb1={},hasRequiredCfb1;function requireCfb1(){if(hasRequiredCfb1)return cfb1;hasRequiredCfb1=1;var t=requireSafeBuffer$1().Buffer;function e(a,c,o){for(var u,h=-1,l=8,b=0,d,p;++h<l;)u=a._cipher.encryptBlock(a._prev),d=c&1<<7-h?128:0,p=u[0]^d,b+=(p&128)>>h%8,a._prev=n(a._prev,o?d:p);return b}function n(a,c){var o=a.length,u=-1,h=t.allocUnsafe(a.length);for(a=t.concat([a,t.from([c])]);++u<o;)h[u]=a[u]<<1|a[u+1]>>7;return h}return cfb1.encrypt=function(a,c,o){for(var u=c.length,h=t.allocUnsafe(u),l=-1;++l<u;)h[l]=e(a,c[l],o);return h},cfb1}var ofb={},hasRequiredOfb;function requireOfb(){if(hasRequiredOfb)return ofb;hasRequiredOfb=1;var t=requireBufferXor();function e(n){return n._prev=n._cipher.encryptBlock(n._prev),n._prev}return ofb.encrypt=function(n,a){for(;n._cache.length<a.length;)n._cache=Buffer.concat([n._cache,e(n)]);var c=n._cache.slice(0,a.length);return n._cache=n._cache.slice(a.length),t(a,c)},ofb}var ctr={},incr32_1,hasRequiredIncr32;function requireIncr32(){if(hasRequiredIncr32)return incr32_1;hasRequiredIncr32=1;function t(e){for(var n=e.length,a;n--;)if(a=e.readUInt8(n),a===255)e.writeUInt8(0,n);else{a++,e.writeUInt8(a,n);break}}return incr32_1=t,incr32_1}var hasRequiredCtr;function requireCtr(){if(hasRequiredCtr)return ctr;hasRequiredCtr=1;var t=requireBufferXor(),e=requireSafeBuffer$1().Buffer,n=requireIncr32();function a(o){var u=o._cipher.encryptBlockRaw(o._prev);return n(o._prev),u}var c=16;return ctr.encrypt=function(o,u){var h=Math.ceil(u.length/c),l=o._cache.length;o._cache=e.concat([o._cache,e.allocUnsafe(h*c)]);for(var b=0;b<h;b++){var d=a(o),p=l+b*c;o._cache.writeUInt32BE(d[0],p+0),o._cache.writeUInt32BE(d[1],p+4),o._cache.writeUInt32BE(d[2],p+8),o._cache.writeUInt32BE(d[3],p+12)}var x=o._cache.slice(0,u.length);return o._cache=o._cache.slice(u.length),t(u,x)},ctr}const aes128={cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192={cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256={cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},require$$2={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128,aes192,aes256,"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}};var modes_1,hasRequiredModes$1;function requireModes$1(){if(hasRequiredModes$1)return modes_1;hasRequiredModes$1=1;var t={ECB:requireEcb(),CBC:requireCbc(),CFB:requireCfb(),CFB8:requireCfb8(),CFB1:requireCfb1(),OFB:requireOfb(),CTR:requireCtr(),GCM:requireCtr()},e=require$$2;for(var n in e)e[n].module=t[e[n].mode];return modes_1=e,modes_1}var aes={},hasRequiredAes;function requireAes(){if(hasRequiredAes)return aes;hasRequiredAes=1;var t=requireSafeBuffer$1().Buffer;function e(h){t.isBuffer(h)||(h=t.from(h));for(var l=h.length/4|0,b=new Array(l),d=0;d<l;d++)b[d]=h.readUInt32BE(d*4);return b}function n(h){for(var l=0;l<h.length;h++)h[l]=0}function a(h,l,b,d,p){for(var x=b[0],m=b[1],v=b[2],g=b[3],$=h[0]^l[0],B=h[1]^l[1],C=h[2]^l[2],F=h[3]^l[3],H,W,Z,ie,te=4,ae=1;ae<p;ae++)H=x[$>>>24]^m[B>>>16&255]^v[C>>>8&255]^g[F&255]^l[te++],W=x[B>>>24]^m[C>>>16&255]^v[F>>>8&255]^g[$&255]^l[te++],Z=x[C>>>24]^m[F>>>16&255]^v[$>>>8&255]^g[B&255]^l[te++],ie=x[F>>>24]^m[$>>>16&255]^v[B>>>8&255]^g[C&255]^l[te++],$=H,B=W,C=Z,F=ie;return H=(d[$>>>24]<<24|d[B>>>16&255]<<16|d[C>>>8&255]<<8|d[F&255])^l[te++],W=(d[B>>>24]<<24|d[C>>>16&255]<<16|d[F>>>8&255]<<8|d[$&255])^l[te++],Z=(d[C>>>24]<<24|d[F>>>16&255]<<16|d[$>>>8&255]<<8|d[B&255])^l[te++],ie=(d[F>>>24]<<24|d[$>>>16&255]<<16|d[B>>>8&255]<<8|d[C&255])^l[te++],H=H>>>0,W=W>>>0,Z=Z>>>0,ie=ie>>>0,[H,W,Z,ie]}var c=[0,1,2,4,8,16,32,64,128,27,54],o=function(){for(var h=new Array(256),l=0;l<256;l++)l<128?h[l]=l<<1:h[l]=l<<1^283;for(var b=[],d=[],p=[[],[],[],[]],x=[[],[],[],[]],m=0,v=0,g=0;g<256;++g){var $=v^v<<1^v<<2^v<<3^v<<4;$=$>>>8^$&255^99,b[m]=$,d[$]=m;var B=h[m],C=h[B],F=h[C],H=h[$]*257^$*16843008;p[0][m]=H<<24|H>>>8,p[1][m]=H<<16|H>>>16,p[2][m]=H<<8|H>>>24,p[3][m]=H,H=F*16843009^C*65537^B*257^m*16843008,x[0][$]=H<<24|H>>>8,x[1][$]=H<<16|H>>>16,x[2][$]=H<<8|H>>>24,x[3][$]=H,m===0?m=v=1:(m=B^h[h[h[F^B]]],v^=h[h[v]])}return{SBOX:b,INV_SBOX:d,SUB_MIX:p,INV_SUB_MIX:x}}();function u(h){this._key=e(h),this._reset()}return u.blockSize=4*4,u.keySize=256/8,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var h=this._key,l=h.length,b=l+6,d=(b+1)*4,p=[],x=0;x<l;x++)p[x]=h[x];for(x=l;x<d;x++){var m=p[x-1];x%l===0?(m=m<<8|m>>>24,m=o.SBOX[m>>>24]<<24|o.SBOX[m>>>16&255]<<16|o.SBOX[m>>>8&255]<<8|o.SBOX[m&255],m^=c[x/l|0]<<24):l>6&&x%l===4&&(m=o.SBOX[m>>>24]<<24|o.SBOX[m>>>16&255]<<16|o.SBOX[m>>>8&255]<<8|o.SBOX[m&255]),p[x]=p[x-l]^m}for(var v=[],g=0;g<d;g++){var $=d-g,B=p[$-(g%4?0:4)];g<4||$<=4?v[g]=B:v[g]=o.INV_SUB_MIX[0][o.SBOX[B>>>24]]^o.INV_SUB_MIX[1][o.SBOX[B>>>16&255]]^o.INV_SUB_MIX[2][o.SBOX[B>>>8&255]]^o.INV_SUB_MIX[3][o.SBOX[B&255]]}this._nRounds=b,this._keySchedule=p,this._invKeySchedule=v},u.prototype.encryptBlockRaw=function(h){return h=e(h),a(h,this._keySchedule,o.SUB_MIX,o.SBOX,this._nRounds)},u.prototype.encryptBlock=function(h){var l=this.encryptBlockRaw(h),b=t.allocUnsafe(16);return b.writeUInt32BE(l[0],0),b.writeUInt32BE(l[1],4),b.writeUInt32BE(l[2],8),b.writeUInt32BE(l[3],12),b},u.prototype.decryptBlock=function(h){h=e(h);var l=h[1];h[1]=h[3],h[3]=l;var b=a(h,this._invKeySchedule,o.INV_SUB_MIX,o.INV_SBOX,this._nRounds),d=t.allocUnsafe(16);return d.writeUInt32BE(b[0],0),d.writeUInt32BE(b[3],4),d.writeUInt32BE(b[2],8),d.writeUInt32BE(b[1],12),d},u.prototype.scrub=function(){n(this._keySchedule),n(this._invKeySchedule),n(this._key)},aes.AES=u,aes}var ghash,hasRequiredGhash;function requireGhash(){if(hasRequiredGhash)return ghash;hasRequiredGhash=1;var t=requireSafeBuffer$1().Buffer,e=t.alloc(16,0);function n(o){return[o.readUInt32BE(0),o.readUInt32BE(4),o.readUInt32BE(8),o.readUInt32BE(12)]}function a(o){var u=t.allocUnsafe(16);return u.writeUInt32BE(o[0]>>>0,0),u.writeUInt32BE(o[1]>>>0,4),u.writeUInt32BE(o[2]>>>0,8),u.writeUInt32BE(o[3]>>>0,12),u}function c(o){this.h=o,this.state=t.alloc(16,0),this.cache=t.allocUnsafe(0)}return c.prototype.ghash=function(o){for(var u=-1;++u<o.length;)this.state[u]^=o[u];this._multiply()},c.prototype._multiply=function(){for(var o=n(this.h),u=[0,0,0,0],h,l,b,d=-1;++d<128;){for(l=(this.state[~~(d/8)]&1<<7-d%8)!==0,l&&(u[0]^=o[0],u[1]^=o[1],u[2]^=o[2],u[3]^=o[3]),b=(o[3]&1)!==0,h=3;h>0;h--)o[h]=o[h]>>>1|(o[h-1]&1)<<31;o[0]=o[0]>>>1,b&&(o[0]=o[0]^225<<24)}this.state=a(u)},c.prototype.update=function(o){this.cache=t.concat([this.cache,o]);for(var u;this.cache.length>=16;)u=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(u)},c.prototype.final=function(o,u){return this.cache.length&&this.ghash(t.concat([this.cache,e],16)),this.ghash(a([0,o,0,u])),this.state},ghash=c,ghash}var authCipher,hasRequiredAuthCipher;function requireAuthCipher(){if(hasRequiredAuthCipher)return authCipher;hasRequiredAuthCipher=1;var t=requireAes(),e=requireSafeBuffer$1().Buffer,n=requireCipherBase(),a=inherits_browserExports,c=requireGhash(),o=requireBufferXor(),u=requireIncr32();function h(d,p){var x=0;d.length!==p.length&&x++;for(var m=Math.min(d.length,p.length),v=0;v<m;++v)x+=d[v]^p[v];return x}function l(d,p,x){if(p.length===12)return d._finID=e.concat([p,e.from([0,0,0,1])]),e.concat([p,e.from([0,0,0,2])]);var m=new c(x),v=p.length,g=v%16;m.update(p),g&&(g=16-g,m.update(e.alloc(g,0))),m.update(e.alloc(8,0));var $=v*8,B=e.alloc(8);B.writeUIntBE($,0,8),m.update(B),d._finID=m.state;var C=e.from(d._finID);return u(C),C}function b(d,p,x,m){n.call(this);var v=e.alloc(4,0);this._cipher=new t.AES(p);var g=this._cipher.encryptBlock(v);this._ghash=new c(g),x=l(this,x,g),this._prev=e.from(x),this._cache=e.allocUnsafe(0),this._secCache=e.allocUnsafe(0),this._decrypt=m,this._alen=0,this._len=0,this._mode=d,this._authTag=null,this._called=!1}return a(b,n),b.prototype._update=function(d){if(!this._called&&this._alen){var p=16-this._alen%16;p<16&&(p=e.alloc(p,0),this._ghash.update(p))}this._called=!0;var x=this._mode.encrypt(this,d);return this._decrypt?this._ghash.update(d):this._ghash.update(x),this._len+=d.length,x},b.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var d=o(this._ghash.final(this._alen*8,this._len*8),this._cipher.encryptBlock(this._finID));if(this._decrypt&&h(d,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=d,this._cipher.scrub()},b.prototype.getAuthTag=function(){if(this._decrypt||!e.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},b.prototype.setAuthTag=function(p){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=p},b.prototype.setAAD=function(p){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(p),this._alen+=p.length},authCipher=b,authCipher}var streamCipher,hasRequiredStreamCipher;function requireStreamCipher(){if(hasRequiredStreamCipher)return streamCipher;hasRequiredStreamCipher=1;var t=requireAes(),e=requireSafeBuffer$1().Buffer,n=requireCipherBase(),a=inherits_browserExports;function c(o,u,h,l){n.call(this),this._cipher=new t.AES(u),this._prev=e.from(h),this._cache=e.allocUnsafe(0),this._secCache=e.allocUnsafe(0),this._decrypt=l,this._mode=o}return a(c,n),c.prototype._update=function(o){return this._mode.encrypt(this,o,this._decrypt)},c.prototype._final=function(){this._cipher.scrub()},streamCipher=c,streamCipher}var evp_bytestokey,hasRequiredEvp_bytestokey;function requireEvp_bytestokey(){if(hasRequiredEvp_bytestokey)return evp_bytestokey;hasRequiredEvp_bytestokey=1;var t=requireSafeBuffer$1().Buffer,e=requireMd5_js();function n(a,c,o,u){if(t.isBuffer(a)||(a=t.from(a,"binary")),c&&(t.isBuffer(c)||(c=t.from(c,"binary")),c.length!==8))throw new RangeError("salt should be Buffer with 8 byte length");for(var h=o/8,l=t.alloc(h),b=t.alloc(u||0),d=t.alloc(0);h>0||u>0;){var p=new e;p.update(d),p.update(a),c&&p.update(c),d=p.digest();var x=0;if(h>0){var m=l.length-h;x=Math.min(h,d.length),d.copy(l,m,0,x),h-=x}if(x<d.length&&u>0){var v=b.length-u,g=Math.min(u,d.length-x);d.copy(b,v,x,x+g),u-=g}}return d.fill(0),{key:l,iv:b}}return evp_bytestokey=n,evp_bytestokey}var hasRequiredEncrypter;function requireEncrypter(){if(hasRequiredEncrypter)return encrypter;hasRequiredEncrypter=1;var t=requireModes$1(),e=requireAuthCipher(),n=requireSafeBuffer$1().Buffer,a=requireStreamCipher(),c=requireCipherBase(),o=requireAes(),u=requireEvp_bytestokey(),h=inherits_browserExports;function l(m,v,g){c.call(this),this._cache=new d,this._cipher=new o.AES(v),this._prev=n.from(g),this._mode=m,this._autopadding=!0}h(l,c),l.prototype._update=function(m){this._cache.add(m);for(var v,g,$=[];v=this._cache.get();)g=this._mode.encrypt(this,v),$.push(g);return n.concat($)};var b=n.alloc(16,16);l.prototype._final=function(){var m=this._cache.flush();if(this._autopadding)return m=this._mode.encrypt(this,m),this._cipher.scrub(),m;if(!m.equals(b))throw this._cipher.scrub(),new Error("data not multiple of block length")},l.prototype.setAutoPadding=function(m){return this._autopadding=!!m,this};function d(){this.cache=n.allocUnsafe(0)}d.prototype.add=function(m){this.cache=n.concat([this.cache,m])},d.prototype.get=function(){if(this.cache.length>15){var m=this.cache.slice(0,16);return this.cache=this.cache.slice(16),m}return null},d.prototype.flush=function(){for(var m=16-this.cache.length,v=n.allocUnsafe(m),g=-1;++g<m;)v.writeUInt8(m,g);return n.concat([this.cache,v])};function p(m,v,g){var $=t[m.toLowerCase()];if(!$)throw new TypeError("invalid suite type");if(typeof v=="string"&&(v=n.from(v)),v.length!==$.key/8)throw new TypeError("invalid key length "+v.length);if(typeof g=="string"&&(g=n.from(g)),$.mode!=="GCM"&&g.length!==$.iv)throw new TypeError("invalid iv length "+g.length);return $.type==="stream"?new a($.module,v,g):$.type==="auth"?new e($.module,v,g):new l($.module,v,g)}function x(m,v){var g=t[m.toLowerCase()];if(!g)throw new TypeError("invalid suite type");var $=u(v,!1,g.key,g.iv);return p(m,$.key,$.iv)}return encrypter.createCipheriv=p,encrypter.createCipher=x,encrypter}var decrypter={},hasRequiredDecrypter;function requireDecrypter(){if(hasRequiredDecrypter)return decrypter;hasRequiredDecrypter=1;var t=requireAuthCipher(),e=requireSafeBuffer$1().Buffer,n=requireModes$1(),a=requireStreamCipher(),c=requireCipherBase(),o=requireAes(),u=requireEvp_bytestokey(),h=inherits_browserExports;function l(m,v,g){c.call(this),this._cache=new b,this._last=void 0,this._cipher=new o.AES(v),this._prev=e.from(g),this._mode=m,this._autopadding=!0}h(l,c),l.prototype._update=function(m){this._cache.add(m);for(var v,g,$=[];v=this._cache.get(this._autopadding);)g=this._mode.decrypt(this,v),$.push(g);return e.concat($)},l.prototype._final=function(){var m=this._cache.flush();if(this._autopadding)return d(this._mode.decrypt(this,m));if(m)throw new Error("data not multiple of block length")},l.prototype.setAutoPadding=function(m){return this._autopadding=!!m,this};function b(){this.cache=e.allocUnsafe(0)}b.prototype.add=function(m){this.cache=e.concat([this.cache,m])},b.prototype.get=function(m){var v;if(m){if(this.cache.length>16)return v=this.cache.slice(0,16),this.cache=this.cache.slice(16),v}else if(this.cache.length>=16)return v=this.cache.slice(0,16),this.cache=this.cache.slice(16),v;return null},b.prototype.flush=function(){if(this.cache.length)return this.cache};function d(m){var v=m[15];if(v<1||v>16)throw new Error("unable to decrypt data");for(var g=-1;++g<v;)if(m[g+(16-v)]!==v)throw new Error("unable to decrypt data");if(v!==16)return m.slice(0,16-v)}function p(m,v,g){var $=n[m.toLowerCase()];if(!$)throw new TypeError("invalid suite type");if(typeof g=="string"&&(g=e.from(g)),$.mode!=="GCM"&&g.length!==$.iv)throw new TypeError("invalid iv length "+g.length);if(typeof v=="string"&&(v=e.from(v)),v.length!==$.key/8)throw new TypeError("invalid key length "+v.length);return $.type==="stream"?new a($.module,v,g,!0):$.type==="auth"?new t($.module,v,g,!0):new l($.module,v,g)}function x(m,v){var g=n[m.toLowerCase()];if(!g)throw new TypeError("invalid suite type");var $=u(v,!1,g.key,g.iv);return p(m,$.key,$.iv)}return decrypter.createDecipher=x,decrypter.createDecipheriv=p,decrypter}var hasRequiredBrowser$6;function requireBrowser$6(){if(hasRequiredBrowser$6)return browser$5;hasRequiredBrowser$6=1;var t=requireEncrypter(),e=requireDecrypter(),n=require$$2;function a(){return Object.keys(n)}return browser$5.createCipher=browser$5.Cipher=t.createCipher,browser$5.createCipheriv=browser$5.Cipheriv=t.createCipheriv,browser$5.createDecipher=browser$5.Decipher=e.createDecipher,browser$5.createDecipheriv=browser$5.Decipheriv=e.createDecipheriv,browser$5.listCiphers=browser$5.getCiphers=a,browser$5}var modes={},hasRequiredModes;function requireModes(){return hasRequiredModes||(hasRequiredModes=1,function(t){t["des-ecb"]={key:8,iv:0},t["des-cbc"]=t.des={key:8,iv:8},t["des-ede3-cbc"]=t.des3={key:24,iv:8},t["des-ede3"]={key:24,iv:0},t["des-ede-cbc"]={key:16,iv:8},t["des-ede"]={key:16,iv:0}}(modes)),modes}var hasRequiredBrowser$5;function requireBrowser$5(){if(hasRequiredBrowser$5)return browser$6;hasRequiredBrowser$5=1;var t=requireBrowserifyDes(),e=requireBrowser$6(),n=requireModes$1(),a=requireModes(),c=requireEvp_bytestokey();function o(d,p){d=d.toLowerCase();var x,m;if(n[d])x=n[d].key,m=n[d].iv;else if(a[d])x=a[d].key*8,m=a[d].iv;else throw new TypeError("invalid suite type");var v=c(p,!1,x,m);return h(d,v.key,v.iv)}function u(d,p){d=d.toLowerCase();var x,m;if(n[d])x=n[d].key,m=n[d].iv;else if(a[d])x=a[d].key*8,m=a[d].iv;else throw new TypeError("invalid suite type");var v=c(p,!1,x,m);return l(d,v.key,v.iv)}function h(d,p,x){if(d=d.toLowerCase(),n[d])return e.createCipheriv(d,p,x);if(a[d])return new t({key:p,iv:x,mode:d});throw new TypeError("invalid suite type")}function l(d,p,x){if(d=d.toLowerCase(),n[d])return e.createDecipheriv(d,p,x);if(a[d])return new t({key:p,iv:x,mode:d,decrypt:!0});throw new TypeError("invalid suite type")}function b(){return Object.keys(a).concat(e.getCiphers())}return browser$6.createCipher=browser$6.Cipher=o,browser$6.createCipheriv=browser$6.Cipheriv=h,browser$6.createDecipher=browser$6.Decipher=u,browser$6.createDecipheriv=browser$6.Decipheriv=l,browser$6.listCiphers=browser$6.getCiphers=b,browser$6}var browser$4={},mr,hasRequiredMr;function requireMr(){if(hasRequiredMr)return mr;hasRequiredMr=1;var t=bnExports,e=requireBrorand();function n(a){this.rand=a||new e.Rand}return mr=n,n.create=function(c){return new n(c)},n.prototype._randbelow=function(c){var o=c.bitLength(),u=Math.ceil(o/8);do var h=new t(this.rand.generate(u));while(h.cmp(c)>=0);return h},n.prototype._randrange=function(c,o){var u=o.sub(c);return c.add(this._randbelow(u))},n.prototype.test=function(c,o,u){var h=c.bitLength(),l=t.mont(c),b=new t(1).toRed(l);o||(o=Math.max(1,h/48|0));for(var d=c.subn(1),p=0;!d.testn(p);p++);for(var x=c.shrn(p),m=d.toRed(l),v=!0;o>0;o--){var g=this._randrange(new t(2),d);u&&u(g);var $=g.toRed(l).redPow(x);if(!($.cmp(b)===0||$.cmp(m)===0)){for(var B=1;B<p;B++){if($=$.redSqr(),$.cmp(b)===0)return!1;if($.cmp(m)===0)break}if(B===p)return!1}}return v},n.prototype.getDivisor=function(c,o){var u=c.bitLength(),h=t.mont(c),l=new t(1).toRed(h);o||(o=Math.max(1,u/48|0));for(var b=c.subn(1),d=0;!b.testn(d);d++);for(var p=c.shrn(d),x=b.toRed(h);o>0;o--){var m=this._randrange(new t(2),b),v=c.gcd(m);if(v.cmpn(1)!==0)return v;var g=m.toRed(h).redPow(p);if(!(g.cmp(l)===0||g.cmp(x)===0)){for(var $=1;$<d;$++){if(g=g.redSqr(),g.cmp(l)===0)return g.fromRed().subn(1).gcd(c);if(g.cmp(x)===0)break}if($===d)return g=g.redSqr(),g.fromRed().subn(1).gcd(c)}}return!1},mr}var generatePrime,hasRequiredGeneratePrime;function requireGeneratePrime(){if(hasRequiredGeneratePrime)return generatePrime;hasRequiredGeneratePrime=1;var t=requireBrowser$b();generatePrime=$,$.simpleSieve=v,$.fermatTest=g;var e=bnExports,n=new e(24),a=requireMr(),c=new a,o=new e(1),u=new e(2),h=new e(5);new e(16),new e(8);var l=new e(10),b=new e(3);new e(7);var d=new e(11),p=new e(4);new e(12);var x=null;function m(){if(x!==null)return x;var B=1048576,C=[];C[0]=2;for(var F=1,H=3;H<B;H+=2){for(var W=Math.ceil(Math.sqrt(H)),Z=0;Z<F&&C[Z]<=W&&H%C[Z]!==0;Z++);F!==Z&&C[Z]<=W||(C[F++]=H)}return x=C,C}function v(B){for(var C=m(),F=0;F<C.length;F++)if(B.modn(C[F])===0)return B.cmpn(C[F])===0;return!0}function g(B){var C=e.mont(B);return u.toRed(C).redPow(B.subn(1)).fromRed().cmpn(1)===0}function $(B,C){if(B<16)return C===2||C===5?new e([140,123]):new e([140,39]);C=new e(C);for(var F,H;;){for(F=new e(t(Math.ceil(B/8)));F.bitLength()>B;)F.ishrn(1);if(F.isEven()&&F.iadd(o),F.testn(1)||F.iadd(u),C.cmp(u)){if(!C.cmp(h))for(;F.mod(l).cmp(b);)F.iadd(p)}else for(;F.mod(n).cmp(d);)F.iadd(p);if(H=F.shrn(1),v(H)&&v(F)&&g(H)&&g(F)&&c.test(H)&&c.test(F))return F}}return generatePrime}const modp1={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18={gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"},require$$1$1={modp1,modp2,modp5,modp14,modp15,modp16,modp17,modp18};var dh,hasRequiredDh;function requireDh(){if(hasRequiredDh)return dh;hasRequiredDh=1;var t=bnExports,e=requireMr(),n=new e,a=new t(24),c=new t(11),o=new t(10),u=new t(3),h=new t(7),l=requireGeneratePrime(),b=requireBrowser$b();dh=v;function d($,B){return B=B||"utf8",Buffer.isBuffer($)||($=new Buffer($,B)),this._pub=new t($),this}function p($,B){return B=B||"utf8",Buffer.isBuffer($)||($=new Buffer($,B)),this._priv=new t($),this}var x={};function m($,B){var C=B.toString("hex"),F=[C,$.toString(16)].join("_");if(F in x)return x[F];var H=0;if($.isEven()||!l.simpleSieve||!l.fermatTest($)||!n.test($))return H+=1,C==="02"||C==="05"?H+=8:H+=4,x[F]=H,H;n.test($.shrn(1))||(H+=2);var W;switch(C){case"02":$.mod(a).cmp(c)&&(H+=8);break;case"05":W=$.mod(o),W.cmp(u)&&W.cmp(h)&&(H+=8);break;default:H+=4}return x[F]=H,H}function v($,B,C){this.setGenerator(B),this.__prime=new t($),this._prime=t.mont(this.__prime),this._primeLen=$.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,C?(this.setPublicKey=d,this.setPrivateKey=p):this._primeCode=8}Object.defineProperty(v.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=m(this.__prime,this.__gen)),this._primeCode}}),v.prototype.generateKeys=function(){return this._priv||(this._priv=new t(b(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},v.prototype.computeSecret=function($){$=new t($),$=$.toRed(this._prime);var B=$.redPow(this._priv).fromRed(),C=new Buffer(B.toArray()),F=this.getPrime();if(C.length<F.length){var H=new Buffer(F.length-C.length);H.fill(0),C=Buffer.concat([H,C])}return C},v.prototype.getPublicKey=function(B){return g(this._pub,B)},v.prototype.getPrivateKey=function(B){return g(this._priv,B)},v.prototype.getPrime=function($){return g(this.__prime,$)},v.prototype.getGenerator=function($){return g(this._gen,$)},v.prototype.setGenerator=function($,B){return B=B||"utf8",Buffer.isBuffer($)||($=new Buffer($,B)),this.__gen=$,this._gen=new t($),this};function g($,B){var C=new Buffer($.toArray());return B?C.toString(B):C}return dh}var hasRequiredBrowser$4;function requireBrowser$4(){if(hasRequiredBrowser$4)return browser$4;hasRequiredBrowser$4=1;var t=requireGeneratePrime(),e=require$$1$1,n=requireDh();function a(u){var h=new Buffer(e[u].prime,"hex"),l=new Buffer(e[u].gen,"hex");return new n(h,l)}var c={binary:!0,hex:!0,base64:!0};function o(u,h,l,b){return Buffer.isBuffer(h)||c[h]===void 0?o(u,"binary",h,l):(h=h||"binary",b=b||"binary",l=l||new Buffer([2]),Buffer.isBuffer(l)||(l=new Buffer(l,b)),typeof u=="number"?new n(t(u,l),l,!0):(Buffer.isBuffer(u)||(u=new Buffer(u,h)),new n(u,l,!0)))}return browser$4.DiffieHellmanGroup=browser$4.createDiffieHellmanGroup=browser$4.getDiffieHellman=a,browser$4.createDiffieHellman=browser$4.DiffieHellman=o,browser$4}var readableBrowser={exports:{}},processNextickArgs={exports:{}},hasRequiredProcessNextickArgs;function requireProcessNextickArgs(){if(hasRequiredProcessNextickArgs)return processNextickArgs.exports;hasRequiredProcessNextickArgs=1,typeof process$1>"u"||!process$1.version||process$1.version.indexOf("v0.")===0||process$1.version.indexOf("v1.")===0&&process$1.version.indexOf("v1.8.")!==0?processNextickArgs.exports={nextTick:t}:processNextickArgs.exports=process$1;function t(e,n,a,c){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var o=arguments.length,u,h;switch(o){case 0:case 1:return process$1.nextTick(e);case 2:return process$1.nextTick(function(){e.call(null,n)});case 3:return process$1.nextTick(function(){e.call(null,n,a)});case 4:return process$1.nextTick(function(){e.call(null,n,a,c)});default:for(u=new Array(o-1),h=0;h<u.length;)u[h++]=arguments[h];return process$1.nextTick(function(){e.apply(null,u)})}}return processNextickArgs.exports}var isarray,hasRequiredIsarray;function requireIsarray(){if(hasRequiredIsarray)return isarray;hasRequiredIsarray=1;var t={}.toString;return isarray=Array.isArray||function(e){return t.call(e)=="[object Array]"},isarray}var streamBrowser,hasRequiredStreamBrowser;function requireStreamBrowser(){return hasRequiredStreamBrowser||(hasRequiredStreamBrowser=1,streamBrowser=requireEvents().EventEmitter),streamBrowser}var safeBuffer={exports:{}},hasRequiredSafeBuffer;function requireSafeBuffer(){return hasRequiredSafeBuffer||(hasRequiredSafeBuffer=1,function(t,e){var n=require$$1$2,a=n.Buffer;function c(u,h){for(var l in u)h[l]=u[l]}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?t.exports=n:(c(n,e),e.Buffer=o);function o(u,h,l){return a(u,h,l)}c(a,o),o.from=function(u,h,l){if(typeof u=="number")throw new TypeError("Argument must not be a number");return a(u,h,l)},o.alloc=function(u,h,l){if(typeof u!="number")throw new TypeError("Argument must be a number");var b=a(u);return h!==void 0?typeof l=="string"?b.fill(h,l):b.fill(h):b.fill(0),b},o.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return a(u)},o.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(u)}}(safeBuffer,safeBuffer.exports)),safeBuffer.exports}var util={},hasRequiredUtil;function requireUtil(){if(hasRequiredUtil)return util;hasRequiredUtil=1;function t(g){return Array.isArray?Array.isArray(g):v(g)==="[object Array]"}util.isArray=t;function e(g){return typeof g=="boolean"}util.isBoolean=e;function n(g){return g===null}util.isNull=n;function a(g){return g==null}util.isNullOrUndefined=a;function c(g){return typeof g=="number"}util.isNumber=c;function o(g){return typeof g=="string"}util.isString=o;function u(g){return typeof g=="symbol"}util.isSymbol=u;function h(g){return g===void 0}util.isUndefined=h;function l(g){return v(g)==="[object RegExp]"}util.isRegExp=l;function b(g){return typeof g=="object"&&g!==null}util.isObject=b;function d(g){return v(g)==="[object Date]"}util.isDate=d;function p(g){return v(g)==="[object Error]"||g instanceof Error}util.isError=p;function x(g){return typeof g=="function"}util.isFunction=x;function m(g){return g===null||typeof g=="boolean"||typeof g=="number"||typeof g=="string"||typeof g=="symbol"||typeof g>"u"}util.isPrimitive=m,util.isBuffer=require$$1$2.Buffer.isBuffer;function v(g){return Object.prototype.toString.call(g)}return util}var BufferList={exports:{}},hasRequiredBufferList;function requireBufferList(){return hasRequiredBufferList||(hasRequiredBufferList=1,function(t){function e(o,u){if(!(o instanceof u))throw new TypeError("Cannot call a class as a function")}var n=requireSafeBuffer().Buffer,a=requireUtil$1();function c(o,u,h){o.copy(u,h)}t.exports=function(){function o(){e(this,o),this.head=null,this.tail=null,this.length=0}return o.prototype.push=function(h){var l={data:h,next:null};this.length>0?this.tail.next=l:this.head=l,this.tail=l,++this.length},o.prototype.unshift=function(h){var l={data:h,next:this.head};this.length===0&&(this.tail=l),this.head=l,++this.length},o.prototype.shift=function(){if(this.length!==0){var h=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,h}},o.prototype.clear=function(){this.head=this.tail=null,this.length=0},o.prototype.join=function(h){if(this.length===0)return"";for(var l=this.head,b=""+l.data;l=l.next;)b+=h+l.data;return b},o.prototype.concat=function(h){if(this.length===0)return n.alloc(0);for(var l=n.allocUnsafe(h>>>0),b=this.head,d=0;b;)c(b.data,l,d),d+=b.data.length,b=b.next;return l},o}(),a&&a.inspect&&a.inspect.custom&&(t.exports.prototype[a.inspect.custom]=function(){var o=a.inspect({length:this.length});return this.constructor.name+" "+o})}(BufferList)),BufferList.exports}var destroy_1,hasRequiredDestroy;function requireDestroy(){if(hasRequiredDestroy)return destroy_1;hasRequiredDestroy=1;var t=requireProcessNextickArgs();function e(c,o){var u=this,h=this._readableState&&this._readableState.destroyed,l=this._writableState&&this._writableState.destroyed;return h||l?(o?o(c):c&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,t.nextTick(a,this,c)):t.nextTick(a,this,c)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(c||null,function(b){!o&&b?u._writableState?u._writableState.errorEmitted||(u._writableState.errorEmitted=!0,t.nextTick(a,u,b)):t.nextTick(a,u,b):o&&o(b)}),this)}function n(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function a(c,o){c.emit("error",o)}return destroy_1={destroy:e,undestroy:n},destroy_1}var _stream_writable,hasRequired_stream_writable;function require_stream_writable(){if(hasRequired_stream_writable)return _stream_writable;hasRequired_stream_writable=1;var t=requireProcessNextickArgs();_stream_writable=g;function e(M){var k=this;this.next=null,this.entry=null,this.finish=function(){I(k,M)}}var n=!process$1.browser&&["v0.10","v0.9."].indexOf(process$1.version.slice(0,5))>-1?setImmediate:t.nextTick,a;g.WritableState=m;var c=Object.create(requireUtil());c.inherits=inherits_browserExports;var o={deprecate:requireBrowser$a()},u=requireStreamBrowser(),h=requireSafeBuffer().Buffer,l=(typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function b(M){return h.from(M)}function d(M){return h.isBuffer(M)||M instanceof l}var p=requireDestroy();c.inherits(g,u);function x(){}function m(M,k){a=a||require_stream_duplex(),M=M||{};var P=k instanceof a;this.objectMode=!!M.objectMode,P&&(this.objectMode=this.objectMode||!!M.writableObjectMode);var _=M.highWaterMark,q=M.writableHighWaterMark,E=this.objectMode?16:16*1024;_||_===0?this.highWaterMark=_:P&&(q||q===0)?this.highWaterMark=q:this.highWaterMark=E,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var j=M.decodeStrings===!1;this.decodeStrings=!j,this.defaultEncoding=M.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ee){ie(k,ee)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}m.prototype.getBuffer=function(){for(var k=this.bufferedRequest,P=[];k;)P.push(k),k=k.next;return P},function(){try{Object.defineProperty(m.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var v;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(v=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(M){return v.call(this,M)?!0:this!==g?!1:M&&M._writableState instanceof m}})):v=function(M){return M instanceof this};function g(M){if(a=a||require_stream_duplex(),!v.call(g,this)&&!(this instanceof a))return new g(M);this._writableState=new m(M,this),this.writable=!0,M&&(typeof M.write=="function"&&(this._write=M.write),typeof M.writev=="function"&&(this._writev=M.writev),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.final=="function"&&(this._final=M.final)),u.call(this)}g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function $(M,k){var P=new Error("write after end");M.emit("error",P),t.nextTick(k,P)}function B(M,k,P,_){var q=!0,E=!1;return P===null?E=new TypeError("May not write null values to stream"):typeof P!="string"&&P!==void 0&&!k.objectMode&&(E=new TypeError("Invalid non-string/buffer chunk")),E&&(M.emit("error",E),t.nextTick(_,E),q=!1),q}g.prototype.write=function(M,k,P){var _=this._writableState,q=!1,E=!_.objectMode&&d(M);return E&&!h.isBuffer(M)&&(M=b(M)),typeof k=="function"&&(P=k,k=null),E?k="buffer":k||(k=_.defaultEncoding),typeof P!="function"&&(P=x),_.ended?$(this,P):(E||B(this,_,M,P))&&(_.pendingcb++,q=F(this,_,E,M,k,P)),q},g.prototype.cork=function(){var M=this._writableState;M.corked++},g.prototype.uncork=function(){var M=this._writableState;M.corked&&(M.corked--,!M.writing&&!M.corked&&!M.bufferProcessing&&M.bufferedRequest&&de(this,M))},g.prototype.setDefaultEncoding=function(k){if(typeof k=="string"&&(k=k.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((k+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+k);return this._writableState.defaultEncoding=k,this};function C(M,k,P){return!M.objectMode&&M.decodeStrings!==!1&&typeof k=="string"&&(k=h.from(k,P)),k}Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function F(M,k,P,_,q,E){if(!P){var j=C(k,_,q);_!==j&&(P=!0,q="buffer",_=j)}var ee=k.objectMode?1:_.length;k.length+=ee;var oe=k.length<k.highWaterMark;if(oe||(k.needDrain=!0),k.writing||k.corked){var Y=k.lastBufferedRequest;k.lastBufferedRequest={chunk:_,encoding:q,isBuf:P,callback:E,next:null},Y?Y.next=k.lastBufferedRequest:k.bufferedRequest=k.lastBufferedRequest,k.bufferedRequestCount+=1}else H(M,k,!1,ee,_,q,E);return oe}function H(M,k,P,_,q,E,j){k.writelen=_,k.writecb=j,k.writing=!0,k.sync=!0,P?M._writev(q,k.onwrite):M._write(q,E,k.onwrite),k.sync=!1}function W(M,k,P,_,q){--k.pendingcb,P?(t.nextTick(q,_),t.nextTick(y,M,k),M._writableState.errorEmitted=!0,M.emit("error",_)):(q(_),M._writableState.errorEmitted=!0,M.emit("error",_),y(M,k))}function Z(M){M.writing=!1,M.writecb=null,M.length-=M.writelen,M.writelen=0}function ie(M,k){var P=M._writableState,_=P.sync,q=P.writecb;if(Z(P),k)W(M,P,_,k,q);else{var E=J(P);!E&&!P.corked&&!P.bufferProcessing&&P.bufferedRequest&&de(M,P),_?n(te,M,P,E,q):te(M,P,E,q)}}function te(M,k,P,_){P||ae(M,k),k.pendingcb--,_(),y(M,k)}function ae(M,k){k.length===0&&k.needDrain&&(k.needDrain=!1,M.emit("drain"))}function de(M,k){k.bufferProcessing=!0;var P=k.bufferedRequest;if(M._writev&&P&&P.next){var _=k.bufferedRequestCount,q=new Array(_),E=k.corkedRequestsFree;E.entry=P;for(var j=0,ee=!0;P;)q[j]=P,P.isBuf||(ee=!1),P=P.next,j+=1;q.allBuffers=ee,H(M,k,!0,k.length,q,"",E.finish),k.pendingcb++,k.lastBufferedRequest=null,E.next?(k.corkedRequestsFree=E.next,E.next=null):k.corkedRequestsFree=new e(k),k.bufferedRequestCount=0}else{for(;P;){var oe=P.chunk,Y=P.encoding,L=P.callback,z=k.objectMode?1:oe.length;if(H(M,k,!1,z,oe,Y,L),P=P.next,k.bufferedRequestCount--,k.writing)break}P===null&&(k.lastBufferedRequest=null)}k.bufferedRequest=P,k.bufferProcessing=!1}g.prototype._write=function(M,k,P){P(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(M,k,P){var _=this._writableState;typeof M=="function"?(P=M,M=null,k=null):typeof k=="function"&&(P=k,k=null),M!=null&&this.write(M,k),_.corked&&(_.corked=1,this.uncork()),_.ending||w(this,_,P)};function J(M){return M.ending&&M.length===0&&M.bufferedRequest===null&&!M.finished&&!M.writing}function R(M,k){M._final(function(P){k.pendingcb--,P&&M.emit("error",P),k.prefinished=!0,M.emit("prefinish"),y(M,k)})}function A(M,k){!k.prefinished&&!k.finalCalled&&(typeof M._final=="function"?(k.pendingcb++,k.finalCalled=!0,t.nextTick(R,M,k)):(k.prefinished=!0,M.emit("prefinish")))}function y(M,k){var P=J(k);return P&&(A(M,k),k.pendingcb===0&&(k.finished=!0,M.emit("finish"))),P}function w(M,k,P){k.ending=!0,y(M,k),P&&(k.finished?t.nextTick(P):M.once("finish",P)),k.ended=!0,M.writable=!1}function I(M,k,P){var _=M.entry;for(M.entry=null;_;){var q=_.callback;k.pendingcb--,q(P),_=_.next}k.corkedRequestsFree.next=M}return Object.defineProperty(g.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(M){this._writableState&&(this._writableState.destroyed=M)}}),g.prototype.destroy=p.destroy,g.prototype._undestroy=p.undestroy,g.prototype._destroy=function(M,k){this.end(),k(M)},_stream_writable}var _stream_duplex,hasRequired_stream_duplex;function require_stream_duplex(){if(hasRequired_stream_duplex)return _stream_duplex;hasRequired_stream_duplex=1;var t=requireProcessNextickArgs(),e=Object.keys||function(p){var x=[];for(var m in p)x.push(m);return x};_stream_duplex=l;var n=Object.create(requireUtil());n.inherits=inherits_browserExports;var a=require_stream_readable(),c=require_stream_writable();n.inherits(l,a);for(var o=e(c.prototype),u=0;u<o.length;u++){var h=o[u];l.prototype[h]||(l.prototype[h]=c.prototype[h])}function l(p){if(!(this instanceof l))return new l(p);a.call(this,p),c.call(this,p),p&&p.readable===!1&&(this.readable=!1),p&&p.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,p&&p.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",b)}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function b(){this.allowHalfOpen||this._writableState.ended||t.nextTick(d,this)}function d(p){p.end()}return Object.defineProperty(l.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(p){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=p,this._writableState.destroyed=p)}}),l.prototype._destroy=function(p,x){this.push(null),this.end(),t.nextTick(x,p)},_stream_duplex}var _stream_readable,hasRequired_stream_readable;function require_stream_readable(){if(hasRequired_stream_readable)return _stream_readable;hasRequired_stream_readable=1;var t=requireProcessNextickArgs();_stream_readable=C;var e=requireIsarray(),n;C.ReadableState=B,requireEvents().EventEmitter;var a=function(L,z){return L.listeners(z).length},c=requireStreamBrowser(),o=requireSafeBuffer().Buffer,u=(typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function h(L){return o.from(L)}function l(L){return o.isBuffer(L)||L instanceof u}var b=Object.create(requireUtil());b.inherits=inherits_browserExports;var d=requireUtil$1(),p=void 0;d&&d.debuglog?p=d.debuglog("stream"):p=function(){};var x=requireBufferList(),m=requireDestroy(),v;b.inherits(C,c);var g=["error","close","destroy","pause","resume"];function $(L,z,re){if(typeof L.prependListener=="function")return L.prependListener(z,re);!L._events||!L._events[z]?L.on(z,re):e(L._events[z])?L._events[z].unshift(re):L._events[z]=[re,L._events[z]]}function B(L,z){n=n||require_stream_duplex(),L=L||{};var re=z instanceof n;this.objectMode=!!L.objectMode,re&&(this.objectMode=this.objectMode||!!L.readableObjectMode);var D=L.highWaterMark,G=L.readableHighWaterMark,U=this.objectMode?16:16*1024;D||D===0?this.highWaterMark=D:re&&(G||G===0)?this.highWaterMark=G:this.highWaterMark=U,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new x,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=L.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,L.encoding&&(v||(v=requireString_decoder().StringDecoder),this.decoder=new v(L.encoding),this.encoding=L.encoding)}function C(L){if(n=n||require_stream_duplex(),!(this instanceof C))return new C(L);this._readableState=new B(L,this),this.readable=!0,L&&(typeof L.read=="function"&&(this._read=L.read),typeof L.destroy=="function"&&(this._destroy=L.destroy)),c.call(this)}Object.defineProperty(C.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(L){this._readableState&&(this._readableState.destroyed=L)}}),C.prototype.destroy=m.destroy,C.prototype._undestroy=m.undestroy,C.prototype._destroy=function(L,z){this.push(null),z(L)},C.prototype.push=function(L,z){var re=this._readableState,D;return re.objectMode?D=!0:typeof L=="string"&&(z=z||re.defaultEncoding,z!==re.encoding&&(L=o.from(L,z),z=""),D=!0),F(this,L,z,!1,D)},C.prototype.unshift=function(L){return F(this,L,null,!0,!1)};function F(L,z,re,D,G){var U=L._readableState;if(z===null)U.reading=!1,de(L,U);else{var Q;G||(Q=W(U,z)),Q?L.emit("error",Q):U.objectMode||z&&z.length>0?(typeof z!="string"&&!U.objectMode&&Object.getPrototypeOf(z)!==o.prototype&&(z=h(z)),D?U.endEmitted?L.emit("error",new Error("stream.unshift() after end event")):H(L,U,z,!0):U.ended?L.emit("error",new Error("stream.push() after EOF")):(U.reading=!1,U.decoder&&!re?(z=U.decoder.write(z),U.objectMode||z.length!==0?H(L,U,z,!1):A(L,U)):H(L,U,z,!1))):D||(U.reading=!1)}return Z(U)}function H(L,z,re,D){z.flowing&&z.length===0&&!z.sync?(L.emit("data",re),L.read(0)):(z.length+=z.objectMode?1:re.length,D?z.buffer.unshift(re):z.buffer.push(re),z.needReadable&&J(L)),A(L,z)}function W(L,z){var re;return!l(z)&&typeof z!="string"&&z!==void 0&&!L.objectMode&&(re=new TypeError("Invalid non-string/buffer chunk")),re}function Z(L){return!L.ended&&(L.needReadable||L.length<L.highWaterMark||L.length===0)}C.prototype.isPaused=function(){return this._readableState.flowing===!1},C.prototype.setEncoding=function(L){return v||(v=requireString_decoder().StringDecoder),this._readableState.decoder=new v(L),this._readableState.encoding=L,this};var ie=8388608;function te(L){return L>=ie?L=ie:(L--,L|=L>>>1,L|=L>>>2,L|=L>>>4,L|=L>>>8,L|=L>>>16,L++),L}function ae(L,z){return L<=0||z.length===0&&z.ended?0:z.objectMode?1:L!==L?z.flowing&&z.length?z.buffer.head.data.length:z.length:(L>z.highWaterMark&&(z.highWaterMark=te(L)),L<=z.length?L:z.ended?z.length:(z.needReadable=!0,0))}C.prototype.read=function(L){p("read",L),L=parseInt(L,10);var z=this._readableState,re=L;if(L!==0&&(z.emittedReadable=!1),L===0&&z.needReadable&&(z.length>=z.highWaterMark||z.ended))return p("read: emitReadable",z.length,z.ended),z.length===0&&z.ended?ee(this):J(this),null;if(L=ae(L,z),L===0&&z.ended)return z.length===0&&ee(this),null;var D=z.needReadable;p("need readable",D),(z.length===0||z.length-L<z.highWaterMark)&&(D=!0,p("length less than watermark",D)),z.ended||z.reading?(D=!1,p("reading or ended",D)):D&&(p("do read"),z.reading=!0,z.sync=!0,z.length===0&&(z.needReadable=!0),this._read(z.highWaterMark),z.sync=!1,z.reading||(L=ae(re,z)));var G;return L>0?G=_(L,z):G=null,G===null?(z.needReadable=!0,L=0):z.length-=L,z.length===0&&(z.ended||(z.needReadable=!0),re!==L&&z.ended&&ee(this)),G!==null&&this.emit("data",G),G};function de(L,z){if(!z.ended){if(z.decoder){var re=z.decoder.end();re&&re.length&&(z.buffer.push(re),z.length+=z.objectMode?1:re.length)}z.ended=!0,J(L)}}function J(L){var z=L._readableState;z.needReadable=!1,z.emittedReadable||(p("emitReadable",z.flowing),z.emittedReadable=!0,z.sync?t.nextTick(R,L):R(L))}function R(L){p("emit readable"),L.emit("readable"),P(L)}function A(L,z){z.readingMore||(z.readingMore=!0,t.nextTick(y,L,z))}function y(L,z){for(var re=z.length;!z.reading&&!z.flowing&&!z.ended&&z.length<z.highWaterMark&&(p("maybeReadMore read 0"),L.read(0),re!==z.length);)re=z.length;z.readingMore=!1}C.prototype._read=function(L){this.emit("error",new Error("_read() is not implemented"))},C.prototype.pipe=function(L,z){var re=this,D=this._readableState;switch(D.pipesCount){case 0:D.pipes=L;break;case 1:D.pipes=[D.pipes,L];break;default:D.pipes.push(L);break}D.pipesCount+=1,p("pipe count=%d opts=%j",D.pipesCount,z);var G=(!z||z.end!==!1)&&L!==process$1.stdout&&L!==process$1.stderr,U=G?fe:Ne;D.endEmitted?t.nextTick(U):re.once("end",U),L.on("unpipe",Q);function Q(ve,Be){p("onunpipe"),ve===re&&Be&&Be.hasUnpiped===!1&&(Be.hasUnpiped=!0,pe())}function fe(){p("onend"),L.end()}var he=w(re);L.on("drain",he);var le=!1;function pe(){p("cleanup"),L.removeListener("close",ye),L.removeListener("finish",$e),L.removeListener("drain",he),L.removeListener("error",ge),L.removeListener("unpipe",Q),re.removeListener("end",fe),re.removeListener("end",Ne),re.removeListener("data",se),le=!0,D.awaitDrain&&(!L._writableState||L._writableState.needDrain)&&he()}var be=!1;re.on("data",se);function se(ve){p("ondata"),be=!1;var Be=L.write(ve);Be===!1&&!be&&((D.pipesCount===1&&D.pipes===L||D.pipesCount>1&&Y(D.pipes,L)!==-1)&&!le&&(p("false write response, pause",D.awaitDrain),D.awaitDrain++,be=!0),re.pause())}function ge(ve){p("onerror",ve),Ne(),L.removeListener("error",ge),a(L,"error")===0&&L.emit("error",ve)}$(L,"error",ge);function ye(){L.removeListener("finish",$e),Ne()}L.once("close",ye);function $e(){p("onfinish"),L.removeListener("close",ye),Ne()}L.once("finish",$e);function Ne(){p("unpipe"),re.unpipe(L)}return L.emit("pipe",re),D.flowing||(p("pipe resume"),re.resume()),L};function w(L){return function(){var z=L._readableState;p("pipeOnDrain",z.awaitDrain),z.awaitDrain&&z.awaitDrain--,z.awaitDrain===0&&a(L,"data")&&(z.flowing=!0,P(L))}}C.prototype.unpipe=function(L){var z=this._readableState,re={hasUnpiped:!1};if(z.pipesCount===0)return this;if(z.pipesCount===1)return L&&L!==z.pipes?this:(L||(L=z.pipes),z.pipes=null,z.pipesCount=0,z.flowing=!1,L&&L.emit("unpipe",this,re),this);if(!L){var D=z.pipes,G=z.pipesCount;z.pipes=null,z.pipesCount=0,z.flowing=!1;for(var U=0;U<G;U++)D[U].emit("unpipe",this,{hasUnpiped:!1});return this}var Q=Y(z.pipes,L);return Q===-1?this:(z.pipes.splice(Q,1),z.pipesCount-=1,z.pipesCount===1&&(z.pipes=z.pipes[0]),L.emit("unpipe",this,re),this)},C.prototype.on=function(L,z){var re=c.prototype.on.call(this,L,z);if(L==="data")this._readableState.flowing!==!1&&this.resume();else if(L==="readable"){var D=this._readableState;!D.endEmitted&&!D.readableListening&&(D.readableListening=D.needReadable=!0,D.emittedReadable=!1,D.reading?D.length&&J(this):t.nextTick(I,this))}return re},C.prototype.addListener=C.prototype.on;function I(L){p("readable nexttick read 0"),L.read(0)}C.prototype.resume=function(){var L=this._readableState;return L.flowing||(p("resume"),L.flowing=!0,M(this,L)),this};function M(L,z){z.resumeScheduled||(z.resumeScheduled=!0,t.nextTick(k,L,z))}function k(L,z){z.reading||(p("resume read 0"),L.read(0)),z.resumeScheduled=!1,z.awaitDrain=0,L.emit("resume"),P(L),z.flowing&&!z.reading&&L.read(0)}C.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function P(L){var z=L._readableState;for(p("flow",z.flowing);z.flowing&&L.read()!==null;);}C.prototype.wrap=function(L){var z=this,re=this._readableState,D=!1;L.on("end",function(){if(p("wrapped end"),re.decoder&&!re.ended){var Q=re.decoder.end();Q&&Q.length&&z.push(Q)}z.push(null)}),L.on("data",function(Q){if(p("wrapped data"),re.decoder&&(Q=re.decoder.write(Q)),!(re.objectMode&&Q==null)&&!(!re.objectMode&&(!Q||!Q.length))){var fe=z.push(Q);fe||(D=!0,L.pause())}});for(var G in L)this[G]===void 0&&typeof L[G]=="function"&&(this[G]=function(Q){return function(){return L[Q].apply(L,arguments)}}(G));for(var U=0;U<g.length;U++)L.on(g[U],this.emit.bind(this,g[U]));return this._read=function(Q){p("wrapped _read",Q),D&&(D=!1,L.resume())},this},Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),C._fromList=_;function _(L,z){if(z.length===0)return null;var re;return z.objectMode?re=z.buffer.shift():!L||L>=z.length?(z.decoder?re=z.buffer.join(""):z.buffer.length===1?re=z.buffer.head.data:re=z.buffer.concat(z.length),z.buffer.clear()):re=q(L,z.buffer,z.decoder),re}function q(L,z,re){var D;return L<z.head.data.length?(D=z.head.data.slice(0,L),z.head.data=z.head.data.slice(L)):L===z.head.data.length?D=z.shift():D=re?E(L,z):j(L,z),D}function E(L,z){var re=z.head,D=1,G=re.data;for(L-=G.length;re=re.next;){var U=re.data,Q=L>U.length?U.length:L;if(Q===U.length?G+=U:G+=U.slice(0,L),L-=Q,L===0){Q===U.length?(++D,re.next?z.head=re.next:z.head=z.tail=null):(z.head=re,re.data=U.slice(Q));break}++D}return z.length-=D,G}function j(L,z){var re=o.allocUnsafe(L),D=z.head,G=1;for(D.data.copy(re),L-=D.data.length;D=D.next;){var U=D.data,Q=L>U.length?U.length:L;if(U.copy(re,re.length-L,0,Q),L-=Q,L===0){Q===U.length?(++G,D.next?z.head=D.next:z.head=z.tail=null):(z.head=D,D.data=U.slice(Q));break}++G}return z.length-=G,re}function ee(L){var z=L._readableState;if(z.length>0)throw new Error('"endReadable()" called on non-empty stream');z.endEmitted||(z.ended=!0,t.nextTick(oe,z,L))}function oe(L,z){!L.endEmitted&&L.length===0&&(L.endEmitted=!0,z.readable=!1,z.emit("end"))}function Y(L,z){for(var re=0,D=L.length;re<D;re++)if(L[re]===z)return re;return-1}return _stream_readable}var _stream_transform,hasRequired_stream_transform;function require_stream_transform(){if(hasRequired_stream_transform)return _stream_transform;hasRequired_stream_transform=1,_stream_transform=a;var t=require_stream_duplex(),e=Object.create(requireUtil());e.inherits=inherits_browserExports,e.inherits(a,t);function n(u,h){var l=this._transformState;l.transforming=!1;var b=l.writecb;if(!b)return this.emit("error",new Error("write callback called multiple times"));l.writechunk=null,l.writecb=null,h!=null&&this.push(h),b(u);var d=this._readableState;d.reading=!1,(d.needReadable||d.length<d.highWaterMark)&&this._read(d.highWaterMark)}function a(u){if(!(this instanceof a))return new a(u);t.call(this,u),this._transformState={afterTransform:n.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,u&&(typeof u.transform=="function"&&(this._transform=u.transform),typeof u.flush=="function"&&(this._flush=u.flush)),this.on("prefinish",c)}function c(){var u=this;typeof this._flush=="function"?this._flush(function(h,l){o(u,h,l)}):o(this,null,null)}a.prototype.push=function(u,h){return this._transformState.needTransform=!1,t.prototype.push.call(this,u,h)},a.prototype._transform=function(u,h,l){throw new Error("_transform() is not implemented")},a.prototype._write=function(u,h,l){var b=this._transformState;if(b.writecb=l,b.writechunk=u,b.writeencoding=h,!b.transforming){var d=this._readableState;(b.needTransform||d.needReadable||d.length<d.highWaterMark)&&this._read(d.highWaterMark)}},a.prototype._read=function(u){var h=this._transformState;h.writechunk!==null&&h.writecb&&!h.transforming?(h.transforming=!0,this._transform(h.writechunk,h.writeencoding,h.afterTransform)):h.needTransform=!0},a.prototype._destroy=function(u,h){var l=this;t.prototype._destroy.call(this,u,function(b){h(b),l.emit("close")})};function o(u,h,l){if(h)return u.emit("error",h);if(l!=null&&u.push(l),u._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(u._transformState.transforming)throw new Error("Calling transform done when still transforming");return u.push(null)}return _stream_transform}var _stream_passthrough,hasRequired_stream_passthrough;function require_stream_passthrough(){if(hasRequired_stream_passthrough)return _stream_passthrough;hasRequired_stream_passthrough=1,_stream_passthrough=n;var t=require_stream_transform(),e=Object.create(requireUtil());e.inherits=inherits_browserExports,e.inherits(n,t);function n(a){if(!(this instanceof n))return new n(a);t.call(this,a)}return n.prototype._transform=function(a,c,o){o(null,a)},_stream_passthrough}var hasRequiredReadableBrowser;function requireReadableBrowser(){return hasRequiredReadableBrowser||(hasRequiredReadableBrowser=1,function(t,e){e=t.exports=require_stream_readable(),e.Stream=e,e.Readable=e,e.Writable=require_stream_writable(),e.Duplex=require_stream_duplex(),e.Transform=require_stream_transform(),e.PassThrough=require_stream_passthrough()}(readableBrowser,readableBrowser.exports)),readableBrowser.exports}var sign$1={exports:{}},bn={exports:{}};bn.exports;var hasRequiredBn;function requireBn(){return hasRequiredBn||(hasRequiredBn=1,function(t){(function(e,n){function a(A,y){if(!A)throw new Error(y||"Assertion failed")}function c(A,y){A.super_=y;var w=function(){};w.prototype=y.prototype,A.prototype=new w,A.prototype.constructor=A}function o(A,y,w){if(o.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((y==="le"||y==="be")&&(w=y,y=10),this._init(A||0,y||10,w||"be"))}typeof e=="object"?e.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var u;try{typeof window<"u"&&typeof window.Buffer<"u"?u=window.Buffer:u=require$$1$2.Buffer}catch{}o.isBN=function(y){return y instanceof o?!0:y!==null&&typeof y=="object"&&y.constructor.wordSize===o.wordSize&&Array.isArray(y.words)},o.max=function(y,w){return y.cmp(w)>0?y:w},o.min=function(y,w){return y.cmp(w)<0?y:w},o.prototype._init=function(y,w,I){if(typeof y=="number")return this._initNumber(y,w,I);if(typeof y=="object")return this._initArray(y,w,I);w==="hex"&&(w=16),a(w===(w|0)&&w>=2&&w<=36),y=y.toString().replace(/\s+/g,"");var M=0;y[0]==="-"&&(M++,this.negative=1),M<y.length&&(w===16?this._parseHex(y,M,I):(this._parseBase(y,w,M),I==="le"&&this._initArray(this.toArray(),w,I)))},o.prototype._initNumber=function(y,w,I){y<0&&(this.negative=1,y=-y),y<67108864?(this.words=[y&67108863],this.length=1):y<4503599627370496?(this.words=[y&67108863,y/67108864&67108863],this.length=2):(a(y<9007199254740992),this.words=[y&67108863,y/67108864&67108863,1],this.length=3),I==="le"&&this._initArray(this.toArray(),w,I)},o.prototype._initArray=function(y,w,I){if(a(typeof y.length=="number"),y.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(y.length/3),this.words=new Array(this.length);for(var M=0;M<this.length;M++)this.words[M]=0;var k,P,_=0;if(I==="be")for(M=y.length-1,k=0;M>=0;M-=3)P=y[M]|y[M-1]<<8|y[M-2]<<16,this.words[k]|=P<<_&67108863,this.words[k+1]=P>>>26-_&67108863,_+=24,_>=26&&(_-=26,k++);else if(I==="le")for(M=0,k=0;M<y.length;M+=3)P=y[M]|y[M+1]<<8|y[M+2]<<16,this.words[k]|=P<<_&67108863,this.words[k+1]=P>>>26-_&67108863,_+=24,_>=26&&(_-=26,k++);return this._strip()};function h(A,y){var w=A.charCodeAt(y);if(w>=48&&w<=57)return w-48;if(w>=65&&w<=70)return w-55;if(w>=97&&w<=102)return w-87;a(!1,"Invalid character in "+A)}function l(A,y,w){var I=h(A,w);return w-1>=y&&(I|=h(A,w-1)<<4),I}o.prototype._parseHex=function(y,w,I){this.length=Math.ceil((y.length-w)/6),this.words=new Array(this.length);for(var M=0;M<this.length;M++)this.words[M]=0;var k=0,P=0,_;if(I==="be")for(M=y.length-1;M>=w;M-=2)_=l(y,w,M)<<k,this.words[P]|=_&67108863,k>=18?(k-=18,P+=1,this.words[P]|=_>>>26):k+=8;else{var q=y.length-w;for(M=q%2===0?w+1:w;M<y.length;M+=2)_=l(y,w,M)<<k,this.words[P]|=_&67108863,k>=18?(k-=18,P+=1,this.words[P]|=_>>>26):k+=8}this._strip()};function b(A,y,w,I){for(var M=0,k=0,P=Math.min(A.length,w),_=y;_<P;_++){var q=A.charCodeAt(_)-48;M*=I,q>=49?k=q-49+10:q>=17?k=q-17+10:k=q,a(q>=0&&k<I,"Invalid character"),M+=k}return M}o.prototype._parseBase=function(y,w,I){this.words=[0],this.length=1;for(var M=0,k=1;k<=67108863;k*=w)M++;M--,k=k/w|0;for(var P=y.length-I,_=P%M,q=Math.min(P,P-_)+I,E=0,j=I;j<q;j+=M)E=b(y,j,j+M,w),this.imuln(k),this.words[0]+E<67108864?this.words[0]+=E:this._iaddn(E);if(_!==0){var ee=1;for(E=b(y,j,y.length,w),j=0;j<_;j++)ee*=w;this.imuln(ee),this.words[0]+E<67108864?this.words[0]+=E:this._iaddn(E)}this._strip()},o.prototype.copy=function(y){y.words=new Array(this.length);for(var w=0;w<this.length;w++)y.words[w]=this.words[w];y.length=this.length,y.negative=this.negative,y.red=this.red};function d(A,y){A.words=y.words,A.length=y.length,A.negative=y.negative,A.red=y.red}if(o.prototype._move=function(y){d(y,this)},o.prototype.clone=function(){var y=new o(null);return this.copy(y),y},o.prototype._expand=function(y){for(;this.length<y;)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")]=p}catch{o.prototype.inspect=p}else o.prototype.inspect=p;function p(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","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"],m=[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],v=[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(y,w){y=y||10,w=w|0||1;var I;if(y===16||y==="hex"){I="";for(var M=0,k=0,P=0;P<this.length;P++){var _=this.words[P],q=((_<<M|k)&16777215).toString(16);k=_>>>24-M&16777215,M+=2,M>=26&&(M-=26,P--),k!==0||P!==this.length-1?I=x[6-q.length]+q+I:I=q+I}for(k!==0&&(I=k.toString(16)+I);I.length%w!==0;)I="0"+I;return this.negative!==0&&(I="-"+I),I}if(y===(y|0)&&y>=2&&y<=36){var E=m[y],j=v[y];I="";var ee=this.clone();for(ee.negative=0;!ee.isZero();){var oe=ee.modrn(j).toString(y);ee=ee.idivn(j),ee.isZero()?I=oe+I:I=x[E-oe.length]+oe+I}for(this.isZero()&&(I="0"+I);I.length%w!==0;)I="0"+I;return this.negative!==0&&(I="-"+I),I}a(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var y=this.words[0];return this.length===2?y+=this.words[1]*67108864:this.length===3&&this.words[2]===1?y+=4503599627370496+this.words[1]*67108864:this.length>2&&a(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-y:y},o.prototype.toJSON=function(){return this.toString(16,2)},u&&(o.prototype.toBuffer=function(y,w){return this.toArrayLike(u,y,w)}),o.prototype.toArray=function(y,w){return this.toArrayLike(Array,y,w)};var g=function(y,w){return y.allocUnsafe?y.allocUnsafe(w):new y(w)};o.prototype.toArrayLike=function(y,w,I){this._strip();var M=this.byteLength(),k=I||Math.max(1,M);a(M<=k,"byte array longer than desired length"),a(k>0,"Requested array length <= 0");var P=g(y,k),_=w==="le"?"LE":"BE";return this["_toArrayLike"+_](P,M),P},o.prototype._toArrayLikeLE=function(y,w){for(var I=0,M=0,k=0,P=0;k<this.length;k++){var _=this.words[k]<<P|M;y[I++]=_&255,I<y.length&&(y[I++]=_>>8&255),I<y.length&&(y[I++]=_>>16&255),P===6?(I<y.length&&(y[I++]=_>>24&255),M=0,P=0):(M=_>>>24,P+=2)}if(I<y.length)for(y[I++]=M;I<y.length;)y[I++]=0},o.prototype._toArrayLikeBE=function(y,w){for(var I=y.length-1,M=0,k=0,P=0;k<this.length;k++){var _=this.words[k]<<P|M;y[I--]=_&255,I>=0&&(y[I--]=_>>8&255),I>=0&&(y[I--]=_>>16&255),P===6?(I>=0&&(y[I--]=_>>24&255),M=0,P=0):(M=_>>>24,P+=2)}if(I>=0)for(y[I--]=M;I>=0;)y[I--]=0},Math.clz32?o.prototype._countBits=function(y){return 32-Math.clz32(y)}:o.prototype._countBits=function(y){var w=y,I=0;return w>=4096&&(I+=13,w>>>=13),w>=64&&(I+=7,w>>>=7),w>=8&&(I+=4,w>>>=4),w>=2&&(I+=2,w>>>=2),I+w},o.prototype._zeroBits=function(y){if(y===0)return 26;var w=y,I=0;return w&8191||(I+=13,w>>>=13),w&127||(I+=7,w>>>=7),w&15||(I+=4,w>>>=4),w&3||(I+=2,w>>>=2),w&1||I++,I},o.prototype.bitLength=function(){var y=this.words[this.length-1],w=this._countBits(y);return(this.length-1)*26+w};function $(A){for(var y=new Array(A.bitLength()),w=0;w<y.length;w++){var I=w/26|0,M=w%26;y[w]=A.words[I]>>>M&1}return y}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var y=0,w=0;w<this.length;w++){var I=this._zeroBits(this.words[w]);if(y+=I,I!==26)break}return y},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(y){return this.negative!==0?this.abs().inotn(y).iaddn(1):this.clone()},o.prototype.fromTwos=function(y){return this.testn(y-1)?this.notn(y).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(y){for(;this.length<y.length;)this.words[this.length++]=0;for(var w=0;w<y.length;w++)this.words[w]=this.words[w]|y.words[w];return this._strip()},o.prototype.ior=function(y){return a((this.negative|y.negative)===0),this.iuor(y)},o.prototype.or=function(y){return this.length>y.length?this.clone().ior(y):y.clone().ior(this)},o.prototype.uor=function(y){return this.length>y.length?this.clone().iuor(y):y.clone().iuor(this)},o.prototype.iuand=function(y){var w;this.length>y.length?w=y:w=this;for(var I=0;I<w.length;I++)this.words[I]=this.words[I]&y.words[I];return this.length=w.length,this._strip()},o.prototype.iand=function(y){return a((this.negative|y.negative)===0),this.iuand(y)},o.prototype.and=function(y){return this.length>y.length?this.clone().iand(y):y.clone().iand(this)},o.prototype.uand=function(y){return this.length>y.length?this.clone().iuand(y):y.clone().iuand(this)},o.prototype.iuxor=function(y){var w,I;this.length>y.length?(w=this,I=y):(w=y,I=this);for(var M=0;M<I.length;M++)this.words[M]=w.words[M]^I.words[M];if(this!==w)for(;M<w.length;M++)this.words[M]=w.words[M];return this.length=w.length,this._strip()},o.prototype.ixor=function(y){return a((this.negative|y.negative)===0),this.iuxor(y)},o.prototype.xor=function(y){return this.length>y.length?this.clone().ixor(y):y.clone().ixor(this)},o.prototype.uxor=function(y){return this.length>y.length?this.clone().iuxor(y):y.clone().iuxor(this)},o.prototype.inotn=function(y){a(typeof y=="number"&&y>=0);var w=Math.ceil(y/26)|0,I=y%26;this._expand(w),I>0&&w--;for(var M=0;M<w;M++)this.words[M]=~this.words[M]&67108863;return I>0&&(this.words[M]=~this.words[M]&67108863>>26-I),this._strip()},o.prototype.notn=function(y){return this.clone().inotn(y)},o.prototype.setn=function(y,w){a(typeof y=="number"&&y>=0);var I=y/26|0,M=y%26;return this._expand(I+1),w?this.words[I]=this.words[I]|1<<M:this.words[I]=this.words[I]&~(1<<M),this._strip()},o.prototype.iadd=function(y){var w;if(this.negative!==0&&y.negative===0)return this.negative=0,w=this.isub(y),this.negative^=1,this._normSign();if(this.negative===0&&y.negative!==0)return y.negative=0,w=this.isub(y),y.negative=1,w._normSign();var I,M;this.length>y.length?(I=this,M=y):(I=y,M=this);for(var k=0,P=0;P<M.length;P++)w=(I.words[P]|0)+(M.words[P]|0)+k,this.words[P]=w&67108863,k=w>>>26;for(;k!==0&&P<I.length;P++)w=(I.words[P]|0)+k,this.words[P]=w&67108863,k=w>>>26;if(this.length=I.length,k!==0)this.words[this.length]=k,this.length++;else if(I!==this)for(;P<I.length;P++)this.words[P]=I.words[P];return this},o.prototype.add=function(y){var w;return y.negative!==0&&this.negative===0?(y.negative=0,w=this.sub(y),y.negative^=1,w):y.negative===0&&this.negative!==0?(this.negative=0,w=y.sub(this),this.negative=1,w):this.length>y.length?this.clone().iadd(y):y.clone().iadd(this)},o.prototype.isub=function(y){if(y.negative!==0){y.negative=0;var w=this.iadd(y);return y.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(y),this.negative=1,this._normSign();var I=this.cmp(y);if(I===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,k;I>0?(M=this,k=y):(M=y,k=this);for(var P=0,_=0;_<k.length;_++)w=(M.words[_]|0)-(k.words[_]|0)+P,P=w>>26,this.words[_]=w&67108863;for(;P!==0&&_<M.length;_++)w=(M.words[_]|0)+P,P=w>>26,this.words[_]=w&67108863;if(P===0&&_<M.length&&M!==this)for(;_<M.length;_++)this.words[_]=M.words[_];return this.length=Math.max(this.length,_),M!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(y){return this.clone().isub(y)};function B(A,y,w){w.negative=y.negative^A.negative;var I=A.length+y.length|0;w.length=I,I=I-1|0;var M=A.words[0]|0,k=y.words[0]|0,P=M*k,_=P&67108863,q=P/67108864|0;w.words[0]=_;for(var E=1;E<I;E++){for(var j=q>>>26,ee=q&67108863,oe=Math.min(E,y.length-1),Y=Math.max(0,E-A.length+1);Y<=oe;Y++){var L=E-Y|0;M=A.words[L]|0,k=y.words[Y]|0,P=M*k+ee,j+=P/67108864|0,ee=P&67108863}w.words[E]=ee|0,q=j|0}return q!==0?w.words[E]=q|0:w.length--,w._strip()}var C=function(y,w,I){var M=y.words,k=w.words,P=I.words,_=0,q,E,j,ee=M[0]|0,oe=ee&8191,Y=ee>>>13,L=M[1]|0,z=L&8191,re=L>>>13,D=M[2]|0,G=D&8191,U=D>>>13,Q=M[3]|0,fe=Q&8191,he=Q>>>13,le=M[4]|0,pe=le&8191,be=le>>>13,se=M[5]|0,ge=se&8191,ye=se>>>13,$e=M[6]|0,Ne=$e&8191,ve=$e>>>13,Be=M[7]|0,De=Be&8191,Se=Be>>>13,Oe=M[8]|0,Ue=Oe&8191,V=Oe>>>13,T=M[9]|0,O=T&8191,X=T>>>13,ne=k[0]|0,ce=ne&8191,ue=ne>>>13,me=k[1]|0,Ee=me&8191,xe=me>>>13,Ae=k[2]|0,_e=Ae&8191,Me=Ae>>>13,Ge=k[3]|0,Ke=Ge&8191,Ie=Ge>>>13,ze=k[4]|0,Ve=ze&8191,Pe=ze>>>13,We=k[5]|0,Je=We&8191,Te=We>>>13,Ze=k[6]|0,Xe=Ze&8191,ke=Ze>>>13,Ye=k[7]|0,Qe=Ye&8191,qe=Ye>>>13,et=k[8]|0,tt=et&8191,Ce=et>>>13,rt=k[9]|0,He=rt&8191,je=rt>>>13;I.negative=y.negative^w.negative,I.length=19,q=Math.imul(oe,ce),E=Math.imul(oe,ue),E=E+Math.imul(Y,ce)|0,j=Math.imul(Y,ue);var at=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(at>>>26)|0,at&=67108863,q=Math.imul(z,ce),E=Math.imul(z,ue),E=E+Math.imul(re,ce)|0,j=Math.imul(re,ue),q=q+Math.imul(oe,Ee)|0,E=E+Math.imul(oe,xe)|0,E=E+Math.imul(Y,Ee)|0,j=j+Math.imul(Y,xe)|0;var st=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(st>>>26)|0,st&=67108863,q=Math.imul(G,ce),E=Math.imul(G,ue),E=E+Math.imul(U,ce)|0,j=Math.imul(U,ue),q=q+Math.imul(z,Ee)|0,E=E+Math.imul(z,xe)|0,E=E+Math.imul(re,Ee)|0,j=j+Math.imul(re,xe)|0,q=q+Math.imul(oe,_e)|0,E=E+Math.imul(oe,Me)|0,E=E+Math.imul(Y,_e)|0,j=j+Math.imul(Y,Me)|0;var ot=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(ot>>>26)|0,ot&=67108863,q=Math.imul(fe,ce),E=Math.imul(fe,ue),E=E+Math.imul(he,ce)|0,j=Math.imul(he,ue),q=q+Math.imul(G,Ee)|0,E=E+Math.imul(G,xe)|0,E=E+Math.imul(U,Ee)|0,j=j+Math.imul(U,xe)|0,q=q+Math.imul(z,_e)|0,E=E+Math.imul(z,Me)|0,E=E+Math.imul(re,_e)|0,j=j+Math.imul(re,Me)|0,q=q+Math.imul(oe,Ke)|0,E=E+Math.imul(oe,Ie)|0,E=E+Math.imul(Y,Ke)|0,j=j+Math.imul(Y,Ie)|0;var ft=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(ft>>>26)|0,ft&=67108863,q=Math.imul(pe,ce),E=Math.imul(pe,ue),E=E+Math.imul(be,ce)|0,j=Math.imul(be,ue),q=q+Math.imul(fe,Ee)|0,E=E+Math.imul(fe,xe)|0,E=E+Math.imul(he,Ee)|0,j=j+Math.imul(he,xe)|0,q=q+Math.imul(G,_e)|0,E=E+Math.imul(G,Me)|0,E=E+Math.imul(U,_e)|0,j=j+Math.imul(U,Me)|0,q=q+Math.imul(z,Ke)|0,E=E+Math.imul(z,Ie)|0,E=E+Math.imul(re,Ke)|0,j=j+Math.imul(re,Ie)|0,q=q+Math.imul(oe,Ve)|0,E=E+Math.imul(oe,Pe)|0,E=E+Math.imul(Y,Ve)|0,j=j+Math.imul(Y,Pe)|0;var ct=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(ct>>>26)|0,ct&=67108863,q=Math.imul(ge,ce),E=Math.imul(ge,ue),E=E+Math.imul(ye,ce)|0,j=Math.imul(ye,ue),q=q+Math.imul(pe,Ee)|0,E=E+Math.imul(pe,xe)|0,E=E+Math.imul(be,Ee)|0,j=j+Math.imul(be,xe)|0,q=q+Math.imul(fe,_e)|0,E=E+Math.imul(fe,Me)|0,E=E+Math.imul(he,_e)|0,j=j+Math.imul(he,Me)|0,q=q+Math.imul(G,Ke)|0,E=E+Math.imul(G,Ie)|0,E=E+Math.imul(U,Ke)|0,j=j+Math.imul(U,Ie)|0,q=q+Math.imul(z,Ve)|0,E=E+Math.imul(z,Pe)|0,E=E+Math.imul(re,Ve)|0,j=j+Math.imul(re,Pe)|0,q=q+Math.imul(oe,Je)|0,E=E+Math.imul(oe,Te)|0,E=E+Math.imul(Y,Je)|0,j=j+Math.imul(Y,Te)|0;var dt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(dt>>>26)|0,dt&=67108863,q=Math.imul(Ne,ce),E=Math.imul(Ne,ue),E=E+Math.imul(ve,ce)|0,j=Math.imul(ve,ue),q=q+Math.imul(ge,Ee)|0,E=E+Math.imul(ge,xe)|0,E=E+Math.imul(ye,Ee)|0,j=j+Math.imul(ye,xe)|0,q=q+Math.imul(pe,_e)|0,E=E+Math.imul(pe,Me)|0,E=E+Math.imul(be,_e)|0,j=j+Math.imul(be,Me)|0,q=q+Math.imul(fe,Ke)|0,E=E+Math.imul(fe,Ie)|0,E=E+Math.imul(he,Ke)|0,j=j+Math.imul(he,Ie)|0,q=q+Math.imul(G,Ve)|0,E=E+Math.imul(G,Pe)|0,E=E+Math.imul(U,Ve)|0,j=j+Math.imul(U,Pe)|0,q=q+Math.imul(z,Je)|0,E=E+Math.imul(z,Te)|0,E=E+Math.imul(re,Je)|0,j=j+Math.imul(re,Te)|0,q=q+Math.imul(oe,Xe)|0,E=E+Math.imul(oe,ke)|0,E=E+Math.imul(Y,Xe)|0,j=j+Math.imul(Y,ke)|0;var ht=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(ht>>>26)|0,ht&=67108863,q=Math.imul(De,ce),E=Math.imul(De,ue),E=E+Math.imul(Se,ce)|0,j=Math.imul(Se,ue),q=q+Math.imul(Ne,Ee)|0,E=E+Math.imul(Ne,xe)|0,E=E+Math.imul(ve,Ee)|0,j=j+Math.imul(ve,xe)|0,q=q+Math.imul(ge,_e)|0,E=E+Math.imul(ge,Me)|0,E=E+Math.imul(ye,_e)|0,j=j+Math.imul(ye,Me)|0,q=q+Math.imul(pe,Ke)|0,E=E+Math.imul(pe,Ie)|0,E=E+Math.imul(be,Ke)|0,j=j+Math.imul(be,Ie)|0,q=q+Math.imul(fe,Ve)|0,E=E+Math.imul(fe,Pe)|0,E=E+Math.imul(he,Ve)|0,j=j+Math.imul(he,Pe)|0,q=q+Math.imul(G,Je)|0,E=E+Math.imul(G,Te)|0,E=E+Math.imul(U,Je)|0,j=j+Math.imul(U,Te)|0,q=q+Math.imul(z,Xe)|0,E=E+Math.imul(z,ke)|0,E=E+Math.imul(re,Xe)|0,j=j+Math.imul(re,ke)|0,q=q+Math.imul(oe,Qe)|0,E=E+Math.imul(oe,qe)|0,E=E+Math.imul(Y,Qe)|0,j=j+Math.imul(Y,qe)|0;var lt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(lt>>>26)|0,lt&=67108863,q=Math.imul(Ue,ce),E=Math.imul(Ue,ue),E=E+Math.imul(V,ce)|0,j=Math.imul(V,ue),q=q+Math.imul(De,Ee)|0,E=E+Math.imul(De,xe)|0,E=E+Math.imul(Se,Ee)|0,j=j+Math.imul(Se,xe)|0,q=q+Math.imul(Ne,_e)|0,E=E+Math.imul(Ne,Me)|0,E=E+Math.imul(ve,_e)|0,j=j+Math.imul(ve,Me)|0,q=q+Math.imul(ge,Ke)|0,E=E+Math.imul(ge,Ie)|0,E=E+Math.imul(ye,Ke)|0,j=j+Math.imul(ye,Ie)|0,q=q+Math.imul(pe,Ve)|0,E=E+Math.imul(pe,Pe)|0,E=E+Math.imul(be,Ve)|0,j=j+Math.imul(be,Pe)|0,q=q+Math.imul(fe,Je)|0,E=E+Math.imul(fe,Te)|0,E=E+Math.imul(he,Je)|0,j=j+Math.imul(he,Te)|0,q=q+Math.imul(G,Xe)|0,E=E+Math.imul(G,ke)|0,E=E+Math.imul(U,Xe)|0,j=j+Math.imul(U,ke)|0,q=q+Math.imul(z,Qe)|0,E=E+Math.imul(z,qe)|0,E=E+Math.imul(re,Qe)|0,j=j+Math.imul(re,qe)|0,q=q+Math.imul(oe,tt)|0,E=E+Math.imul(oe,Ce)|0,E=E+Math.imul(Y,tt)|0,j=j+Math.imul(Y,Ce)|0;var pt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(pt>>>26)|0,pt&=67108863,q=Math.imul(O,ce),E=Math.imul(O,ue),E=E+Math.imul(X,ce)|0,j=Math.imul(X,ue),q=q+Math.imul(Ue,Ee)|0,E=E+Math.imul(Ue,xe)|0,E=E+Math.imul(V,Ee)|0,j=j+Math.imul(V,xe)|0,q=q+Math.imul(De,_e)|0,E=E+Math.imul(De,Me)|0,E=E+Math.imul(Se,_e)|0,j=j+Math.imul(Se,Me)|0,q=q+Math.imul(Ne,Ke)|0,E=E+Math.imul(Ne,Ie)|0,E=E+Math.imul(ve,Ke)|0,j=j+Math.imul(ve,Ie)|0,q=q+Math.imul(ge,Ve)|0,E=E+Math.imul(ge,Pe)|0,E=E+Math.imul(ye,Ve)|0,j=j+Math.imul(ye,Pe)|0,q=q+Math.imul(pe,Je)|0,E=E+Math.imul(pe,Te)|0,E=E+Math.imul(be,Je)|0,j=j+Math.imul(be,Te)|0,q=q+Math.imul(fe,Xe)|0,E=E+Math.imul(fe,ke)|0,E=E+Math.imul(he,Xe)|0,j=j+Math.imul(he,ke)|0,q=q+Math.imul(G,Qe)|0,E=E+Math.imul(G,qe)|0,E=E+Math.imul(U,Qe)|0,j=j+Math.imul(U,qe)|0,q=q+Math.imul(z,tt)|0,E=E+Math.imul(z,Ce)|0,E=E+Math.imul(re,tt)|0,j=j+Math.imul(re,Ce)|0,q=q+Math.imul(oe,He)|0,E=E+Math.imul(oe,je)|0,E=E+Math.imul(Y,He)|0,j=j+Math.imul(Y,je)|0;var bt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(bt>>>26)|0,bt&=67108863,q=Math.imul(O,Ee),E=Math.imul(O,xe),E=E+Math.imul(X,Ee)|0,j=Math.imul(X,xe),q=q+Math.imul(Ue,_e)|0,E=E+Math.imul(Ue,Me)|0,E=E+Math.imul(V,_e)|0,j=j+Math.imul(V,Me)|0,q=q+Math.imul(De,Ke)|0,E=E+Math.imul(De,Ie)|0,E=E+Math.imul(Se,Ke)|0,j=j+Math.imul(Se,Ie)|0,q=q+Math.imul(Ne,Ve)|0,E=E+Math.imul(Ne,Pe)|0,E=E+Math.imul(ve,Ve)|0,j=j+Math.imul(ve,Pe)|0,q=q+Math.imul(ge,Je)|0,E=E+Math.imul(ge,Te)|0,E=E+Math.imul(ye,Je)|0,j=j+Math.imul(ye,Te)|0,q=q+Math.imul(pe,Xe)|0,E=E+Math.imul(pe,ke)|0,E=E+Math.imul(be,Xe)|0,j=j+Math.imul(be,ke)|0,q=q+Math.imul(fe,Qe)|0,E=E+Math.imul(fe,qe)|0,E=E+Math.imul(he,Qe)|0,j=j+Math.imul(he,qe)|0,q=q+Math.imul(G,tt)|0,E=E+Math.imul(G,Ce)|0,E=E+Math.imul(U,tt)|0,j=j+Math.imul(U,Ce)|0,q=q+Math.imul(z,He)|0,E=E+Math.imul(z,je)|0,E=E+Math.imul(re,He)|0,j=j+Math.imul(re,je)|0;var At=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(At>>>26)|0,At&=67108863,q=Math.imul(O,_e),E=Math.imul(O,Me),E=E+Math.imul(X,_e)|0,j=Math.imul(X,Me),q=q+Math.imul(Ue,Ke)|0,E=E+Math.imul(Ue,Ie)|0,E=E+Math.imul(V,Ke)|0,j=j+Math.imul(V,Ie)|0,q=q+Math.imul(De,Ve)|0,E=E+Math.imul(De,Pe)|0,E=E+Math.imul(Se,Ve)|0,j=j+Math.imul(Se,Pe)|0,q=q+Math.imul(Ne,Je)|0,E=E+Math.imul(Ne,Te)|0,E=E+Math.imul(ve,Je)|0,j=j+Math.imul(ve,Te)|0,q=q+Math.imul(ge,Xe)|0,E=E+Math.imul(ge,ke)|0,E=E+Math.imul(ye,Xe)|0,j=j+Math.imul(ye,ke)|0,q=q+Math.imul(pe,Qe)|0,E=E+Math.imul(pe,qe)|0,E=E+Math.imul(be,Qe)|0,j=j+Math.imul(be,qe)|0,q=q+Math.imul(fe,tt)|0,E=E+Math.imul(fe,Ce)|0,E=E+Math.imul(he,tt)|0,j=j+Math.imul(he,Ce)|0,q=q+Math.imul(G,He)|0,E=E+Math.imul(G,je)|0,E=E+Math.imul(U,He)|0,j=j+Math.imul(U,je)|0;var Bt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,q=Math.imul(O,Ke),E=Math.imul(O,Ie),E=E+Math.imul(X,Ke)|0,j=Math.imul(X,Ie),q=q+Math.imul(Ue,Ve)|0,E=E+Math.imul(Ue,Pe)|0,E=E+Math.imul(V,Ve)|0,j=j+Math.imul(V,Pe)|0,q=q+Math.imul(De,Je)|0,E=E+Math.imul(De,Te)|0,E=E+Math.imul(Se,Je)|0,j=j+Math.imul(Se,Te)|0,q=q+Math.imul(Ne,Xe)|0,E=E+Math.imul(Ne,ke)|0,E=E+Math.imul(ve,Xe)|0,j=j+Math.imul(ve,ke)|0,q=q+Math.imul(ge,Qe)|0,E=E+Math.imul(ge,qe)|0,E=E+Math.imul(ye,Qe)|0,j=j+Math.imul(ye,qe)|0,q=q+Math.imul(pe,tt)|0,E=E+Math.imul(pe,Ce)|0,E=E+Math.imul(be,tt)|0,j=j+Math.imul(be,Ce)|0,q=q+Math.imul(fe,He)|0,E=E+Math.imul(fe,je)|0,E=E+Math.imul(he,He)|0,j=j+Math.imul(he,je)|0;var Rt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,q=Math.imul(O,Ve),E=Math.imul(O,Pe),E=E+Math.imul(X,Ve)|0,j=Math.imul(X,Pe),q=q+Math.imul(Ue,Je)|0,E=E+Math.imul(Ue,Te)|0,E=E+Math.imul(V,Je)|0,j=j+Math.imul(V,Te)|0,q=q+Math.imul(De,Xe)|0,E=E+Math.imul(De,ke)|0,E=E+Math.imul(Se,Xe)|0,j=j+Math.imul(Se,ke)|0,q=q+Math.imul(Ne,Qe)|0,E=E+Math.imul(Ne,qe)|0,E=E+Math.imul(ve,Qe)|0,j=j+Math.imul(ve,qe)|0,q=q+Math.imul(ge,tt)|0,E=E+Math.imul(ge,Ce)|0,E=E+Math.imul(ye,tt)|0,j=j+Math.imul(ye,Ce)|0,q=q+Math.imul(pe,He)|0,E=E+Math.imul(pe,je)|0,E=E+Math.imul(be,He)|0,j=j+Math.imul(be,je)|0;var $t=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+($t>>>26)|0,$t&=67108863,q=Math.imul(O,Je),E=Math.imul(O,Te),E=E+Math.imul(X,Je)|0,j=Math.imul(X,Te),q=q+Math.imul(Ue,Xe)|0,E=E+Math.imul(Ue,ke)|0,E=E+Math.imul(V,Xe)|0,j=j+Math.imul(V,ke)|0,q=q+Math.imul(De,Qe)|0,E=E+Math.imul(De,qe)|0,E=E+Math.imul(Se,Qe)|0,j=j+Math.imul(Se,qe)|0,q=q+Math.imul(Ne,tt)|0,E=E+Math.imul(Ne,Ce)|0,E=E+Math.imul(ve,tt)|0,j=j+Math.imul(ve,Ce)|0,q=q+Math.imul(ge,He)|0,E=E+Math.imul(ge,je)|0,E=E+Math.imul(ye,He)|0,j=j+Math.imul(ye,je)|0;var Mt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,q=Math.imul(O,Xe),E=Math.imul(O,ke),E=E+Math.imul(X,Xe)|0,j=Math.imul(X,ke),q=q+Math.imul(Ue,Qe)|0,E=E+Math.imul(Ue,qe)|0,E=E+Math.imul(V,Qe)|0,j=j+Math.imul(V,qe)|0,q=q+Math.imul(De,tt)|0,E=E+Math.imul(De,Ce)|0,E=E+Math.imul(Se,tt)|0,j=j+Math.imul(Se,Ce)|0,q=q+Math.imul(Ne,He)|0,E=E+Math.imul(Ne,je)|0,E=E+Math.imul(ve,He)|0,j=j+Math.imul(ve,je)|0;var It=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(It>>>26)|0,It&=67108863,q=Math.imul(O,Qe),E=Math.imul(O,qe),E=E+Math.imul(X,Qe)|0,j=Math.imul(X,qe),q=q+Math.imul(Ue,tt)|0,E=E+Math.imul(Ue,Ce)|0,E=E+Math.imul(V,tt)|0,j=j+Math.imul(V,Ce)|0,q=q+Math.imul(De,He)|0,E=E+Math.imul(De,je)|0,E=E+Math.imul(Se,He)|0,j=j+Math.imul(Se,je)|0;var Pt=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,q=Math.imul(O,tt),E=Math.imul(O,Ce),E=E+Math.imul(X,tt)|0,j=Math.imul(X,Ce),q=q+Math.imul(Ue,He)|0,E=E+Math.imul(Ue,je)|0,E=E+Math.imul(V,He)|0,j=j+Math.imul(V,je)|0;var hr=(_+q|0)+((E&8191)<<13)|0;_=(j+(E>>>13)|0)+(hr>>>26)|0,hr&=67108863,q=Math.imul(O,He),E=Math.imul(O,je),E=E+Math.imul(X,He)|0,j=Math.imul(X,je);var lr=(_+q|0)+((E&8191)<<13)|0;return _=(j+(E>>>13)|0)+(lr>>>26)|0,lr&=67108863,P[0]=at,P[1]=st,P[2]=ot,P[3]=ft,P[4]=ct,P[5]=dt,P[6]=ht,P[7]=lt,P[8]=pt,P[9]=bt,P[10]=At,P[11]=Bt,P[12]=Rt,P[13]=$t,P[14]=Mt,P[15]=It,P[16]=Pt,P[17]=hr,P[18]=lr,_!==0&&(P[19]=_,I.length++),I};Math.imul||(C=B);function F(A,y,w){w.negative=y.negative^A.negative,w.length=A.length+y.length;for(var I=0,M=0,k=0;k<w.length-1;k++){var P=M;M=0;for(var _=I&67108863,q=Math.min(k,y.length-1),E=Math.max(0,k-A.length+1);E<=q;E++){var j=k-E,ee=A.words[j]|0,oe=y.words[E]|0,Y=ee*oe,L=Y&67108863;P=P+(Y/67108864|0)|0,L=L+_|0,_=L&67108863,P=P+(L>>>26)|0,M+=P>>>26,P&=67108863}w.words[k]=_,I=P,P=M}return I!==0?w.words[k]=I:w.length--,w._strip()}function H(A,y,w){return F(A,y,w)}o.prototype.mulTo=function(y,w){var I,M=this.length+y.length;return this.length===10&&y.length===10?I=C(this,y,w):M<63?I=B(this,y,w):M<1024?I=F(this,y,w):I=H(this,y,w),I},o.prototype.mul=function(y){var w=new o(null);return w.words=new Array(this.length+y.length),this.mulTo(y,w)},o.prototype.mulf=function(y){var w=new o(null);return w.words=new Array(this.length+y.length),H(this,y,w)},o.prototype.imul=function(y){return this.clone().mulTo(y,this)},o.prototype.imuln=function(y){var w=y<0;w&&(y=-y),a(typeof y=="number"),a(y<67108864);for(var I=0,M=0;M<this.length;M++){var k=(this.words[M]|0)*y,P=(k&67108863)+(I&67108863);I>>=26,I+=k/67108864|0,I+=P>>>26,this.words[M]=P&67108863}return I!==0&&(this.words[M]=I,this.length++),w?this.ineg():this},o.prototype.muln=function(y){return this.clone().imuln(y)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(y){var w=$(y);if(w.length===0)return new o(1);for(var I=this,M=0;M<w.length&&w[M]===0;M++,I=I.sqr());if(++M<w.length)for(var k=I.sqr();M<w.length;M++,k=k.sqr())w[M]!==0&&(I=I.mul(k));return I},o.prototype.iushln=function(y){a(typeof y=="number"&&y>=0);var w=y%26,I=(y-w)/26,M=67108863>>>26-w<<26-w,k;if(w!==0){var P=0;for(k=0;k<this.length;k++){var _=this.words[k]&M,q=(this.words[k]|0)-_<<w;this.words[k]=q|P,P=_>>>26-w}P&&(this.words[k]=P,this.length++)}if(I!==0){for(k=this.length-1;k>=0;k--)this.words[k+I]=this.words[k];for(k=0;k<I;k++)this.words[k]=0;this.length+=I}return this._strip()},o.prototype.ishln=function(y){return a(this.negative===0),this.iushln(y)},o.prototype.iushrn=function(y,w,I){a(typeof y=="number"&&y>=0);var M;w?M=(w-w%26)/26:M=0;var k=y%26,P=Math.min((y-k)/26,this.length),_=67108863^67108863>>>k<<k,q=I;if(M-=P,M=Math.max(0,M),q){for(var E=0;E<P;E++)q.words[E]=this.words[E];q.length=P}if(P!==0)if(this.length>P)for(this.length-=P,E=0;E<this.length;E++)this.words[E]=this.words[E+P];else this.words[0]=0,this.length=1;var j=0;for(E=this.length-1;E>=0&&(j!==0||E>=M);E--){var ee=this.words[E]|0;this.words[E]=j<<26-k|ee>>>k,j=ee&_}return q&&j!==0&&(q.words[q.length++]=j),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(y,w,I){return a(this.negative===0),this.iushrn(y,w,I)},o.prototype.shln=function(y){return this.clone().ishln(y)},o.prototype.ushln=function(y){return this.clone().iushln(y)},o.prototype.shrn=function(y){return this.clone().ishrn(y)},o.prototype.ushrn=function(y){return this.clone().iushrn(y)},o.prototype.testn=function(y){a(typeof y=="number"&&y>=0);var w=y%26,I=(y-w)/26,M=1<<w;if(this.length<=I)return!1;var k=this.words[I];return!!(k&M)},o.prototype.imaskn=function(y){a(typeof y=="number"&&y>=0);var w=y%26,I=(y-w)/26;if(a(this.negative===0,"imaskn works only with positive numbers"),this.length<=I)return this;if(w!==0&&I++,this.length=Math.min(I,this.length),w!==0){var M=67108863^67108863>>>w<<w;this.words[this.length-1]&=M}return this._strip()},o.prototype.maskn=function(y){return this.clone().imaskn(y)},o.prototype.iaddn=function(y){return a(typeof y=="number"),a(y<67108864),y<0?this.isubn(-y):this.negative!==0?this.length===1&&(this.words[0]|0)<=y?(this.words[0]=y-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(y),this.negative=1,this):this._iaddn(y)},o.prototype._iaddn=function(y){this.words[0]+=y;for(var w=0;w<this.length&&this.words[w]>=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},o.prototype.isubn=function(y){if(a(typeof y=="number"),a(y<67108864),y<0)return this.iaddn(-y);if(this.negative!==0)return this.negative=0,this.iaddn(y),this.negative=1,this;if(this.words[0]-=y,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w<this.length&&this.words[w]<0;w++)this.words[w]+=67108864,this.words[w+1]-=1;return this._strip()},o.prototype.addn=function(y){return this.clone().iaddn(y)},o.prototype.subn=function(y){return this.clone().isubn(y)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(y,w,I){var M=y.length+I,k;this._expand(M);var P,_=0;for(k=0;k<y.length;k++){P=(this.words[k+I]|0)+_;var q=(y.words[k]|0)*w;P-=q&67108863,_=(P>>26)-(q/67108864|0),this.words[k+I]=P&67108863}for(;k<this.length-I;k++)P=(this.words[k+I]|0)+_,_=P>>26,this.words[k+I]=P&67108863;if(_===0)return this._strip();for(a(_===-1),_=0,k=0;k<this.length;k++)P=-(this.words[k]|0)+_,_=P>>26,this.words[k]=P&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(y,w){var I=this.length-y.length,M=this.clone(),k=y,P=k.words[k.length-1]|0,_=this._countBits(P);I=26-_,I!==0&&(k=k.ushln(I),M.iushln(I),P=k.words[k.length-1]|0);var q=M.length-k.length,E;if(w!=="mod"){E=new o(null),E.length=q+1,E.words=new Array(E.length);for(var j=0;j<E.length;j++)E.words[j]=0}var ee=M.clone()._ishlnsubmul(k,1,q);ee.negative===0&&(M=ee,E&&(E.words[q]=1));for(var oe=q-1;oe>=0;oe--){var Y=(M.words[k.length+oe]|0)*67108864+(M.words[k.length+oe-1]|0);for(Y=Math.min(Y/P|0,67108863),M._ishlnsubmul(k,Y,oe);M.negative!==0;)Y--,M.negative=0,M._ishlnsubmul(k,1,oe),M.isZero()||(M.negative^=1);E&&(E.words[oe]=Y)}return E&&E._strip(),M._strip(),w!=="div"&&I!==0&&M.iushrn(I),{div:E||null,mod:M}},o.prototype.divmod=function(y,w,I){if(a(!y.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var M,k,P;return this.negative!==0&&y.negative===0?(P=this.neg().divmod(y,w),w!=="mod"&&(M=P.div.neg()),w!=="div"&&(k=P.mod.neg(),I&&k.negative!==0&&k.iadd(y)),{div:M,mod:k}):this.negative===0&&y.negative!==0?(P=this.divmod(y.neg(),w),w!=="mod"&&(M=P.div.neg()),{div:M,mod:P.mod}):this.negative&y.negative?(P=this.neg().divmod(y.neg(),w),w!=="div"&&(k=P.mod.neg(),I&&k.negative!==0&&k.isub(y)),{div:P.div,mod:k}):y.length>this.length||this.cmp(y)<0?{div:new o(0),mod:this}:y.length===1?w==="div"?{div:this.divn(y.words[0]),mod:null}:w==="mod"?{div:null,mod:new o(this.modrn(y.words[0]))}:{div:this.divn(y.words[0]),mod:new o(this.modrn(y.words[0]))}:this._wordDiv(y,w)},o.prototype.div=function(y){return this.divmod(y,"div",!1).div},o.prototype.mod=function(y){return this.divmod(y,"mod",!1).mod},o.prototype.umod=function(y){return this.divmod(y,"mod",!0).mod},o.prototype.divRound=function(y){var w=this.divmod(y);if(w.mod.isZero())return w.div;var I=w.div.negative!==0?w.mod.isub(y):w.mod,M=y.ushrn(1),k=y.andln(1),P=I.cmp(M);return P<0||k===1&&P===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},o.prototype.modrn=function(y){var w=y<0;w&&(y=-y),a(y<=67108863);for(var I=(1<<26)%y,M=0,k=this.length-1;k>=0;k--)M=(I*M+(this.words[k]|0))%y;return w?-M:M},o.prototype.modn=function(y){return this.modrn(y)},o.prototype.idivn=function(y){var w=y<0;w&&(y=-y),a(y<=67108863);for(var I=0,M=this.length-1;M>=0;M--){var k=(this.words[M]|0)+I*67108864;this.words[M]=k/y|0,I=k%y}return this._strip(),w?this.ineg():this},o.prototype.divn=function(y){return this.clone().idivn(y)},o.prototype.egcd=function(y){a(y.negative===0),a(!y.isZero());var w=this,I=y.clone();w.negative!==0?w=w.umod(y):w=w.clone();for(var M=new o(1),k=new o(0),P=new o(0),_=new o(1),q=0;w.isEven()&&I.isEven();)w.iushrn(1),I.iushrn(1),++q;for(var E=I.clone(),j=w.clone();!w.isZero();){for(var ee=0,oe=1;!(w.words[0]&oe)&&ee<26;++ee,oe<<=1);if(ee>0)for(w.iushrn(ee);ee-- >0;)(M.isOdd()||k.isOdd())&&(M.iadd(E),k.isub(j)),M.iushrn(1),k.iushrn(1);for(var Y=0,L=1;!(I.words[0]&L)&&Y<26;++Y,L<<=1);if(Y>0)for(I.iushrn(Y);Y-- >0;)(P.isOdd()||_.isOdd())&&(P.iadd(E),_.isub(j)),P.iushrn(1),_.iushrn(1);w.cmp(I)>=0?(w.isub(I),M.isub(P),k.isub(_)):(I.isub(w),P.isub(M),_.isub(k))}return{a:P,b:_,gcd:I.iushln(q)}},o.prototype._invmp=function(y){a(y.negative===0),a(!y.isZero());var w=this,I=y.clone();w.negative!==0?w=w.umod(y):w=w.clone();for(var M=new o(1),k=new o(0),P=I.clone();w.cmpn(1)>0&&I.cmpn(1)>0;){for(var _=0,q=1;!(w.words[0]&q)&&_<26;++_,q<<=1);if(_>0)for(w.iushrn(_);_-- >0;)M.isOdd()&&M.iadd(P),M.iushrn(1);for(var E=0,j=1;!(I.words[0]&j)&&E<26;++E,j<<=1);if(E>0)for(I.iushrn(E);E-- >0;)k.isOdd()&&k.iadd(P),k.iushrn(1);w.cmp(I)>=0?(w.isub(I),M.isub(k)):(I.isub(w),k.isub(M))}var ee;return w.cmpn(1)===0?ee=M:ee=k,ee.cmpn(0)<0&&ee.iadd(y),ee},o.prototype.gcd=function(y){if(this.isZero())return y.abs();if(y.isZero())return this.abs();var w=this.clone(),I=y.clone();w.negative=0,I.negative=0;for(var M=0;w.isEven()&&I.isEven();M++)w.iushrn(1),I.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;I.isEven();)I.iushrn(1);var k=w.cmp(I);if(k<0){var P=w;w=I,I=P}else if(k===0||I.cmpn(1)===0)break;w.isub(I)}while(!0);return I.iushln(M)},o.prototype.invm=function(y){return this.egcd(y).a.umod(y)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(y){return this.words[0]&y},o.prototype.bincn=function(y){a(typeof y=="number");var w=y%26,I=(y-w)/26,M=1<<w;if(this.length<=I)return this._expand(I+1),this.words[I]|=M,this;for(var k=M,P=I;k!==0&&P<this.length;P++){var _=this.words[P]|0;_+=k,k=_>>>26,_&=67108863,this.words[P]=_}return k!==0&&(this.words[P]=k,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(y){var w=y<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this._strip();var I;if(this.length>1)I=1;else{w&&(y=-y),a(y<=67108863,"Number is too big");var M=this.words[0]|0;I=M===y?0:M<y?-1:1}return this.negative!==0?-I|0:I},o.prototype.cmp=function(y){if(this.negative!==0&&y.negative===0)return-1;if(this.negative===0&&y.negative!==0)return 1;var w=this.ucmp(y);return this.negative!==0?-w|0:w},o.prototype.ucmp=function(y){if(this.length>y.length)return 1;if(this.length<y.length)return-1;for(var w=0,I=this.length-1;I>=0;I--){var M=this.words[I]|0,k=y.words[I]|0;if(M!==k){M<k?w=-1:M>k&&(w=1);break}}return w},o.prototype.gtn=function(y){return this.cmpn(y)===1},o.prototype.gt=function(y){return this.cmp(y)===1},o.prototype.gten=function(y){return this.cmpn(y)>=0},o.prototype.gte=function(y){return this.cmp(y)>=0},o.prototype.ltn=function(y){return this.cmpn(y)===-1},o.prototype.lt=function(y){return this.cmp(y)===-1},o.prototype.lten=function(y){return this.cmpn(y)<=0},o.prototype.lte=function(y){return this.cmp(y)<=0},o.prototype.eqn=function(y){return this.cmpn(y)===0},o.prototype.eq=function(y){return this.cmp(y)===0},o.red=function(y){return new J(y)},o.prototype.toRed=function(y){return a(!this.red,"Already a number in reduction context"),a(this.negative===0,"red works only with positives"),y.convertTo(this)._forceRed(y)},o.prototype.fromRed=function(){return a(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(y){return this.red=y,this},o.prototype.forceRed=function(y){return a(!this.red,"Already a number in reduction context"),this._forceRed(y)},o.prototype.redAdd=function(y){return a(this.red,"redAdd works only with red numbers"),this.red.add(this,y)},o.prototype.redIAdd=function(y){return a(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,y)},o.prototype.redSub=function(y){return a(this.red,"redSub works only with red numbers"),this.red.sub(this,y)},o.prototype.redISub=function(y){return a(this.red,"redISub works only with red numbers"),this.red.isub(this,y)},o.prototype.redShl=function(y){return a(this.red,"redShl works only with red numbers"),this.red.shl(this,y)},o.prototype.redMul=function(y){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,y),this.red.mul(this,y)},o.prototype.redIMul=function(y){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,y),this.red.imul(this,y)},o.prototype.redSqr=function(){return a(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return a(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return a(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return a(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return a(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(y){return a(this.red&&!y.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,y)};var W={k256:null,p224:null,p192:null,p25519:null};function Z(A,y){this.name=A,this.p=new o(y,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 y=new o(null);return y.words=new Array(Math.ceil(this.n/13)),y},Z.prototype.ireduce=function(y){var w=y,I;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),I=w.bitLength();while(I>this.n);var M=I<this.n?-1:w.ucmp(this.p);return M===0?(w.words[0]=0,w.length=1):M>0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},Z.prototype.split=function(y,w){y.iushrn(this.n,0,w)},Z.prototype.imulK=function(y){return y.imul(this.k)};function ie(){Z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}c(ie,Z),ie.prototype.split=function(y,w){for(var I=4194303,M=Math.min(y.length,9),k=0;k<M;k++)w.words[k]=y.words[k];if(w.length=M,y.length<=9){y.words[0]=0,y.length=1;return}var P=y.words[9];for(w.words[w.length++]=P&I,k=10;k<y.length;k++){var _=y.words[k]|0;y.words[k-10]=(_&I)<<4|P>>>22,P=_}P>>>=22,y.words[k-10]=P,P===0&&y.length>10?y.length-=10:y.length-=9},ie.prototype.imulK=function(y){y.words[y.length]=0,y.words[y.length+1]=0,y.length+=2;for(var w=0,I=0;I<y.length;I++){var M=y.words[I]|0;w+=M*977,y.words[I]=w&67108863,w=M*64+(w/67108864|0)}return y.words[y.length-1]===0&&(y.length--,y.words[y.length-1]===0&&y.length--),y};function te(){Z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}c(te,Z);function ae(){Z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}c(ae,Z);function de(){Z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}c(de,Z),de.prototype.imulK=function(y){for(var w=0,I=0;I<y.length;I++){var M=(y.words[I]|0)*19+w,k=M&67108863;M>>>=26,y.words[I]=k,w=M}return w!==0&&(y.words[y.length++]=w),y},o._prime=function(y){if(W[y])return W[y];var w;if(y==="k256")w=new ie;else if(y==="p224")w=new te;else if(y==="p192")w=new ae;else if(y==="p25519")w=new de;else throw new Error("Unknown prime "+y);return W[y]=w,w};function J(A){if(typeof A=="string"){var y=o._prime(A);this.m=y.p,this.prime=y}else a(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}J.prototype._verify1=function(y){a(y.negative===0,"red works only with positives"),a(y.red,"red works only with red numbers")},J.prototype._verify2=function(y,w){a((y.negative|w.negative)===0,"red works only with positives"),a(y.red&&y.red===w.red,"red works only with red numbers")},J.prototype.imod=function(y){return this.prime?this.prime.ireduce(y)._forceRed(this):(d(y,y.umod(this.m)._forceRed(this)),y)},J.prototype.neg=function(y){return y.isZero()?y.clone():this.m.sub(y)._forceRed(this)},J.prototype.add=function(y,w){this._verify2(y,w);var I=y.add(w);return I.cmp(this.m)>=0&&I.isub(this.m),I._forceRed(this)},J.prototype.iadd=function(y,w){this._verify2(y,w);var I=y.iadd(w);return I.cmp(this.m)>=0&&I.isub(this.m),I},J.prototype.sub=function(y,w){this._verify2(y,w);var I=y.sub(w);return I.cmpn(0)<0&&I.iadd(this.m),I._forceRed(this)},J.prototype.isub=function(y,w){this._verify2(y,w);var I=y.isub(w);return I.cmpn(0)<0&&I.iadd(this.m),I},J.prototype.shl=function(y,w){return this._verify1(y),this.imod(y.ushln(w))},J.prototype.imul=function(y,w){return this._verify2(y,w),this.imod(y.imul(w))},J.prototype.mul=function(y,w){return this._verify2(y,w),this.imod(y.mul(w))},J.prototype.isqr=function(y){return this.imul(y,y.clone())},J.prototype.sqr=function(y){return this.mul(y,y)},J.prototype.sqrt=function(y){if(y.isZero())return y.clone();var w=this.m.andln(3);if(a(w%2===1),w===3){var I=this.m.add(new o(1)).iushrn(2);return this.pow(y,I)}for(var M=this.m.subn(1),k=0;!M.isZero()&&M.andln(1)===0;)k++,M.iushrn(1);a(!M.isZero());var P=new o(1).toRed(this),_=P.redNeg(),q=this.m.subn(1).iushrn(1),E=this.m.bitLength();for(E=new o(2*E*E).toRed(this);this.pow(E,q).cmp(_)!==0;)E.redIAdd(_);for(var j=this.pow(E,M),ee=this.pow(y,M.addn(1).iushrn(1)),oe=this.pow(y,M),Y=k;oe.cmp(P)!==0;){for(var L=oe,z=0;L.cmp(P)!==0;z++)L=L.redSqr();a(z<Y);var re=this.pow(j,new o(1).iushln(Y-z-1));ee=ee.redMul(re),j=re.redSqr(),oe=oe.redMul(j),Y=z}return ee},J.prototype.invm=function(y){var w=y._invmp(this.m);return w.negative!==0?(w.negative=0,this.imod(w).redNeg()):this.imod(w)},J.prototype.pow=function(y,w){if(w.isZero())return new o(1).toRed(this);if(w.cmpn(1)===0)return y.clone();var I=4,M=new Array(1<<I);M[0]=new o(1).toRed(this),M[1]=y;for(var k=2;k<M.length;k++)M[k]=this.mul(M[k-1],y);var P=M[0],_=0,q=0,E=w.bitLength()%26;for(E===0&&(E=26),k=w.length-1;k>=0;k--){for(var j=w.words[k],ee=E-1;ee>=0;ee--){var oe=j>>ee&1;if(P!==M[0]&&(P=this.sqr(P)),oe===0&&_===0){q=0;continue}_<<=1,_|=oe,q++,!(q!==I&&(k!==0||ee!==0))&&(P=this.mul(P,M[_]),q=0,_=0)}E=26}return P},J.prototype.convertTo=function(y){var w=y.umod(this.m);return w===y?w.clone():w},J.prototype.convertFrom=function(y){var w=y.clone();return w.red=null,w},o.mont=function(y){return new R(y)};function R(A){J.call(this,A),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)}c(R,J),R.prototype.convertTo=function(y){return this.imod(y.ushln(this.shift))},R.prototype.convertFrom=function(y){var w=this.imod(y.mul(this.rinv));return w.red=null,w},R.prototype.imul=function(y,w){if(y.isZero()||w.isZero())return y.words[0]=0,y.length=1,y;var I=y.imul(w),M=I.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),k=I.isub(M).iushrn(this.shift),P=k;return k.cmp(this.m)>=0?P=k.isub(this.m):k.cmpn(0)<0&&(P=k.iadd(this.m)),P._forceRed(this)},R.prototype.mul=function(y,w){if(y.isZero()||w.isZero())return new o(0)._forceRed(this);var I=y.mul(w),M=I.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),k=I.isub(M).iushrn(this.shift),P=k;return k.cmp(this.m)>=0?P=k.isub(this.m):k.cmpn(0)<0&&(P=k.iadd(this.m)),P._forceRed(this)},R.prototype.invm=function(y){var w=this.imod(y._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(t,commonjsGlobal)}(bn)),bn.exports}var browserifyRsa,hasRequiredBrowserifyRsa;function requireBrowserifyRsa(){if(hasRequiredBrowserifyRsa)return browserifyRsa;hasRequiredBrowserifyRsa=1;var t=requireBn(),e=requireBrowser$b(),n=requireSafeBuffer$1().Buffer;function a(u){var h=u.modulus.byteLength(),l;do l=new t(e(h));while(l.cmp(u.modulus)>=0||!l.umod(u.prime1)||!l.umod(u.prime2));return l}function c(u){var h=a(u),l=h.toRed(t.mont(u.modulus)).redPow(new t(u.publicExponent)).fromRed();return{blinder:l,unblinder:h.invm(u.modulus)}}function o(u,h){var l=c(h),b=h.modulus.byteLength(),d=new t(u).mul(l.blinder).umod(h.modulus),p=d.toRed(t.mont(h.prime1)),x=d.toRed(t.mont(h.prime2)),m=h.coefficient,v=h.prime1,g=h.prime2,$=p.redPow(h.exponent1).fromRed(),B=x.redPow(h.exponent2).fromRed(),C=$.isub(B).imul(m).umod(v).imul(g);return B.iadd(C).imul(l.unblinder).umod(h.modulus).toArrayLike(n,"be",b)}return o.getr=a,browserifyRsa=o,browserifyRsa}var asn1$1={},asn1={},api={},vmBrowserify={},hasRequiredVmBrowserify;function requireVmBrowserify(){return hasRequiredVmBrowserify||(hasRequiredVmBrowserify=1,function(exports){var indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1},Object_keys=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)e.push(n);return e},forEach=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n<t.length;n++)e(t[n],n,t)},defineProp=function(){try{return Object.defineProperty({},"_",{}),function(t,e,n){Object.defineProperty(t,e,{writable:!0,enumerable:!1,configurable:!0,value:n})}}catch{return function(e,n,a){e[n]=a}}}(),globals=["Array","Boolean","Date","Error","EvalError","Function","Infinity","JSON","Math","NaN","Number","Object","RangeError","ReferenceError","RegExp","String","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","eval","isFinite","isNaN","parseFloat","parseInt","undefined","unescape"];function Context(){}Context.prototype={};var Script=exports.Script=function(e){if(!(this instanceof Script))return new Script(e);this.code=e};Script.prototype.runInContext=function(t){if(!(t instanceof Context))throw new TypeError("needs a 'context' argument.");var e=document.createElement("iframe");e.style||(e.style={}),e.style.display="none",document.body.appendChild(e);var n=e.contentWindow,a=n.eval,c=n.execScript;!a&&c&&(c.call(n,"null"),a=n.eval),forEach(Object_keys(t),function(h){n[h]=t[h]}),forEach(globals,function(h){t[h]&&(n[h]=t[h])});var o=Object_keys(n),u=a.call(n,this.code);return forEach(Object_keys(n),function(h){(h in t||indexOf(o,h)===-1)&&(t[h]=n[h])}),forEach(globals,function(h){h in t||defineProp(t,h,n[h])}),document.body.removeChild(e),u},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInNewContext=function(t){var e=Script.createContext(t),n=this.runInContext(e);return t&&forEach(Object_keys(e),function(a){t[a]=e[a]}),n},forEach(Object_keys(Script.prototype),function(t){exports[t]=Script[t]=function(e){var n=Script(e);return n[t].apply(n,[].slice.call(arguments,1))}}),exports.isContext=function(t){return t instanceof Context},exports.createScript=function(t){return exports.Script(t)},exports.createContext=Script.createContext=function(t){var e=new Context;return typeof t=="object"&&forEach(Object_keys(t),function(n){e[n]=t[n]}),e}}(vmBrowserify)),vmBrowserify}var hasRequiredApi;function requireApi(){return hasRequiredApi||(hasRequiredApi=1,function(t){var e=requireAsn1$1(),n=inherits_browserExports,a=t;a.define=function(u,h){return new c(u,h)};function c(o,u){this.name=o,this.body=u,this.decoders={},this.encoders={}}c.prototype._createNamed=function(u){var h;try{h=requireVmBrowserify().runInThisContext("(function "+this.name+`(entity) {
20
- this._initNamed(entity);
21
- })`)}catch{h=function(b){this._initNamed(b)}}return n(h,u),h.prototype._initNamed=function(b){u.call(this,b)},new h(this)},c.prototype._getDecoder=function(u){return u=u||"der",this.decoders.hasOwnProperty(u)||(this.decoders[u]=this._createNamed(e.decoders[u])),this.decoders[u]},c.prototype.decode=function(u,h,l){return this._getDecoder(h).decode(u,l)},c.prototype._getEncoder=function(u){return u=u||"der",this.encoders.hasOwnProperty(u)||(this.encoders[u]=this._createNamed(e.encoders[u])),this.encoders[u]},c.prototype.encode=function(u,h,l){return this._getEncoder(h).encode(u,l)}}(api)),api}var base$1={},reporter={},hasRequiredReporter;function requireReporter(){if(hasRequiredReporter)return reporter;hasRequiredReporter=1;var t=inherits_browserExports;function e(a){this._reporterState={obj:null,path:[],options:a||{},errors:[]}}reporter.Reporter=e,e.prototype.isError=function(c){return c instanceof n},e.prototype.save=function(){var c=this._reporterState;return{obj:c.obj,pathLen:c.path.length}},e.prototype.restore=function(c){var o=this._reporterState;o.obj=c.obj,o.path=o.path.slice(0,c.pathLen)},e.prototype.enterKey=function(c){return this._reporterState.path.push(c)},e.prototype.exitKey=function(c){var o=this._reporterState;o.path=o.path.slice(0,c-1)},e.prototype.leaveKey=function(c,o,u){var h=this._reporterState;this.exitKey(c),h.obj!==null&&(h.obj[o]=u)},e.prototype.path=function(){return this._reporterState.path.join("/")},e.prototype.enterObject=function(){var c=this._reporterState,o=c.obj;return c.obj={},o},e.prototype.leaveObject=function(c){var o=this._reporterState,u=o.obj;return o.obj=c,u},e.prototype.error=function(c){var o,u=this._reporterState,h=c instanceof n;if(h?o=c:o=new n(u.path.map(function(l){return"["+JSON.stringify(l)+"]"}).join(""),c.message||c,c.stack),!u.options.partial)throw o;return h||u.errors.push(o),o},e.prototype.wrapResult=function(c){var o=this._reporterState;return o.options.partial?{result:this.isError(c)?null:c,errors:o.errors}:c};function n(a,c){this.path=a,this.rethrow(c)}return t(n,Error),n.prototype.rethrow=function(c){if(this.message=c+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,n),!this.stack)try{throw new Error(this.message)}catch(o){this.stack=o.stack}return this},reporter}var buffer={},hasRequiredBuffer;function requireBuffer(){if(hasRequiredBuffer)return buffer;hasRequiredBuffer=1;var t=inherits_browserExports,e=requireBase().Reporter,n=require$$1$2.Buffer;function a(o,u){if(e.call(this,u),!n.isBuffer(o)){this.error("Input not Buffer");return}this.base=o,this.offset=0,this.length=o.length}t(a,e),buffer.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:e.prototype.save.call(this)}},a.prototype.restore=function(u){var h=new a(this.base);return h.offset=u.offset,h.length=this.offset,this.offset=u.offset,e.prototype.restore.call(this,u.reporter),h},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(u){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(u||"DecoderBuffer overrun")},a.prototype.skip=function(u,h){if(!(this.offset+u<=this.length))return this.error(h||"DecoderBuffer overrun");var l=new a(this.base);return l._reporterState=this._reporterState,l.offset=this.offset,l.length=this.offset+u,this.offset+=u,l},a.prototype.raw=function(u){return this.base.slice(u?u.offset:this.offset,this.length)};function c(o,u){if(Array.isArray(o))this.length=0,this.value=o.map(function(h){return h instanceof c||(h=new c(h,u)),this.length+=h.length,h},this);else if(typeof o=="number"){if(!(0<=o&&o<=255))return u.error("non-byte EncoderBuffer value");this.value=o,this.length=1}else if(typeof o=="string")this.value=o,this.length=n.byteLength(o);else if(n.isBuffer(o))this.value=o,this.length=o.length;else return u.error("Unsupported type: "+typeof o)}return buffer.EncoderBuffer=c,c.prototype.join=function(u,h){return u||(u=new n(this.length)),h||(h=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(l){l.join(u,h),h+=l.length}):(typeof this.value=="number"?u[h]=this.value:typeof this.value=="string"?u.write(this.value,h):n.isBuffer(this.value)&&this.value.copy(u,h),h+=this.length)),u},buffer}var node,hasRequiredNode;function requireNode(){if(hasRequiredNode)return node;hasRequiredNode=1;var t=requireBase().Reporter,e=requireBase().EncoderBuffer,n=requireBase().DecoderBuffer,a=minimalisticAssert,c=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],o=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(c),u=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function h(b,d){var p={};this._baseState=p,p.enc=b,p.parent=d||null,p.children=null,p.tag=null,p.args=null,p.reverseArgs=null,p.choice=null,p.optional=!1,p.any=!1,p.obj=!1,p.use=null,p.useDecoder=null,p.key=null,p.default=null,p.explicit=null,p.implicit=null,p.contains=null,p.parent||(p.children=[],this._wrap())}node=h;var l=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return h.prototype.clone=function(){var d=this._baseState,p={};l.forEach(function(m){p[m]=d[m]});var x=new this.constructor(p.parent);return x._baseState=p,x},h.prototype._wrap=function(){var d=this._baseState;o.forEach(function(p){this[p]=function(){var m=new this.constructor(this);return d.children.push(m),m[p].apply(m,arguments)}},this)},h.prototype._init=function(d){var p=this._baseState;a(p.parent===null),d.call(this),p.children=p.children.filter(function(x){return x._baseState.parent===this},this),a.equal(p.children.length,1,"Root node can have only one child")},h.prototype._useArgs=function(d){var p=this._baseState,x=d.filter(function(m){return m instanceof this.constructor},this);d=d.filter(function(m){return!(m instanceof this.constructor)},this),x.length!==0&&(a(p.children===null),p.children=x,x.forEach(function(m){m._baseState.parent=this},this)),d.length!==0&&(a(p.args===null),p.args=d,p.reverseArgs=d.map(function(m){if(typeof m!="object"||m.constructor!==Object)return m;var v={};return Object.keys(m).forEach(function(g){g==(g|0)&&(g|=0);var $=m[g];v[$]=g}),v}))},u.forEach(function(b){h.prototype[b]=function(){var p=this._baseState;throw new Error(b+" not implemented for encoding: "+p.enc)}}),c.forEach(function(b){h.prototype[b]=function(){var p=this._baseState,x=Array.prototype.slice.call(arguments);return a(p.tag===null),p.tag=b,this._useArgs(x),this}}),h.prototype.use=function(d){a(d);var p=this._baseState;return a(p.use===null),p.use=d,this},h.prototype.optional=function(){var d=this._baseState;return d.optional=!0,this},h.prototype.def=function(d){var p=this._baseState;return a(p.default===null),p.default=d,p.optional=!0,this},h.prototype.explicit=function(d){var p=this._baseState;return a(p.explicit===null&&p.implicit===null),p.explicit=d,this},h.prototype.implicit=function(d){var p=this._baseState;return a(p.explicit===null&&p.implicit===null),p.implicit=d,this},h.prototype.obj=function(){var d=this._baseState,p=Array.prototype.slice.call(arguments);return d.obj=!0,p.length!==0&&this._useArgs(p),this},h.prototype.key=function(d){var p=this._baseState;return a(p.key===null),p.key=d,this},h.prototype.any=function(){var d=this._baseState;return d.any=!0,this},h.prototype.choice=function(d){var p=this._baseState;return a(p.choice===null),p.choice=d,this._useArgs(Object.keys(d).map(function(x){return d[x]})),this},h.prototype.contains=function(d){var p=this._baseState;return a(p.use===null),p.contains=d,this},h.prototype._decode=function(d,p){var x=this._baseState;if(x.parent===null)return d.wrapResult(x.children[0]._decode(d,p));var m=x.default,v=!0,g=null;if(x.key!==null&&(g=d.enterKey(x.key)),x.optional){var $=null;if(x.explicit!==null?$=x.explicit:x.implicit!==null?$=x.implicit:x.tag!==null&&($=x.tag),$===null&&!x.any){var B=d.save();try{x.choice===null?this._decodeGeneric(x.tag,d,p):this._decodeChoice(d,p),v=!0}catch{v=!1}d.restore(B)}else if(v=this._peekTag(d,$,x.any),d.isError(v))return v}var C;if(x.obj&&v&&(C=d.enterObject()),v){if(x.explicit!==null){var F=this._decodeTag(d,x.explicit);if(d.isError(F))return F;d=F}var H=d.offset;if(x.use===null&&x.choice===null){if(x.any)var B=d.save();var W=this._decodeTag(d,x.implicit!==null?x.implicit:x.tag,x.any);if(d.isError(W))return W;x.any?m=d.raw(B):d=W}if(p&&p.track&&x.tag!==null&&p.track(d.path(),H,d.length,"tagged"),p&&p.track&&x.tag!==null&&p.track(d.path(),d.offset,d.length,"content"),x.any?m=m:x.choice===null?m=this._decodeGeneric(x.tag,d,p):m=this._decodeChoice(d,p),d.isError(m))return m;if(!x.any&&x.choice===null&&x.children!==null&&x.children.forEach(function(te){te._decode(d,p)}),x.contains&&(x.tag==="octstr"||x.tag==="bitstr")){var Z=new n(m);m=this._getUse(x.contains,d._reporterState.obj)._decode(Z,p)}}return x.obj&&v&&(m=d.leaveObject(C)),x.key!==null&&(m!==null||v===!0)?d.leaveKey(g,x.key,m):g!==null&&d.exitKey(g),m},h.prototype._decodeGeneric=function(d,p,x){var m=this._baseState;return d==="seq"||d==="set"?null:d==="seqof"||d==="setof"?this._decodeList(p,d,m.args[0],x):/str$/.test(d)?this._decodeStr(p,d,x):d==="objid"&&m.args?this._decodeObjid(p,m.args[0],m.args[1],x):d==="objid"?this._decodeObjid(p,null,null,x):d==="gentime"||d==="utctime"?this._decodeTime(p,d,x):d==="null_"?this._decodeNull(p,x):d==="bool"?this._decodeBool(p,x):d==="objDesc"?this._decodeStr(p,d,x):d==="int"||d==="enum"?this._decodeInt(p,m.args&&m.args[0],x):m.use!==null?this._getUse(m.use,p._reporterState.obj)._decode(p,x):p.error("unknown tag: "+d)},h.prototype._getUse=function(d,p){var x=this._baseState;return x.useDecoder=this._use(d,p),a(x.useDecoder._baseState.parent===null),x.useDecoder=x.useDecoder._baseState.children[0],x.implicit!==x.useDecoder._baseState.implicit&&(x.useDecoder=x.useDecoder.clone(),x.useDecoder._baseState.implicit=x.implicit),x.useDecoder},h.prototype._decodeChoice=function(d,p){var x=this._baseState,m=null,v=!1;return Object.keys(x.choice).some(function(g){var $=d.save(),B=x.choice[g];try{var C=B._decode(d,p);if(d.isError(C))return!1;m={type:g,value:C},v=!0}catch{return d.restore($),!1}return!0},this),v?m:d.error("Choice not matched")},h.prototype._createEncoderBuffer=function(d){return new e(d,this.reporter)},h.prototype._encode=function(d,p,x){var m=this._baseState;if(!(m.default!==null&&m.default===d)){var v=this._encodeValue(d,p,x);if(v!==void 0&&!this._skipDefault(v,p,x))return v}},h.prototype._encodeValue=function(d,p,x){var m=this._baseState;if(m.parent===null)return m.children[0]._encode(d,p||new t);var B=null;if(this.reporter=p,m.optional&&d===void 0)if(m.default!==null)d=m.default;else return;var v=null,g=!1;if(m.any)B=this._createEncoderBuffer(d);else if(m.choice)B=this._encodeChoice(d,p);else if(m.contains)v=this._getUse(m.contains,x)._encode(d,p),g=!0;else if(m.children)v=m.children.map(function(H){if(H._baseState.tag==="null_")return H._encode(null,p,d);if(H._baseState.key===null)return p.error("Child should have a key");var W=p.enterKey(H._baseState.key);if(typeof d!="object")return p.error("Child expected, but input is not object");var Z=H._encode(d[H._baseState.key],p,d);return p.leaveKey(W),Z},this).filter(function(H){return H}),v=this._createEncoderBuffer(v);else if(m.tag==="seqof"||m.tag==="setof"){if(!(m.args&&m.args.length===1))return p.error("Too many args for : "+m.tag);if(!Array.isArray(d))return p.error("seqof/setof, but data is not Array");var $=this.clone();$._baseState.implicit=null,v=this._createEncoderBuffer(d.map(function(H){var W=this._baseState;return this._getUse(W.args[0],d)._encode(H,p)},$))}else m.use!==null?B=this._getUse(m.use,x)._encode(d,p):(v=this._encodePrimitive(m.tag,d),g=!0);var B;if(!m.any&&m.choice===null){var C=m.implicit!==null?m.implicit:m.tag,F=m.implicit===null?"universal":"context";C===null?m.use===null&&p.error("Tag could be omitted only for .use()"):m.use===null&&(B=this._encodeComposite(C,g,F,v))}return m.explicit!==null&&(B=this._encodeComposite(m.explicit,!1,"context",B)),B},h.prototype._encodeChoice=function(d,p){var x=this._baseState,m=x.choice[d.type];return m||a(!1,d.type+" not found in "+JSON.stringify(Object.keys(x.choice))),m._encode(d.value,p)},h.prototype._encodePrimitive=function(d,p){var x=this._baseState;if(/str$/.test(d))return this._encodeStr(p,d);if(d==="objid"&&x.args)return this._encodeObjid(p,x.reverseArgs[0],x.args[1]);if(d==="objid")return this._encodeObjid(p,null,null);if(d==="gentime"||d==="utctime")return this._encodeTime(p,d);if(d==="null_")return this._encodeNull();if(d==="int"||d==="enum")return this._encodeInt(p,x.args&&x.reverseArgs[0]);if(d==="bool")return this._encodeBool(p);if(d==="objDesc")return this._encodeStr(p,d);throw new Error("Unsupported tag: "+d)},h.prototype._isNumstr=function(d){return/^[0-9 ]*$/.test(d)},h.prototype._isPrintstr=function(d){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(d)},node}var hasRequiredBase;function requireBase(){return hasRequiredBase||(hasRequiredBase=1,function(t){var e=t;e.Reporter=requireReporter().Reporter,e.DecoderBuffer=requireBuffer().DecoderBuffer,e.EncoderBuffer=requireBuffer().EncoderBuffer,e.Node=requireNode()}(base$1)),base$1}var constants={},der={},hasRequiredDer$2;function requireDer$2(){return hasRequiredDer$2||(hasRequiredDer$2=1,function(t){var e=requireConstants();t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=e._reverse(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=e._reverse(t.tag)}(der)),der}var hasRequiredConstants;function requireConstants(){return hasRequiredConstants||(hasRequiredConstants=1,function(t){var e=t;e._reverse=function(a){var c={};return Object.keys(a).forEach(function(o){(o|0)==o&&(o=o|0);var u=a[o];c[u]=o}),c},e.der=requireDer$2()}(constants)),constants}var decoders={},der_1$1,hasRequiredDer$1;function requireDer$1(){if(hasRequiredDer$1)return der_1$1;hasRequiredDer$1=1;var t=inherits_browserExports,e=requireAsn1$1(),n=e.base,a=e.bignum,c=e.constants.der;function o(b){this.enc="der",this.name=b.name,this.entity=b,this.tree=new u,this.tree._init(b.body)}der_1$1=o,o.prototype.decode=function(d,p){return d instanceof n.DecoderBuffer||(d=new n.DecoderBuffer(d,p)),this.tree._decode(d,p)};function u(b){n.Node.call(this,"der",b)}t(u,n.Node),u.prototype._peekTag=function(d,p,x){if(d.isEmpty())return!1;var m=d.save(),v=h(d,'Failed to peek tag: "'+p+'"');return d.isError(v)?v:(d.restore(m),v.tag===p||v.tagStr===p||v.tagStr+"of"===p||x)},u.prototype._decodeTag=function(d,p,x){var m=h(d,'Failed to decode tag of "'+p+'"');if(d.isError(m))return m;var v=l(d,m.primitive,'Failed to get length of "'+p+'"');if(d.isError(v))return v;if(!x&&m.tag!==p&&m.tagStr!==p&&m.tagStr+"of"!==p)return d.error('Failed to match tag: "'+p+'"');if(m.primitive||v!==null)return d.skip(v,'Failed to match body of: "'+p+'"');var g=d.save(),$=this._skipUntilEnd(d,'Failed to skip indefinite length body: "'+this.tag+'"');return d.isError($)?$:(v=d.offset-g.offset,d.restore(g),d.skip(v,'Failed to match body of: "'+p+'"'))},u.prototype._skipUntilEnd=function(d,p){for(;;){var x=h(d,p);if(d.isError(x))return x;var m=l(d,x.primitive,p);if(d.isError(m))return m;var v;if(x.primitive||m!==null?v=d.skip(m):v=this._skipUntilEnd(d,p),d.isError(v))return v;if(x.tagStr==="end")break}},u.prototype._decodeList=function(d,p,x,m){for(var v=[];!d.isEmpty();){var g=this._peekTag(d,"end");if(d.isError(g))return g;var $=x.decode(d,"der",m);if(d.isError($)&&g)break;v.push($)}return v},u.prototype._decodeStr=function(d,p){if(p==="bitstr"){var x=d.readUInt8();return d.isError(x)?x:{unused:x,data:d.raw()}}else if(p==="bmpstr"){var m=d.raw();if(m.length%2===1)return d.error("Decoding of string type: bmpstr length mismatch");for(var v="",g=0;g<m.length/2;g++)v+=String.fromCharCode(m.readUInt16BE(g*2));return v}else if(p==="numstr"){var $=d.raw().toString("ascii");return this._isNumstr($)?$:d.error("Decoding of string type: numstr unsupported characters")}else{if(p==="octstr")return d.raw();if(p==="objDesc")return d.raw();if(p==="printstr"){var B=d.raw().toString("ascii");return this._isPrintstr(B)?B:d.error("Decoding of string type: printstr unsupported characters")}else return/str$/.test(p)?d.raw().toString():d.error("Decoding of string type: "+p+" unsupported")}},u.prototype._decodeObjid=function(d,p,x){for(var m,v=[],g=0;!d.isEmpty();){var $=d.readUInt8();g<<=7,g|=$&127,$&128||(v.push(g),g=0)}$&128&&v.push(g);var B=v[0]/40|0,C=v[0]%40;if(x?m=v:m=[B,C].concat(v.slice(1)),p){var F=p[m.join(" ")];F===void 0&&(F=p[m.join(".")]),F!==void 0&&(m=F)}return m},u.prototype._decodeTime=function(d,p){var x=d.raw().toString();if(p==="gentime")var m=x.slice(0,4)|0,v=x.slice(4,6)|0,g=x.slice(6,8)|0,$=x.slice(8,10)|0,B=x.slice(10,12)|0,C=x.slice(12,14)|0;else if(p==="utctime"){var m=x.slice(0,2)|0,v=x.slice(2,4)|0,g=x.slice(4,6)|0,$=x.slice(6,8)|0,B=x.slice(8,10)|0,C=x.slice(10,12)|0;m<70?m=2e3+m:m=1900+m}else return d.error("Decoding "+p+" time is not supported yet");return Date.UTC(m,v-1,g,$,B,C,0)},u.prototype._decodeNull=function(d){return null},u.prototype._decodeBool=function(d){var p=d.readUInt8();return d.isError(p)?p:p!==0},u.prototype._decodeInt=function(d,p){var x=d.raw(),m=new a(x);return p&&(m=p[m.toString(10)]||m),m},u.prototype._use=function(d,p){return typeof d=="function"&&(d=d(p)),d._getDecoder("der").tree};function h(b,d){var p=b.readUInt8(d);if(b.isError(p))return p;var x=c.tagClass[p>>6],m=(p&32)===0;if((p&31)===31){var v=p;for(p=0;(v&128)===128;){if(v=b.readUInt8(d),b.isError(v))return v;p<<=7,p|=v&127}}else p&=31;var g=c.tag[p];return{cls:x,primitive:m,tag:p,tagStr:g}}function l(b,d,p){var x=b.readUInt8(p);if(b.isError(x))return x;if(!d&&x===128)return null;if(!(x&128))return x;var m=x&127;if(m>4)return b.error("length octect is too long");x=0;for(var v=0;v<m;v++){x<<=8;var g=b.readUInt8(p);if(b.isError(g))return g;x|=g}return x}return der_1$1}var pem$1,hasRequiredPem$1;function requirePem$1(){if(hasRequiredPem$1)return pem$1;hasRequiredPem$1=1;var t=inherits_browserExports,e=require$$1$2.Buffer,n=requireDer$1();function a(c){n.call(this,c),this.enc="pem"}return t(a,n),pem$1=a,a.prototype.decode=function(o,u){for(var h=o.toString().split(/[\r\n]+/g),l=u.label.toUpperCase(),b=/^-----(BEGIN|END) ([^-]+)-----$/,d=-1,p=-1,x=0;x<h.length;x++){var m=h[x].match(b);if(m!==null&&m[2]===l)if(d===-1){if(m[1]!=="BEGIN")break;d=x}else{if(m[1]!=="END")break;p=x;break}}if(d===-1||p===-1)throw new Error("PEM section not found for: "+l);var v=h.slice(d+1,p).join("");v.replace(/[^a-z0-9\+\/=]+/gi,"");var g=new e(v,"base64");return n.prototype.decode.call(this,g,u)},pem$1}var hasRequiredDecoders;function requireDecoders(){return hasRequiredDecoders||(hasRequiredDecoders=1,function(t){var e=t;e.der=requireDer$1(),e.pem=requirePem$1()}(decoders)),decoders}var encoders={},der_1,hasRequiredDer;function requireDer(){if(hasRequiredDer)return der_1;hasRequiredDer=1;var t=inherits_browserExports,e=require$$1$2.Buffer,n=requireAsn1$1(),a=n.base,c=n.constants.der;function o(b){this.enc="der",this.name=b.name,this.entity=b,this.tree=new u,this.tree._init(b.body)}der_1=o,o.prototype.encode=function(d,p){return this.tree._encode(d,p).join()};function u(b){a.Node.call(this,"der",b)}t(u,a.Node),u.prototype._encodeComposite=function(d,p,x,m){var v=l(d,p,x,this.reporter);if(m.length<128){var B=new e(2);return B[0]=v,B[1]=m.length,this._createEncoderBuffer([B,m])}for(var g=1,$=m.length;$>=256;$>>=8)g++;var B=new e(2+g);B[0]=v,B[1]=128|g;for(var $=1+g,C=m.length;C>0;$--,C>>=8)B[$]=C&255;return this._createEncoderBuffer([B,m])},u.prototype._encodeStr=function(d,p){if(p==="bitstr")return this._createEncoderBuffer([d.unused|0,d.data]);if(p==="bmpstr"){for(var x=new e(d.length*2),m=0;m<d.length;m++)x.writeUInt16BE(d.charCodeAt(m),m*2);return this._createEncoderBuffer(x)}else return p==="numstr"?this._isNumstr(d)?this._createEncoderBuffer(d):this.reporter.error("Encoding of string type: numstr supports only digits and space"):p==="printstr"?this._isPrintstr(d)?this._createEncoderBuffer(d):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(p)?this._createEncoderBuffer(d):p==="objDesc"?this._createEncoderBuffer(d):this.reporter.error("Encoding of string type: "+p+" unsupported")},u.prototype._encodeObjid=function(d,p,x){if(typeof d=="string"){if(!p)return this.reporter.error("string objid given, but no values map found");if(!p.hasOwnProperty(d))return this.reporter.error("objid not found in values map");d=p[d].split(/[\s\.]+/g);for(var m=0;m<d.length;m++)d[m]|=0}else if(Array.isArray(d)){d=d.slice();for(var m=0;m<d.length;m++)d[m]|=0}if(!Array.isArray(d))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(d));if(!x){if(d[1]>=40)return this.reporter.error("Second objid identifier OOB");d.splice(0,2,d[0]*40+d[1])}for(var v=0,m=0;m<d.length;m++){var g=d[m];for(v++;g>=128;g>>=7)v++}for(var $=new e(v),B=$.length-1,m=d.length-1;m>=0;m--){var g=d[m];for($[B--]=g&127;(g>>=7)>0;)$[B--]=128|g&127}return this._createEncoderBuffer($)};function h(b){return b<10?"0"+b:b}u.prototype._encodeTime=function(d,p){var x,m=new Date(d);return p==="gentime"?x=[h(m.getFullYear()),h(m.getUTCMonth()+1),h(m.getUTCDate()),h(m.getUTCHours()),h(m.getUTCMinutes()),h(m.getUTCSeconds()),"Z"].join(""):p==="utctime"?x=[h(m.getFullYear()%100),h(m.getUTCMonth()+1),h(m.getUTCDate()),h(m.getUTCHours()),h(m.getUTCMinutes()),h(m.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+p+" time is not supported yet"),this._encodeStr(x,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(d,p){if(typeof d=="string"){if(!p)return this.reporter.error("String int or enum given, but no values map");if(!p.hasOwnProperty(d))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(d));d=p[d]}if(typeof d!="number"&&!e.isBuffer(d)){var x=d.toArray();!d.sign&&x[0]&128&&x.unshift(0),d=new e(x)}if(e.isBuffer(d)){var m=d.length;d.length===0&&m++;var g=new e(m);return d.copy(g),d.length===0&&(g[0]=0),this._createEncoderBuffer(g)}if(d<128)return this._createEncoderBuffer(d);if(d<256)return this._createEncoderBuffer([0,d]);for(var m=1,v=d;v>=256;v>>=8)m++;for(var g=new Array(m),v=g.length-1;v>=0;v--)g[v]=d&255,d>>=8;return g[0]&128&&g.unshift(0),this._createEncoderBuffer(new e(g))},u.prototype._encodeBool=function(d){return this._createEncoderBuffer(d?255:0)},u.prototype._use=function(d,p){return typeof d=="function"&&(d=d(p)),d._getEncoder("der").tree},u.prototype._skipDefault=function(d,p,x){var m=this._baseState,v;if(m.default===null)return!1;var g=d.join();if(m.defaultBuffer===void 0&&(m.defaultBuffer=this._encodeValue(m.default,p,x).join()),g.length!==m.defaultBuffer.length)return!1;for(v=0;v<g.length;v++)if(g[v]!==m.defaultBuffer[v])return!1;return!0};function l(b,d,p,x){var m;if(b==="seqof"?b="seq":b==="setof"&&(b="set"),c.tagByName.hasOwnProperty(b))m=c.tagByName[b];else if(typeof b=="number"&&(b|0)===b)m=b;else return x.error("Unknown tag: "+b);return m>=31?x.error("Multi-octet tag encoding unsupported"):(d||(m|=32),m|=c.tagClassByName[p||"universal"]<<6,m)}return der_1}var pem,hasRequiredPem;function requirePem(){if(hasRequiredPem)return pem;hasRequiredPem=1;var t=inherits_browserExports,e=requireDer();function n(a){e.call(this,a),this.enc="pem"}return t(n,e),pem=n,n.prototype.encode=function(c,o){for(var u=e.prototype.encode.call(this,c),h=u.toString("base64"),l=["-----BEGIN "+o.label+"-----"],b=0;b<h.length;b+=64)l.push(h.slice(b,b+64));return l.push("-----END "+o.label+"-----"),l.join(`
22
- `)},pem}var hasRequiredEncoders;function requireEncoders(){return hasRequiredEncoders||(hasRequiredEncoders=1,function(t){var e=t;e.der=requireDer(),e.pem=requirePem()}(encoders)),encoders}var hasRequiredAsn1$1;function requireAsn1$1(){return hasRequiredAsn1$1||(hasRequiredAsn1$1=1,function(t){var e=t;e.bignum=bnExports,e.define=requireApi().define,e.base=requireBase(),e.constants=requireConstants(),e.decoders=requireDecoders(),e.encoders=requireEncoders()}(asn1)),asn1}var certificate,hasRequiredCertificate;function requireCertificate(){if(hasRequiredCertificate)return certificate;hasRequiredCertificate=1;var t=requireAsn1$1(),e=t.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),n=t.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=t.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),c=t.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),o=t.define("RelativeDistinguishedName",function(){this.setof(n)}),u=t.define("RDNSequence",function(){this.seqof(o)}),h=t.define("Name",function(){this.choice({rdnSequence:this.use(u)})}),l=t.define("Validity",function(){this.seq().obj(this.key("notBefore").use(e),this.key("notAfter").use(e))}),b=t.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=t.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(h),this.key("validity").use(l),this.key("subject").use(h),this.key("subjectPublicKeyInfo").use(c),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(b).optional())}),p=t.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});return certificate=p,certificate}var hasRequiredAsn1;function requireAsn1(){if(hasRequiredAsn1)return asn1$1;hasRequiredAsn1=1;var t=requireAsn1$1();asn1$1.certificate=requireCertificate();var e=t.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});asn1$1.RSAPrivateKey=e;var n=t.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});asn1$1.RSAPublicKey=n;var a=t.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),c=t.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())});asn1$1.PublicKey=c;var o=t.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(a),this.key("subjectPrivateKey").octstr())});asn1$1.PrivateKey=o;var u=t.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});asn1$1.EncryptedPrivateKey=u;var h=t.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});asn1$1.DSAPrivateKey=h,asn1$1.DSAparam=t.define("DSAparam",function(){this.int()});var l=t.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),b=t.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});return asn1$1.ECPrivateKey=b,asn1$1.signature=t.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())}),asn1$1}const require$$1={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"};var fixProc,hasRequiredFixProc;function requireFixProc(){if(hasRequiredFixProc)return fixProc;hasRequiredFixProc=1;var t=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,e=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,a=requireEvp_bytestokey(),c=requireBrowser$6(),o=requireSafeBuffer$1().Buffer;return fixProc=function(u,h){var l=u.toString(),b=l.match(t),d;if(b){var x="aes"+b[1],m=o.from(b[2],"hex"),v=o.from(b[3].replace(/[\r\n]/g,""),"base64"),g=a(h,m.slice(0,8),parseInt(b[1],10)).key,$=[],B=c.createDecipheriv(x,g,m);$.push(B.update(v)),$.push(B.final()),d=o.concat($)}else{var p=l.match(n);d=o.from(p[2].replace(/[\r\n]/g,""),"base64")}var C=l.match(e)[1];return{tag:C,data:d}},fixProc}var parseAsn1,hasRequiredParseAsn1;function requireParseAsn1(){if(hasRequiredParseAsn1)return parseAsn1;hasRequiredParseAsn1=1;var t=requireAsn1(),e=require$$1,n=requireFixProc(),a=requireBrowser$6(),c=requireBrowser$7(),o=requireSafeBuffer$1().Buffer;function u(l,b){var d=l.algorithm.decrypt.kde.kdeparams.salt,p=parseInt(l.algorithm.decrypt.kde.kdeparams.iters.toString(),10),x=e[l.algorithm.decrypt.cipher.algo.join(".")],m=l.algorithm.decrypt.cipher.iv,v=l.subjectPrivateKey,g=parseInt(x.split("-")[1],10)/8,$=c.pbkdf2Sync(b,d,p,g,"sha1"),B=a.createDecipheriv(x,$,m),C=[];return C.push(B.update(v)),C.push(B.final()),o.concat(C)}function h(l){var b;typeof l=="object"&&!o.isBuffer(l)&&(b=l.passphrase,l=l.key),typeof l=="string"&&(l=o.from(l));var d=n(l,b),p=d.tag,x=d.data,m,v;switch(p){case"CERTIFICATE":v=t.certificate.decode(x,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(v||(v=t.PublicKey.decode(x,"der")),m=v.algorithm.algorithm.join("."),m){case"1.2.840.113549.1.1.1":return t.RSAPublicKey.decode(v.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return v.subjectPrivateKey=v.subjectPublicKey,{type:"ec",data:v};case"1.2.840.10040.4.1":return v.algorithm.params.pub_key=t.DSAparam.decode(v.subjectPublicKey.data,"der"),{type:"dsa",data:v.algorithm.params};default:throw new Error("unknown key id "+m)}case"ENCRYPTED PRIVATE KEY":x=t.EncryptedPrivateKey.decode(x,"der"),x=u(x,b);case"PRIVATE KEY":switch(v=t.PrivateKey.decode(x,"der"),m=v.algorithm.algorithm.join("."),m){case"1.2.840.113549.1.1.1":return t.RSAPrivateKey.decode(v.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:v.algorithm.curve,privateKey:t.ECPrivateKey.decode(v.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return v.algorithm.params.priv_key=t.DSAparam.decode(v.subjectPrivateKey,"der"),{type:"dsa",params:v.algorithm.params};default:throw new Error("unknown key id "+m)}case"RSA PUBLIC KEY":return t.RSAPublicKey.decode(x,"der");case"RSA PRIVATE KEY":return t.RSAPrivateKey.decode(x,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:t.DSAPrivateKey.decode(x,"der")};case"EC PRIVATE KEY":return x=t.ECPrivateKey.decode(x,"der"),{curve:x.parameters.value,privateKey:x.privateKey};default:throw new Error("unknown key type "+p)}}return h.signature=t.signature,parseAsn1=h,parseAsn1}const require$$4={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"};var hasRequiredSign;function requireSign(){if(hasRequiredSign)return sign$1.exports;hasRequiredSign=1;var t=requireSafeBuffer$1().Buffer,e=requireBrowser$8(),n=requireBrowserifyRsa(),a=requireElliptic().ec,c=requireBn(),o=requireParseAsn1(),u=require$$4,h=1;function l(B,C,F,H,W){var Z=o(C);if(Z.curve){if(H!=="ecdsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");return b(B,Z)}else if(Z.type==="dsa"){if(H!=="dsa")throw new Error("wrong private key type");return d(B,Z,F)}if(H!=="rsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");if(C.padding!==void 0&&C.padding!==h)throw new Error("illegal or unsupported padding mode");B=t.concat([W,B]);for(var ie=Z.modulus.byteLength(),te=[0,1];B.length+te.length+1<ie;)te.push(255);te.push(0);for(var ae=-1;++ae<B.length;)te.push(B[ae]);var de=n(te,Z);return de}function b(B,C){var F=u[C.curve.join(".")];if(!F)throw new Error("unknown curve "+C.curve.join("."));var H=new a(F),W=H.keyFromPrivate(C.privateKey),Z=W.sign(B);return t.from(Z.toDER())}function d(B,C,F){for(var H=C.params.priv_key,W=C.params.p,Z=C.params.q,ie=C.params.g,te=new c(0),ae,de=m(B,Z).mod(Z),J=!1,R=x(H,Z,B,F);J===!1;)ae=g(Z,R,F),te=$(ie,ae,W,Z),J=ae.invm(Z).imul(de.add(H.mul(te))).mod(Z),J.cmpn(0)===0&&(J=!1,te=new c(0));return p(te,J)}function p(B,C){B=B.toArray(),C=C.toArray(),B[0]&128&&(B=[0].concat(B)),C[0]&128&&(C=[0].concat(C));var F=B.length+C.length+4,H=[48,F,2,B.length];return H=H.concat(B,[2,C.length],C),t.from(H)}function x(B,C,F,H){if(B=t.from(B.toArray()),B.length<C.byteLength()){var W=t.alloc(C.byteLength()-B.length);B=t.concat([W,B])}var Z=F.length,ie=v(F,C),te=t.alloc(Z);te.fill(1);var ae=t.alloc(Z);return ae=e(H,ae).update(te).update(t.from([0])).update(B).update(ie).digest(),te=e(H,ae).update(te).digest(),ae=e(H,ae).update(te).update(t.from([1])).update(B).update(ie).digest(),te=e(H,ae).update(te).digest(),{k:ae,v:te}}function m(B,C){var F=new c(B),H=(B.length<<3)-C.bitLength();return H>0&&F.ishrn(H),F}function v(B,C){B=m(B,C),B=B.mod(C);var F=t.from(B.toArray());if(F.length<C.byteLength()){var H=t.alloc(C.byteLength()-F.length);F=t.concat([H,F])}return F}function g(B,C,F){var H,W;do{for(H=t.alloc(0);H.length*8<B.bitLength();)C.v=e(F,C.k).update(C.v).digest(),H=t.concat([H,C.v]);W=m(H,B),C.k=e(F,C.k).update(C.v).update(t.from([0])).digest(),C.v=e(F,C.k).update(C.v).digest()}while(W.cmp(B)!==-1);return W}function $(B,C,F,H){return B.toRed(c.mont(F)).redPow(C).fromRed().mod(H)}return sign$1.exports=l,sign$1.exports.getKey=x,sign$1.exports.makeKey=g,sign$1.exports}var verify_1,hasRequiredVerify;function requireVerify(){if(hasRequiredVerify)return verify_1;hasRequiredVerify=1;var t=requireSafeBuffer$1().Buffer,e=requireBn(),n=requireElliptic().ec,a=requireParseAsn1(),c=require$$4;function o(b,d,p,x,m){var v=a(p);if(v.type==="ec"){if(x!=="ecdsa"&&x!=="ecdsa/rsa")throw new Error("wrong public key type");return u(b,d,v)}else if(v.type==="dsa"){if(x!=="dsa")throw new Error("wrong public key type");return h(b,d,v)}if(x!=="rsa"&&x!=="ecdsa/rsa")throw new Error("wrong public key type");d=t.concat([m,d]);for(var g=v.modulus.byteLength(),$=[1],B=0;d.length+$.length+2<g;)$.push(255),B+=1;$.push(0);for(var C=-1;++C<d.length;)$.push(d[C]);$=t.from($);var F=e.mont(v.modulus);b=new e(b).toRed(F),b=b.redPow(new e(v.publicExponent)),b=t.from(b.fromRed().toArray());var H=B<8?1:0;for(g=Math.min(b.length,$.length),b.length!==$.length&&(H=1),C=-1;++C<g;)H|=b[C]^$[C];return H===0}function u(b,d,p){var x=c[p.data.algorithm.curve.join(".")];if(!x)throw new Error("unknown curve "+p.data.algorithm.curve.join("."));var m=new n(x),v=p.data.subjectPrivateKey.data;return m.verify(d,b,v)}function h(b,d,p){var x=p.data.p,m=p.data.q,v=p.data.g,g=p.data.pub_key,$=a.signature.decode(b,"der"),B=$.s,C=$.r;l(B,m),l(C,m);var F=e.mont(x),H=B.invm(m),W=v.toRed(F).redPow(new e(d).mul(H).mod(m)).fromRed().mul(g.toRed(F).redPow(C.mul(H).mod(m)).fromRed()).mod(x).mod(m);return W.cmp(C)===0}function l(b,d){if(b.cmpn(0)<=0)throw new Error("invalid sig");if(b.cmp(d)>=0)throw new Error("invalid sig")}return verify_1=o,verify_1}var browser$3,hasRequiredBrowser$3;function requireBrowser$3(){if(hasRequiredBrowser$3)return browser$3;hasRequiredBrowser$3=1;var t=requireSafeBuffer$1().Buffer,e=requireBrowser$9(),n=requireReadableBrowser(),a=inherits_browserExports,c=requireSign(),o=requireVerify(),u=require$$6;Object.keys(u).forEach(function(p){u[p].id=t.from(u[p].id,"hex"),u[p.toLowerCase()]=u[p]});function h(p){n.Writable.call(this);var x=u[p];if(!x)throw new Error("Unknown message digest");this._hashType=x.hash,this._hash=e(x.hash),this._tag=x.id,this._signType=x.sign}a(h,n.Writable),h.prototype._write=function(x,m,v){this._hash.update(x),v()},h.prototype.update=function(x,m){return this._hash.update(typeof x=="string"?t.from(x,m):x),this},h.prototype.sign=function(x,m){this.end();var v=this._hash.digest(),g=c(v,x,this._hashType,this._signType,this._tag);return m?g.toString(m):g};function l(p){n.Writable.call(this);var x=u[p];if(!x)throw new Error("Unknown message digest");this._hash=e(x.hash),this._tag=x.id,this._signType=x.sign}a(l,n.Writable),l.prototype._write=function(x,m,v){this._hash.update(x),v()},l.prototype.update=function(x,m){return this._hash.update(typeof x=="string"?t.from(x,m):x),this},l.prototype.verify=function(x,m,v){var g=typeof m=="string"?t.from(m,v):m;this.end();var $=this._hash.digest();return o(g,$,x,this._signType,this._tag)};function b(p){return new h(p)}function d(p){return new l(p)}return browser$3={Sign:b,Verify:d,createSign:b,createVerify:d},browser$3}var browser$2,hasRequiredBrowser$2;function requireBrowser$2(){if(hasRequiredBrowser$2)return browser$2;hasRequiredBrowser$2=1;var t=requireElliptic(),e=bnExports;browser$2=function(u){return new a(u)};var n={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};n.p224=n.secp224r1,n.p256=n.secp256r1=n.prime256v1,n.p192=n.secp192r1=n.prime192v1,n.p384=n.secp384r1,n.p521=n.secp521r1;function a(o){this.curveType=n[o],this.curveType||(this.curveType={name:o}),this.curve=new t.ec(this.curveType.name),this.keys=void 0}a.prototype.generateKeys=function(o,u){return this.keys=this.curve.genKeyPair(),this.getPublicKey(o,u)},a.prototype.computeSecret=function(o,u,h){u=u||"utf8",Buffer.isBuffer(o)||(o=new Buffer(o,u));var l=this.curve.keyFromPublic(o).getPublic(),b=l.mul(this.keys.getPrivate()).getX();return c(b,h,this.curveType.byteLength)},a.prototype.getPublicKey=function(o,u){var h=this.keys.getPublic(u==="compressed",!0);return u==="hybrid"&&(h[h.length-1]%2?h[0]=7:h[0]=6),c(h,o)},a.prototype.getPrivateKey=function(o){return c(this.keys.getPrivate(),o)},a.prototype.setPublicKey=function(o,u){return u=u||"utf8",Buffer.isBuffer(o)||(o=new Buffer(o,u)),this.keys._importPublic(o),this},a.prototype.setPrivateKey=function(o,u){u=u||"utf8",Buffer.isBuffer(o)||(o=new Buffer(o,u));var h=new e(o);return h=h.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(h),this};function c(o,u,h){Array.isArray(o)||(o=o.toArray());var l=new Buffer(o);if(h&&l.length<h){var b=new Buffer(h-l.length);b.fill(0),l=Buffer.concat([b,l])}return u?l.toString(u):l}return browser$2}var browser$1={},mgf,hasRequiredMgf;function requireMgf(){if(hasRequiredMgf)return mgf;hasRequiredMgf=1;var t=requireBrowser$9(),e=requireSafeBuffer$1().Buffer;mgf=function(a,c){for(var o=e.alloc(0),u=0,h;o.length<c;)h=n(u++),o=e.concat([o,t("sha1").update(a).update(h).digest()]);return o.slice(0,c)};function n(a){var c=e.allocUnsafe(4);return c.writeUInt32BE(a,0),c}return mgf}var xor,hasRequiredXor;function requireXor(){return hasRequiredXor||(hasRequiredXor=1,xor=function(e,n){for(var a=e.length,c=-1;++c<a;)e[c]^=n[c];return e}),xor}var withPublic_1,hasRequiredWithPublic;function requireWithPublic(){if(hasRequiredWithPublic)return withPublic_1;hasRequiredWithPublic=1;var t=bnExports,e=requireSafeBuffer$1().Buffer;function n(a,c){return e.from(a.toRed(t.mont(c.modulus)).redPow(new t(c.publicExponent)).fromRed().toArray())}return withPublic_1=n,withPublic_1}var publicEncrypt,hasRequiredPublicEncrypt;function requirePublicEncrypt(){if(hasRequiredPublicEncrypt)return publicEncrypt;hasRequiredPublicEncrypt=1;var t=requireParseAsn1(),e=requireBrowser$b(),n=requireBrowser$9(),a=requireMgf(),c=requireXor(),o=bnExports,u=requireWithPublic(),h=requireBrowserifyRsa(),l=requireSafeBuffer$1().Buffer;publicEncrypt=function(m,v,g){var $;m.padding?$=m.padding:g?$=1:$=4;var B=t(m),C;if($===4)C=b(B,v);else if($===1)C=d(B,v,g);else if($===3){if(C=new o(v),C.cmp(B.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return g?h(C,B):u(C,B)};function b(x,m){var v=x.modulus.byteLength(),g=m.length,$=n("sha1").update(l.alloc(0)).digest(),B=$.length,C=2*B;if(g>v-C-2)throw new Error("message too long");var F=l.alloc(v-g-C-2),H=v-B-1,W=e(B),Z=c(l.concat([$,F,l.alloc(1,1),m],H),a(W,H)),ie=c(W,a(Z,B));return new o(l.concat([l.alloc(1),ie,Z],v))}function d(x,m,v){var g=m.length,$=x.modulus.byteLength();if(g>$-11)throw new Error("message too long");var B;return v?B=l.alloc($-g-3,255):B=p($-g-3),new o(l.concat([l.from([0,v?1:2]),B,l.alloc(1),m],$))}function p(x){for(var m=l.allocUnsafe(x),v=0,g=e(x*2),$=0,B;v<x;)$===g.length&&(g=e(x*2),$=0),B=g[$++],B&&(m[v++]=B);return m}return publicEncrypt}var privateDecrypt,hasRequiredPrivateDecrypt;function requirePrivateDecrypt(){if(hasRequiredPrivateDecrypt)return privateDecrypt;hasRequiredPrivateDecrypt=1;var t=requireParseAsn1(),e=requireMgf(),n=requireXor(),a=bnExports,c=requireBrowserifyRsa(),o=requireBrowser$9(),u=requireWithPublic(),h=requireSafeBuffer$1().Buffer;privateDecrypt=function(x,m,v){var g;x.padding?g=x.padding:v?g=1:g=4;var $=t(x),B=$.modulus.byteLength();if(m.length>B||new a(m).cmp($.modulus)>=0)throw new Error("decryption error");var C;v?C=u(new a(m),$):C=c(m,$);var F=h.alloc(B-C.length);if(C=h.concat([F,C],B),g===4)return l($,C);if(g===1)return b($,C,v);if(g===3)return C;throw new Error("unknown padding")};function l(p,x){var m=p.modulus.byteLength(),v=o("sha1").update(h.alloc(0)).digest(),g=v.length;if(x[0]!==0)throw new Error("decryption error");var $=x.slice(1,g+1),B=x.slice(g+1),C=n($,e(B,g)),F=n(B,e(C,m-g-1));if(d(v,F.slice(0,g)))throw new Error("decryption error");for(var H=g;F[H]===0;)H++;if(F[H++]!==1)throw new Error("decryption error");return F.slice(H)}function b(p,x,m){for(var v=x.slice(0,2),g=2,$=0;x[g++]!==0;)if(g>=x.length){$++;break}var B=x.slice(2,g-1);if((v.toString("hex")!=="0002"&&!m||v.toString("hex")!=="0001"&&m)&&$++,B.length<8&&$++,$)throw new Error("decryption error");return x.slice(g)}function d(p,x){p=h.from(p),x=h.from(x);var m=0,v=p.length;p.length!==x.length&&(m++,v=Math.min(p.length,x.length));for(var g=-1;++g<v;)m+=p[g]^x[g];return m}return privateDecrypt}var hasRequiredBrowser$1;function requireBrowser$1(){return hasRequiredBrowser$1||(hasRequiredBrowser$1=1,function(t){t.publicEncrypt=requirePublicEncrypt(),t.privateDecrypt=requirePrivateDecrypt(),t.privateEncrypt=function(n,a){return t.publicEncrypt(n,a,!0)},t.publicDecrypt=function(n,a){return t.privateDecrypt(n,a,!0)}}(browser$1)),browser$1}var browser={},hasRequiredBrowser;function requireBrowser(){if(hasRequiredBrowser)return browser;hasRequiredBrowser=1;function t(){throw new Error(`secure random number generation not supported by this browser
23
- use chrome, FireFox or Internet Explorer 11`)}var e=requireSafeBuffer$1(),n=requireBrowser$b(),a=e.Buffer,c=e.kMaxLength,o=commonjsGlobal.crypto||commonjsGlobal.msCrypto,u=Math.pow(2,32)-1;function h(x,m){if(typeof x!="number"||x!==x)throw new TypeError("offset must be a number");if(x>u||x<0)throw new TypeError("offset must be a uint32");if(x>c||x>m)throw new RangeError("offset out of range")}function l(x,m,v){if(typeof x!="number"||x!==x)throw new TypeError("size must be a number");if(x>u||x<0)throw new TypeError("size must be a uint32");if(x+m>v||x>c)throw new RangeError("buffer too small")}o&&o.getRandomValues||!process$1.browser?(browser.randomFill=b,browser.randomFillSync=p):(browser.randomFill=t,browser.randomFillSync=t);function b(x,m,v,g){if(!a.isBuffer(x)&&!(x instanceof commonjsGlobal.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof m=="function")g=m,m=0,v=x.length;else if(typeof v=="function")g=v,v=x.length-m;else if(typeof g!="function")throw new TypeError('"cb" argument must be a function');return h(m,x.length),l(v,m,x.length),d(x,m,v,g)}function d(x,m,v,g){if(process$1.browser){var $=x.buffer,B=new Uint8Array($,m,v);if(o.getRandomValues(B),g){process$1.nextTick(function(){g(null,x)});return}return x}if(g){n(v,function(F,H){if(F)return g(F);H.copy(x,m),g(null,x)});return}var C=n(v);return C.copy(x,m),x}function p(x,m,v){if(typeof m>"u"&&(m=0),!a.isBuffer(x)&&!(x instanceof commonjsGlobal.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return h(m,x.length),v===void 0&&(v=x.length-m),l(v,m,x.length),d(x,m,v)}return browser}var hasRequiredCryptoBrowserify;function requireCryptoBrowserify(){if(hasRequiredCryptoBrowserify)return cryptoBrowserify;hasRequiredCryptoBrowserify=1,cryptoBrowserify.randomBytes=cryptoBrowserify.rng=cryptoBrowserify.pseudoRandomBytes=cryptoBrowserify.prng=requireBrowser$b(),cryptoBrowserify.createHash=cryptoBrowserify.Hash=requireBrowser$9(),cryptoBrowserify.createHmac=cryptoBrowserify.Hmac=requireBrowser$8();var t=requireAlgos(),e=Object.keys(t),n=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(e);cryptoBrowserify.getHashes=function(){return n};var a=requireBrowser$7();cryptoBrowserify.pbkdf2=a.pbkdf2,cryptoBrowserify.pbkdf2Sync=a.pbkdf2Sync;var c=requireBrowser$5();cryptoBrowserify.Cipher=c.Cipher,cryptoBrowserify.createCipher=c.createCipher,cryptoBrowserify.Cipheriv=c.Cipheriv,cryptoBrowserify.createCipheriv=c.createCipheriv,cryptoBrowserify.Decipher=c.Decipher,cryptoBrowserify.createDecipher=c.createDecipher,cryptoBrowserify.Decipheriv=c.Decipheriv,cryptoBrowserify.createDecipheriv=c.createDecipheriv,cryptoBrowserify.getCiphers=c.getCiphers,cryptoBrowserify.listCiphers=c.listCiphers;var o=requireBrowser$4();cryptoBrowserify.DiffieHellmanGroup=o.DiffieHellmanGroup,cryptoBrowserify.createDiffieHellmanGroup=o.createDiffieHellmanGroup,cryptoBrowserify.getDiffieHellman=o.getDiffieHellman,cryptoBrowserify.createDiffieHellman=o.createDiffieHellman,cryptoBrowserify.DiffieHellman=o.DiffieHellman;var u=requireBrowser$3();cryptoBrowserify.createSign=u.createSign,cryptoBrowserify.Sign=u.Sign,cryptoBrowserify.createVerify=u.createVerify,cryptoBrowserify.Verify=u.Verify,cryptoBrowserify.createECDH=requireBrowser$2();var h=requireBrowser$1();cryptoBrowserify.publicEncrypt=h.publicEncrypt,cryptoBrowserify.privateEncrypt=h.privateEncrypt,cryptoBrowserify.publicDecrypt=h.publicDecrypt,cryptoBrowserify.privateDecrypt=h.privateDecrypt;var l=requireBrowser();return cryptoBrowserify.randomFill=l.randomFill,cryptoBrowserify.randomFillSync=l.randomFillSync,cryptoBrowserify.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(`
24
- `))},cryptoBrowserify.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6},cryptoBrowserify}var hasRequiredBrorand;function requireBrorand(){if(hasRequiredBrorand)return brorand.exports;hasRequiredBrorand=1;var t;brorand.exports=function(c){return t||(t=new e(null)),t.generate(c)};function e(a){this.rand=a}if(brorand.exports.Rand=e,e.prototype.generate=function(c){return this._rand(c)},e.prototype._rand=function(c){if(this.rand.getBytes)return this.rand.getBytes(c);for(var o=new Uint8Array(c),u=0;u<o.length;u++)o[u]=this.rand.getByte();return o},typeof self=="object")self.crypto&&self.crypto.getRandomValues?e.prototype._rand=function(c){var o=new Uint8Array(c);return self.crypto.getRandomValues(o),o}:self.msCrypto&&self.msCrypto.getRandomValues?e.prototype._rand=function(c){var o=new Uint8Array(c);return self.msCrypto.getRandomValues(o),o}:typeof window=="object"&&(e.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var n=requireCryptoBrowserify();if(typeof n.randomBytes!="function")throw new Error("Not supported");e.prototype._rand=function(c){return n.randomBytes(c)}}catch{}return brorand.exports}var curve={},BN$6=bnExports,utils$l=utils$o,getNAF=utils$l.getNAF,getJSF=utils$l.getJSF,assert$d=utils$l.assert;function BaseCurve(t,e){this.type=t,this.p=new BN$6(e.p,16),this.red=e.prime?BN$6.red(e.prime):BN$6.mont(this.p),this.zero=new BN$6(0).toRed(this.red),this.one=new BN$6(1).toRed(this.red),this.two=new BN$6(2).toRed(this.red),this.n=e.n&&new BN$6(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var base=BaseCurve;BaseCurve.prototype.point=function t(){throw new Error("Not implemented")};BaseCurve.prototype.validate=function t(){throw new Error("Not implemented")};BaseCurve.prototype._fixedNafMul=function t(e,n){assert$d(e.precomputed);var a=e._getDoubles(),c=getNAF(n,1,this._bitLength),o=(1<<a.step+1)-(a.step%2===0?2:1);o/=3;var u=[],h,l;for(h=0;h<c.length;h+=a.step){l=0;for(var b=h+a.step-1;b>=h;b--)l=(l<<1)+c[b];u.push(l)}for(var d=this.jpoint(null,null,null),p=this.jpoint(null,null,null),x=o;x>0;x--){for(h=0;h<u.length;h++)l=u[h],l===x?p=p.mixedAdd(a.points[h]):l===-x&&(p=p.mixedAdd(a.points[h].neg()));d=d.add(p)}return d.toP()};BaseCurve.prototype._wnafMul=function t(e,n){var a=4,c=e._getNAFPoints(a);a=c.wnd;for(var o=c.points,u=getNAF(n,a,this._bitLength),h=this.jpoint(null,null,null),l=u.length-1;l>=0;l--){for(var b=0;l>=0&&u[l]===0;l--)b++;if(l>=0&&b++,h=h.dblp(b),l<0)break;var d=u[l];assert$d(d!==0),e.type==="affine"?d>0?h=h.mixedAdd(o[d-1>>1]):h=h.mixedAdd(o[-d-1>>1].neg()):d>0?h=h.add(o[d-1>>1]):h=h.add(o[-d-1>>1].neg())}return e.type==="affine"?h.toP():h};BaseCurve.prototype._wnafMulAdd=function t(e,n,a,c,o){var u=this._wnafT1,h=this._wnafT2,l=this._wnafT3,b=0,d,p,x;for(d=0;d<c;d++){x=n[d];var m=x._getNAFPoints(e);u[d]=m.wnd,h[d]=m.points}for(d=c-1;d>=1;d-=2){var v=d-1,g=d;if(u[v]!==1||u[g]!==1){l[v]=getNAF(a[v],u[v],this._bitLength),l[g]=getNAF(a[g],u[g],this._bitLength),b=Math.max(l[v].length,b),b=Math.max(l[g].length,b);continue}var $=[n[v],null,null,n[g]];n[v].y.cmp(n[g].y)===0?($[1]=n[v].add(n[g]),$[2]=n[v].toJ().mixedAdd(n[g].neg())):n[v].y.cmp(n[g].y.redNeg())===0?($[1]=n[v].toJ().mixedAdd(n[g]),$[2]=n[v].add(n[g].neg())):($[1]=n[v].toJ().mixedAdd(n[g]),$[2]=n[v].toJ().mixedAdd(n[g].neg()));var B=[-3,-1,-5,-7,0,7,5,1,3],C=getJSF(a[v],a[g]);for(b=Math.max(C[0].length,b),l[v]=new Array(b),l[g]=new Array(b),p=0;p<b;p++){var F=C[0][p]|0,H=C[1][p]|0;l[v][p]=B[(F+1)*3+(H+1)],l[g][p]=0,h[v]=$}}var W=this.jpoint(null,null,null),Z=this._wnafT4;for(d=b;d>=0;d--){for(var ie=0;d>=0;){var te=!0;for(p=0;p<c;p++)Z[p]=l[p][d]|0,Z[p]!==0&&(te=!1);if(!te)break;ie++,d--}if(d>=0&&ie++,W=W.dblp(ie),d<0)break;for(p=0;p<c;p++){var ae=Z[p];ae!==0&&(ae>0?x=h[p][ae-1>>1]:ae<0&&(x=h[p][-ae-1>>1].neg()),x.type==="affine"?W=W.mixedAdd(x):W=W.add(x))}}for(d=0;d<c;d++)h[d]=null;return o?W:W.toP()};function BasePoint(t,e){this.curve=t,this.type=e,this.precomputed=null}BaseCurve.BasePoint=BasePoint;BasePoint.prototype.eq=function t(){throw new Error("Not implemented")};BasePoint.prototype.validate=function t(){return this.curve.validate(this)};BaseCurve.prototype.decodePoint=function t(e,n){e=utils$l.toArray(e,n);var a=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*a){e[0]===6?assert$d(e[e.length-1]%2===0):e[0]===7&&assert$d(e[e.length-1]%2===1);var c=this.point(e.slice(1,1+a),e.slice(1+a,1+2*a));return c}else if((e[0]===2||e[0]===3)&&e.length-1===a)return this.pointFromX(e.slice(1,1+a),e[0]===3);throw new Error("Unknown point format")};BasePoint.prototype.encodeCompressed=function t(e){return this.encode(e,!0)};BasePoint.prototype._encode=function t(e){var n=this.curve.p.byteLength(),a=this.getX().toArray("be",n);return e?[this.getY().isEven()?2:3].concat(a):[4].concat(a,this.getY().toArray("be",n))};BasePoint.prototype.encode=function t(e,n){return utils$l.encode(this._encode(n),e)};BasePoint.prototype.precompute=function t(e){if(this.precomputed)return this;var n={doubles:null,naf:null,beta:null};return n.naf=this._getNAFPoints(8),n.doubles=this._getDoubles(4,e),n.beta=this._getBeta(),this.precomputed=n,this};BasePoint.prototype._hasDoubles=function t(e){if(!this.precomputed)return!1;var n=this.precomputed.doubles;return n?n.points.length>=Math.ceil((e.bitLength()+1)/n.step):!1};BasePoint.prototype._getDoubles=function t(e,n){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var a=[this],c=this,o=0;o<n;o+=e){for(var u=0;u<e;u++)c=c.dbl();a.push(c)}return{step:e,points:a}};BasePoint.prototype._getNAFPoints=function t(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var n=[this],a=(1<<e)-1,c=a===1?null:this.dbl(),o=1;o<a;o++)n[o]=n[o-1].add(c);return{wnd:e,points:n}};BasePoint.prototype._getBeta=function t(){return null};BasePoint.prototype.dblp=function t(e){for(var n=this,a=0;a<e;a++)n=n.dbl();return n};var utils$k=utils$o,BN$5=bnExports,inherits$4=inherits_browserExports,Base$2=base,assert$c=utils$k.assert;function ShortCurve(t){Base$2.call(this,"short",t),this.a=new BN$5(t.a,16).toRed(this.red),this.b=new BN$5(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}inherits$4(ShortCurve,Base$2);var short=ShortCurve;ShortCurve.prototype._getEndomorphism=function t(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var n,a;if(e.beta)n=new BN$5(e.beta,16).toRed(this.red);else{var c=this._getEndoRoots(this.p);n=c[0].cmp(c[1])<0?c[0]:c[1],n=n.toRed(this.red)}if(e.lambda)a=new BN$5(e.lambda,16);else{var o=this._getEndoRoots(this.n);this.g.mul(o[0]).x.cmp(this.g.x.redMul(n))===0?a=o[0]:(a=o[1],assert$c(this.g.mul(a).x.cmp(this.g.x.redMul(n))===0))}var u;return e.basis?u=e.basis.map(function(h){return{a:new BN$5(h.a,16),b:new BN$5(h.b,16)}}):u=this._getEndoBasis(a),{beta:n,lambda:a,basis:u}}};ShortCurve.prototype._getEndoRoots=function t(e){var n=e===this.p?this.red:BN$5.mont(e),a=new BN$5(2).toRed(n).redInvm(),c=a.redNeg(),o=new BN$5(3).toRed(n).redNeg().redSqrt().redMul(a),u=c.redAdd(o).fromRed(),h=c.redSub(o).fromRed();return[u,h]};ShortCurve.prototype._getEndoBasis=function t(e){for(var n=this.n.ushrn(Math.floor(this.n.bitLength()/2)),a=e,c=this.n.clone(),o=new BN$5(1),u=new BN$5(0),h=new BN$5(0),l=new BN$5(1),b,d,p,x,m,v,g,$=0,B,C;a.cmpn(0)!==0;){var F=c.div(a);B=c.sub(F.mul(a)),C=h.sub(F.mul(o));var H=l.sub(F.mul(u));if(!p&&B.cmp(n)<0)b=g.neg(),d=o,p=B.neg(),x=C;else if(p&&++$===2)break;g=B,c=a,a=B,h=o,o=C,l=u,u=H}m=B.neg(),v=C;var W=p.sqr().add(x.sqr()),Z=m.sqr().add(v.sqr());return Z.cmp(W)>=0&&(m=b,v=d),p.negative&&(p=p.neg(),x=x.neg()),m.negative&&(m=m.neg(),v=v.neg()),[{a:p,b:x},{a:m,b:v}]};ShortCurve.prototype._endoSplit=function t(e){var n=this.endo.basis,a=n[0],c=n[1],o=c.b.mul(e).divRound(this.n),u=a.b.neg().mul(e).divRound(this.n),h=o.mul(a.a),l=u.mul(c.a),b=o.mul(a.b),d=u.mul(c.b),p=e.sub(h).sub(l),x=b.add(d).neg();return{k1:p,k2:x}};ShortCurve.prototype.pointFromX=function t(e,n){e=new BN$5(e,16),e.red||(e=e.toRed(this.red));var a=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),c=a.redSqrt();if(c.redSqr().redSub(a).cmp(this.zero)!==0)throw new Error("invalid point");var o=c.fromRed().isOdd();return(n&&!o||!n&&o)&&(c=c.redNeg()),this.point(e,c)};ShortCurve.prototype.validate=function t(e){if(e.inf)return!0;var n=e.x,a=e.y,c=this.a.redMul(n),o=n.redSqr().redMul(n).redIAdd(c).redIAdd(this.b);return a.redSqr().redISub(o).cmpn(0)===0};ShortCurve.prototype._endoWnafMulAdd=function t(e,n,a){for(var c=this._endoWnafT1,o=this._endoWnafT2,u=0;u<e.length;u++){var h=this._endoSplit(n[u]),l=e[u],b=l._getBeta();h.k1.negative&&(h.k1.ineg(),l=l.neg(!0)),h.k2.negative&&(h.k2.ineg(),b=b.neg(!0)),c[u*2]=l,c[u*2+1]=b,o[u*2]=h.k1,o[u*2+1]=h.k2}for(var d=this._wnafMulAdd(1,c,o,u*2,a),p=0;p<u*2;p++)c[p]=null,o[p]=null;return d};function Point$2(t,e,n,a){Base$2.BasePoint.call(this,t,"affine"),e===null&&n===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN$5(e,16),this.y=new BN$5(n,16),a&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}inherits$4(Point$2,Base$2.BasePoint);ShortCurve.prototype.point=function t(e,n,a){return new Point$2(this,e,n,a)};ShortCurve.prototype.pointFromJSON=function t(e,n){return Point$2.fromJSON(this,e,n)};Point$2.prototype._getBeta=function t(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var n=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var a=this.curve,c=function(o){return a.point(o.x.redMul(a.endo.beta),o.y)};e.beta=n,n.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(c)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(c)}}}return n}};Point$2.prototype.toJSON=function t(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};Point$2.fromJSON=function t(e,n,a){typeof n=="string"&&(n=JSON.parse(n));var c=e.point(n[0],n[1],a);if(!n[2])return c;function o(h){return e.point(h[0],h[1],a)}var u=n[2];return c.precomputed={beta:null,doubles:u.doubles&&{step:u.doubles.step,points:[c].concat(u.doubles.points.map(o))},naf:u.naf&&{wnd:u.naf.wnd,points:[c].concat(u.naf.points.map(o))}},c};Point$2.prototype.inspect=function t(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};Point$2.prototype.isInfinity=function t(){return this.inf};Point$2.prototype.add=function t(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var n=this.y.redSub(e.y);n.cmpn(0)!==0&&(n=n.redMul(this.x.redSub(e.x).redInvm()));var a=n.redSqr().redISub(this.x).redISub(e.x),c=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,c)};Point$2.prototype.dbl=function t(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var n=this.curve.a,a=this.x.redSqr(),c=e.redInvm(),o=a.redAdd(a).redIAdd(a).redIAdd(n).redMul(c),u=o.redSqr().redISub(this.x.redAdd(this.x)),h=o.redMul(this.x.redSub(u)).redISub(this.y);return this.curve.point(u,h)};Point$2.prototype.getX=function t(){return this.x.fromRed()};Point$2.prototype.getY=function t(){return this.y.fromRed()};Point$2.prototype.mul=function t(e){return e=new BN$5(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Point$2.prototype.mulAdd=function t(e,n,a){var c=[this,n],o=[e,a];return this.curve.endo?this.curve._endoWnafMulAdd(c,o):this.curve._wnafMulAdd(1,c,o,2)};Point$2.prototype.jmulAdd=function t(e,n,a){var c=[this,n],o=[e,a];return this.curve.endo?this.curve._endoWnafMulAdd(c,o,!0):this.curve._wnafMulAdd(1,c,o,2,!0)};Point$2.prototype.eq=function t(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Point$2.prototype.neg=function t(e){if(this.inf)return this;var n=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var a=this.precomputed,c=function(o){return o.neg()};n.precomputed={naf:a.naf&&{wnd:a.naf.wnd,points:a.naf.points.map(c)},doubles:a.doubles&&{step:a.doubles.step,points:a.doubles.points.map(c)}}}return n};Point$2.prototype.toJ=function t(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function JPoint(t,e,n,a){Base$2.BasePoint.call(this,t,"jacobian"),e===null&&n===null&&a===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN$5(0)):(this.x=new BN$5(e,16),this.y=new BN$5(n,16),this.z=new BN$5(a,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits$4(JPoint,Base$2.BasePoint);ShortCurve.prototype.jpoint=function t(e,n,a){return new JPoint(this,e,n,a)};JPoint.prototype.toP=function t(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),n=e.redSqr(),a=this.x.redMul(n),c=this.y.redMul(n).redMul(e);return this.curve.point(a,c)};JPoint.prototype.neg=function t(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};JPoint.prototype.add=function t(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var n=e.z.redSqr(),a=this.z.redSqr(),c=this.x.redMul(n),o=e.x.redMul(a),u=this.y.redMul(n.redMul(e.z)),h=e.y.redMul(a.redMul(this.z)),l=c.redSub(o),b=u.redSub(h);if(l.cmpn(0)===0)return b.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=l.redSqr(),p=d.redMul(l),x=c.redMul(d),m=b.redSqr().redIAdd(p).redISub(x).redISub(x),v=b.redMul(x.redISub(m)).redISub(u.redMul(p)),g=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(m,v,g)};JPoint.prototype.mixedAdd=function t(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var n=this.z.redSqr(),a=this.x,c=e.x.redMul(n),o=this.y,u=e.y.redMul(n).redMul(this.z),h=a.redSub(c),l=o.redSub(u);if(h.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=h.redSqr(),d=b.redMul(h),p=a.redMul(b),x=l.redSqr().redIAdd(d).redISub(p).redISub(p),m=l.redMul(p.redISub(x)).redISub(o.redMul(d)),v=this.z.redMul(h);return this.curve.jpoint(x,m,v)};JPoint.prototype.dblp=function t(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var n;if(this.curve.zeroA||this.curve.threeA){var a=this;for(n=0;n<e;n++)a=a.dbl();return a}var c=this.curve.a,o=this.curve.tinv,u=this.x,h=this.y,l=this.z,b=l.redSqr().redSqr(),d=h.redAdd(h);for(n=0;n<e;n++){var p=u.redSqr(),x=d.redSqr(),m=x.redSqr(),v=p.redAdd(p).redIAdd(p).redIAdd(c.redMul(b)),g=u.redMul(x),$=v.redSqr().redISub(g.redAdd(g)),B=g.redISub($),C=v.redMul(B);C=C.redIAdd(C).redISub(m);var F=d.redMul(l);n+1<e&&(b=b.redMul(m)),u=$,l=F,d=C}return this.curve.jpoint(u,d.redMul(o),l)};JPoint.prototype.dbl=function t(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};JPoint.prototype._zeroDbl=function t(){var e,n,a;if(this.zOne){var c=this.x.redSqr(),o=this.y.redSqr(),u=o.redSqr(),h=this.x.redAdd(o).redSqr().redISub(c).redISub(u);h=h.redIAdd(h);var l=c.redAdd(c).redIAdd(c),b=l.redSqr().redISub(h).redISub(h),d=u.redIAdd(u);d=d.redIAdd(d),d=d.redIAdd(d),e=b,n=l.redMul(h.redISub(b)).redISub(d),a=this.y.redAdd(this.y)}else{var p=this.x.redSqr(),x=this.y.redSqr(),m=x.redSqr(),v=this.x.redAdd(x).redSqr().redISub(p).redISub(m);v=v.redIAdd(v);var g=p.redAdd(p).redIAdd(p),$=g.redSqr(),B=m.redIAdd(m);B=B.redIAdd(B),B=B.redIAdd(B),e=$.redISub(v).redISub(v),n=g.redMul(v.redISub(e)).redISub(B),a=this.y.redMul(this.z),a=a.redIAdd(a)}return this.curve.jpoint(e,n,a)};JPoint.prototype._threeDbl=function t(){var e,n,a;if(this.zOne){var c=this.x.redSqr(),o=this.y.redSqr(),u=o.redSqr(),h=this.x.redAdd(o).redSqr().redISub(c).redISub(u);h=h.redIAdd(h);var l=c.redAdd(c).redIAdd(c).redIAdd(this.curve.a),b=l.redSqr().redISub(h).redISub(h);e=b;var d=u.redIAdd(u);d=d.redIAdd(d),d=d.redIAdd(d),n=l.redMul(h.redISub(b)).redISub(d),a=this.y.redAdd(this.y)}else{var p=this.z.redSqr(),x=this.y.redSqr(),m=this.x.redMul(x),v=this.x.redSub(p).redMul(this.x.redAdd(p));v=v.redAdd(v).redIAdd(v);var g=m.redIAdd(m);g=g.redIAdd(g);var $=g.redAdd(g);e=v.redSqr().redISub($),a=this.y.redAdd(this.z).redSqr().redISub(x).redISub(p);var B=x.redSqr();B=B.redIAdd(B),B=B.redIAdd(B),B=B.redIAdd(B),n=v.redMul(g.redISub(e)).redISub(B)}return this.curve.jpoint(e,n,a)};JPoint.prototype._dbl=function t(){var e=this.curve.a,n=this.x,a=this.y,c=this.z,o=c.redSqr().redSqr(),u=n.redSqr(),h=a.redSqr(),l=u.redAdd(u).redIAdd(u).redIAdd(e.redMul(o)),b=n.redAdd(n);b=b.redIAdd(b);var d=b.redMul(h),p=l.redSqr().redISub(d.redAdd(d)),x=d.redISub(p),m=h.redSqr();m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var v=l.redMul(x).redISub(m),g=a.redAdd(a).redMul(c);return this.curve.jpoint(p,v,g)};JPoint.prototype.trpl=function t(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),n=this.y.redSqr(),a=this.z.redSqr(),c=n.redSqr(),o=e.redAdd(e).redIAdd(e),u=o.redSqr(),h=this.x.redAdd(n).redSqr().redISub(e).redISub(c);h=h.redIAdd(h),h=h.redAdd(h).redIAdd(h),h=h.redISub(u);var l=h.redSqr(),b=c.redIAdd(c);b=b.redIAdd(b),b=b.redIAdd(b),b=b.redIAdd(b);var d=o.redIAdd(h).redSqr().redISub(u).redISub(l).redISub(b),p=n.redMul(d);p=p.redIAdd(p),p=p.redIAdd(p);var x=this.x.redMul(l).redISub(p);x=x.redIAdd(x),x=x.redIAdd(x);var m=this.y.redMul(d.redMul(b.redISub(d)).redISub(h.redMul(l)));m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var v=this.z.redAdd(h).redSqr().redISub(a).redISub(l);return this.curve.jpoint(x,m,v)};JPoint.prototype.mul=function t(e,n){return e=new BN$5(e,n),this.curve._wnafMul(this,e)};JPoint.prototype.eq=function t(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var n=this.z.redSqr(),a=e.z.redSqr();if(this.x.redMul(a).redISub(e.x.redMul(n)).cmpn(0)!==0)return!1;var c=n.redMul(this.z),o=a.redMul(e.z);return this.y.redMul(o).redISub(e.y.redMul(c)).cmpn(0)===0};JPoint.prototype.eqXToP=function t(e){var n=this.z.redSqr(),a=e.toRed(this.curve.red).redMul(n);if(this.x.cmp(a)===0)return!0;for(var c=e.clone(),o=this.curve.redN.redMul(n);;){if(c.iadd(this.curve.n),c.cmp(this.curve.p)>=0)return!1;if(a.redIAdd(o),this.x.cmp(a)===0)return!0}};JPoint.prototype.inspect=function t(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};JPoint.prototype.isInfinity=function t(){return this.z.cmpn(0)===0};var BN$4=bnExports,inherits$3=inherits_browserExports,Base$1=base,utils$j=utils$o;function MontCurve(t){Base$1.call(this,"mont",t),this.a=new BN$4(t.a,16).toRed(this.red),this.b=new BN$4(t.b,16).toRed(this.red),this.i4=new BN$4(4).toRed(this.red).redInvm(),this.two=new BN$4(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}inherits$3(MontCurve,Base$1);var mont=MontCurve;MontCurve.prototype.validate=function t(e){var n=e.normalize().x,a=n.redSqr(),c=a.redMul(n).redAdd(a.redMul(this.a)).redAdd(n),o=c.redSqrt();return o.redSqr().cmp(c)===0};function Point$1(t,e,n){Base$1.BasePoint.call(this,t,"projective"),e===null&&n===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN$4(e,16),this.z=new BN$4(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}inherits$3(Point$1,Base$1.BasePoint);MontCurve.prototype.decodePoint=function t(e,n){return this.point(utils$j.toArray(e,n),1)};MontCurve.prototype.point=function t(e,n){return new Point$1(this,e,n)};MontCurve.prototype.pointFromJSON=function t(e){return Point$1.fromJSON(this,e)};Point$1.prototype.precompute=function t(){};Point$1.prototype._encode=function t(){return this.getX().toArray("be",this.curve.p.byteLength())};Point$1.fromJSON=function t(e,n){return new Point$1(e,n[0],n[1]||e.one)};Point$1.prototype.inspect=function t(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"};Point$1.prototype.isInfinity=function t(){return this.z.cmpn(0)===0};Point$1.prototype.dbl=function t(){var e=this.x.redAdd(this.z),n=e.redSqr(),a=this.x.redSub(this.z),c=a.redSqr(),o=n.redSub(c),u=n.redMul(c),h=o.redMul(c.redAdd(this.curve.a24.redMul(o)));return this.curve.point(u,h)};Point$1.prototype.add=function t(){throw new Error("Not supported on Montgomery curve")};Point$1.prototype.diffAdd=function t(e,n){var a=this.x.redAdd(this.z),c=this.x.redSub(this.z),o=e.x.redAdd(e.z),u=e.x.redSub(e.z),h=u.redMul(a),l=o.redMul(c),b=n.z.redMul(h.redAdd(l).redSqr()),d=n.x.redMul(h.redISub(l).redSqr());return this.curve.point(b,d)};Point$1.prototype.mul=function t(e){for(var n=e.clone(),a=this,c=this.curve.point(null,null),o=this,u=[];n.cmpn(0)!==0;n.iushrn(1))u.push(n.andln(1));for(var h=u.length-1;h>=0;h--)u[h]===0?(a=a.diffAdd(c,o),c=c.dbl()):(c=a.diffAdd(c,o),a=a.dbl());return c};Point$1.prototype.mulAdd=function t(){throw new Error("Not supported on Montgomery curve")};Point$1.prototype.jumlAdd=function t(){throw new Error("Not supported on Montgomery curve")};Point$1.prototype.eq=function t(e){return this.getX().cmp(e.getX())===0};Point$1.prototype.normalize=function t(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};Point$1.prototype.getX=function t(){return this.normalize(),this.x.fromRed()};var utils$i=utils$o,BN$3=bnExports,inherits$2=inherits_browserExports,Base=base,assert$b=utils$i.assert;function EdwardsCurve(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,Base.call(this,"edwards",t),this.a=new BN$3(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new BN$3(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new BN$3(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert$b(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}inherits$2(EdwardsCurve,Base);var edwards=EdwardsCurve;EdwardsCurve.prototype._mulA=function t(e){return this.mOneA?e.redNeg():this.a.redMul(e)};EdwardsCurve.prototype._mulC=function t(e){return this.oneC?e:this.c.redMul(e)};EdwardsCurve.prototype.jpoint=function t(e,n,a,c){return this.point(e,n,a,c)};EdwardsCurve.prototype.pointFromX=function t(e,n){e=new BN$3(e,16),e.red||(e=e.toRed(this.red));var a=e.redSqr(),c=this.c2.redSub(this.a.redMul(a)),o=this.one.redSub(this.c2.redMul(this.d).redMul(a)),u=c.redMul(o.redInvm()),h=u.redSqrt();if(h.redSqr().redSub(u).cmp(this.zero)!==0)throw new Error("invalid point");var l=h.fromRed().isOdd();return(n&&!l||!n&&l)&&(h=h.redNeg()),this.point(e,h)};EdwardsCurve.prototype.pointFromY=function t(e,n){e=new BN$3(e,16),e.red||(e=e.toRed(this.red));var a=e.redSqr(),c=a.redSub(this.c2),o=a.redMul(this.d).redMul(this.c2).redSub(this.a),u=c.redMul(o.redInvm());if(u.cmp(this.zero)===0){if(n)throw new Error("invalid point");return this.point(this.zero,e)}var h=u.redSqrt();if(h.redSqr().redSub(u).cmp(this.zero)!==0)throw new Error("invalid point");return h.fromRed().isOdd()!==n&&(h=h.redNeg()),this.point(h,e)};EdwardsCurve.prototype.validate=function t(e){if(e.isInfinity())return!0;e.normalize();var n=e.x.redSqr(),a=e.y.redSqr(),c=n.redMul(this.a).redAdd(a),o=this.c2.redMul(this.one.redAdd(this.d.redMul(n).redMul(a)));return c.cmp(o)===0};function Point(t,e,n,a,c){Base.BasePoint.call(this,t,"projective"),e===null&&n===null&&a===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new BN$3(e,16),this.y=new BN$3(n,16),this.z=a?new BN$3(a,16):this.curve.one,this.t=c&&new BN$3(c,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}inherits$2(Point,Base.BasePoint);EdwardsCurve.prototype.pointFromJSON=function t(e){return Point.fromJSON(this,e)};EdwardsCurve.prototype.point=function t(e,n,a,c){return new Point(this,e,n,a,c)};Point.fromJSON=function t(e,n){return new Point(e,n[0],n[1],n[2])};Point.prototype.inspect=function t(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"};Point.prototype.isInfinity=function t(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Point.prototype._extDbl=function t(){var e=this.x.redSqr(),n=this.y.redSqr(),a=this.z.redSqr();a=a.redIAdd(a);var c=this.curve._mulA(e),o=this.x.redAdd(this.y).redSqr().redISub(e).redISub(n),u=c.redAdd(n),h=u.redSub(a),l=c.redSub(n),b=o.redMul(h),d=u.redMul(l),p=o.redMul(l),x=h.redMul(u);return this.curve.point(b,d,x,p)};Point.prototype._projDbl=function t(){var e=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),a=this.y.redSqr(),c,o,u,h,l,b;if(this.curve.twisted){h=this.curve._mulA(n);var d=h.redAdd(a);this.zOne?(c=e.redSub(n).redSub(a).redMul(d.redSub(this.curve.two)),o=d.redMul(h.redSub(a)),u=d.redSqr().redSub(d).redSub(d)):(l=this.z.redSqr(),b=d.redSub(l).redISub(l),c=e.redSub(n).redISub(a).redMul(b),o=d.redMul(h.redSub(a)),u=d.redMul(b))}else h=n.redAdd(a),l=this.curve._mulC(this.z).redSqr(),b=h.redSub(l).redSub(l),c=this.curve._mulC(e.redISub(h)).redMul(b),o=this.curve._mulC(h).redMul(n.redISub(a)),u=h.redMul(b);return this.curve.point(c,o,u)};Point.prototype.dbl=function t(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Point.prototype._extAdd=function t(e){var n=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),a=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),c=this.t.redMul(this.curve.dd).redMul(e.t),o=this.z.redMul(e.z.redAdd(e.z)),u=a.redSub(n),h=o.redSub(c),l=o.redAdd(c),b=a.redAdd(n),d=u.redMul(h),p=l.redMul(b),x=u.redMul(b),m=h.redMul(l);return this.curve.point(d,p,m,x)};Point.prototype._projAdd=function t(e){var n=this.z.redMul(e.z),a=n.redSqr(),c=this.x.redMul(e.x),o=this.y.redMul(e.y),u=this.curve.d.redMul(c).redMul(o),h=a.redSub(u),l=a.redAdd(u),b=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(c).redISub(o),d=n.redMul(h).redMul(b),p,x;return this.curve.twisted?(p=n.redMul(l).redMul(o.redSub(this.curve._mulA(c))),x=h.redMul(l)):(p=n.redMul(l).redMul(o.redSub(c)),x=this.curve._mulC(h).redMul(l)),this.curve.point(d,p,x)};Point.prototype.add=function t(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Point.prototype.mul=function t(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Point.prototype.mulAdd=function t(e,n,a){return this.curve._wnafMulAdd(1,[this,n],[e,a],2,!1)};Point.prototype.jmulAdd=function t(e,n,a){return this.curve._wnafMulAdd(1,[this,n],[e,a],2,!0)};Point.prototype.normalize=function t(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Point.prototype.neg=function t(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Point.prototype.getX=function t(){return this.normalize(),this.x.fromRed()};Point.prototype.getY=function t(){return this.normalize(),this.y.fromRed()};Point.prototype.eq=function t(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Point.prototype.eqXToP=function t(e){var n=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(n)===0)return!0;for(var a=e.clone(),c=this.curve.redN.redMul(this.z);;){if(a.iadd(this.curve.n),a.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(c),this.x.cmp(n)===0)return!0}};Point.prototype.toP=Point.prototype.normalize;Point.prototype.mixedAdd=Point.prototype.add;(function(t){var e=t;e.base=base,e.short=short,e.mont=mont,e.edwards=edwards})(curve);var curves$1={},hash$2={},utils$h={},assert$a=minimalisticAssert,inherits$1=inherits_browserExports;utils$h.inherits=inherits$1;function isSurrogatePair(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function toArray$1(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),c=0;c<t.length;c+=2)n.push(parseInt(t[c]+t[c+1],16))}else for(var a=0,c=0;c<t.length;c++){var o=t.charCodeAt(c);o<128?n[a++]=o:o<2048?(n[a++]=o>>6|192,n[a++]=o&63|128):isSurrogatePair(t,c)?(o=65536+((o&1023)<<10)+(t.charCodeAt(++c)&1023),n[a++]=o>>18|240,n[a++]=o>>12&63|128,n[a++]=o>>6&63|128,n[a++]=o&63|128):(n[a++]=o>>12|224,n[a++]=o>>6&63|128,n[a++]=o&63|128)}else for(c=0;c<t.length;c++)n[c]=t[c]|0;return n}utils$h.toArray=toArray$1;function toHex(t){for(var e="",n=0;n<t.length;n++)e+=zero2(t[n].toString(16));return e}utils$h.toHex=toHex;function htonl(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}utils$h.htonl=htonl;function toHex32(t,e){for(var n="",a=0;a<t.length;a++){var c=t[a];e==="little"&&(c=htonl(c)),n+=zero8(c.toString(16))}return n}utils$h.toHex32=toHex32;function zero2(t){return t.length===1?"0"+t:t}utils$h.zero2=zero2;function zero8(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}utils$h.zero8=zero8;function join32(t,e,n,a){var c=n-e;assert$a(c%4===0);for(var o=new Array(c/4),u=0,h=e;u<o.length;u++,h+=4){var l;a==="big"?l=t[h]<<24|t[h+1]<<16|t[h+2]<<8|t[h+3]:l=t[h+3]<<24|t[h+2]<<16|t[h+1]<<8|t[h],o[u]=l>>>0}return o}utils$h.join32=join32;function split32(t,e){for(var n=new Array(t.length*4),a=0,c=0;a<t.length;a++,c+=4){var o=t[a];e==="big"?(n[c]=o>>>24,n[c+1]=o>>>16&255,n[c+2]=o>>>8&255,n[c+3]=o&255):(n[c+3]=o>>>24,n[c+2]=o>>>16&255,n[c+1]=o>>>8&255,n[c]=o&255)}return n}utils$h.split32=split32;function rotr32$1(t,e){return t>>>e|t<<32-e}utils$h.rotr32=rotr32$1;function rotl32$2(t,e){return t<<e|t>>>32-e}utils$h.rotl32=rotl32$2;function sum32$3(t,e){return t+e>>>0}utils$h.sum32=sum32$3;function sum32_3$1(t,e,n){return t+e+n>>>0}utils$h.sum32_3=sum32_3$1;function sum32_4$2(t,e,n,a){return t+e+n+a>>>0}utils$h.sum32_4=sum32_4$2;function sum32_5$2(t,e,n,a,c){return t+e+n+a+c>>>0}utils$h.sum32_5=sum32_5$2;function sum64$1(t,e,n,a){var c=t[e],o=t[e+1],u=a+o>>>0,h=(u<a?1:0)+n+c;t[e]=h>>>0,t[e+1]=u}utils$h.sum64=sum64$1;function sum64_hi$1(t,e,n,a){var c=e+a>>>0,o=(c<e?1:0)+t+n;return o>>>0}utils$h.sum64_hi=sum64_hi$1;function sum64_lo$1(t,e,n,a){var c=e+a;return c>>>0}utils$h.sum64_lo=sum64_lo$1;function sum64_4_hi$1(t,e,n,a,c,o,u,h){var l=0,b=e;b=b+a>>>0,l+=b<e?1:0,b=b+o>>>0,l+=b<o?1:0,b=b+h>>>0,l+=b<h?1:0;var d=t+n+c+u+l;return d>>>0}utils$h.sum64_4_hi=sum64_4_hi$1;function sum64_4_lo$1(t,e,n,a,c,o,u,h){var l=e+a+o+h;return l>>>0}utils$h.sum64_4_lo=sum64_4_lo$1;function sum64_5_hi$1(t,e,n,a,c,o,u,h,l,b){var d=0,p=e;p=p+a>>>0,d+=p<e?1:0,p=p+o>>>0,d+=p<o?1:0,p=p+h>>>0,d+=p<h?1:0,p=p+b>>>0,d+=p<b?1:0;var x=t+n+c+u+l+d;return x>>>0}utils$h.sum64_5_hi=sum64_5_hi$1;function sum64_5_lo$1(t,e,n,a,c,o,u,h,l,b){var d=e+a+o+h+b;return d>>>0}utils$h.sum64_5_lo=sum64_5_lo$1;function rotr64_hi$1(t,e,n){var a=e<<32-n|t>>>n;return a>>>0}utils$h.rotr64_hi=rotr64_hi$1;function rotr64_lo$1(t,e,n){var a=t<<32-n|e>>>n;return a>>>0}utils$h.rotr64_lo=rotr64_lo$1;function shr64_hi$1(t,e,n){return t>>>n}utils$h.shr64_hi=shr64_hi$1;function shr64_lo$1(t,e,n){var a=t<<32-n|e>>>n;return a>>>0}utils$h.shr64_lo=shr64_lo$1;var common$5={},utils$g=utils$h,assert$9=minimalisticAssert;function BlockHash$4(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}common$5.BlockHash=BlockHash$4;BlockHash$4.prototype.update=function t(e,n){if(e=utils$g.toArray(e,n),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var a=e.length%this._delta8;this.pending=e.slice(e.length-a,e.length),this.pending.length===0&&(this.pending=null),e=utils$g.join32(e,0,e.length-a,this.endian);for(var c=0;c<e.length;c+=this._delta32)this._update(e,c,c+this._delta32)}return this};BlockHash$4.prototype.digest=function t(e){return this.update(this._pad()),assert$9(this.pending===null),this._digest(e)};BlockHash$4.prototype._pad=function t(){var e=this.pendingTotal,n=this._delta8,a=n-(e+this.padLength)%n,c=new Array(a+this.padLength);c[0]=128;for(var o=1;o<a;o++)c[o]=0;if(e<<=3,this.endian==="big"){for(var u=8;u<this.padLength;u++)c[o++]=0;c[o++]=0,c[o++]=0,c[o++]=0,c[o++]=0,c[o++]=e>>>24&255,c[o++]=e>>>16&255,c[o++]=e>>>8&255,c[o++]=e&255}else for(c[o++]=e&255,c[o++]=e>>>8&255,c[o++]=e>>>16&255,c[o++]=e>>>24&255,c[o++]=0,c[o++]=0,c[o++]=0,c[o++]=0,u=8;u<this.padLength;u++)c[o++]=0;return c};var sha={},common$4={},utils$f=utils$h,rotr32=utils$f.rotr32;function ft_1$1(t,e,n,a){if(t===0)return ch32$1(e,n,a);if(t===1||t===3)return p32(e,n,a);if(t===2)return maj32$1(e,n,a)}common$4.ft_1=ft_1$1;function ch32$1(t,e,n){return t&e^~t&n}common$4.ch32=ch32$1;function maj32$1(t,e,n){return t&e^t&n^e&n}common$4.maj32=maj32$1;function p32(t,e,n){return t^e^n}common$4.p32=p32;function s0_256$1(t){return rotr32(t,2)^rotr32(t,13)^rotr32(t,22)}common$4.s0_256=s0_256$1;function s1_256$1(t){return rotr32(t,6)^rotr32(t,11)^rotr32(t,25)}common$4.s1_256=s1_256$1;function g0_256$1(t){return rotr32(t,7)^rotr32(t,18)^t>>>3}common$4.g0_256=g0_256$1;function g1_256$1(t){return rotr32(t,17)^rotr32(t,19)^t>>>10}common$4.g1_256=g1_256$1;var utils$e=utils$h,common$3=common$5,shaCommon$1=common$4,rotl32$1=utils$e.rotl32,sum32$2=utils$e.sum32,sum32_5$1=utils$e.sum32_5,ft_1=shaCommon$1.ft_1,BlockHash$3=common$3.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash$3.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils$e.inherits(SHA1,BlockHash$3);var _1=SHA1;SHA1.blockSize=512;SHA1.outSize=160;SHA1.hmacStrength=80;SHA1.padLength=64;SHA1.prototype._update=function t(e,n){for(var a=this.W,c=0;c<16;c++)a[c]=e[n+c];for(;c<a.length;c++)a[c]=rotl32$1(a[c-3]^a[c-8]^a[c-14]^a[c-16],1);var o=this.h[0],u=this.h[1],h=this.h[2],l=this.h[3],b=this.h[4];for(c=0;c<a.length;c++){var d=~~(c/20),p=sum32_5$1(rotl32$1(o,5),ft_1(d,u,h,l),b,a[c],sha1_K[d]);b=l,l=h,h=rotl32$1(u,30),u=o,o=p}this.h[0]=sum32$2(this.h[0],o),this.h[1]=sum32$2(this.h[1],u),this.h[2]=sum32$2(this.h[2],h),this.h[3]=sum32$2(this.h[3],l),this.h[4]=sum32$2(this.h[4],b)};SHA1.prototype._digest=function t(e){return e==="hex"?utils$e.toHex32(this.h,"big"):utils$e.split32(this.h,"big")};var utils$d=utils$h,common$2=common$5,shaCommon=common$4,assert$8=minimalisticAssert,sum32$1=utils$d.sum32,sum32_4$1=utils$d.sum32_4,sum32_5=utils$d.sum32_5,ch32=shaCommon.ch32,maj32=shaCommon.maj32,s0_256=shaCommon.s0_256,s1_256=shaCommon.s1_256,g0_256=shaCommon.g0_256,g1_256=shaCommon.g1_256,BlockHash$2=common$2.BlockHash,sha256_K=[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];function SHA256$1(){if(!(this instanceof SHA256$1))return new SHA256$1;BlockHash$2.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=sha256_K,this.W=new Array(64)}utils$d.inherits(SHA256$1,BlockHash$2);var _256=SHA256$1;SHA256$1.blockSize=512;SHA256$1.outSize=256;SHA256$1.hmacStrength=192;SHA256$1.padLength=64;SHA256$1.prototype._update=function t(e,n){for(var a=this.W,c=0;c<16;c++)a[c]=e[n+c];for(;c<a.length;c++)a[c]=sum32_4$1(g1_256(a[c-2]),a[c-7],g0_256(a[c-15]),a[c-16]);var o=this.h[0],u=this.h[1],h=this.h[2],l=this.h[3],b=this.h[4],d=this.h[5],p=this.h[6],x=this.h[7];for(assert$8(this.k.length===a.length),c=0;c<a.length;c++){var m=sum32_5(x,s1_256(b),ch32(b,d,p),this.k[c],a[c]),v=sum32$1(s0_256(o),maj32(o,u,h));x=p,p=d,d=b,b=sum32$1(l,m),l=h,h=u,u=o,o=sum32$1(m,v)}this.h[0]=sum32$1(this.h[0],o),this.h[1]=sum32$1(this.h[1],u),this.h[2]=sum32$1(this.h[2],h),this.h[3]=sum32$1(this.h[3],l),this.h[4]=sum32$1(this.h[4],b),this.h[5]=sum32$1(this.h[5],d),this.h[6]=sum32$1(this.h[6],p),this.h[7]=sum32$1(this.h[7],x)};SHA256$1.prototype._digest=function t(e){return e==="hex"?utils$d.toHex32(this.h,"big"):utils$d.split32(this.h,"big")};var utils$c=utils$h,SHA256=_256;function SHA224(){if(!(this instanceof SHA224))return new SHA224;SHA256.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}utils$c.inherits(SHA224,SHA256);var _224=SHA224;SHA224.blockSize=512;SHA224.outSize=224;SHA224.hmacStrength=192;SHA224.padLength=64;SHA224.prototype._digest=function t(e){return e==="hex"?utils$c.toHex32(this.h.slice(0,7),"big"):utils$c.split32(this.h.slice(0,7),"big")};var utils$b=utils$h,common$1=common$5,assert$7=minimalisticAssert,rotr64_hi=utils$b.rotr64_hi,rotr64_lo=utils$b.rotr64_lo,shr64_hi=utils$b.shr64_hi,shr64_lo=utils$b.shr64_lo,sum64=utils$b.sum64,sum64_hi=utils$b.sum64_hi,sum64_lo=utils$b.sum64_lo,sum64_4_hi=utils$b.sum64_4_hi,sum64_4_lo=utils$b.sum64_4_lo,sum64_5_hi=utils$b.sum64_5_hi,sum64_5_lo=utils$b.sum64_5_lo,BlockHash$1=common$1.BlockHash,sha512_K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function SHA512$1(){if(!(this instanceof SHA512$1))return new SHA512$1;BlockHash$1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=sha512_K,this.W=new Array(160)}utils$b.inherits(SHA512$1,BlockHash$1);var _512=SHA512$1;SHA512$1.blockSize=1024;SHA512$1.outSize=512;SHA512$1.hmacStrength=192;SHA512$1.padLength=128;SHA512$1.prototype._prepareBlock=function t(e,n){for(var a=this.W,c=0;c<32;c++)a[c]=e[n+c];for(;c<a.length;c+=2){var o=g1_512_hi(a[c-4],a[c-3]),u=g1_512_lo(a[c-4],a[c-3]),h=a[c-14],l=a[c-13],b=g0_512_hi(a[c-30],a[c-29]),d=g0_512_lo(a[c-30],a[c-29]),p=a[c-32],x=a[c-31];a[c]=sum64_4_hi(o,u,h,l,b,d,p,x),a[c+1]=sum64_4_lo(o,u,h,l,b,d,p,x)}};SHA512$1.prototype._update=function t(e,n){this._prepareBlock(e,n);var a=this.W,c=this.h[0],o=this.h[1],u=this.h[2],h=this.h[3],l=this.h[4],b=this.h[5],d=this.h[6],p=this.h[7],x=this.h[8],m=this.h[9],v=this.h[10],g=this.h[11],$=this.h[12],B=this.h[13],C=this.h[14],F=this.h[15];assert$7(this.k.length===a.length);for(var H=0;H<a.length;H+=2){var W=C,Z=F,ie=s1_512_hi(x,m),te=s1_512_lo(x,m),ae=ch64_hi(x,m,v,g,$),de=ch64_lo(x,m,v,g,$,B),J=this.k[H],R=this.k[H+1],A=a[H],y=a[H+1],w=sum64_5_hi(W,Z,ie,te,ae,de,J,R,A,y),I=sum64_5_lo(W,Z,ie,te,ae,de,J,R,A,y);W=s0_512_hi(c,o),Z=s0_512_lo(c,o),ie=maj64_hi(c,o,u,h,l),te=maj64_lo(c,o,u,h,l,b);var M=sum64_hi(W,Z,ie,te),k=sum64_lo(W,Z,ie,te);C=$,F=B,$=v,B=g,v=x,g=m,x=sum64_hi(d,p,w,I),m=sum64_lo(p,p,w,I),d=l,p=b,l=u,b=h,u=c,h=o,c=sum64_hi(w,I,M,k),o=sum64_lo(w,I,M,k)}sum64(this.h,0,c,o),sum64(this.h,2,u,h),sum64(this.h,4,l,b),sum64(this.h,6,d,p),sum64(this.h,8,x,m),sum64(this.h,10,v,g),sum64(this.h,12,$,B),sum64(this.h,14,C,F)};SHA512$1.prototype._digest=function t(e){return e==="hex"?utils$b.toHex32(this.h,"big"):utils$b.split32(this.h,"big")};function ch64_hi(t,e,n,a,c){var o=t&n^~t&c;return o<0&&(o+=4294967296),o}function ch64_lo(t,e,n,a,c,o){var u=e&a^~e&o;return u<0&&(u+=4294967296),u}function maj64_hi(t,e,n,a,c){var o=t&n^t&c^n&c;return o<0&&(o+=4294967296),o}function maj64_lo(t,e,n,a,c,o){var u=e&a^e&o^a&o;return u<0&&(u+=4294967296),u}function s0_512_hi(t,e){var n=rotr64_hi(t,e,28),a=rotr64_hi(e,t,2),c=rotr64_hi(e,t,7),o=n^a^c;return o<0&&(o+=4294967296),o}function s0_512_lo(t,e){var n=rotr64_lo(t,e,28),a=rotr64_lo(e,t,2),c=rotr64_lo(e,t,7),o=n^a^c;return o<0&&(o+=4294967296),o}function s1_512_hi(t,e){var n=rotr64_hi(t,e,14),a=rotr64_hi(t,e,18),c=rotr64_hi(e,t,9),o=n^a^c;return o<0&&(o+=4294967296),o}function s1_512_lo(t,e){var n=rotr64_lo(t,e,14),a=rotr64_lo(t,e,18),c=rotr64_lo(e,t,9),o=n^a^c;return o<0&&(o+=4294967296),o}function g0_512_hi(t,e){var n=rotr64_hi(t,e,1),a=rotr64_hi(t,e,8),c=shr64_hi(t,e,7),o=n^a^c;return o<0&&(o+=4294967296),o}function g0_512_lo(t,e){var n=rotr64_lo(t,e,1),a=rotr64_lo(t,e,8),c=shr64_lo(t,e,7),o=n^a^c;return o<0&&(o+=4294967296),o}function g1_512_hi(t,e){var n=rotr64_hi(t,e,19),a=rotr64_hi(e,t,29),c=shr64_hi(t,e,6),o=n^a^c;return o<0&&(o+=4294967296),o}function g1_512_lo(t,e){var n=rotr64_lo(t,e,19),a=rotr64_lo(e,t,29),c=shr64_lo(t,e,6),o=n^a^c;return o<0&&(o+=4294967296),o}var utils$a=utils$h,SHA512=_512;function SHA384(){if(!(this instanceof SHA384))return new SHA384;SHA512.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}utils$a.inherits(SHA384,SHA512);var _384=SHA384;SHA384.blockSize=1024;SHA384.outSize=384;SHA384.hmacStrength=192;SHA384.padLength=128;SHA384.prototype._digest=function t(e){return e==="hex"?utils$a.toHex32(this.h.slice(0,12),"big"):utils$a.split32(this.h.slice(0,12),"big")};sha.sha1=_1;sha.sha224=_224;sha.sha256=_256;sha.sha384=_384;sha.sha512=_512;var ripemd={},utils$9=utils$h,common=common$5,rotl32=utils$9.rotl32,sum32=utils$9.sum32,sum32_3=utils$9.sum32_3,sum32_4=utils$9.sum32_4,BlockHash=common.BlockHash;function RIPEMD160(){if(!(this instanceof RIPEMD160))return new RIPEMD160;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}utils$9.inherits(RIPEMD160,BlockHash);ripemd.ripemd160=RIPEMD160;RIPEMD160.blockSize=512;RIPEMD160.outSize=160;RIPEMD160.hmacStrength=192;RIPEMD160.padLength=64;RIPEMD160.prototype._update=function t(e,n){for(var a=this.h[0],c=this.h[1],o=this.h[2],u=this.h[3],h=this.h[4],l=a,b=c,d=o,p=u,x=h,m=0;m<80;m++){var v=sum32(rotl32(sum32_4(a,f(m,c,o,u),e[r[m]+n],K(m)),s[m]),h);a=h,h=u,u=rotl32(o,10),o=c,c=v,v=sum32(rotl32(sum32_4(l,f(79-m,b,d,p),e[rh[m]+n],Kh(m)),sh[m]),x),l=x,x=p,p=rotl32(d,10),d=b,b=v}v=sum32_3(this.h[1],o,p),this.h[1]=sum32_3(this.h[2],u,x),this.h[2]=sum32_3(this.h[3],h,l),this.h[3]=sum32_3(this.h[4],a,b),this.h[4]=sum32_3(this.h[0],c,d),this.h[0]=v};RIPEMD160.prototype._digest=function t(e){return e==="hex"?utils$9.toHex32(this.h,"little"):utils$9.split32(this.h,"little")};function f(t,e,n,a){return t<=15?e^n^a:t<=31?e&n|~e&a:t<=47?(e|~n)^a:t<=63?e&a|n&~a:e^(n|~a)}function K(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function Kh(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var r=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],rh=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],s=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sh=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],utils$8=utils$h,assert$6=minimalisticAssert;function Hmac(t,e,n){if(!(this instanceof Hmac))return new Hmac(t,e,n);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(utils$8.toArray(e,n))}var hmac=Hmac;Hmac.prototype._init=function t(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),assert$6(e.length<=this.blockSize);for(var n=e.length;n<this.blockSize;n++)e.push(0);for(n=0;n<e.length;n++)e[n]^=54;for(this.inner=new this.Hash().update(e),n=0;n<e.length;n++)e[n]^=106;this.outer=new this.Hash().update(e)};Hmac.prototype.update=function t(e,n){return this.inner.update(e,n),this};Hmac.prototype.digest=function t(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)};(function(t){var e=t;e.utils=utils$h,e.common=common$5,e.sha=sha,e.ripemd=ripemd,e.hmac=hmac,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160})(hash$2);var secp256k1,hasRequiredSecp256k1;function requireSecp256k1(){return hasRequiredSecp256k1||(hasRequiredSecp256k1=1,secp256k1={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),secp256k1}(function(t){var e=t,n=hash$2,a=curve,c=utils$o,o=c.assert;function u(b){b.type==="short"?this.curve=new a.short(b):b.type==="edwards"?this.curve=new a.edwards(b):this.curve=new a.mont(b),this.g=this.curve.g,this.n=this.curve.n,this.hash=b.hash,o(this.g.validate(),"Invalid curve"),o(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=u;function h(b,d){Object.defineProperty(e,b,{configurable:!0,enumerable:!0,get:function(){var p=new u(d);return Object.defineProperty(e,b,{configurable:!0,enumerable:!0,value:p}),p}})}h("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:n.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),h("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:n.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),h("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:n.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),h("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:n.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),h("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:n.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),h("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:n.sha256,gRed:!1,g:["9"]}),h("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:n.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var l;try{l=requireSecp256k1()}catch{l=void 0}h("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:n.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",l]})})(curves$1);var hash$1=hash$2,utils$7=utils$n,assert$5=minimalisticAssert;function HmacDRBG(t){if(!(this instanceof HmacDRBG))return new HmacDRBG(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=utils$7.toArray(t.entropy,t.entropyEnc||"hex"),n=utils$7.toArray(t.nonce,t.nonceEnc||"hex"),a=utils$7.toArray(t.pers,t.persEnc||"hex");assert$5(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,n,a)}var hmacDrbg=HmacDRBG;HmacDRBG.prototype._init=function t(e,n,a){var c=e.concat(n).concat(a);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o<this.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(c),this._reseed=1,this.reseedInterval=281474976710656};HmacDRBG.prototype._hmac=function t(){return new hash$1.hmac(this.hash,this.K)};HmacDRBG.prototype._update=function t(e){var n=this._hmac().update(this.V).update([0]);e&&(n=n.update(e)),this.K=n.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())};HmacDRBG.prototype.reseed=function t(e,n,a,c){typeof n!="string"&&(c=a,a=n,n=null),e=utils$7.toArray(e,n),a=utils$7.toArray(a,c),assert$5(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(a||[])),this._reseed=1};HmacDRBG.prototype.generate=function t(e,n,a,c){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof n!="string"&&(c=a,a=n,n=null),a&&(a=utils$7.toArray(a,c||"hex"),this._update(a));for(var o=[];o.length<e;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var u=o.slice(0,e);return this._update(a),this._reseed++,utils$7.encode(u,n)};var BN$2=bnExports,utils$6=utils$o,assert$4=utils$6.assert;function KeyPair$2(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var key$1=KeyPair$2;KeyPair$2.fromPublic=function t(e,n,a){return n instanceof KeyPair$2?n:new KeyPair$2(e,{pub:n,pubEnc:a})};KeyPair$2.fromPrivate=function t(e,n,a){return n instanceof KeyPair$2?n:new KeyPair$2(e,{priv:n,privEnc:a})};KeyPair$2.prototype.validate=function t(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};KeyPair$2.prototype.getPublic=function t(e,n){return typeof e=="string"&&(n=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),n?this.pub.encode(n,e):this.pub};KeyPair$2.prototype.getPrivate=function t(e){return e==="hex"?this.priv.toString(16,2):this.priv};KeyPair$2.prototype._importPrivate=function t(e,n){this.priv=new BN$2(e,n||16),this.priv=this.priv.umod(this.ec.curve.n)};KeyPair$2.prototype._importPublic=function t(e,n){if(e.x||e.y){this.ec.curve.type==="mont"?assert$4(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&assert$4(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,n)};KeyPair$2.prototype.derive=function t(e){return e.validate()||assert$4(e.validate(),"public point not validated"),e.mul(this.priv).getX()};KeyPair$2.prototype.sign=function t(e,n,a){return this.ec.sign(e,this,n,a)};KeyPair$2.prototype.verify=function t(e,n){return this.ec.verify(e,n,this)};KeyPair$2.prototype.inspect=function t(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var BN$1=bnExports,utils$5=utils$o,assert$3=utils$5.assert;function Signature$2(t,e){if(t instanceof Signature$2)return t;this._importDER(t,e)||(assert$3(t.r&&t.s,"Signature without r or s"),this.r=new BN$1(t.r,16),this.s=new BN$1(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var signature$1=Signature$2;function Position(){this.place=0}function getLength(t,e){var n=t[e.place++];if(!(n&128))return n;var a=n&15;if(a===0||a>4||t[e.place]===0)return!1;for(var c=0,o=0,u=e.place;o<a;o++,u++)c<<=8,c|=t[u],c>>>=0;return c<=127?!1:(e.place=u,c)}function rmPadding(t){for(var e=0,n=t.length-1;!t[e]&&!(t[e+1]&128)&&e<n;)e++;return e===0?t:t.slice(e)}Signature$2.prototype._importDER=function t(e,n){e=utils$5.toArray(e,n);var a=new Position;if(e[a.place++]!==48)return!1;var c=getLength(e,a);if(c===!1||c+a.place!==e.length||e[a.place++]!==2)return!1;var o=getLength(e,a);if(o===!1||e[a.place]&128)return!1;var u=e.slice(a.place,o+a.place);if(a.place+=o,e[a.place++]!==2)return!1;var h=getLength(e,a);if(h===!1||e.length!==h+a.place||e[a.place]&128)return!1;var l=e.slice(a.place,h+a.place);if(u[0]===0)if(u[1]&128)u=u.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new BN$1(u),this.s=new BN$1(l),this.recoveryParam=null,!0};function constructLength(t,e){if(e<128){t.push(e);return}var n=1+(Math.log(e)/Math.LN2>>>3);for(t.push(n|128);--n;)t.push(e>>>(n<<3)&255);t.push(e)}Signature$2.prototype.toDER=function t(e){var n=this.r.toArray(),a=this.s.toArray();for(n[0]&128&&(n=[0].concat(n)),a[0]&128&&(a=[0].concat(a)),n=rmPadding(n),a=rmPadding(a);!a[0]&&!(a[1]&128);)a=a.slice(1);var c=[2];constructLength(c,n.length),c=c.concat(n),c.push(2),constructLength(c,a.length);var o=c.concat(a),u=[48];return constructLength(u,o.length),u=u.concat(o),utils$5.encode(u,e)};var ec$1,hasRequiredEc;function requireEc(){if(hasRequiredEc)return ec$1;hasRequiredEc=1;var t=bnExports,e=hmacDrbg,n=utils$o,a=curves$1,c=requireBrorand(),o=n.assert,u=key$1,h=signature$1;function l(b){if(!(this instanceof l))return new l(b);typeof b=="string"&&(o(Object.prototype.hasOwnProperty.call(a,b),"Unknown curve "+b),b=a[b]),b instanceof a.PresetCurve&&(b={curve:b}),this.curve=b.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=b.curve.g,this.g.precompute(b.curve.n.bitLength()+1),this.hash=b.hash||b.curve.hash}return ec$1=l,l.prototype.keyPair=function(d){return new u(this,d)},l.prototype.keyFromPrivate=function(d,p){return u.fromPrivate(this,d,p)},l.prototype.keyFromPublic=function(d,p){return u.fromPublic(this,d,p)},l.prototype.genKeyPair=function(d){d||(d={});for(var p=new e({hash:this.hash,pers:d.pers,persEnc:d.persEnc||"utf8",entropy:d.entropy||c(this.hash.hmacStrength),entropyEnc:d.entropy&&d.entropyEnc||"utf8",nonce:this.n.toArray()}),x=this.n.byteLength(),m=this.n.sub(new t(2));;){var v=new t(p.generate(x));if(!(v.cmp(m)>0))return v.iaddn(1),this.keyFromPrivate(v)}},l.prototype._truncateToN=function(d,p){var x=d.byteLength()*8-this.n.bitLength();return x>0&&(d=d.ushrn(x)),!p&&d.cmp(this.n)>=0?d.sub(this.n):d},l.prototype.sign=function(d,p,x,m){typeof x=="object"&&(m=x,x=null),m||(m={}),p=this.keyFromPrivate(p,x),d=this._truncateToN(new t(d,16));for(var v=this.n.byteLength(),g=p.getPrivate().toArray("be",v),$=d.toArray("be",v),B=new e({hash:this.hash,entropy:g,nonce:$,pers:m.pers,persEnc:m.persEnc||"utf8"}),C=this.n.sub(new t(1)),F=0;;F++){var H=m.k?m.k(F):new t(B.generate(this.n.byteLength()));if(H=this._truncateToN(H,!0),!(H.cmpn(1)<=0||H.cmp(C)>=0)){var W=this.g.mul(H);if(!W.isInfinity()){var Z=W.getX(),ie=Z.umod(this.n);if(ie.cmpn(0)!==0){var te=H.invm(this.n).mul(ie.mul(p.getPrivate()).iadd(d));if(te=te.umod(this.n),te.cmpn(0)!==0){var ae=(W.getY().isOdd()?1:0)|(Z.cmp(ie)!==0?2:0);return m.canonical&&te.cmp(this.nh)>0&&(te=this.n.sub(te),ae^=1),new h({r:ie,s:te,recoveryParam:ae})}}}}}},l.prototype.verify=function(d,p,x,m){d=this._truncateToN(new t(d,16)),x=this.keyFromPublic(x,m),p=new h(p,"hex");var v=p.r,g=p.s;if(v.cmpn(1)<0||v.cmp(this.n)>=0||g.cmpn(1)<0||g.cmp(this.n)>=0)return!1;var $=g.invm(this.n),B=$.mul(d).umod(this.n),C=$.mul(v).umod(this.n),F;return this.curve._maxwellTrick?(F=this.g.jmulAdd(B,x.getPublic(),C),F.isInfinity()?!1:F.eqXToP(v)):(F=this.g.mulAdd(B,x.getPublic(),C),F.isInfinity()?!1:F.getX().umod(this.n).cmp(v)===0)},l.prototype.recoverPubKey=function(b,d,p,x){o((3&p)===p,"The recovery param is more than two bits"),d=new h(d,x);var m=this.n,v=new t(b),g=d.r,$=d.s,B=p&1,C=p>>1;if(g.cmp(this.curve.p.umod(this.curve.n))>=0&&C)throw new Error("Unable to find sencond key candinate");C?g=this.curve.pointFromX(g.add(this.curve.n),B):g=this.curve.pointFromX(g,B);var F=d.r.invm(m),H=m.sub(v).mul(F).umod(m),W=$.mul(F).umod(m);return this.g.mulAdd(H,g,W)},l.prototype.getKeyRecoveryParam=function(b,d,p,x){if(d=new h(d,x),d.recoveryParam!==null)return d.recoveryParam;for(var m=0;m<4;m++){var v;try{v=this.recoverPubKey(b,d,m)}catch{continue}if(v.eq(p))return m}throw new Error("Unable to find valid recovery factor")},ec$1}var utils$4=utils$o,assert$2=utils$4.assert,parseBytes$2=utils$4.parseBytes,cachedProperty$1=utils$4.cachedProperty;function KeyPair$1(t,e){this.eddsa=t,this._secret=parseBytes$2(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=parseBytes$2(e.pub)}KeyPair$1.fromPublic=function t(e,n){return n instanceof KeyPair$1?n:new KeyPair$1(e,{pub:n})};KeyPair$1.fromSecret=function t(e,n){return n instanceof KeyPair$1?n:new KeyPair$1(e,{secret:n})};KeyPair$1.prototype.secret=function t(){return this._secret};cachedProperty$1(KeyPair$1,"pubBytes",function t(){return this.eddsa.encodePoint(this.pub())});cachedProperty$1(KeyPair$1,"pub",function t(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});cachedProperty$1(KeyPair$1,"privBytes",function t(){var e=this.eddsa,n=this.hash(),a=e.encodingLength-1,c=n.slice(0,e.encodingLength);return c[0]&=248,c[a]&=127,c[a]|=64,c});cachedProperty$1(KeyPair$1,"priv",function t(){return this.eddsa.decodeInt(this.privBytes())});cachedProperty$1(KeyPair$1,"hash",function t(){return this.eddsa.hash().update(this.secret()).digest()});cachedProperty$1(KeyPair$1,"messagePrefix",function t(){return this.hash().slice(this.eddsa.encodingLength)});KeyPair$1.prototype.sign=function t(e){return assert$2(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};KeyPair$1.prototype.verify=function t(e,n){return this.eddsa.verify(e,n,this)};KeyPair$1.prototype.getSecret=function t(e){return assert$2(this._secret,"KeyPair is public only"),utils$4.encode(this.secret(),e)};KeyPair$1.prototype.getPublic=function t(e){return utils$4.encode(this.pubBytes(),e)};var key=KeyPair$1,BN=bnExports,utils$3=utils$o,assert$1=utils$3.assert,cachedProperty=utils$3.cachedProperty,parseBytes$1=utils$3.parseBytes;function Signature$1(t,e){this.eddsa=t,typeof e!="object"&&(e=parseBytes$1(e)),Array.isArray(e)&&(assert$1(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),assert$1(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof BN&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}cachedProperty(Signature$1,"S",function t(){return this.eddsa.decodeInt(this.Sencoded())});cachedProperty(Signature$1,"R",function t(){return this.eddsa.decodePoint(this.Rencoded())});cachedProperty(Signature$1,"Rencoded",function t(){return this.eddsa.encodePoint(this.R())});cachedProperty(Signature$1,"Sencoded",function t(){return this.eddsa.encodeInt(this.S())});Signature$1.prototype.toBytes=function t(){return this.Rencoded().concat(this.Sencoded())};Signature$1.prototype.toHex=function t(){return utils$3.encode(this.toBytes(),"hex").toUpperCase()};var signature=Signature$1,hash=hash$2,curves=curves$1,utils$2=utils$o,assert=utils$2.assert,parseBytes=utils$2.parseBytes,KeyPair=key,Signature=signature;function EDDSA(t){if(assert(t==="ed25519","only tested with ed25519 so far"),!(this instanceof EDDSA))return new EDDSA(t);t=curves[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=hash.sha512}var eddsa=EDDSA;EDDSA.prototype.sign=function t(e,n){e=parseBytes(e);var a=this.keyFromSecret(n),c=this.hashInt(a.messagePrefix(),e),o=this.g.mul(c),u=this.encodePoint(o),h=this.hashInt(u,a.pubBytes(),e).mul(a.priv()),l=c.add(h).umod(this.curve.n);return this.makeSignature({R:o,S:l,Rencoded:u})};EDDSA.prototype.verify=function t(e,n,a){if(e=parseBytes(e),n=this.makeSignature(n),n.S().gte(n.eddsa.curve.n)||n.S().isNeg())return!1;var c=this.keyFromPublic(a),o=this.hashInt(n.Rencoded(),c.pubBytes(),e),u=this.g.mul(n.S()),h=n.R().add(c.pub().mul(o));return h.eq(u)};EDDSA.prototype.hashInt=function t(){for(var e=this.hash(),n=0;n<arguments.length;n++)e.update(arguments[n]);return utils$2.intFromLE(e.digest()).umod(this.curve.n)};EDDSA.prototype.keyFromPublic=function t(e){return KeyPair.fromPublic(this,e)};EDDSA.prototype.keyFromSecret=function t(e){return KeyPair.fromSecret(this,e)};EDDSA.prototype.makeSignature=function t(e){return e instanceof Signature?e:new Signature(this,e)};EDDSA.prototype.encodePoint=function t(e){var n=e.getY().toArray("le",this.encodingLength);return n[this.encodingLength-1]|=e.getX().isOdd()?128:0,n};EDDSA.prototype.decodePoint=function t(e){e=utils$2.parseBytes(e);var n=e.length-1,a=e.slice(0,n).concat(e[n]&-129),c=(e[n]&128)!==0,o=utils$2.intFromLE(a);return this.curve.pointFromY(o,c)};EDDSA.prototype.encodeInt=function t(e){return e.toArray("le",this.encodingLength)};EDDSA.prototype.decodeInt=function t(e){return utils$2.intFromLE(e)};EDDSA.prototype.isPoint=function t(e){return e instanceof this.pointClass};var hasRequiredElliptic;function requireElliptic(){return hasRequiredElliptic||(hasRequiredElliptic=1,function(t){var e=t;e.version=require$$0.version,e.utils=utils$o,e.rand=requireBrorand(),e.curve=curve,e.curves=curves$1,e.ec=requireEc(),e.eddsa=eddsa}(elliptic)),elliptic}var ellipticExports=requireElliptic();const pkg=getDefaultExportFromCjs$1(ellipticExports),{ec}=pkg,UNCOMPRESSED_RECOVERY_ID=27,keccak256Hash=distExports.Utils.keccak256Hash;function getConsensualPrivateKey(t){return isBytes(t,32)?t:isHexString(t)&&t.length===64?hexToBytes(t):keccak256Hash(t)}function isPostageBatchId(t){return isHexString(t)&&t.length===64}function isPostageStamp(t){return isHexString(t)&&t.length===226}function publicKeyToAddress(t){return keccak256Hash(t.slice(1)).slice(12)}function hashWithEthereumPrefix(t){const e=`Ethereum Signed Message:
25
- ${t.length}`,n=new TextEncoder().encode(e);return keccak256Hash(n,t)}function defaultSign(t,e){const n=new ec("secp256k1"),a=n.keyFromPrivate(e),c=hashWithEthereumPrefix(t),o=n.sign(c,a,{canonical:!0,pers:void 0});if(o.recoveryParam===null)throw new Error("signDigest recovery param was null");return new Uint8Array([...o.r.toArray("be",32),...o.s.toArray("be",32),o.recoveryParam+UNCOMPRESSED_RECOVERY_ID])}function makePrivateKeySigner(t){const n=new ec("secp256k1").keyFromPrivate(t),a=publicKeyToAddress(n.getPublic().encode("array",!1));return{sign:c=>defaultSign(c,t),address:a}}function isObject$1(t){return t!==null&&typeof t=="object"}function isStrictlyObject(t){return isObject$1(t)&&!Array.isArray(t)}function assertSignerFn(t){if(!isStrictlyObject(t))throw new TypeError("Signer must be an object!");const e=t;if(!isBytes(e.address,20))throw new TypeError("Signer's address must be Uint8Array with 20 bytes!");if(typeof e.sign!="function")throw new TypeError("Signer sign property needs to be function!")}function makeSigner(t){if(typeof t=="string"){const e=makeHexString(t,64),n=hexToBytes(e);return makePrivateKeySigner(n)}else if(t instanceof Uint8Array)return assertBytes(t,32),makePrivateKeySigner(t);return assertSignerFn(t),t}function inProximity(t,e,n){if(t.length!==e.length||t.length!==32)throw new Error("Lengths are incorrect at proximity check");let a=0,c=n;for(;c>0;)if(c>=8){if(t[a]!==e[a])return!1;a++,c-=8}else{const o=t[a]>>>8-c,u=e[a]>>>8-c;return o===u}return!0}function isBytes(t,e){return t instanceof Uint8Array&&t.length===e}function assertBytes(t,e){if(!isBytes(t,e))throw new TypeError(`Parameter is not valid Bytes of length: ${e} !== ${t.length}`)}function serializeBytes(...t){const e=t.reduce((c,o)=>c+o.length,0),n=new Uint8Array(e);let a=0;return t.forEach(c=>{n.set(c,a),a+=c.length}),n}function bytesToHex(t,e){const n=c=>c.toString(16).padStart(2,"0"),a=Array.from(t,n).join("");if(e&&a.length!==e)throw new TypeError(`Resulting HexString does not have expected length ${e}: ${a}`);return a}function intToHex(t,e){if(!Number.isInteger(t))throw new TypeError("the value provided is not integer");if(t>Number.MAX_SAFE_INTEGER)throw new TypeError("the value provided exceeds safe integer");if(t<0)throw new TypeError("the value provided is a negative integer");const n=t.toString(16);if(e&&n.length!==e)throw new TypeError(`Resulting HexString does not have expected length ${e}: ${n}`);return n}function hexToBytes(t){assertHexString(t);const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++){const a=t.substr(n*2,2);e[n]=parseInt(a,16)}return e}function isHexString(t,e){return typeof t=="string"&&/^[0-9a-f]+$/i.test(t)&&(!e||t.length===e)}function isPrefixedHexString(t){return typeof t=="string"&&/^0x[0-9a-f]+$/i.test(t)}function serializePayload(t){return new TextEncoder().encode(JSON.stringify(t))}function assertHexString(t,e,n="value"){if(!isHexString(t,e)){if(isPrefixedHexString(t))throw new TypeError(`${n} not valid non prefixed hex string (has 0x prefix): ${t}`);const a=e?` of length ${e}`:"";throw new TypeError(`${n} not valid hex string${a}: ${t}`)}}function makeHexString(t,e){if(typeof t=="number")return intToHex(t,e);if(t instanceof Uint8Array)return bytesToHex(t,e);if(typeof t=="string")if(isPrefixedHexString(t)){const n=t.slice(2);if(e&&n.length!==e)throw new TypeError(`Length mismatch for valid hex string. Expecting length ${e}: ${n}`);return n}else return assertHexString(t,e),t;throw new TypeError("Not HexString compatible type!")}function wrapBytesWithHelpers(t){return Object.assign(t,{text:()=>new TextDecoder("utf-8").decode(t),json:()=>JSON.parse(new TextDecoder("utf-8").decode(t)),hex:()=>bytesToHex(t)})}async function makeSingleOwnerChunk(t,e,n){const a=t.address(),c=distExports.Utils.keccak256Hash(e,a),o=await sign(n,c),u=serializeBytes(e,o,t.span(),t.payload),h=makeSOCAddress(e,n.address);return{...t,data:()=>u,identifier:()=>e,signature:()=>o,address:()=>h,owner:()=>n.address}}function makeSOCAddress(t,e){return distExports.Utils.keccak256Hash(t,e)}async function sign(t,e){const n=await t.sign(e);if(typeof n=="string"){const a=makeHexString(n);return hexToBytes(a)}if(n instanceof Uint8Array)return n;throw new TypeError("Invalid output of sign function!")}function bind(t,e){return function(){return t.apply(e,arguments)}}const{toString}=Object.prototype,{getPrototypeOf}=Object,kindOf=(t=>e=>{const n=toString.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),kindOfTest=t=>(t=t.toLowerCase(),e=>kindOf(e)===t),typeOfTest=t=>e=>typeof e===t,{isArray}=Array,isUndefined=typeOfTest("undefined");function isBuffer(t){return t!==null&&!isUndefined(t)&&t.constructor!==null&&!isUndefined(t.constructor)&&isFunction(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const isArrayBuffer=kindOfTest("ArrayBuffer");function isArrayBufferView(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&isArrayBuffer(t.buffer),e}const isString=typeOfTest("string"),isFunction=typeOfTest("function"),isNumber=typeOfTest("number"),isObject=t=>t!==null&&typeof t=="object",isBoolean=t=>t===!0||t===!1,isPlainObject=t=>{if(kindOf(t)!=="object")return!1;const e=getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},isDate=kindOfTest("Date"),isFile=kindOfTest("File"),isBlob=kindOfTest("Blob"),isFileList=kindOfTest("FileList"),isStream=t=>isObject(t)&&isFunction(t.pipe),isFormData=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||isFunction(t.append)&&((e=kindOf(t))==="formdata"||e==="object"&&isFunction(t.toString)&&t.toString()==="[object FormData]"))},isURLSearchParams=kindOfTest("URLSearchParams"),[isReadableStream,isRequest,isResponse,isHeaders]=["ReadableStream","Request","Response","Headers"].map(kindOfTest),trim=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function forEach(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let a,c;if(typeof t!="object"&&(t=[t]),isArray(t))for(a=0,c=t.length;a<c;a++)e.call(null,t[a],a,t);else{const o=n?Object.getOwnPropertyNames(t):Object.keys(t),u=o.length;let h;for(a=0;a<u;a++)h=o[a],e.call(null,t[h],h,t)}}function findKey(t,e){e=e.toLowerCase();const n=Object.keys(t);let a=n.length,c;for(;a-- >0;)if(c=n[a],e===c.toLowerCase())return c;return null}const _global=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global$1,isContextDefined=t=>!isUndefined(t)&&t!==_global;function merge(){const{caseless:t}=isContextDefined(this)&&this||{},e={},n=(a,c)=>{const o=t&&findKey(e,c)||c;isPlainObject(e[o])&&isPlainObject(a)?e[o]=merge(e[o],a):isPlainObject(a)?e[o]=merge({},a):isArray(a)?e[o]=a.slice():e[o]=a};for(let a=0,c=arguments.length;a<c;a++)arguments[a]&&forEach(arguments[a],n);return e}const extend=(t,e,n,{allOwnKeys:a}={})=>(forEach(e,(c,o)=>{n&&isFunction(c)?t[o]=bind(c,n):t[o]=c},{allOwnKeys:a}),t),stripBOM=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),inherits=(t,e,n,a)=>{t.prototype=Object.create(e.prototype,a),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},toFlatObject=(t,e,n,a)=>{let c,o,u;const h={};if(e=e||{},t==null)return e;do{for(c=Object.getOwnPropertyNames(t),o=c.length;o-- >0;)u=c[o],(!a||a(u,t,e))&&!h[u]&&(e[u]=t[u],h[u]=!0);t=n!==!1&&getPrototypeOf(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},endsWith=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const a=t.indexOf(e,n);return a!==-1&&a===n},toArray=t=>{if(!t)return null;if(isArray(t))return t;let e=t.length;if(!isNumber(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},isTypedArray=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&getPrototypeOf(Uint8Array)),forEachEntry=(t,e)=>{const a=(t&&t[Symbol.iterator]).call(t);let c;for(;(c=a.next())&&!c.done;){const o=c.value;e.call(t,o[0],o[1])}},matchAll=(t,e)=>{let n;const a=[];for(;(n=t.exec(e))!==null;)a.push(n);return a},isHTMLForm=kindOfTest("HTMLFormElement"),toCamelCase=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,a,c){return a.toUpperCase()+c}),hasOwnProperty=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),isRegExp=kindOfTest("RegExp"),reduceDescriptors=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),a={};forEach(n,(c,o)=>{let u;(u=e(c,o,t))!==!1&&(a[o]=u||c)}),Object.defineProperties(t,a)},freezeMethods=t=>{reduceDescriptors(t,(e,n)=>{if(isFunction(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const a=t[n];if(isFunction(a)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet=(t,e)=>{const n={},a=c=>{c.forEach(o=>{n[o]=!0})};return isArray(t)?a(t):a(String(t).split(e)),n},noop=()=>{},toFiniteNumber=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,ALPHA="abcdefghijklmnopqrstuvwxyz",DIGIT="0123456789",ALPHABET={DIGIT,ALPHA,ALPHA_DIGIT:ALPHA+ALPHA.toUpperCase()+DIGIT},generateString=(t=16,e=ALPHABET.ALPHA_DIGIT)=>{let n="";const{length:a}=e;for(;t--;)n+=e[Math.random()*a|0];return n};function isSpecCompliantForm(t){return!!(t&&isFunction(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const toJSONObject=t=>{const e=new Array(10),n=(a,c)=>{if(isObject(a)){if(e.indexOf(a)>=0)return;if(!("toJSON"in a)){e[c]=a;const o=isArray(a)?[]:{};return forEach(a,(u,h)=>{const l=n(u,c+1);!isUndefined(l)&&(o[h]=l)}),e[c]=void 0,o}}return a};return n(t,0)},isAsyncFn=kindOfTest("AsyncFunction"),isThenable=t=>t&&(isObject(t)||isFunction(t))&&isFunction(t.then)&&isFunction(t.catch),_setImmediate=((t,e)=>t?setImmediate:e?((n,a)=>(_global.addEventListener("message",({source:c,data:o})=>{c===_global&&o===n&&a.length&&a.shift()()},!1),c=>{a.push(c),_global.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",isFunction(_global.postMessage)),asap=typeof queueMicrotask<"u"?queueMicrotask.bind(_global):typeof process$1<"u"&&process$1.nextTick||_setImmediate,utils$1={isArray,isArrayBuffer,isBuffer,isFormData,isArrayBufferView,isString,isNumber,isBoolean,isObject,isPlainObject,isReadableStream,isRequest,isResponse,isHeaders,isUndefined,isDate,isFile,isBlob,isRegExp,isFunction,isStream,isURLSearchParams,isTypedArray,isFileList,forEach,merge,extend,trim,stripBOM,inherits,toFlatObject,kindOf,kindOfTest,endsWith,toArray,forEachEntry,matchAll,isHTMLForm,hasOwnProperty,hasOwnProp:hasOwnProperty,reduceDescriptors,freezeMethods,toObjectSet,toCamelCase,noop,toFiniteNumber,findKey,global:_global,isContextDefined,ALPHABET,generateString,isSpecCompliantForm,toJSONObject,isAsyncFn,isThenable,setImmediate:_setImmediate,asap};function AxiosError$1(t,e,n,a,c){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),a&&(this.request=a),c&&(this.response=c,this.status=c.status?c.status:null)}utils$1.inherits(AxiosError$1,Error,{toJSON:function t(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:utils$1.toJSONObject(this.config),code:this.code,status:this.status}}});const prototype$1=AxiosError$1.prototype,descriptors={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{descriptors[t]={value:t}});Object.defineProperties(AxiosError$1,descriptors);Object.defineProperty(prototype$1,"isAxiosError",{value:!0});AxiosError$1.from=(t,e,n,a,c,o)=>{const u=Object.create(prototype$1);return utils$1.toFlatObject(t,u,function(l){return l!==Error.prototype},h=>h!=="isAxiosError"),AxiosError$1.call(u,t.message,e,n,a,c),u.cause=t,u.name=t.name,o&&Object.assign(u,o),u};const httpAdapter=null;function isVisitable(t){return utils$1.isPlainObject(t)||utils$1.isArray(t)}function removeBrackets(t){return utils$1.endsWith(t,"[]")?t.slice(0,-2):t}function renderKey(t,e,n){return t?t.concat(e).map(function(c,o){return c=removeBrackets(c),!n&&o?"["+c+"]":c}).join(n?".":""):e}function isFlatArray(t){return utils$1.isArray(t)&&!t.some(isVisitable)}const predicates=utils$1.toFlatObject(utils$1,{},null,function t(e){return/^is[A-Z]/.test(e)});function toFormData$1(t,e,n){if(!utils$1.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=utils$1.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,$){return!utils$1.isUndefined($[g])});const a=n.metaTokens,c=n.visitor||d,o=n.dots,u=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&utils$1.isSpecCompliantForm(e);if(!utils$1.isFunction(c))throw new TypeError("visitor must be a function");function b(v){if(v===null)return"";if(utils$1.isDate(v))return v.toISOString();if(!l&&utils$1.isBlob(v))throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");return utils$1.isArrayBuffer(v)||utils$1.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,$){let B=v;if(v&&!$&&typeof v=="object"){if(utils$1.endsWith(g,"{}"))g=a?g:g.slice(0,-2),v=JSON.stringify(v);else if(utils$1.isArray(v)&&isFlatArray(v)||(utils$1.isFileList(v)||utils$1.endsWith(g,"[]"))&&(B=utils$1.toArray(v)))return g=removeBrackets(g),B.forEach(function(F,H){!(utils$1.isUndefined(F)||F===null)&&e.append(u===!0?renderKey([g],H,o):u===null?g:g+"[]",b(F))}),!1}return isVisitable(v)?!0:(e.append(renderKey($,g,o),b(v)),!1)}const p=[],x=Object.assign(predicates,{defaultVisitor:d,convertValue:b,isVisitable});function m(v,g){if(!utils$1.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),utils$1.forEach(v,function(B,C){(!(utils$1.isUndefined(B)||B===null)&&c.call(e,B,utils$1.isString(C)?C.trim():C,g,x))===!0&&m(B,g?g.concat(C):[C])}),p.pop()}}if(!utils$1.isObject(t))throw new TypeError("data must be an object");return m(t),e}function encode$1(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(a){return e[a]})}function AxiosURLSearchParams(t,e){this._pairs=[],t&&toFormData$1(t,this,e)}const prototype=AxiosURLSearchParams.prototype;prototype.append=function t(e,n){this._pairs.push([e,n])};prototype.toString=function t(e){const n=e?function(a){return e.call(this,a,encode$1)}:encode$1;return this._pairs.map(function(c){return n(c[0])+"="+n(c[1])},"").join("&")};function encode(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function buildURL(t,e,n){if(!e)return t;const a=n&&n.encode||encode;utils$1.isFunction(n)&&(n={serialize:n});const c=n&&n.serialize;let o;if(c?o=c(e,n):o=utils$1.isURLSearchParams(e)?e.toString():new AxiosURLSearchParams(e,n).toString(a),o){const u=t.indexOf("#");u!==-1&&(t=t.slice(0,u)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class InterceptorManager{constructor(){this.handlers=[]}use(e,n,a){return this.handlers.push({fulfilled:e,rejected:n,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){utils$1.forEach(this.handlers,function(a){a!==null&&e(a)})}}const transitionalDefaults={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},URLSearchParams$1=typeof URLSearchParams<"u"?URLSearchParams:AxiosURLSearchParams,FormData$1=typeof FormData<"u"?FormData:null,Blob$1=typeof Blob<"u"?Blob:null,platform$1={isBrowser:!0,classes:{URLSearchParams:URLSearchParams$1,FormData:FormData$1,Blob:Blob$1},protocols:["http","https","file","blob","url","data"]},hasBrowserEnv=typeof window<"u"&&typeof document<"u",_navigator=typeof navigator=="object"&&navigator||void 0,hasStandardBrowserEnv=hasBrowserEnv&&(!_navigator||["ReactNative","NativeScript","NS"].indexOf(_navigator.product)<0),hasStandardBrowserWebWorkerEnv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",origin=hasBrowserEnv&&window.location.href||"http://localhost",utils=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv,hasStandardBrowserEnv,hasStandardBrowserWebWorkerEnv,navigator:_navigator,origin},Symbol.toStringTag,{value:"Module"})),platform={...utils,...platform$1};function toURLEncodedForm(t,e){return toFormData$1(t,new platform.classes.URLSearchParams,Object.assign({visitor:function(n,a,c,o){return platform.isNode&&utils$1.isBuffer(n)?(this.append(a,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},e))}function parsePropPath(t){return utils$1.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function arrayToObject(t){const e={},n=Object.keys(t);let a;const c=n.length;let o;for(a=0;a<c;a++)o=n[a],e[o]=t[o];return e}function formDataToJSON(t){function e(n,a,c,o){let u=n[o++];if(u==="__proto__")return!0;const h=Number.isFinite(+u),l=o>=n.length;return u=!u&&utils$1.isArray(c)?c.length:u,l?(utils$1.hasOwnProp(c,u)?c[u]=[c[u],a]:c[u]=a,!h):((!c[u]||!utils$1.isObject(c[u]))&&(c[u]=[]),e(n,a,c[u],o)&&utils$1.isArray(c[u])&&(c[u]=arrayToObject(c[u])),!h)}if(utils$1.isFormData(t)&&utils$1.isFunction(t.entries)){const n={};return utils$1.forEachEntry(t,(a,c)=>{e(parsePropPath(a),c,n,0)}),n}return null}function stringifySafely(t,e,n){if(utils$1.isString(t))try{return(e||JSON.parse)(t),utils$1.trim(t)}catch(a){if(a.name!=="SyntaxError")throw a}return(0,JSON.stringify)(t)}const defaults={transitional:transitionalDefaults,adapter:["xhr","http","fetch"],transformRequest:[function t(e,n){const a=n.getContentType()||"",c=a.indexOf("application/json")>-1,o=utils$1.isObject(e);if(o&&utils$1.isHTMLForm(e)&&(e=new FormData(e)),utils$1.isFormData(e))return c?JSON.stringify(formDataToJSON(e)):e;if(utils$1.isArrayBuffer(e)||utils$1.isBuffer(e)||utils$1.isStream(e)||utils$1.isFile(e)||utils$1.isBlob(e)||utils$1.isReadableStream(e))return e;if(utils$1.isArrayBufferView(e))return e.buffer;if(utils$1.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let h;if(o){if(a.indexOf("application/x-www-form-urlencoded")>-1)return toURLEncodedForm(e,this.formSerializer).toString();if((h=utils$1.isFileList(e))||a.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return toFormData$1(h?{"files[]":e}:e,l&&new l,this.formSerializer)}}return o||c?(n.setContentType("application/json",!1),stringifySafely(e)):e}],transformResponse:[function t(e){const n=this.transitional||defaults.transitional,a=n&&n.forcedJSONParsing,c=this.responseType==="json";if(utils$1.isResponse(e)||utils$1.isReadableStream(e))return e;if(e&&utils$1.isString(e)&&(a&&!this.responseType||c)){const u=!(n&&n.silentJSONParsing)&&c;try{return JSON.parse(e)}catch(h){if(u)throw h.name==="SyntaxError"?AxiosError$1.from(h,AxiosError$1.ERR_BAD_RESPONSE,this,null,this.response):h}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:platform.classes.FormData,Blob:platform.classes.Blob},validateStatus:function t(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};utils$1.forEach(["delete","get","head","post","put","patch"],t=>{defaults.headers[t]={}});const ignoreDuplicateOf=utils$1.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),parseHeaders=t=>{const e={};let n,a,c;return t&&t.split(`
26
- `).forEach(function(u){c=u.indexOf(":"),n=u.substring(0,c).trim().toLowerCase(),a=u.substring(c+1).trim(),!(!n||e[n]&&ignoreDuplicateOf[n])&&(n==="set-cookie"?e[n]?e[n].push(a):e[n]=[a]:e[n]=e[n]?e[n]+", "+a:a)}),e},$internals=Symbol("internals");function normalizeHeader(t){return t&&String(t).trim().toLowerCase()}function normalizeValue(t){return t===!1||t==null?t:utils$1.isArray(t)?t.map(normalizeValue):String(t)}function parseTokens(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=n.exec(t);)e[a[1]]=a[2];return e}const isValidHeaderName=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function matchHeaderValue(t,e,n,a,c){if(utils$1.isFunction(a))return a.call(this,e,n);if(c&&(e=n),!!utils$1.isString(e)){if(utils$1.isString(a))return e.indexOf(a)!==-1;if(utils$1.isRegExp(a))return a.test(e)}}function formatHeader(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,a)=>n.toUpperCase()+a)}function buildAccessors(t,e){const n=utils$1.toCamelCase(" "+e);["get","set","has"].forEach(a=>{Object.defineProperty(t,a+n,{value:function(c,o,u){return this[a].call(this,e,c,o,u)},configurable:!0})})}let AxiosHeaders$1=class{constructor(e){e&&this.set(e)}set(e,n,a){const c=this;function o(h,l,b){const d=normalizeHeader(l);if(!d)throw new Error("header name must be a non-empty string");const p=utils$1.findKey(c,d);(!p||c[p]===void 0||b===!0||b===void 0&&c[p]!==!1)&&(c[p||l]=normalizeValue(h))}const u=(h,l)=>utils$1.forEach(h,(b,d)=>o(b,d,l));if(utils$1.isPlainObject(e)||e instanceof this.constructor)u(e,n);else if(utils$1.isString(e)&&(e=e.trim())&&!isValidHeaderName(e))u(parseHeaders(e),n);else if(utils$1.isHeaders(e))for(const[h,l]of e.entries())o(l,h,a);else e!=null&&o(n,e,a);return this}get(e,n){if(e=normalizeHeader(e),e){const a=utils$1.findKey(this,e);if(a){const c=this[a];if(!n)return c;if(n===!0)return parseTokens(c);if(utils$1.isFunction(n))return n.call(this,c,a);if(utils$1.isRegExp(n))return n.exec(c);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=normalizeHeader(e),e){const a=utils$1.findKey(this,e);return!!(a&&this[a]!==void 0&&(!n||matchHeaderValue(this,this[a],a,n)))}return!1}delete(e,n){const a=this;let c=!1;function o(u){if(u=normalizeHeader(u),u){const h=utils$1.findKey(a,u);h&&(!n||matchHeaderValue(a,a[h],h,n))&&(delete a[h],c=!0)}}return utils$1.isArray(e)?e.forEach(o):o(e),c}clear(e){const n=Object.keys(this);let a=n.length,c=!1;for(;a--;){const o=n[a];(!e||matchHeaderValue(this,this[o],o,e,!0))&&(delete this[o],c=!0)}return c}normalize(e){const n=this,a={};return utils$1.forEach(this,(c,o)=>{const u=utils$1.findKey(a,o);if(u){n[u]=normalizeValue(c),delete n[o];return}const h=e?formatHeader(o):String(o).trim();h!==o&&delete n[o],n[h]=normalizeValue(c),a[h]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return utils$1.forEach(this,(a,c)=>{a!=null&&a!==!1&&(n[c]=e&&utils$1.isArray(a)?a.join(", "):a)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
27
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const a=new this(e);return n.forEach(c=>a.set(c)),a}static accessor(e){const a=(this[$internals]=this[$internals]={accessors:{}}).accessors,c=this.prototype;function o(u){const h=normalizeHeader(u);a[h]||(buildAccessors(c,u),a[h]=!0)}return utils$1.isArray(e)?e.forEach(o):o(e),this}};AxiosHeaders$1.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);utils$1.reduceDescriptors(AxiosHeaders$1.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(a){this[n]=a}}});utils$1.freezeMethods(AxiosHeaders$1);function transformData(t,e){const n=this||defaults,a=e||n,c=AxiosHeaders$1.from(a.headers);let o=a.data;return utils$1.forEach(t,function(h){o=h.call(n,o,c.normalize(),e?e.status:void 0)}),c.normalize(),o}function isCancel$1(t){return!!(t&&t.__CANCEL__)}function CanceledError$1(t,e,n){AxiosError$1.call(this,t??"canceled",AxiosError$1.ERR_CANCELED,e,n),this.name="CanceledError"}utils$1.inherits(CanceledError$1,AxiosError$1,{__CANCEL__:!0});function settle(t,e,n){const a=n.config.validateStatus;!n.status||!a||a(n.status)?t(n):e(new AxiosError$1("Request failed with status code "+n.status,[AxiosError$1.ERR_BAD_REQUEST,AxiosError$1.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function parseProtocol(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function speedometer(t,e){t=t||10;const n=new Array(t),a=new Array(t);let c=0,o=0,u;return e=e!==void 0?e:1e3,function(l){const b=Date.now(),d=a[o];u||(u=b),n[c]=l,a[c]=b;let p=o,x=0;for(;p!==c;)x+=n[p++],p=p%t;if(c=(c+1)%t,c===o&&(o=(o+1)%t),b-u<e)return;const m=d&&b-d;return m?Math.round(x*1e3/m):void 0}}function throttle(t,e){let n=0,a=1e3/e,c,o;const u=(b,d=Date.now())=>{n=d,c=null,o&&(clearTimeout(o),o=null),t.apply(null,b)};return[(...b)=>{const d=Date.now(),p=d-n;p>=a?u(b,d):(c=b,o||(o=setTimeout(()=>{o=null,u(c)},a-p)))},()=>c&&u(c)]}const progressEventReducer=(t,e,n=3)=>{let a=0;const c=speedometer(50,250);return throttle(o=>{const u=o.loaded,h=o.lengthComputable?o.total:void 0,l=u-a,b=c(l),d=u<=h;a=u;const p={loaded:u,total:h,progress:h?u/h:void 0,bytes:l,rate:b||void 0,estimated:b&&h&&d?(h-u)/b:void 0,event:o,lengthComputable:h!=null,[e?"download":"upload"]:!0};t(p)},n)},progressEventDecorator=(t,e)=>{const n=t!=null;return[a=>e[0]({lengthComputable:n,total:t,loaded:a}),e[1]]},asyncDecorator=t=>(...e)=>utils$1.asap(()=>t(...e)),isURLSameOrigin=platform.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,platform.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(platform.origin),platform.navigator&&/(msie|trident)/i.test(platform.navigator.userAgent)):()=>!0,cookies=platform.hasStandardBrowserEnv?{write(t,e,n,a,c,o){const u=[t+"="+encodeURIComponent(e)];utils$1.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),utils$1.isString(a)&&u.push("path="+a),utils$1.isString(c)&&u.push("domain="+c),o===!0&&u.push("secure"),document.cookie=u.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function isAbsoluteURL(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function combineURLs(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function buildFullPath(t,e){return t&&!isAbsoluteURL(e)?combineURLs(t,e):e}const headersToObject=t=>t instanceof AxiosHeaders$1?{...t}:t;function mergeConfig$1(t,e){e=e||{};const n={};function a(b,d,p,x){return utils$1.isPlainObject(b)&&utils$1.isPlainObject(d)?utils$1.merge.call({caseless:x},b,d):utils$1.isPlainObject(d)?utils$1.merge({},d):utils$1.isArray(d)?d.slice():d}function c(b,d,p,x){if(utils$1.isUndefined(d)){if(!utils$1.isUndefined(b))return a(void 0,b,p,x)}else return a(b,d,p,x)}function o(b,d){if(!utils$1.isUndefined(d))return a(void 0,d)}function u(b,d){if(utils$1.isUndefined(d)){if(!utils$1.isUndefined(b))return a(void 0,b)}else return a(void 0,d)}function h(b,d,p){if(p in e)return a(b,d);if(p in t)return a(void 0,b)}const l={url:o,method:o,data:o,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:h,headers:(b,d,p)=>c(headersToObject(b),headersToObject(d),p,!0)};return utils$1.forEach(Object.keys(Object.assign({},t,e)),function(d){const p=l[d]||c,x=p(t[d],e[d],d);utils$1.isUndefined(x)&&p!==h||(n[d]=x)}),n}const resolveConfig=t=>{const e=mergeConfig$1({},t);let{data:n,withXSRFToken:a,xsrfHeaderName:c,xsrfCookieName:o,headers:u,auth:h}=e;e.headers=u=AxiosHeaders$1.from(u),e.url=buildURL(buildFullPath(e.baseURL,e.url),t.params,t.paramsSerializer),h&&u.set("Authorization","Basic "+btoa((h.username||"")+":"+(h.password?unescape(encodeURIComponent(h.password)):"")));let l;if(utils$1.isFormData(n)){if(platform.hasStandardBrowserEnv||platform.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((l=u.getContentType())!==!1){const[b,...d]=l?l.split(";").map(p=>p.trim()).filter(Boolean):[];u.setContentType([b||"multipart/form-data",...d].join("; "))}}if(platform.hasStandardBrowserEnv&&(a&&utils$1.isFunction(a)&&(a=a(e)),a||a!==!1&&isURLSameOrigin(e.url))){const b=c&&o&&cookies.read(o);b&&u.set(c,b)}return e},isXHRAdapterSupported=typeof XMLHttpRequest<"u",xhrAdapter=isXHRAdapterSupported&&function(t){return new Promise(function(n,a){const c=resolveConfig(t);let o=c.data;const u=AxiosHeaders$1.from(c.headers).normalize();let{responseType:h,onUploadProgress:l,onDownloadProgress:b}=c,d,p,x,m,v;function g(){m&&m(),v&&v(),c.cancelToken&&c.cancelToken.unsubscribe(d),c.signal&&c.signal.removeEventListener("abort",d)}let $=new XMLHttpRequest;$.open(c.method.toUpperCase(),c.url,!0),$.timeout=c.timeout;function B(){if(!$)return;const F=AxiosHeaders$1.from("getAllResponseHeaders"in $&&$.getAllResponseHeaders()),W={data:!h||h==="text"||h==="json"?$.responseText:$.response,status:$.status,statusText:$.statusText,headers:F,config:t,request:$};settle(function(ie){n(ie),g()},function(ie){a(ie),g()},W),$=null}"onloadend"in $?$.onloadend=B:$.onreadystatechange=function(){!$||$.readyState!==4||$.status===0&&!($.responseURL&&$.responseURL.indexOf("file:")===0)||setTimeout(B)},$.onabort=function(){$&&(a(new AxiosError$1("Request aborted",AxiosError$1.ECONNABORTED,t,$)),$=null)},$.onerror=function(){a(new AxiosError$1("Network Error",AxiosError$1.ERR_NETWORK,t,$)),$=null},$.ontimeout=function(){let H=c.timeout?"timeout of "+c.timeout+"ms exceeded":"timeout exceeded";const W=c.transitional||transitionalDefaults;c.timeoutErrorMessage&&(H=c.timeoutErrorMessage),a(new AxiosError$1(H,W.clarifyTimeoutError?AxiosError$1.ETIMEDOUT:AxiosError$1.ECONNABORTED,t,$)),$=null},o===void 0&&u.setContentType(null),"setRequestHeader"in $&&utils$1.forEach(u.toJSON(),function(H,W){$.setRequestHeader(W,H)}),utils$1.isUndefined(c.withCredentials)||($.withCredentials=!!c.withCredentials),h&&h!=="json"&&($.responseType=c.responseType),b&&([x,v]=progressEventReducer(b,!0),$.addEventListener("progress",x)),l&&$.upload&&([p,m]=progressEventReducer(l),$.upload.addEventListener("progress",p),$.upload.addEventListener("loadend",m)),(c.cancelToken||c.signal)&&(d=F=>{$&&(a(!F||F.type?new CanceledError$1(null,t,$):F),$.abort(),$=null)},c.cancelToken&&c.cancelToken.subscribe(d),c.signal&&(c.signal.aborted?d():c.signal.addEventListener("abort",d)));const C=parseProtocol(c.url);if(C&&platform.protocols.indexOf(C)===-1){a(new AxiosError$1("Unsupported protocol "+C+":",AxiosError$1.ERR_BAD_REQUEST,t));return}$.send(o||null)})},composeSignals=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let a=new AbortController,c;const o=function(b){if(!c){c=!0,h();const d=b instanceof Error?b:this.reason;a.abort(d instanceof AxiosError$1?d:new CanceledError$1(d instanceof Error?d.message:d))}};let u=e&&setTimeout(()=>{u=null,o(new AxiosError$1(`timeout ${e} of ms exceeded`,AxiosError$1.ETIMEDOUT))},e);const h=()=>{t&&(u&&clearTimeout(u),u=null,t.forEach(b=>{b.unsubscribe?b.unsubscribe(o):b.removeEventListener("abort",o)}),t=null)};t.forEach(b=>b.addEventListener("abort",o));const{signal:l}=a;return l.unsubscribe=()=>utils$1.asap(h),l}},streamChunk=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let a=0,c;for(;a<n;)c=a+e,yield t.slice(a,c),a=c},readBytes=async function*(t,e){for await(const n of readStream(t))yield*streamChunk(n,e)},readStream=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:a}=await e.read();if(n)break;yield a}}finally{await e.cancel()}},trackStream=(t,e,n,a)=>{const c=readBytes(t,e);let o=0,u,h=l=>{u||(u=!0,a&&a(l))};return new ReadableStream({async pull(l){try{const{done:b,value:d}=await c.next();if(b){h(),l.close();return}let p=d.byteLength;if(n){let x=o+=p;n(x)}l.enqueue(new Uint8Array(d))}catch(b){throw h(b),b}},cancel(l){return h(l),c.return()}},{highWaterMark:2})},isFetchSupported=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",isReadableStreamSupported=isFetchSupported&&typeof ReadableStream=="function",encodeText=isFetchSupported&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),test=(t,...e)=>{try{return!!t(...e)}catch{return!1}},supportsRequestStream=isReadableStreamSupported&&test(()=>{let t=!1;const e=new Request(platform.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),DEFAULT_CHUNK_SIZE=64*1024,supportsResponseStream=isReadableStreamSupported&&test(()=>utils$1.isReadableStream(new Response("").body)),resolvers={stream:supportsResponseStream&&(t=>t.body)};isFetchSupported&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!resolvers[e]&&(resolvers[e]=utils$1.isFunction(t[e])?n=>n[e]():(n,a)=>{throw new AxiosError$1(`Response type '${e}' is not supported`,AxiosError$1.ERR_NOT_SUPPORT,a)})})})(new Response);const getBodyLength=async t=>{if(t==null)return 0;if(utils$1.isBlob(t))return t.size;if(utils$1.isSpecCompliantForm(t))return(await new Request(platform.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(utils$1.isArrayBufferView(t)||utils$1.isArrayBuffer(t))return t.byteLength;if(utils$1.isURLSearchParams(t)&&(t=t+""),utils$1.isString(t))return(await encodeText(t)).byteLength},resolveBodyLength=async(t,e)=>{const n=utils$1.toFiniteNumber(t.getContentLength());return n??getBodyLength(e)},fetchAdapter=isFetchSupported&&(async t=>{let{url:e,method:n,data:a,signal:c,cancelToken:o,timeout:u,onDownloadProgress:h,onUploadProgress:l,responseType:b,headers:d,withCredentials:p="same-origin",fetchOptions:x}=resolveConfig(t);b=b?(b+"").toLowerCase():"text";let m=composeSignals([c,o&&o.toAbortSignal()],u),v;const g=m&&m.unsubscribe&&(()=>{m.unsubscribe()});let $;try{if(l&&supportsRequestStream&&n!=="get"&&n!=="head"&&($=await resolveBodyLength(d,a))!==0){let W=new Request(e,{method:"POST",body:a,duplex:"half"}),Z;if(utils$1.isFormData(a)&&(Z=W.headers.get("content-type"))&&d.setContentType(Z),W.body){const[ie,te]=progressEventDecorator($,progressEventReducer(asyncDecorator(l)));a=trackStream(W.body,DEFAULT_CHUNK_SIZE,ie,te)}}utils$1.isString(p)||(p=p?"include":"omit");const B="credentials"in Request.prototype;v=new Request(e,{...x,signal:m,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:a,duplex:"half",credentials:B?p:void 0});let C=await fetch(v);const F=supportsResponseStream&&(b==="stream"||b==="response");if(supportsResponseStream&&(h||F&&g)){const W={};["status","statusText","headers"].forEach(ae=>{W[ae]=C[ae]});const Z=utils$1.toFiniteNumber(C.headers.get("content-length")),[ie,te]=h&&progressEventDecorator(Z,progressEventReducer(asyncDecorator(h),!0))||[];C=new Response(trackStream(C.body,DEFAULT_CHUNK_SIZE,ie,()=>{te&&te(),g&&g()}),W)}b=b||"text";let H=await resolvers[utils$1.findKey(resolvers,b)||"text"](C,t);return!F&&g&&g(),await new Promise((W,Z)=>{settle(W,Z,{data:H,headers:AxiosHeaders$1.from(C.headers),status:C.status,statusText:C.statusText,config:t,request:v})})}catch(B){throw g&&g(),B&&B.name==="TypeError"&&/fetch/i.test(B.message)?Object.assign(new AxiosError$1("Network Error",AxiosError$1.ERR_NETWORK,t,v),{cause:B.cause||B}):AxiosError$1.from(B,B&&B.code,t,v)}}),knownAdapters={http:httpAdapter,xhr:xhrAdapter,fetch:fetchAdapter};utils$1.forEach(knownAdapters,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const renderReason=t=>`- ${t}`,isResolvedHandle=t=>utils$1.isFunction(t)||t===null||t===!1,adapters={getAdapter:t=>{t=utils$1.isArray(t)?t:[t];const{length:e}=t;let n,a;const c={};for(let o=0;o<e;o++){n=t[o];let u;if(a=n,!isResolvedHandle(n)&&(a=knownAdapters[(u=String(n)).toLowerCase()],a===void 0))throw new AxiosError$1(`Unknown adapter '${u}'`);if(a)break;c[u||"#"+o]=a}if(!a){const o=Object.entries(c).map(([h,l])=>`adapter ${h} `+(l===!1?"is not supported by the environment":"is not available in the build"));let u=e?o.length>1?`since :
28
- `+o.map(renderReason).join(`
29
- `):" "+renderReason(o[0]):"as no adapter specified";throw new AxiosError$1("There is no suitable adapter to dispatch the request "+u,"ERR_NOT_SUPPORT")}return a},adapters:knownAdapters};function throwIfCancellationRequested(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new CanceledError$1(null,t)}function dispatchRequest(t){return throwIfCancellationRequested(t),t.headers=AxiosHeaders$1.from(t.headers),t.data=transformData.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),adapters.getAdapter(t.adapter||defaults.adapter)(t).then(function(a){return throwIfCancellationRequested(t),a.data=transformData.call(t,t.transformResponse,a),a.headers=AxiosHeaders$1.from(a.headers),a},function(a){return isCancel$1(a)||(throwIfCancellationRequested(t),a&&a.response&&(a.response.data=transformData.call(t,t.transformResponse,a.response),a.response.headers=AxiosHeaders$1.from(a.response.headers))),Promise.reject(a)})}const VERSION$1="1.7.9",validators$1={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{validators$1[t]=function(a){return typeof a===t||"a"+(e<1?"n ":" ")+t}});const deprecatedWarnings={};validators$1.transitional=function t(e,n,a){function c(o,u){return"[Axios v"+VERSION$1+"] Transitional option '"+o+"'"+u+(a?". "+a:"")}return(o,u,h)=>{if(e===!1)throw new AxiosError$1(c(u," has been removed"+(n?" in "+n:"")),AxiosError$1.ERR_DEPRECATED);return n&&!deprecatedWarnings[u]&&(deprecatedWarnings[u]=!0,console.warn(c(u," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,u,h):!0}};validators$1.spelling=function t(e){return(n,a)=>(console.warn(`${a} is likely a misspelling of ${e}`),!0)};function assertOptions(t,e,n){if(typeof t!="object")throw new AxiosError$1("options must be an object",AxiosError$1.ERR_BAD_OPTION_VALUE);const a=Object.keys(t);let c=a.length;for(;c-- >0;){const o=a[c],u=e[o];if(u){const h=t[o],l=h===void 0||u(h,o,t);if(l!==!0)throw new AxiosError$1("option "+o+" must be "+l,AxiosError$1.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new AxiosError$1("Unknown option "+o,AxiosError$1.ERR_BAD_OPTION)}}const validator={assertOptions,validators:validators$1},validators=validator.validators;let Axios$1=class{constructor(e){this.defaults=e,this.interceptors={request:new InterceptorManager,response:new InterceptorManager}}async request(e,n){try{return await this._request(e,n)}catch(a){if(a instanceof Error){let c={};Error.captureStackTrace?Error.captureStackTrace(c):c=new Error;const o=c.stack?c.stack.replace(/^.+\n/,""):"";try{a.stack?o&&!String(a.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(a.stack+=`
30
- `+o):a.stack=o}catch{}}throw a}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=mergeConfig$1(this.defaults,n);const{transitional:a,paramsSerializer:c,headers:o}=n;a!==void 0&&validator.assertOptions(a,{silentJSONParsing:validators.transitional(validators.boolean),forcedJSONParsing:validators.transitional(validators.boolean),clarifyTimeoutError:validators.transitional(validators.boolean)},!1),c!=null&&(utils$1.isFunction(c)?n.paramsSerializer={serialize:c}:validator.assertOptions(c,{encode:validators.function,serialize:validators.function},!0)),validator.assertOptions(n,{baseUrl:validators.spelling("baseURL"),withXsrfToken:validators.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=o&&utils$1.merge(o.common,o[n.method]);o&&utils$1.forEach(["delete","get","head","post","put","patch","common"],v=>{delete o[v]}),n.headers=AxiosHeaders$1.concat(u,o);const h=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,h.unshift(g.fulfilled,g.rejected))});const b=[];this.interceptors.response.forEach(function(g){b.push(g.fulfilled,g.rejected)});let d,p=0,x;if(!l){const v=[dispatchRequest.bind(this),void 0];for(v.unshift.apply(v,h),v.push.apply(v,b),x=v.length,d=Promise.resolve(n);p<x;)d=d.then(v[p++],v[p++]);return d}x=h.length;let m=n;for(p=0;p<x;){const v=h[p++],g=h[p++];try{m=v(m)}catch($){g.call(this,$);break}}try{d=dispatchRequest.call(this,m)}catch(v){return Promise.reject(v)}for(p=0,x=b.length;p<x;)d=d.then(b[p++],b[p++]);return d}getUri(e){e=mergeConfig$1(this.defaults,e);const n=buildFullPath(e.baseURL,e.url);return buildURL(n,e.params,e.paramsSerializer)}};utils$1.forEach(["delete","get","head","options"],function t(e){Axios$1.prototype[e]=function(n,a){return this.request(mergeConfig$1(a||{},{method:e,url:n,data:(a||{}).data}))}});utils$1.forEach(["post","put","patch"],function t(e){function n(a){return function(o,u,h){return this.request(mergeConfig$1(h||{},{method:e,headers:a?{"Content-Type":"multipart/form-data"}:{},url:o,data:u}))}}Axios$1.prototype[e]=n(),Axios$1.prototype[e+"Form"]=n(!0)});let CancelToken$1=class Sr{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const a=this;this.promise.then(c=>{if(!a._listeners)return;let o=a._listeners.length;for(;o-- >0;)a._listeners[o](c);a._listeners=null}),this.promise.then=c=>{let o;const u=new Promise(h=>{a.subscribe(h),o=h}).then(c);return u.cancel=function(){a.unsubscribe(o)},u},e(function(o,u,h){a.reason||(a.reason=new CanceledError$1(o,u,h),n(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=a=>{e.abort(a)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new Sr(function(c){e=c}),cancel:e}}};function spread$1(t){return function(n){return t.apply(null,n)}}function isAxiosError$1(t){return utils$1.isObject(t)&&t.isAxiosError===!0}const HttpStatusCode$1={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(HttpStatusCode$1).forEach(([t,e])=>{HttpStatusCode$1[e]=t});function createInstance(t){const e=new Axios$1(t),n=bind(Axios$1.prototype.request,e);return utils$1.extend(n,Axios$1.prototype,e,{allOwnKeys:!0}),utils$1.extend(n,e,null,{allOwnKeys:!0}),n.create=function(c){return createInstance(mergeConfig$1(t,c))},n}const axios=createInstance(defaults);axios.Axios=Axios$1;axios.CanceledError=CanceledError$1;axios.CancelToken=CancelToken$1;axios.isCancel=isCancel$1;axios.VERSION=VERSION$1;axios.toFormData=toFormData$1;axios.AxiosError=AxiosError$1;axios.Cancel=axios.CanceledError;axios.all=function t(e){return Promise.all(e)};axios.spread=spread$1;axios.isAxiosError=isAxiosError$1;axios.mergeConfig=mergeConfig$1;axios.AxiosHeaders=AxiosHeaders$1;axios.formToJSON=t=>formDataToJSON(utils$1.isHTMLForm(t)?new FormData(t):t);axios.getAdapter=adapters.getAdapter;axios.HttpStatusCode=HttpStatusCode$1;axios.default=axios;const{Axios,AxiosError,CanceledError,isCancel,CancelToken,VERSION,all,Cancel,isAxiosError,spread,toFormData,AxiosHeaders,HttpStatusCode,formToJSON,getAdapter,mergeConfig}=axios;async function uploadSingleOwnerChunkData(t,e,n,a,c,o){const u=distExports.makeChunk(c),h=await makeSingleOwnerChunk(u,a,n),l=bytesToHex(h.owner()),b=bytesToHex(a),d=bytesToHex(h.signature()),p=serializeBytes(h.span(),h.payload);return await uploadSoc(t,l,b,d,p,e),h}function gsocSubscribe(t,e,n){if(assertSubscriptionHandler(n),typeof e!="string"||e.length!==64)throw new TypeError("soc address has to be an string and 32 bytes!");const a=webSocket(t,`gsoc/subscribe/${e}`);let c=!1;const o=()=>{c===!1&&(c=!0,a.terminate?a.terminate():a.close())};return a.onmessage=async u=>{const h=await prepareWebsocketData(u.data);h.length>0&&n.onMessage(wrapBytesWithHelpers(h))},a.onerror=u=>{c||n.onError(new BeeError(u.message))},o}async function uploadSoc(t,e,n,a,c,o,u){return(await http({...t,method:"post",url:`soc/${e}/${n}`,data:c,headers:{"content-type":"application/octet-stream",...extractUploadHeaders(o)},responseType:"json",params:{sig:a}})).data.reference}function assertSubscriptionHandler(t){if(!isStrictlyObject(t))throw new TypeError("SubscriptionHandler has to be object!");const e=t;if(typeof e.onMessage!="function")throw new TypeError("onMessage property of SubscriptionHandler has to be function!");if(typeof e.onError!="function")throw new TypeError("onError property of SubscriptionHandler has to be function!")}async function prepareWebsocketData(t){if(typeof t=="string")return new TextEncoder().encode(t);if(t instanceof Buffer)return new Uint8Array(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(t instanceof Blob)return new Uint8Array(await t.arrayBuffer());throw new TypeError("unknown websocket data type")}function webSocket(t,e){const n=t.replace(/^http/i,"ws");return new WebSocket$1(`${n}/${e}`)}function extractUploadHeaders(t,e){const n={};if(isPostageBatchId(t))n["swarm-postage-batch-id"]=t;else if(isPostageStamp(t))n["swarm-postage-stamp"]=t;else throw Error("Postage is invalid. Define either a postage batch id or a postage stamp (coming from envelope)");return n}async function http(t){var e;try{return t.headers||(t.headers={}),t.headers={...DEFAULT_HTTP_CONFIG.headers,...t.headers},await axios(t)}catch(n){throw n instanceof AxiosError?new BeeResponseError(n.message,n.code,n.status,(e=n.response)==null?void 0:e.status,n.config,n.response):n}}const DEFAULT_HTTP_CONFIG={headers:{accept:"application/json, text/plain, */*"},maxBodyLength:1/0,maxContentLength:1/0};class BeeError extends Error{constructor(e){super(e)}}class BeeResponseError extends BeeError{constructor(n,a,c,o,u,h){super(n);Fe(this,"code");Fe(this,"axiosStatus");Fe(this,"status");Fe(this,"config");Fe(this,"response");this.code=a,this.axiosStatus=c,this.status=o,this.config=u,this.response=h}}const DEFAULT_RESOURCE_ID="any",DEFAULT_POSTAGE_BATCH_ID="0000000000000000000000000000000000000000000000000000000000000000",DEFAULT_CONSENSUS_ID="SimpleGraffiti:v1";class InformationSignal{constructor(e,n){Fe(this,"postage");Fe(this,"beeApiUrl");Fe(this,"consensusHash");Fe(this,"assertGraffitiRecord");var a,c;if(assertBeeUrl(e),this.beeApiUrl=e,this.postage=(n==null?void 0:n.postage)??DEFAULT_POSTAGE_BATCH_ID,this.assertGraffitiRecord=((a=n==null?void 0:n.consensus)==null?void 0:a.assertRecord)??assertInformationSignalRecord,this.consensusHash=keccak256Hash(((c=n==null?void 0:n.consensus)==null?void 0:c.id)??DEFAULT_CONSENSUS_ID),!isHexString(this.postage))throw new Error("Postage batch id or postage stamp has to be a hex string!")}subscribe(e,n=DEFAULT_RESOURCE_ID){const a=getConsensualPrivateKey(n),c=makeSigner(a),o=makeSOCAddress(this.consensusHash,c.address),u={onMessage:l=>{try{const b=l.json();this.assertGraffitiRecord(b),e.onMessage(b)}catch(b){e.onError(b)}},onError:e.onError};return{close:gsocSubscribe(this.beeApiUrl,bytesToHex(o),u),gsocAddress:o}}listen(e,n=DEFAULT_RESOURCE_ID){return this.subscribe(e,n)}async write(e,n=DEFAULT_RESOURCE_ID,a){this.assertGraffitiRecord(e);const c=getConsensualPrivateKey(n),o=makeSigner(c);return uploadSingleOwnerChunkData({baseURL:this.beeApiUrl,...a},this.postage,o,this.consensusHash,serializePayload(e))}async send(e,n=DEFAULT_RESOURCE_ID){return this.write(e,n)}mineResourceId(e,n){if(isHexString(e)&&(e=hexToBytes(e)),typeof n!="number")throw new Error("storageDepth argument must be a number");if(n>32)throw new Error("Storage depth cannot be greater than 32!");if(e.length!==32)throw new Error("Bee address has to be 32 bytes!");const a=new Uint8Array(32);let c,o;do{for(let u=0;u<a.length;u++)if(a[u]===255)a[u]=0;else{a[u]++;break}c=makeSigner(a),o=makeSOCAddress(this.consensusHash,c.address)}while(!inProximity(e,o,n));return{resourceId:a,gsocAddress:o}}mine(e,n){return this.mineResourceId(e,n)}}function assertBeeUrl(t){if(!isValidBeeUrl(t))throw new Error("URL is not valid!")}function isValidBeeUrl(t){try{if(typeof t!="string")return!1;const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch(e){if(e instanceof TypeError||e.code!==null&&e.code==="ERR_INVALID_URL")return!1;throw e}}function isInformationSignalRecord(t){return t!==null&&typeof t=="string"}function assertInformationSignalRecord(t){if(!isInformationSignalRecord(t))throw new Error("Value is not a valid Graffiti Feed Record")}class SwarmChatUtils{constructor(e){this.UPLOAD_GSOC_TIMEOUT=2e3,this.handleError=e}generateUsersFeedId(e){return`${e}_EthercastChat_Users`}generateUserOwnedFeedId(e,n){return`${e}_EthercastChat_${n}`}initBees(e){var u;if(!e.singleBee&&!e.multiBees)throw new Error("No bees provided");const n={},a=h=>({bee:new beeJs.Bee(h.url),stamp:h.stamp,main:h.main}),c=h=>{if(!h)throw new Error("No bee configurations provided");return h.map(l=>({bee:new beeJs.Bee(l.url),stamp:l.stamp,main:l.main}))};if(e.singleBee){if(!e.singleBee.stamp)throw new Error("No postage stamp provided for the single bee");return{single:a(e.singleBee)}}const o=["gsoc","reader","writer"];for(const h of o){const l=(u=e.multiBees)==null?void 0:u[h];l&&(l.singleBee?n[h]=a(l.singleBee):l.multiBees&&(n[h]=c(l.multiBees)))}return n}selectBee(e,n,a){const c=e[n];if(!c)throw new Error(`No ${n} bees available`);if(Array.isArray(c)){if(a){const u=c.find(h=>h.main);if(u)return u}const o=c.filter(u=>!u.main);if(o.length>0){const u=Math.floor(Math.random()*o.length);return o[u]}throw new Error(`No non-main ${n} bees available`)}if(c.bee)return c;throw new Error(`No ${n} bees available`)}validateUserObject(e){try{if(typeof e.username!="string")throw"username should be a string";if(typeof e.address!="string")throw"address should be a string";if(typeof e.timestamp!="number")throw"timestamp should be number";if(typeof e.signature!="string")throw"signature should be a string";const n=["username","address","timestamp","signature","index"],a=Object.keys(e).filter(u=>!n.includes(u));if(a.length>0)throw`Unexpected properties found: ${a.join(", ")}`;const c={username:e.username,address:e.address,timestamp:e.timestamp};if(verifyMessage(JSON.stringify(c),e.signature)!==e.address)throw"Signature verification failed!";return!0}catch(n){return this.handleError({error:n,context:"This User object is not correct",throw:!1}),!1}}orderMessages(e){return e.sort((n,a)=>n.timestamp-a.timestamp)}async retryAwaitableAsync(e,n=3,a=250){return new Promise((c,o)=>{e().then(c).catch(u=>{n>0?(console.info(`Retrying... Attempts left: ${n}. Error: ${u.message}`),setTimeout(()=>{this.retryAwaitableAsync(e,n-1,a).then(c).catch(o)},a)):(this.handleError({error:u,context:`Failed after ${n} initial attempts. Last error: ${u.message}`,throw:!1}),o(u))})})}async uploadObjectToBee(e,n,a){try{return await e.uploadData(a,this.serializeGraffitiRecord(n),{redundancyLevel:4})}catch(c){return this.handleError({error:c,context:"uploadObjectToBee",throw:!1}),null}}graffitiFeedWriterFromTopic(e,n,a){const{consensusHash:c,graffitiSigner:o}=this.generateGraffitiFeedMetadata(n);return e.makeFeedWriter("sequence",c,o,a)}graffitiFeedReaderFromTopic(e,n,a){const{consensusHash:c,graffitiSigner:o}=this.generateGraffitiFeedMetadata(n);return e.makeFeedReader("sequence",c,o.address,a)}async getLatestFeedIndex(e,n,a){try{const o=await e.makeFeedReader("sequence",n,a).download(),u=parseInt(o.feedIndex.toString(),HEX_RADIX),h=parseInt(o.feedIndexNext,HEX_RADIX);return{latestIndex:u,nextIndex:h}}catch(c){if(this.isNotFoundError(c))return{latestIndex:-1,nextIndex:0};throw c}}subscribeToGsoc(e,n,a,c){try{if(!a)throw"ResourceID was not provided!";return new InformationSignal(e,{consensus:{id:`SwarmDecentralizedChat::${n}`,assertRecord:h=>{const l=JSON.parse(h);return this.validateUserObject(l)}}}).subscribe({onMessage:c,onError:console.log},a)}catch(o){return this.handleError({error:o,context:"subscribeToGSOC",throw:!0}),null}}async sendMessageToGsoc(e,n,a,c,o){try{if(!c)throw"ResourceID was not provided!";return await new InformationSignal(e,{consensus:{id:`SwarmDecentralizedChat::${a}`,assertRecord:l=>!0},postage:n}).write(o,c,{timeout:this.UPLOAD_GSOC_TIMEOUT})}catch(u){this.handleError({error:u,context:"sendMessageToGSOC",throw:!1})}}getConsensualPrivateKey(e){return beeJs.Utils.isHexString(e)&&e.length===64?beeJs.Utils.hexToBytes(e):beeJs.Utils.keccak256Hash(e)}getGraffitiWallet(e){const n=hexlify(e);return new Wallet(n)}serializeGraffitiRecord(e){return new TextEncoder().encode(JSON.stringify(e))}generateGraffitiFeedMetadata(e){const n=this.generateUsersFeedId(e),a=this.getConsensualPrivateKey(n),c=this.getGraffitiWallet(a),o={address:beeJs.Utils.hexToBytes(c.address.slice(2)),sign:async h=>await c.signMessage(h)};return{consensusHash:beeJs.Utils.keccak256Hash(CONSENSUS_ID),graffitiSigner:o}}isNotFoundError(e){return e.stack.includes("404")||e.message.includes("Not Found")||e.message.includes("404")}}class SwarmChat{constructor(e){this.emitter=new EventEmitter,this.utils=new SwarmChatUtils(this.handleError.bind(this)),this.messagesQueue=new Queue({clearWaitTime:200},this.handleError.bind(this)),this.gsocListenerQueue=new Queue({clearWaitTime:200},this.handleError.bind(this)),this.fetchMessageTimer=null,this.keepUserAliveTimer=null,this.idleUserCleanupInterval=null,this.KEEP_ALIVE_INTERVAL_TIME=2500,this.FETCH_MESSAGE_INTERVAL_TIME=1e3,this.IDLE_USER_CLEANUP_INTERVAL_TIME=5e3,this.READ_MESSAGE_TIMEOUT=1500,this.users={},this.userIndexCache={},this.userPunishmentCache={},this.tempUser=null,this.gsocResourceId=null,this.gsocSubscribtion=null,this.ownIndex=null,this.ownAddress=e.ownAddress,this.privateKey=e.privateKey,this.topic=e.topic,this.nickname=e.nickname,this.gsocResourceId=e.gsocResourceId,this.bees=this.utils.initBees(e.bees),this.KEEP_ALIVE_INTERVAL_TIME=e.keepAliveIntervalTime||this.KEEP_ALIVE_INTERVAL_TIME,this.FETCH_MESSAGE_INTERVAL_TIME=e.fetchMessageIntervalTime||this.FETCH_MESSAGE_INTERVAL_TIME,this.IDLE_USER_CLEANUP_INTERVAL_TIME=e.idleUserCleanupIntervalTime||this.IDLE_USER_CLEANUP_INTERVAL_TIME,this.READ_MESSAGE_TIMEOUT=e.readMessageTimeout||this.READ_MESSAGE_TIMEOUT}start(){this.initSelfIndex(),this.listenToNewSubscribers(),this.startKeepMeAliveProcess(),this.startMessagesFetchProcess(),this.startIdleUserCleanup()}stop(){this.stopListenToNewSubscribers(),this.stopKeepMeAliveProcess(),this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.emitter.cleanAll()}isUserRegistered(e){return!!this.users[e]}getEmitter(){return this.emitter}async initSelfIndex(){try{const e=this.utils.generateUserOwnedFeedId(this.topic,this.ownAddress),n=this.getReaderBee(),a=n.makeFeedTopic(e),{latestIndex:c}=await this.utils.retryAwaitableAsync(()=>this.utils.getLatestFeedIndex(n,a,this.ownAddress));this.ownIndex=c}catch(e){this.handleError({error:e,context:"initSelfIndex",throw:!1})}}listenToNewSubscribers(){try{if(!this.gsocResourceId)throw new Error("GSOC Resource ID is not defined");this.emitter.emit(EVENTS.LOADING_INIT_USERS,!0);const e=this.getMainGsocBee();this.gsocSubscribtion=this.utils.subscribeToGsoc(e.url,this.topic,this.gsocResourceId,n=>this.gsocListenerQueue.enqueue(()=>this.userRegistrationOnGsoc(n)))}catch(e){this.handleError({error:e,context:"Could not listen to new subscribers",throw:!0})}}async sendMessage(e){const n={id:v4(),username:this.nickname,address:this.ownAddress,timestamp:Date.now(),message:e};try{if(this.ownIndex===null)throw new Error("Cannot send message with null index");this.emitter.emit(EVENTS.MESSAGE_REQUEST_SENT,n);const{bee:a,stamp:c}=this.getWriterBee(),o=await this.utils.retryAwaitableAsync(()=>this.utils.uploadObjectToBee(a,n,c));if(!o)throw"Could not upload message data to bee";const u=this.utils.generateUserOwnedFeedId(this.topic,this.ownAddress),h=a.makeFeedTopic(u),l=a.makeFeedWriter("sequence",h,this.privateKey),b=this.ownIndex===-1?0:this.ownIndex+1;for(await l.upload(c,o.reference,{index:b}),this.ownIndex=b;!this.isUserIndexRead(this.ownAddress,this.ownIndex);)await sleep(200)}catch(a){this.emitter.emit(EVENTS.MESSAGE_REQUEST_ERROR,n),this.handleError({error:a,context:"sendMessage",throw:!1})}}async keepUserAlive(){try{if(!this.gsocResourceId)throw new Error("GSOC Resource ID is not defined");const e=this.getOwnIndex();if(e===null)return;const n=new Wallet(this.privateKey),a=n.address;if(a.toLowerCase()!==this.ownAddress.toLowerCase())throw new Error("The provided address does not match the address derived from the private key");if(this.checkUserPunishment(a))return;const c=Date.now(),o=await n.signMessage(JSON.stringify({username:this.nickname,address:a,timestamp:c})),u={address:a,timestamp:c,signature:o,index:e,username:this.nickname};if(!this.utils.validateUserObject(u))throw new Error("User object validation failed");const{bee:h,stamp:l}=this.getGsocBee(),b=await this.utils.sendMessageToGsoc(h.url,l,this.topic,this.gsocResourceId,JSON.stringify(u));if(!(b!=null&&b.payload.length))throw"Error writing User object to GSOC!"}catch(e){this.handleError({error:e,context:"registerUser",throw:!1})}}orderMessages(e){return this.utils.orderMessages(e)}isUserIndexRead(e,n){return this.userIndexCache[e]===n}setUserIndexCache(e){this.userIndexCache[e.address]=e.index}getOwnIndex(){return this.ownIndex}removeIdleUsers(){const e=Date.now();for(const n of Object.values(this.users))e-n.timestamp>30*SECOND&&delete this.users[n.address]}setUser(e){this.users[e.address]=e}checkUserPunishment(e){return this.userPunishmentCache[e]>0?(this.userPunishmentCache[e]--,!0):!1}userRegistrationOnGsoc(e){var n;try{let a;try{a=JSON.parse(e)}catch{console.error("Invalid GSOC message format:",e);return}if(((n=this.tempUser)==null?void 0:n.address)===a.address&&this.userPunishmentCache[a.address]===0&&Object.keys(this.users).length>1){this.userPunishmentCache[a.address]=Object.keys(this.users).length;return}this.setUser(a),this.tempUser=a}catch(a){this.handleError({error:a,context:"userRegisteredThroughGsoc",throw:!1})}}async readMessagesForAll(){if(!await this.messagesQueue.waitForProcessing())for(const n of Object.values(this.users))this.messagesQueue.enqueue(()=>this.readMessage(n,this.topic))}async readMessage(e,n){try{if(e.index===-1||this.isUserIndexRead(e.address,e.index))return;const c=this.getReaderBee(),o=this.utils.generateUserOwnedFeedId(n,e.address),u=c.makeFeedTopic(o),l=await c.makeFeedReader("sequence",u,e.address,{timeout:this.READ_MESSAGE_TIMEOUT}).download({index:e.index}),b=await c.downloadData(l.reference,{headers:{"Swarm-Redundancy-Level":"0"}}),d=JSON.parse(new TextDecoder().decode(b));this.emitter.emit(EVENTS.MESSAGE_RECEIVED,d),this.setUserIndexCache(e)}catch(a){a instanceof Error&&this.handleError({error:a,context:"readMessage",throw:!1})}finally{this.ownAddress===e.address&&this.emitter.emit(EVENTS.LOADING_INIT_USERS,!1)}}stopListenToNewSubscribers(){this.gsocSubscribtion&&(this.gsocSubscribtion.close(),this.gsocSubscribtion=null)}startKeepMeAliveProcess(){if(this.keepUserAliveTimer){console.warn("Keep me alive process is already running.");return}this.keepUserAliveTimer=setInterval(this.keepUserAlive.bind(this),this.KEEP_ALIVE_INTERVAL_TIME)}stopKeepMeAliveProcess(){this.keepUserAliveTimer&&(clearInterval(this.keepUserAliveTimer),this.keepUserAliveTimer=null)}startMessagesFetchProcess(){if(this.fetchMessageTimer){console.warn("Messages fetch process is already running.");return}this.fetchMessageTimer=setInterval(this.readMessagesForAll.bind(this),this.FETCH_MESSAGE_INTERVAL_TIME)}stopMessagesFetchProcess(){this.fetchMessageTimer&&(clearInterval(this.fetchMessageTimer),this.fetchMessageTimer=null)}startIdleUserCleanup(){if(this.idleUserCleanupInterval){console.warn("Idle user cleanup is already running.");return}this.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),this.IDLE_USER_CLEANUP_INTERVAL_TIME)}stopIdleUserCleanup(){this.idleUserCleanupInterval&&(clearInterval(this.idleUserCleanupInterval),this.idleUserCleanupInterval=null)}getMainGsocBee(){const{bee:e}=this.utils.selectBee(this.bees,BeeType.GSOC,!0);if(!e)throw new Error("Could not get main GSOC bee");return e}getGsocBee(){const{bee:e,stamp:n}=this.utils.selectBee(this.bees,BeeType.GSOC);if(!e)throw new Error("Could not get GSOC bee");if(!n)throw new Error("Could not get valid gsoc stamp");return{bee:e,stamp:n}}getReaderBee(){const{bee:e}=this.utils.selectBee(this.bees,BeeType.READER);if(!e)throw new Error("Could not get reader bee");return e}getWriterBee(){const{bee:e,stamp:n}=this.utils.selectBee(this.bees,BeeType.WRITER);if(!e)throw new Error("Could not get writer bee");if(!n)throw new Error("Could not get valid writer stamp");return{bee:e,stamp:n}}handleError(e){if(console.error(`Error in ${e.context}: ${e.error.message}`),this.emitter.emit(EVENTS.ERROR,e),e.throw)throw new Error(`Error in ${e.context}`)}}exports.EVENTS=EVENTS;exports.SwarmChat=SwarmChat;
18
+ */(function(r){const e=Cp,t=bb,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=h,r.SlowBuffer=V,r.INSPECT_MAX_BYTES=50;const i=2147483647;r.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:a}=globalThis;h.TYPED_ARRAY_SUPPORT=u(),!h.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 u(){try{const N=new s(1),_={foo:function(){return 42}};return Object.setPrototypeOf(_,s.prototype),Object.setPrototypeOf(N,_),N.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function l(N){if(N>i)throw new RangeError('The value "'+N+'" is invalid for option "size"');const _=new s(N);return Object.setPrototypeOf(_,h.prototype),_}function h(N,_,v){if(typeof N=="number"){if(typeof _=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(N)}return g(N,_,v)}h.poolSize=8192;function g(N,_,v){if(typeof N=="string")return S(N,_);if(o.isView(N))return C(N);if(N==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof N);if(Yt(N,o)||N&&Yt(N.buffer,o)||typeof a<"u"&&(Yt(N,a)||N&&Yt(N.buffer,a)))return H(N,_,v);if(typeof N=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const $=N.valueOf&&N.valueOf();if($!=null&&$!==N)return h.from($,_,v);const j=D(N);if(j)return j;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof N[Symbol.toPrimitive]=="function")return h.from(N[Symbol.toPrimitive]("string"),_,v);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof N)}h.from=function(N,_,v){return g(N,_,v)},Object.setPrototypeOf(h.prototype,s.prototype),Object.setPrototypeOf(h,s);function b(N){if(typeof N!="number")throw new TypeError('"size" argument must be of type number');if(N<0)throw new RangeError('The value "'+N+'" is invalid for option "size"')}function w(N,_,v){return b(N),N<=0?l(N):_!==void 0?typeof v=="string"?l(N).fill(_,v):l(N).fill(_):l(N)}h.alloc=function(N,_,v){return w(N,_,v)};function I(N){return b(N),l(N<0?0:z(N)|0)}h.allocUnsafe=function(N){return I(N)},h.allocUnsafeSlow=function(N){return I(N)};function S(N,_){if((typeof _!="string"||_==="")&&(_="utf8"),!h.isEncoding(_))throw new TypeError("Unknown encoding: "+_);const v=Z(N,_)|0;let $=l(v);const j=$.write(N,_);return j!==v&&($=$.slice(0,j)),$}function x(N){const _=N.length<0?0:z(N.length)|0,v=l(_);for(let $=0;$<_;$+=1)v[$]=N[$]&255;return v}function C(N){if(Yt(N,s)){const _=new s(N);return H(_.buffer,_.byteOffset,_.byteLength)}return x(N)}function H(N,_,v){if(_<0||N.byteLength<_)throw new RangeError('"offset" is outside of buffer bounds');if(N.byteLength<_+(v||0))throw new RangeError('"length" is outside of buffer bounds');let $;return _===void 0&&v===void 0?$=new s(N):v===void 0?$=new s(N,_):$=new s(N,_,v),Object.setPrototypeOf($,h.prototype),$}function D(N){if(h.isBuffer(N)){const _=z(N.length)|0,v=l(_);return v.length===0||N.copy(v,0,0,_),v}if(N.length!==void 0)return typeof N.length!="number"||bt(N.length)?l(0):x(N);if(N.type==="Buffer"&&Array.isArray(N.data))return x(N.data)}function z(N){if(N>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return N|0}function V(N){return+N!=N&&(N=0),h.alloc(+N)}h.isBuffer=function(_){return _!=null&&_._isBuffer===!0&&_!==h.prototype},h.compare=function(_,v){if(Yt(_,s)&&(_=h.from(_,_.offset,_.byteLength)),Yt(v,s)&&(v=h.from(v,v.offset,v.byteLength)),!h.isBuffer(_)||!h.isBuffer(v))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(_===v)return 0;let $=_.length,j=v.length;for(let J=0,ae=Math.min($,j);J<ae;++J)if(_[J]!==v[J]){$=_[J],j=v[J];break}return $<j?-1:j<$?1:0},h.isEncoding=function(_){switch(String(_).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}},h.concat=function(_,v){if(!Array.isArray(_))throw new TypeError('"list" argument must be an Array of Buffers');if(_.length===0)return h.alloc(0);let $;if(v===void 0)for(v=0,$=0;$<_.length;++$)v+=_[$].length;const j=h.allocUnsafe(v);let J=0;for($=0;$<_.length;++$){let ae=_[$];if(Yt(ae,s))J+ae.length>j.length?(h.isBuffer(ae)||(ae=h.from(ae)),ae.copy(j,J)):s.prototype.set.call(j,ae,J);else if(h.isBuffer(ae))ae.copy(j,J);else throw new TypeError('"list" argument must be an Array of Buffers');J+=ae.length}return j};function Z(N,_){if(h.isBuffer(N))return N.length;if(o.isView(N)||Yt(N,o))return N.byteLength;if(typeof N!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof N);const v=N.length,$=arguments.length>2&&arguments[2]===!0;if(!$&&v===0)return 0;let j=!1;for(;;)switch(_){case"ascii":case"latin1":case"binary":return v;case"utf8":case"utf-8":return Et(N).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v*2;case"hex":return v>>>1;case"base64":return ft(N).length;default:if(j)return $?-1:Et(N).length;_=(""+_).toLowerCase(),j=!0}}h.byteLength=Z;function K(N,_,v){let $=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((v===void 0||v>this.length)&&(v=this.length),v<=0)||(v>>>=0,_>>>=0,v<=_))return"";for(N||(N="utf8");;)switch(N){case"hex":return A(this,_,v);case"utf8":case"utf-8":return k(this,_,v);case"ascii":return G(this,_,v);case"latin1":case"binary":return P(this,_,v);case"base64":return E(this,_,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,_,v);default:if($)throw new TypeError("Unknown encoding: "+N);N=(N+"").toLowerCase(),$=!0}}h.prototype._isBuffer=!0;function W(N,_,v){const $=N[_];N[_]=N[v],N[v]=$}h.prototype.swap16=function(){const _=this.length;if(_%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let v=0;v<_;v+=2)W(this,v,v+1);return this},h.prototype.swap32=function(){const _=this.length;if(_%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let v=0;v<_;v+=4)W(this,v,v+3),W(this,v+1,v+2);return this},h.prototype.swap64=function(){const _=this.length;if(_%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let v=0;v<_;v+=8)W(this,v,v+7),W(this,v+1,v+6),W(this,v+2,v+5),W(this,v+3,v+4);return this},h.prototype.toString=function(){const _=this.length;return _===0?"":arguments.length===0?k(this,0,_):K.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(_){if(!h.isBuffer(_))throw new TypeError("Argument must be a Buffer");return this===_?!0:h.compare(this,_)===0},h.prototype.inspect=function(){let _="";const v=r.INSPECT_MAX_BYTES;return _=this.toString("hex",0,v).replace(/(.{2})/g,"$1 ").trim(),this.length>v&&(_+=" ... "),"<Buffer "+_+">"},n&&(h.prototype[n]=h.prototype.inspect),h.prototype.compare=function(_,v,$,j,J){if(Yt(_,s)&&(_=h.from(_,_.offset,_.byteLength)),!h.isBuffer(_))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof _);if(v===void 0&&(v=0),$===void 0&&($=_?_.length:0),j===void 0&&(j=0),J===void 0&&(J=this.length),v<0||$>_.length||j<0||J>this.length)throw new RangeError("out of range index");if(j>=J&&v>=$)return 0;if(j>=J)return-1;if(v>=$)return 1;if(v>>>=0,$>>>=0,j>>>=0,J>>>=0,this===_)return 0;let ae=J-j,Ze=$-v;const Ve=Math.min(ae,Ze),We=this.slice(j,J),Ut=_.slice(v,$);for(let He=0;He<Ve;++He)if(We[He]!==Ut[He]){ae=We[He],Ze=Ut[He];break}return ae<Ze?-1:Ze<ae?1:0};function oe(N,_,v,$,j){if(N.length===0)return-1;if(typeof v=="string"?($=v,v=0):v>2147483647?v=2147483647:v<-2147483648&&(v=-2147483648),v=+v,bt(v)&&(v=j?0:N.length-1),v<0&&(v=N.length+v),v>=N.length){if(j)return-1;v=N.length-1}else if(v<0)if(j)v=0;else return-1;if(typeof _=="string"&&(_=h.from(_,$)),h.isBuffer(_))return _.length===0?-1:ce(N,_,v,$,j);if(typeof _=="number")return _=_&255,typeof s.prototype.indexOf=="function"?j?s.prototype.indexOf.call(N,_,v):s.prototype.lastIndexOf.call(N,_,v):ce(N,[_],v,$,j);throw new TypeError("val must be string, number or Buffer")}function ce(N,_,v,$,j){let J=1,ae=N.length,Ze=_.length;if($!==void 0&&($=String($).toLowerCase(),$==="ucs2"||$==="ucs-2"||$==="utf16le"||$==="utf-16le")){if(N.length<2||_.length<2)return-1;J=2,ae/=2,Ze/=2,v/=2}function Ve(Ut,He){return J===1?Ut[He]:Ut.readUInt16BE(He*J)}let We;if(j){let Ut=-1;for(We=v;We<ae;We++)if(Ve(N,We)===Ve(_,Ut===-1?0:We-Ut)){if(Ut===-1&&(Ut=We),We-Ut+1===Ze)return Ut*J}else Ut!==-1&&(We-=We-Ut),Ut=-1}else for(v+Ze>ae&&(v=ae-Ze),We=v;We>=0;We--){let Ut=!0;for(let He=0;He<Ze;He++)if(Ve(N,We+He)!==Ve(_,He)){Ut=!1;break}if(Ut)return We}return-1}h.prototype.includes=function(_,v,$){return this.indexOf(_,v,$)!==-1},h.prototype.indexOf=function(_,v,$){return oe(this,_,v,$,!0)},h.prototype.lastIndexOf=function(_,v,$){return oe(this,_,v,$,!1)};function ne(N,_,v,$){v=Number(v)||0;const j=N.length-v;$?($=Number($),$>j&&($=j)):$=j;const J=_.length;$>J/2&&($=J/2);let ae;for(ae=0;ae<$;++ae){const Ze=parseInt(_.substr(ae*2,2),16);if(bt(Ze))return ae;N[v+ae]=Ze}return ae}function ue(N,_,v,$){return xt(Et(_,N.length-v),N,v,$)}function B(N,_,v,$){return xt(St(_),N,v,$)}function p(N,_,v,$){return xt(ft(_),N,v,$)}function m(N,_,v,$){return xt(Ar(_,N.length-v),N,v,$)}h.prototype.write=function(_,v,$,j){if(v===void 0)j="utf8",$=this.length,v=0;else if($===void 0&&typeof v=="string")j=v,$=this.length,v=0;else if(isFinite(v))v=v>>>0,isFinite($)?($=$>>>0,j===void 0&&(j="utf8")):(j=$,$=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const J=this.length-v;if(($===void 0||$>J)&&($=J),_.length>0&&($<0||v<0)||v>this.length)throw new RangeError("Attempt to write outside buffer bounds");j||(j="utf8");let ae=!1;for(;;)switch(j){case"hex":return ne(this,_,v,$);case"utf8":case"utf-8":return ue(this,_,v,$);case"ascii":case"latin1":case"binary":return B(this,_,v,$);case"base64":return p(this,_,v,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,_,v,$);default:if(ae)throw new TypeError("Unknown encoding: "+j);j=(""+j).toLowerCase(),ae=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(N,_,v){return _===0&&v===N.length?e.fromByteArray(N):e.fromByteArray(N.slice(_,v))}function k(N,_,v){v=Math.min(N.length,v);const $=[];let j=_;for(;j<v;){const J=N[j];let ae=null,Ze=J>239?4:J>223?3:J>191?2:1;if(j+Ze<=v){let Ve,We,Ut,He;switch(Ze){case 1:J<128&&(ae=J);break;case 2:Ve=N[j+1],(Ve&192)===128&&(He=(J&31)<<6|Ve&63,He>127&&(ae=He));break;case 3:Ve=N[j+1],We=N[j+2],(Ve&192)===128&&(We&192)===128&&(He=(J&15)<<12|(Ve&63)<<6|We&63,He>2047&&(He<55296||He>57343)&&(ae=He));break;case 4:Ve=N[j+1],We=N[j+2],Ut=N[j+3],(Ve&192)===128&&(We&192)===128&&(Ut&192)===128&&(He=(J&15)<<18|(Ve&63)<<12|(We&63)<<6|Ut&63,He>65535&&He<1114112&&(ae=He))}}ae===null?(ae=65533,Ze=1):ae>65535&&(ae-=65536,$.push(ae>>>10&1023|55296),ae=56320|ae&1023),$.push(ae),j+=Ze}return M($)}const O=4096;function M(N){const _=N.length;if(_<=O)return String.fromCharCode.apply(String,N);let v="",$=0;for(;$<_;)v+=String.fromCharCode.apply(String,N.slice($,$+=O));return v}function G(N,_,v){let $="";v=Math.min(N.length,v);for(let j=_;j<v;++j)$+=String.fromCharCode(N[j]&127);return $}function P(N,_,v){let $="";v=Math.min(N.length,v);for(let j=_;j<v;++j)$+=String.fromCharCode(N[j]);return $}function A(N,_,v){const $=N.length;(!_||_<0)&&(_=0),(!v||v<0||v>$)&&(v=$);let j="";for(let J=_;J<v;++J)j+=kt[N[J]];return j}function U(N,_,v){const $=N.slice(_,v);let j="";for(let J=0;J<$.length-1;J+=2)j+=String.fromCharCode($[J]+$[J+1]*256);return j}h.prototype.slice=function(_,v){const $=this.length;_=~~_,v=v===void 0?$:~~v,_<0?(_+=$,_<0&&(_=0)):_>$&&(_=$),v<0?(v+=$,v<0&&(v=0)):v>$&&(v=$),v<_&&(v=_);const j=this.subarray(_,v);return Object.setPrototypeOf(j,h.prototype),j};function le(N,_,v){if(N%1!==0||N<0)throw new RangeError("offset is not uint");if(N+_>v)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let j=this[_],J=1,ae=0;for(;++ae<v&&(J*=256);)j+=this[_+ae]*J;return j},h.prototype.readUintBE=h.prototype.readUIntBE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let j=this[_+--v],J=1;for(;v>0&&(J*=256);)j+=this[_+--v]*J;return j},h.prototype.readUint8=h.prototype.readUInt8=function(_,v){return _=_>>>0,v||le(_,1,this.length),this[_]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(_,v){return _=_>>>0,v||le(_,2,this.length),this[_]|this[_+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(_,v){return _=_>>>0,v||le(_,2,this.length),this[_]<<8|this[_+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(_,v){return _=_>>>0,v||le(_,4,this.length),(this[_]|this[_+1]<<8|this[_+2]<<16)+this[_+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]*16777216+(this[_+1]<<16|this[_+2]<<8|this[_+3])},h.prototype.readBigUInt64LE=Xr(function(_){_=_>>>0,Jt(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&lt(_,this.length-8);const j=v+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24,J=this[++_]+this[++_]*2**8+this[++_]*2**16+$*2**24;return BigInt(j)+(BigInt(J)<<BigInt(32))}),h.prototype.readBigUInt64BE=Xr(function(_){_=_>>>0,Jt(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&lt(_,this.length-8);const j=v*2**24+this[++_]*2**16+this[++_]*2**8+this[++_],J=this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+$;return(BigInt(j)<<BigInt(32))+BigInt(J)}),h.prototype.readIntLE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let j=this[_],J=1,ae=0;for(;++ae<v&&(J*=256);)j+=this[_+ae]*J;return J*=128,j>=J&&(j-=Math.pow(2,8*v)),j},h.prototype.readIntBE=function(_,v,$){_=_>>>0,v=v>>>0,$||le(_,v,this.length);let j=v,J=1,ae=this[_+--j];for(;j>0&&(J*=256);)ae+=this[_+--j]*J;return J*=128,ae>=J&&(ae-=Math.pow(2,8*v)),ae},h.prototype.readInt8=function(_,v){return _=_>>>0,v||le(_,1,this.length),this[_]&128?(255-this[_]+1)*-1:this[_]},h.prototype.readInt16LE=function(_,v){_=_>>>0,v||le(_,2,this.length);const $=this[_]|this[_+1]<<8;return $&32768?$|4294901760:$},h.prototype.readInt16BE=function(_,v){_=_>>>0,v||le(_,2,this.length);const $=this[_+1]|this[_]<<8;return $&32768?$|4294901760:$},h.prototype.readInt32LE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]|this[_+1]<<8|this[_+2]<<16|this[_+3]<<24},h.prototype.readInt32BE=function(_,v){return _=_>>>0,v||le(_,4,this.length),this[_]<<24|this[_+1]<<16|this[_+2]<<8|this[_+3]},h.prototype.readBigInt64LE=Xr(function(_){_=_>>>0,Jt(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&lt(_,this.length-8);const j=this[_+4]+this[_+5]*2**8+this[_+6]*2**16+($<<24);return(BigInt(j)<<BigInt(32))+BigInt(v+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24)}),h.prototype.readBigInt64BE=Xr(function(_){_=_>>>0,Jt(_,"offset");const v=this[_],$=this[_+7];(v===void 0||$===void 0)&&lt(_,this.length-8);const j=(v<<24)+this[++_]*2**16+this[++_]*2**8+this[++_];return(BigInt(j)<<BigInt(32))+BigInt(this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+$)}),h.prototype.readFloatLE=function(_,v){return _=_>>>0,v||le(_,4,this.length),t.read(this,_,!0,23,4)},h.prototype.readFloatBE=function(_,v){return _=_>>>0,v||le(_,4,this.length),t.read(this,_,!1,23,4)},h.prototype.readDoubleLE=function(_,v){return _=_>>>0,v||le(_,8,this.length),t.read(this,_,!0,52,8)},h.prototype.readDoubleBE=function(_,v){return _=_>>>0,v||le(_,8,this.length),t.read(this,_,!1,52,8)};function ee(N,_,v,$,j,J){if(!h.isBuffer(N))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>j||_<J)throw new RangeError('"value" argument is out of bounds');if(v+$>N.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(_,v,$,j){if(_=+_,v=v>>>0,$=$>>>0,!j){const Ze=Math.pow(2,8*$)-1;ee(this,_,v,$,Ze,0)}let J=1,ae=0;for(this[v]=_&255;++ae<$&&(J*=256);)this[v+ae]=_/J&255;return v+$},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(_,v,$,j){if(_=+_,v=v>>>0,$=$>>>0,!j){const Ze=Math.pow(2,8*$)-1;ee(this,_,v,$,Ze,0)}let J=$-1,ae=1;for(this[v+J]=_&255;--J>=0&&(ae*=256);)this[v+J]=_/ae&255;return v+$},h.prototype.writeUint8=h.prototype.writeUInt8=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,1,255,0),this[v]=_&255,v+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,2,65535,0),this[v]=_&255,this[v+1]=_>>>8,v+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,2,65535,0),this[v]=_>>>8,this[v+1]=_&255,v+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,4,4294967295,0),this[v+3]=_>>>24,this[v+2]=_>>>16,this[v+1]=_>>>8,this[v]=_&255,v+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,4,4294967295,0),this[v]=_>>>24,this[v+1]=_>>>16,this[v+2]=_>>>8,this[v+3]=_&255,v+4};function re(N,_,v,$,j){et(_,$,j,N,v,7);let J=Number(_&BigInt(4294967295));N[v++]=J,J=J>>8,N[v++]=J,J=J>>8,N[v++]=J,J=J>>8,N[v++]=J;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return N[v++]=ae,ae=ae>>8,N[v++]=ae,ae=ae>>8,N[v++]=ae,ae=ae>>8,N[v++]=ae,v}function he(N,_,v,$,j){et(_,$,j,N,v,7);let J=Number(_&BigInt(4294967295));N[v+7]=J,J=J>>8,N[v+6]=J,J=J>>8,N[v+5]=J,J=J>>8,N[v+4]=J;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return N[v+3]=ae,ae=ae>>8,N[v+2]=ae,ae=ae>>8,N[v+1]=ae,ae=ae>>8,N[v]=ae,v+8}h.prototype.writeBigUInt64LE=Xr(function(_,v=0){return re(this,_,v,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Xr(function(_,v=0){return he(this,_,v,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(_,v,$,j){if(_=+_,v=v>>>0,!j){const Ve=Math.pow(2,8*$-1);ee(this,_,v,$,Ve-1,-Ve)}let J=0,ae=1,Ze=0;for(this[v]=_&255;++J<$&&(ae*=256);)_<0&&Ze===0&&this[v+J-1]!==0&&(Ze=1),this[v+J]=(_/ae>>0)-Ze&255;return v+$},h.prototype.writeIntBE=function(_,v,$,j){if(_=+_,v=v>>>0,!j){const Ve=Math.pow(2,8*$-1);ee(this,_,v,$,Ve-1,-Ve)}let J=$-1,ae=1,Ze=0;for(this[v+J]=_&255;--J>=0&&(ae*=256);)_<0&&Ze===0&&this[v+J+1]!==0&&(Ze=1),this[v+J]=(_/ae>>0)-Ze&255;return v+$},h.prototype.writeInt8=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,1,127,-128),_<0&&(_=255+_+1),this[v]=_&255,v+1},h.prototype.writeInt16LE=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,2,32767,-32768),this[v]=_&255,this[v+1]=_>>>8,v+2},h.prototype.writeInt16BE=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,2,32767,-32768),this[v]=_>>>8,this[v+1]=_&255,v+2},h.prototype.writeInt32LE=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,4,2147483647,-2147483648),this[v]=_&255,this[v+1]=_>>>8,this[v+2]=_>>>16,this[v+3]=_>>>24,v+4},h.prototype.writeInt32BE=function(_,v,$){return _=+_,v=v>>>0,$||ee(this,_,v,4,2147483647,-2147483648),_<0&&(_=4294967295+_+1),this[v]=_>>>24,this[v+1]=_>>>16,this[v+2]=_>>>8,this[v+3]=_&255,v+4},h.prototype.writeBigInt64LE=Xr(function(_,v=0){return re(this,_,v,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Xr(function(_,v=0){return he(this,_,v,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ye(N,_,v,$,j,J){if(v+$>N.length)throw new RangeError("Index out of range");if(v<0)throw new RangeError("Index out of range")}function be(N,_,v,$,j){return _=+_,v=v>>>0,j||ye(N,_,v,4),t.write(N,_,v,$,23,4),v+4}h.prototype.writeFloatLE=function(_,v,$){return be(this,_,v,!0,$)},h.prototype.writeFloatBE=function(_,v,$){return be(this,_,v,!1,$)};function je(N,_,v,$,j){return _=+_,v=v>>>0,j||ye(N,_,v,8),t.write(N,_,v,$,52,8),v+8}h.prototype.writeDoubleLE=function(_,v,$){return je(this,_,v,!0,$)},h.prototype.writeDoubleBE=function(_,v,$){return je(this,_,v,!1,$)},h.prototype.copy=function(_,v,$,j){if(!h.isBuffer(_))throw new TypeError("argument should be a Buffer");if($||($=0),!j&&j!==0&&(j=this.length),v>=_.length&&(v=_.length),v||(v=0),j>0&&j<$&&(j=$),j===$||_.length===0||this.length===0)return 0;if(v<0)throw new RangeError("targetStart out of bounds");if($<0||$>=this.length)throw new RangeError("Index out of range");if(j<0)throw new RangeError("sourceEnd out of bounds");j>this.length&&(j=this.length),_.length-v<j-$&&(j=_.length-v+$);const J=j-$;return this===_&&typeof s.prototype.copyWithin=="function"?this.copyWithin(v,$,j):s.prototype.set.call(_,this.subarray($,j),v),J},h.prototype.fill=function(_,v,$,j){if(typeof _=="string"){if(typeof v=="string"?(j=v,v=0,$=this.length):typeof $=="string"&&(j=$,$=this.length),j!==void 0&&typeof j!="string")throw new TypeError("encoding must be a string");if(typeof j=="string"&&!h.isEncoding(j))throw new TypeError("Unknown encoding: "+j);if(_.length===1){const ae=_.charCodeAt(0);(j==="utf8"&&ae<128||j==="latin1")&&(_=ae)}}else typeof _=="number"?_=_&255:typeof _=="boolean"&&(_=Number(_));if(v<0||this.length<v||this.length<$)throw new RangeError("Out of range index");if($<=v)return this;v=v>>>0,$=$===void 0?this.length:$>>>0,_||(_=0);let J;if(typeof _=="number")for(J=v;J<$;++J)this[J]=_;else{const ae=h.isBuffer(_)?_:h.from(_,j),Ze=ae.length;if(Ze===0)throw new TypeError('The value "'+_+'" is invalid for argument "value"');for(J=0;J<$-v;++J)this[J+v]=ae[J%Ze]}return this};const $e={};function Oe(N,_,v){$e[N]=class extends v{constructor(){super(),Object.defineProperty(this,"message",{value:_.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${N}]`,this.stack,delete this.name}get code(){return N}set code(j){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:j,writable:!0})}toString(){return`${this.name} [${N}]: ${this.message}`}}}Oe("ERR_BUFFER_OUT_OF_BOUNDS",function(N){return N?`${N} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Oe("ERR_INVALID_ARG_TYPE",function(N,_){return`The "${N}" argument must be of type number. Received type ${typeof _}`},TypeError),Oe("ERR_OUT_OF_RANGE",function(N,_,v){let $=`The value of "${N}" is out of range.`,j=v;return Number.isInteger(v)&&Math.abs(v)>2**32?j=Xe(String(v)):typeof v=="bigint"&&(j=String(v),(v>BigInt(2)**BigInt(32)||v<-(BigInt(2)**BigInt(32)))&&(j=Xe(j)),j+="n"),$+=` It must be ${_}. Received ${j}`,$},RangeError);function Xe(N){let _="",v=N.length;const $=N[0]==="-"?1:0;for(;v>=$+4;v-=3)_=`_${N.slice(v-3,v)}${_}`;return`${N.slice(0,v)}${_}`}function qe(N,_,v){Jt(_,"offset"),(N[_]===void 0||N[_+v]===void 0)&&lt(_,N.length-(v+1))}function et(N,_,v,$,j,J){if(N>v||N<_){const ae=typeof _=="bigint"?"n":"";let Ze;throw _===0||_===BigInt(0)?Ze=`>= 0${ae} and < 2${ae} ** ${(J+1)*8}${ae}`:Ze=`>= -(2${ae} ** ${(J+1)*8-1}${ae}) and < 2 ** ${(J+1)*8-1}${ae}`,new $e.ERR_OUT_OF_RANGE("value",Ze,N)}qe($,j,J)}function Jt(N,_){if(typeof N!="number")throw new $e.ERR_INVALID_ARG_TYPE(_,"number",N)}function lt(N,_,v){throw Math.floor(N)!==N?(Jt(N,v),new $e.ERR_OUT_OF_RANGE("offset","an integer",N)):_<0?new $e.ERR_BUFFER_OUT_OF_BOUNDS:new $e.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${_}`,N)}const Mt=/[^+/0-9A-Za-z-_]/g;function oo(N){if(N=N.split("=")[0],N=N.trim().replace(Mt,""),N.length<2)return"";for(;N.length%4!==0;)N=N+"=";return N}function Et(N,_){_=_||1/0;let v;const $=N.length;let j=null;const J=[];for(let ae=0;ae<$;++ae){if(v=N.charCodeAt(ae),v>55295&&v<57344){if(!j){if(v>56319){(_-=3)>-1&&J.push(239,191,189);continue}else if(ae+1===$){(_-=3)>-1&&J.push(239,191,189);continue}j=v;continue}if(v<56320){(_-=3)>-1&&J.push(239,191,189),j=v;continue}v=(j-55296<<10|v-56320)+65536}else j&&(_-=3)>-1&&J.push(239,191,189);if(j=null,v<128){if((_-=1)<0)break;J.push(v)}else if(v<2048){if((_-=2)<0)break;J.push(v>>6|192,v&63|128)}else if(v<65536){if((_-=3)<0)break;J.push(v>>12|224,v>>6&63|128,v&63|128)}else if(v<1114112){if((_-=4)<0)break;J.push(v>>18|240,v>>12&63|128,v>>6&63|128,v&63|128)}else throw new Error("Invalid code point")}return J}function St(N){const _=[];for(let v=0;v<N.length;++v)_.push(N.charCodeAt(v)&255);return _}function Ar(N,_){let v,$,j;const J=[];for(let ae=0;ae<N.length&&!((_-=2)<0);++ae)v=N.charCodeAt(ae),$=v>>8,j=v%256,J.push(j),J.push($);return J}function ft(N){return e.toByteArray(oo(N))}function xt(N,_,v,$){let j;for(j=0;j<$&&!(j+v>=_.length||j>=N.length);++j)_[j+v]=N[j];return j}function Yt(N,_){return N instanceof _||N!=null&&N.constructor!=null&&N.constructor.name!=null&&N.constructor.name===_.name}function bt(N){return N!==N}const kt=function(){const N="0123456789abcdef",_=new Array(256);for(let v=0;v<16;++v){const $=v*16;for(let j=0;j<16;++j)_[$+j]=N[v]+N[j]}return _}();function Xr(N){return typeof BigInt>"u"?Lt:N}function Lt(){throw new Error("BigInt not supported")}})(wb);const Qe=wb.Buffer,Ne=wb.Buffer,FV=Object.freeze(Object.defineProperty({__proto__:null,Buffer:Ne,default:Qe},Symbol.toStringTag,{value:"Module"}));var _b={exports:{}};const Ab=gp(FV);_b.exports;(function(r){(function(e,t){function n(B,p){if(!B)throw new Error(p||"Assertion failed")}function i(B,p){B.super_=p;var m=function(){};m.prototype=p.prototype,B.prototype=new m,B.prototype.constructor=B}function s(B,p,m){if(s.isBN(B))return B;this.negative=0,this.words=null,this.length=0,this.red=null,B!==null&&((p==="le"||p==="be")&&(m=p,p=10),this._init(B||0,p||10,m||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Ab.Buffer}catch{}s.isBN=function(p){return p instanceof s?!0:p!==null&&typeof p=="object"&&p.constructor.wordSize===s.wordSize&&Array.isArray(p.words)},s.max=function(p,m){return p.cmp(m)>0?p:m},s.min=function(p,m){return p.cmp(m)<0?p:m},s.prototype._init=function(p,m,E){if(typeof p=="number")return this._initNumber(p,m,E);if(typeof p=="object")return this._initArray(p,m,E);m==="hex"&&(m=16),n(m===(m|0)&&m>=2&&m<=36),p=p.toString().replace(/\s+/g,"");var k=0;p[0]==="-"&&(k++,this.negative=1),k<p.length&&(m===16?this._parseHex(p,k,E):(this._parseBase(p,m,k),E==="le"&&this._initArray(this.toArray(),m,E)))},s.prototype._initNumber=function(p,m,E){p<0&&(this.negative=1,p=-p),p<67108864?(this.words=[p&67108863],this.length=1):p<4503599627370496?(this.words=[p&67108863,p/67108864&67108863],this.length=2):(n(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),E==="le"&&this._initArray(this.toArray(),m,E)},s.prototype._initArray=function(p,m,E){if(n(typeof p.length=="number"),p.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(p.length/3),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var O,M,G=0;if(E==="be")for(k=p.length-1,O=0;k>=0;k-=3)M=p[k]|p[k-1]<<8|p[k-2]<<16,this.words[O]|=M<<G&67108863,this.words[O+1]=M>>>26-G&67108863,G+=24,G>=26&&(G-=26,O++);else if(E==="le")for(k=0,O=0;k<p.length;k+=3)M=p[k]|p[k+1]<<8|p[k+2]<<16,this.words[O]|=M<<G&67108863,this.words[O+1]=M>>>26-G&67108863,G+=24,G>=26&&(G-=26,O++);return this._strip()};function a(B,p){var m=B.charCodeAt(p);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;n(!1,"Invalid character in "+B)}function u(B,p,m){var E=a(B,m);return m-1>=p&&(E|=a(B,m-1)<<4),E}s.prototype._parseHex=function(p,m,E){this.length=Math.ceil((p.length-m)/6),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var O=0,M=0,G;if(E==="be")for(k=p.length-1;k>=m;k-=2)G=u(p,m,k)<<O,this.words[M]|=G&67108863,O>=18?(O-=18,M+=1,this.words[M]|=G>>>26):O+=8;else{var P=p.length-m;for(k=P%2===0?m+1:m;k<p.length;k+=2)G=u(p,m,k)<<O,this.words[M]|=G&67108863,O>=18?(O-=18,M+=1,this.words[M]|=G>>>26):O+=8}this._strip()};function l(B,p,m,E){for(var k=0,O=0,M=Math.min(B.length,m),G=p;G<M;G++){var P=B.charCodeAt(G)-48;k*=E,P>=49?O=P-49+10:P>=17?O=P-17+10:O=P,n(P>=0&&O<E,"Invalid character"),k+=O}return k}s.prototype._parseBase=function(p,m,E){this.words=[0],this.length=1;for(var k=0,O=1;O<=67108863;O*=m)k++;k--,O=O/m|0;for(var M=p.length-E,G=M%k,P=Math.min(M,M-G)+E,A=0,U=E;U<P;U+=k)A=l(p,U,U+k,m),this.imuln(O),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A);if(G!==0){var le=1;for(A=l(p,U,p.length,m),U=0;U<G;U++)le*=m;this.imuln(le),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A)}this._strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var m=0;m<this.length;m++)p.words[m]=this.words[m];p.length=this.length,p.negative=this.negative,p.red=this.red};function h(B,p){B.words=p.words,B.length=p.length,B.negative=p.negative,B.red=p.red}if(s.prototype._move=function(p){h(p,this)},s.prototype.clone=function(){var p=new s(null);return this.copy(p),p},s.prototype._expand=function(p){for(;this.length<p;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{s.prototype.inspect=g}else s.prototype.inspect=g;function g(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var b=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],w=[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];s.prototype.toString=function(p,m){p=p||10,m=m|0||1;var E;if(p===16||p==="hex"){E="";for(var k=0,O=0,M=0;M<this.length;M++){var G=this.words[M],P=((G<<k|O)&16777215).toString(16);O=G>>>24-k&16777215,k+=2,k>=26&&(k-=26,M--),O!==0||M!==this.length-1?E=b[6-P.length]+P+E:E=P+E}for(O!==0&&(E=O.toString(16)+E);E.length%m!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}if(p===(p|0)&&p>=2&&p<=36){var A=w[p],U=I[p];E="";var le=this.clone();for(le.negative=0;!le.isZero();){var ee=le.modrn(U).toString(p);le=le.idivn(U),le.isZero()?E=ee+E:E=b[A-ee.length]+ee+E}for(this.isZero()&&(E="0"+E);E.length%m!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var p=this.words[0];return this.length===2?p+=this.words[1]*67108864:this.length===3&&this.words[2]===1?p+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(p,m){return this.toArrayLike(o,p,m)}),s.prototype.toArray=function(p,m){return this.toArrayLike(Array,p,m)};var S=function(p,m){return p.allocUnsafe?p.allocUnsafe(m):new p(m)};s.prototype.toArrayLike=function(p,m,E){this._strip();var k=this.byteLength(),O=E||Math.max(1,k);n(k<=O,"byte array longer than desired length"),n(O>0,"Requested array length <= 0");var M=S(p,O),G=m==="le"?"LE":"BE";return this["_toArrayLike"+G](M,k),M},s.prototype._toArrayLikeLE=function(p,m){for(var E=0,k=0,O=0,M=0;O<this.length;O++){var G=this.words[O]<<M|k;p[E++]=G&255,E<p.length&&(p[E++]=G>>8&255),E<p.length&&(p[E++]=G>>16&255),M===6?(E<p.length&&(p[E++]=G>>24&255),k=0,M=0):(k=G>>>24,M+=2)}if(E<p.length)for(p[E++]=k;E<p.length;)p[E++]=0},s.prototype._toArrayLikeBE=function(p,m){for(var E=p.length-1,k=0,O=0,M=0;O<this.length;O++){var G=this.words[O]<<M|k;p[E--]=G&255,E>=0&&(p[E--]=G>>8&255),E>=0&&(p[E--]=G>>16&255),M===6?(E>=0&&(p[E--]=G>>24&255),k=0,M=0):(k=G>>>24,M+=2)}if(E>=0)for(p[E--]=k;E>=0;)p[E--]=0},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var m=p,E=0;return m>=4096&&(E+=13,m>>>=13),m>=64&&(E+=7,m>>>=7),m>=8&&(E+=4,m>>>=4),m>=2&&(E+=2,m>>>=2),E+m},s.prototype._zeroBits=function(p){if(p===0)return 26;var m=p,E=0;return m&8191||(E+=13,m>>>=13),m&127||(E+=7,m>>>=7),m&15||(E+=4,m>>>=4),m&3||(E+=2,m>>>=2),m&1||E++,E},s.prototype.bitLength=function(){var p=this.words[this.length-1],m=this._countBits(p);return(this.length-1)*26+m};function x(B){for(var p=new Array(B.bitLength()),m=0;m<p.length;m++){var E=m/26|0,k=m%26;p[m]=B.words[E]>>>k&1}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,m=0;m<this.length;m++){var E=this._zeroBits(this.words[m]);if(p+=E,E!==26)break}return p},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(p){return this.negative!==0?this.abs().inotn(p).iaddn(1):this.clone()},s.prototype.fromTwos=function(p){return this.testn(p-1)?this.notn(p).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(p){for(;this.length<p.length;)this.words[this.length++]=0;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]|p.words[m];return this._strip()},s.prototype.ior=function(p){return n((this.negative|p.negative)===0),this.iuor(p)},s.prototype.or=function(p){return this.length>p.length?this.clone().ior(p):p.clone().ior(this)},s.prototype.uor=function(p){return this.length>p.length?this.clone().iuor(p):p.clone().iuor(this)},s.prototype.iuand=function(p){var m;this.length>p.length?m=p:m=this;for(var E=0;E<m.length;E++)this.words[E]=this.words[E]&p.words[E];return this.length=m.length,this._strip()},s.prototype.iand=function(p){return n((this.negative|p.negative)===0),this.iuand(p)},s.prototype.and=function(p){return this.length>p.length?this.clone().iand(p):p.clone().iand(this)},s.prototype.uand=function(p){return this.length>p.length?this.clone().iuand(p):p.clone().iuand(this)},s.prototype.iuxor=function(p){var m,E;this.length>p.length?(m=this,E=p):(m=p,E=this);for(var k=0;k<E.length;k++)this.words[k]=m.words[k]^E.words[k];if(this!==m)for(;k<m.length;k++)this.words[k]=m.words[k];return this.length=m.length,this._strip()},s.prototype.ixor=function(p){return n((this.negative|p.negative)===0),this.iuxor(p)},s.prototype.xor=function(p){return this.length>p.length?this.clone().ixor(p):p.clone().ixor(this)},s.prototype.uxor=function(p){return this.length>p.length?this.clone().iuxor(p):p.clone().iuxor(this)},s.prototype.inotn=function(p){n(typeof p=="number"&&p>=0);var m=Math.ceil(p/26)|0,E=p%26;this._expand(m),E>0&&m--;for(var k=0;k<m;k++)this.words[k]=~this.words[k]&67108863;return E>0&&(this.words[k]=~this.words[k]&67108863>>26-E),this._strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,m){n(typeof p=="number"&&p>=0);var E=p/26|0,k=p%26;return this._expand(E+1),m?this.words[E]=this.words[E]|1<<k:this.words[E]=this.words[E]&~(1<<k),this._strip()},s.prototype.iadd=function(p){var m;if(this.negative!==0&&p.negative===0)return this.negative=0,m=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,m=this.isub(p),p.negative=1,m._normSign();var E,k;this.length>p.length?(E=this,k=p):(E=p,k=this);for(var O=0,M=0;M<k.length;M++)m=(E.words[M]|0)+(k.words[M]|0)+O,this.words[M]=m&67108863,O=m>>>26;for(;O!==0&&M<E.length;M++)m=(E.words[M]|0)+O,this.words[M]=m&67108863,O=m>>>26;if(this.length=E.length,O!==0)this.words[this.length]=O,this.length++;else if(E!==this)for(;M<E.length;M++)this.words[M]=E.words[M];return this},s.prototype.add=function(p){var m;return p.negative!==0&&this.negative===0?(p.negative=0,m=this.sub(p),p.negative^=1,m):p.negative===0&&this.negative!==0?(this.negative=0,m=p.sub(this),this.negative=1,m):this.length>p.length?this.clone().iadd(p):p.clone().iadd(this)},s.prototype.isub=function(p){if(p.negative!==0){p.negative=0;var m=this.iadd(p);return p.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var E=this.cmp(p);if(E===0)return this.negative=0,this.length=1,this.words[0]=0,this;var k,O;E>0?(k=this,O=p):(k=p,O=this);for(var M=0,G=0;G<O.length;G++)m=(k.words[G]|0)-(O.words[G]|0)+M,M=m>>26,this.words[G]=m&67108863;for(;M!==0&&G<k.length;G++)m=(k.words[G]|0)+M,M=m>>26,this.words[G]=m&67108863;if(M===0&&G<k.length&&k!==this)for(;G<k.length;G++)this.words[G]=k.words[G];return this.length=Math.max(this.length,G),k!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function C(B,p,m){m.negative=p.negative^B.negative;var E=B.length+p.length|0;m.length=E,E=E-1|0;var k=B.words[0]|0,O=p.words[0]|0,M=k*O,G=M&67108863,P=M/67108864|0;m.words[0]=G;for(var A=1;A<E;A++){for(var U=P>>>26,le=P&67108863,ee=Math.min(A,p.length-1),re=Math.max(0,A-B.length+1);re<=ee;re++){var he=A-re|0;k=B.words[he]|0,O=p.words[re]|0,M=k*O+le,U+=M/67108864|0,le=M&67108863}m.words[A]=le|0,P=U|0}return P!==0?m.words[A]=P|0:m.length--,m._strip()}var H=function(p,m,E){var k=p.words,O=m.words,M=E.words,G=0,P,A,U,le=k[0]|0,ee=le&8191,re=le>>>13,he=k[1]|0,ye=he&8191,be=he>>>13,je=k[2]|0,$e=je&8191,Oe=je>>>13,Xe=k[3]|0,qe=Xe&8191,et=Xe>>>13,Jt=k[4]|0,lt=Jt&8191,Mt=Jt>>>13,oo=k[5]|0,Et=oo&8191,St=oo>>>13,Ar=k[6]|0,ft=Ar&8191,xt=Ar>>>13,Yt=k[7]|0,bt=Yt&8191,kt=Yt>>>13,Xr=k[8]|0,Lt=Xr&8191,N=Xr>>>13,_=k[9]|0,v=_&8191,$=_>>>13,j=O[0]|0,J=j&8191,ae=j>>>13,Ze=O[1]|0,Ve=Ze&8191,We=Ze>>>13,Ut=O[2]|0,He=Ut&8191,ar=Ut>>>13,Ad=O[3]|0,cr=Ad&8191,ur=Ad>>>13,vd=O[4]|0,Xt=vd&8191,lr=vd>>>13,Ed=O[5]|0,er=Ed&8191,fr=Ed>>>13,ua=O[6]|0,Vt=ua&8191,hr=ua>>>13,xd=O[7]|0,dr=xd&8191,pr=xd>>>13,Rd=O[8]|0,gr=Rd&8191,yr=Rd>>>13,la=O[9]|0,mr=la&8191,wr=la>>>13;E.negative=p.negative^m.negative,E.length=19,P=Math.imul(ee,J),A=Math.imul(ee,ae),A=A+Math.imul(re,J)|0,U=Math.imul(re,ae);var Wl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Wl>>>26)|0,Wl&=67108863,P=Math.imul(ye,J),A=Math.imul(ye,ae),A=A+Math.imul(be,J)|0,U=Math.imul(be,ae),P=P+Math.imul(ee,Ve)|0,A=A+Math.imul(ee,We)|0,A=A+Math.imul(re,Ve)|0,U=U+Math.imul(re,We)|0;var Pc=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Pc>>>26)|0,Pc&=67108863,P=Math.imul($e,J),A=Math.imul($e,ae),A=A+Math.imul(Oe,J)|0,U=Math.imul(Oe,ae),P=P+Math.imul(ye,Ve)|0,A=A+Math.imul(ye,We)|0,A=A+Math.imul(be,Ve)|0,U=U+Math.imul(be,We)|0,P=P+Math.imul(ee,He)|0,A=A+Math.imul(ee,ar)|0,A=A+Math.imul(re,He)|0,U=U+Math.imul(re,ar)|0;var Vl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,P=Math.imul(qe,J),A=Math.imul(qe,ae),A=A+Math.imul(et,J)|0,U=Math.imul(et,ae),P=P+Math.imul($e,Ve)|0,A=A+Math.imul($e,We)|0,A=A+Math.imul(Oe,Ve)|0,U=U+Math.imul(Oe,We)|0,P=P+Math.imul(ye,He)|0,A=A+Math.imul(ye,ar)|0,A=A+Math.imul(be,He)|0,U=U+Math.imul(be,ar)|0,P=P+Math.imul(ee,cr)|0,A=A+Math.imul(ee,ur)|0,A=A+Math.imul(re,cr)|0,U=U+Math.imul(re,ur)|0;var ql=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(ql>>>26)|0,ql&=67108863,P=Math.imul(lt,J),A=Math.imul(lt,ae),A=A+Math.imul(Mt,J)|0,U=Math.imul(Mt,ae),P=P+Math.imul(qe,Ve)|0,A=A+Math.imul(qe,We)|0,A=A+Math.imul(et,Ve)|0,U=U+Math.imul(et,We)|0,P=P+Math.imul($e,He)|0,A=A+Math.imul($e,ar)|0,A=A+Math.imul(Oe,He)|0,U=U+Math.imul(Oe,ar)|0,P=P+Math.imul(ye,cr)|0,A=A+Math.imul(ye,ur)|0,A=A+Math.imul(be,cr)|0,U=U+Math.imul(be,ur)|0,P=P+Math.imul(ee,Xt)|0,A=A+Math.imul(ee,lr)|0,A=A+Math.imul(re,Xt)|0,U=U+Math.imul(re,lr)|0;var Zl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Zl>>>26)|0,Zl&=67108863,P=Math.imul(Et,J),A=Math.imul(Et,ae),A=A+Math.imul(St,J)|0,U=Math.imul(St,ae),P=P+Math.imul(lt,Ve)|0,A=A+Math.imul(lt,We)|0,A=A+Math.imul(Mt,Ve)|0,U=U+Math.imul(Mt,We)|0,P=P+Math.imul(qe,He)|0,A=A+Math.imul(qe,ar)|0,A=A+Math.imul(et,He)|0,U=U+Math.imul(et,ar)|0,P=P+Math.imul($e,cr)|0,A=A+Math.imul($e,ur)|0,A=A+Math.imul(Oe,cr)|0,U=U+Math.imul(Oe,ur)|0,P=P+Math.imul(ye,Xt)|0,A=A+Math.imul(ye,lr)|0,A=A+Math.imul(be,Xt)|0,U=U+Math.imul(be,lr)|0,P=P+Math.imul(ee,er)|0,A=A+Math.imul(ee,fr)|0,A=A+Math.imul(re,er)|0,U=U+Math.imul(re,fr)|0;var Ql=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Ql>>>26)|0,Ql&=67108863,P=Math.imul(ft,J),A=Math.imul(ft,ae),A=A+Math.imul(xt,J)|0,U=Math.imul(xt,ae),P=P+Math.imul(Et,Ve)|0,A=A+Math.imul(Et,We)|0,A=A+Math.imul(St,Ve)|0,U=U+Math.imul(St,We)|0,P=P+Math.imul(lt,He)|0,A=A+Math.imul(lt,ar)|0,A=A+Math.imul(Mt,He)|0,U=U+Math.imul(Mt,ar)|0,P=P+Math.imul(qe,cr)|0,A=A+Math.imul(qe,ur)|0,A=A+Math.imul(et,cr)|0,U=U+Math.imul(et,ur)|0,P=P+Math.imul($e,Xt)|0,A=A+Math.imul($e,lr)|0,A=A+Math.imul(Oe,Xt)|0,U=U+Math.imul(Oe,lr)|0,P=P+Math.imul(ye,er)|0,A=A+Math.imul(ye,fr)|0,A=A+Math.imul(be,er)|0,U=U+Math.imul(be,fr)|0,P=P+Math.imul(ee,Vt)|0,A=A+Math.imul(ee,hr)|0,A=A+Math.imul(re,Vt)|0,U=U+Math.imul(re,hr)|0;var Mc=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Mc>>>26)|0,Mc&=67108863,P=Math.imul(bt,J),A=Math.imul(bt,ae),A=A+Math.imul(kt,J)|0,U=Math.imul(kt,ae),P=P+Math.imul(ft,Ve)|0,A=A+Math.imul(ft,We)|0,A=A+Math.imul(xt,Ve)|0,U=U+Math.imul(xt,We)|0,P=P+Math.imul(Et,He)|0,A=A+Math.imul(Et,ar)|0,A=A+Math.imul(St,He)|0,U=U+Math.imul(St,ar)|0,P=P+Math.imul(lt,cr)|0,A=A+Math.imul(lt,ur)|0,A=A+Math.imul(Mt,cr)|0,U=U+Math.imul(Mt,ur)|0,P=P+Math.imul(qe,Xt)|0,A=A+Math.imul(qe,lr)|0,A=A+Math.imul(et,Xt)|0,U=U+Math.imul(et,lr)|0,P=P+Math.imul($e,er)|0,A=A+Math.imul($e,fr)|0,A=A+Math.imul(Oe,er)|0,U=U+Math.imul(Oe,fr)|0,P=P+Math.imul(ye,Vt)|0,A=A+Math.imul(ye,hr)|0,A=A+Math.imul(be,Vt)|0,U=U+Math.imul(be,hr)|0,P=P+Math.imul(ee,dr)|0,A=A+Math.imul(ee,pr)|0,A=A+Math.imul(re,dr)|0,U=U+Math.imul(re,pr)|0;var Jl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Jl>>>26)|0,Jl&=67108863,P=Math.imul(Lt,J),A=Math.imul(Lt,ae),A=A+Math.imul(N,J)|0,U=Math.imul(N,ae),P=P+Math.imul(bt,Ve)|0,A=A+Math.imul(bt,We)|0,A=A+Math.imul(kt,Ve)|0,U=U+Math.imul(kt,We)|0,P=P+Math.imul(ft,He)|0,A=A+Math.imul(ft,ar)|0,A=A+Math.imul(xt,He)|0,U=U+Math.imul(xt,ar)|0,P=P+Math.imul(Et,cr)|0,A=A+Math.imul(Et,ur)|0,A=A+Math.imul(St,cr)|0,U=U+Math.imul(St,ur)|0,P=P+Math.imul(lt,Xt)|0,A=A+Math.imul(lt,lr)|0,A=A+Math.imul(Mt,Xt)|0,U=U+Math.imul(Mt,lr)|0,P=P+Math.imul(qe,er)|0,A=A+Math.imul(qe,fr)|0,A=A+Math.imul(et,er)|0,U=U+Math.imul(et,fr)|0,P=P+Math.imul($e,Vt)|0,A=A+Math.imul($e,hr)|0,A=A+Math.imul(Oe,Vt)|0,U=U+Math.imul(Oe,hr)|0,P=P+Math.imul(ye,dr)|0,A=A+Math.imul(ye,pr)|0,A=A+Math.imul(be,dr)|0,U=U+Math.imul(be,pr)|0,P=P+Math.imul(ee,gr)|0,A=A+Math.imul(ee,yr)|0,A=A+Math.imul(re,gr)|0,U=U+Math.imul(re,yr)|0;var ms=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(ms>>>26)|0,ms&=67108863,P=Math.imul(v,J),A=Math.imul(v,ae),A=A+Math.imul($,J)|0,U=Math.imul($,ae),P=P+Math.imul(Lt,Ve)|0,A=A+Math.imul(Lt,We)|0,A=A+Math.imul(N,Ve)|0,U=U+Math.imul(N,We)|0,P=P+Math.imul(bt,He)|0,A=A+Math.imul(bt,ar)|0,A=A+Math.imul(kt,He)|0,U=U+Math.imul(kt,ar)|0,P=P+Math.imul(ft,cr)|0,A=A+Math.imul(ft,ur)|0,A=A+Math.imul(xt,cr)|0,U=U+Math.imul(xt,ur)|0,P=P+Math.imul(Et,Xt)|0,A=A+Math.imul(Et,lr)|0,A=A+Math.imul(St,Xt)|0,U=U+Math.imul(St,lr)|0,P=P+Math.imul(lt,er)|0,A=A+Math.imul(lt,fr)|0,A=A+Math.imul(Mt,er)|0,U=U+Math.imul(Mt,fr)|0,P=P+Math.imul(qe,Vt)|0,A=A+Math.imul(qe,hr)|0,A=A+Math.imul(et,Vt)|0,U=U+Math.imul(et,hr)|0,P=P+Math.imul($e,dr)|0,A=A+Math.imul($e,pr)|0,A=A+Math.imul(Oe,dr)|0,U=U+Math.imul(Oe,pr)|0,P=P+Math.imul(ye,gr)|0,A=A+Math.imul(ye,yr)|0,A=A+Math.imul(be,gr)|0,U=U+Math.imul(be,yr)|0,P=P+Math.imul(ee,mr)|0,A=A+Math.imul(ee,wr)|0,A=A+Math.imul(re,mr)|0,U=U+Math.imul(re,wr)|0;var Yl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Yl>>>26)|0,Yl&=67108863,P=Math.imul(v,Ve),A=Math.imul(v,We),A=A+Math.imul($,Ve)|0,U=Math.imul($,We),P=P+Math.imul(Lt,He)|0,A=A+Math.imul(Lt,ar)|0,A=A+Math.imul(N,He)|0,U=U+Math.imul(N,ar)|0,P=P+Math.imul(bt,cr)|0,A=A+Math.imul(bt,ur)|0,A=A+Math.imul(kt,cr)|0,U=U+Math.imul(kt,ur)|0,P=P+Math.imul(ft,Xt)|0,A=A+Math.imul(ft,lr)|0,A=A+Math.imul(xt,Xt)|0,U=U+Math.imul(xt,lr)|0,P=P+Math.imul(Et,er)|0,A=A+Math.imul(Et,fr)|0,A=A+Math.imul(St,er)|0,U=U+Math.imul(St,fr)|0,P=P+Math.imul(lt,Vt)|0,A=A+Math.imul(lt,hr)|0,A=A+Math.imul(Mt,Vt)|0,U=U+Math.imul(Mt,hr)|0,P=P+Math.imul(qe,dr)|0,A=A+Math.imul(qe,pr)|0,A=A+Math.imul(et,dr)|0,U=U+Math.imul(et,pr)|0,P=P+Math.imul($e,gr)|0,A=A+Math.imul($e,yr)|0,A=A+Math.imul(Oe,gr)|0,U=U+Math.imul(Oe,yr)|0,P=P+Math.imul(ye,mr)|0,A=A+Math.imul(ye,wr)|0,A=A+Math.imul(be,mr)|0,U=U+Math.imul(be,wr)|0;var pi=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(pi>>>26)|0,pi&=67108863,P=Math.imul(v,He),A=Math.imul(v,ar),A=A+Math.imul($,He)|0,U=Math.imul($,ar),P=P+Math.imul(Lt,cr)|0,A=A+Math.imul(Lt,ur)|0,A=A+Math.imul(N,cr)|0,U=U+Math.imul(N,ur)|0,P=P+Math.imul(bt,Xt)|0,A=A+Math.imul(bt,lr)|0,A=A+Math.imul(kt,Xt)|0,U=U+Math.imul(kt,lr)|0,P=P+Math.imul(ft,er)|0,A=A+Math.imul(ft,fr)|0,A=A+Math.imul(xt,er)|0,U=U+Math.imul(xt,fr)|0,P=P+Math.imul(Et,Vt)|0,A=A+Math.imul(Et,hr)|0,A=A+Math.imul(St,Vt)|0,U=U+Math.imul(St,hr)|0,P=P+Math.imul(lt,dr)|0,A=A+Math.imul(lt,pr)|0,A=A+Math.imul(Mt,dr)|0,U=U+Math.imul(Mt,pr)|0,P=P+Math.imul(qe,gr)|0,A=A+Math.imul(qe,yr)|0,A=A+Math.imul(et,gr)|0,U=U+Math.imul(et,yr)|0,P=P+Math.imul($e,mr)|0,A=A+Math.imul($e,wr)|0,A=A+Math.imul(Oe,mr)|0,U=U+Math.imul(Oe,wr)|0;var Xl=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Xl>>>26)|0,Xl&=67108863,P=Math.imul(v,cr),A=Math.imul(v,ur),A=A+Math.imul($,cr)|0,U=Math.imul($,ur),P=P+Math.imul(Lt,Xt)|0,A=A+Math.imul(Lt,lr)|0,A=A+Math.imul(N,Xt)|0,U=U+Math.imul(N,lr)|0,P=P+Math.imul(bt,er)|0,A=A+Math.imul(bt,fr)|0,A=A+Math.imul(kt,er)|0,U=U+Math.imul(kt,fr)|0,P=P+Math.imul(ft,Vt)|0,A=A+Math.imul(ft,hr)|0,A=A+Math.imul(xt,Vt)|0,U=U+Math.imul(xt,hr)|0,P=P+Math.imul(Et,dr)|0,A=A+Math.imul(Et,pr)|0,A=A+Math.imul(St,dr)|0,U=U+Math.imul(St,pr)|0,P=P+Math.imul(lt,gr)|0,A=A+Math.imul(lt,yr)|0,A=A+Math.imul(Mt,gr)|0,U=U+Math.imul(Mt,yr)|0,P=P+Math.imul(qe,mr)|0,A=A+Math.imul(qe,wr)|0,A=A+Math.imul(et,mr)|0,U=U+Math.imul(et,wr)|0;var ef=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(ef>>>26)|0,ef&=67108863,P=Math.imul(v,Xt),A=Math.imul(v,lr),A=A+Math.imul($,Xt)|0,U=Math.imul($,lr),P=P+Math.imul(Lt,er)|0,A=A+Math.imul(Lt,fr)|0,A=A+Math.imul(N,er)|0,U=U+Math.imul(N,fr)|0,P=P+Math.imul(bt,Vt)|0,A=A+Math.imul(bt,hr)|0,A=A+Math.imul(kt,Vt)|0,U=U+Math.imul(kt,hr)|0,P=P+Math.imul(ft,dr)|0,A=A+Math.imul(ft,pr)|0,A=A+Math.imul(xt,dr)|0,U=U+Math.imul(xt,pr)|0,P=P+Math.imul(Et,gr)|0,A=A+Math.imul(Et,yr)|0,A=A+Math.imul(St,gr)|0,U=U+Math.imul(St,yr)|0,P=P+Math.imul(lt,mr)|0,A=A+Math.imul(lt,wr)|0,A=A+Math.imul(Mt,mr)|0,U=U+Math.imul(Mt,wr)|0;var Lc=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(Lc>>>26)|0,Lc&=67108863,P=Math.imul(v,er),A=Math.imul(v,fr),A=A+Math.imul($,er)|0,U=Math.imul($,fr),P=P+Math.imul(Lt,Vt)|0,A=A+Math.imul(Lt,hr)|0,A=A+Math.imul(N,Vt)|0,U=U+Math.imul(N,hr)|0,P=P+Math.imul(bt,dr)|0,A=A+Math.imul(bt,pr)|0,A=A+Math.imul(kt,dr)|0,U=U+Math.imul(kt,pr)|0,P=P+Math.imul(ft,gr)|0,A=A+Math.imul(ft,yr)|0,A=A+Math.imul(xt,gr)|0,U=U+Math.imul(xt,yr)|0,P=P+Math.imul(Et,mr)|0,A=A+Math.imul(Et,wr)|0,A=A+Math.imul(St,mr)|0,U=U+Math.imul(St,wr)|0;var tf=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(tf>>>26)|0,tf&=67108863,P=Math.imul(v,Vt),A=Math.imul(v,hr),A=A+Math.imul($,Vt)|0,U=Math.imul($,hr),P=P+Math.imul(Lt,dr)|0,A=A+Math.imul(Lt,pr)|0,A=A+Math.imul(N,dr)|0,U=U+Math.imul(N,pr)|0,P=P+Math.imul(bt,gr)|0,A=A+Math.imul(bt,yr)|0,A=A+Math.imul(kt,gr)|0,U=U+Math.imul(kt,yr)|0,P=P+Math.imul(ft,mr)|0,A=A+Math.imul(ft,wr)|0,A=A+Math.imul(xt,mr)|0,U=U+Math.imul(xt,wr)|0;var rf=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(rf>>>26)|0,rf&=67108863,P=Math.imul(v,dr),A=Math.imul(v,pr),A=A+Math.imul($,dr)|0,U=Math.imul($,pr),P=P+Math.imul(Lt,gr)|0,A=A+Math.imul(Lt,yr)|0,A=A+Math.imul(N,gr)|0,U=U+Math.imul(N,yr)|0,P=P+Math.imul(bt,mr)|0,A=A+Math.imul(bt,wr)|0,A=A+Math.imul(kt,mr)|0,U=U+Math.imul(kt,wr)|0;var nf=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(nf>>>26)|0,nf&=67108863,P=Math.imul(v,gr),A=Math.imul(v,yr),A=A+Math.imul($,gr)|0,U=Math.imul($,yr),P=P+Math.imul(Lt,mr)|0,A=A+Math.imul(Lt,wr)|0,A=A+Math.imul(N,mr)|0,U=U+Math.imul(N,wr)|0;var sf=(G+P|0)+((A&8191)<<13)|0;G=(U+(A>>>13)|0)+(sf>>>26)|0,sf&=67108863,P=Math.imul(v,mr),A=Math.imul(v,wr),A=A+Math.imul($,mr)|0,U=Math.imul($,wr);var ao=(G+P|0)+((A&8191)<<13)|0;return G=(U+(A>>>13)|0)+(ao>>>26)|0,ao&=67108863,M[0]=Wl,M[1]=Pc,M[2]=Vl,M[3]=ql,M[4]=Zl,M[5]=Ql,M[6]=Mc,M[7]=Jl,M[8]=ms,M[9]=Yl,M[10]=pi,M[11]=Xl,M[12]=ef,M[13]=Lc,M[14]=tf,M[15]=rf,M[16]=nf,M[17]=sf,M[18]=ao,G!==0&&(M[19]=G,E.length++),E};Math.imul||(H=C);function D(B,p,m){m.negative=p.negative^B.negative,m.length=B.length+p.length;for(var E=0,k=0,O=0;O<m.length-1;O++){var M=k;k=0;for(var G=E&67108863,P=Math.min(O,p.length-1),A=Math.max(0,O-B.length+1);A<=P;A++){var U=O-A,le=B.words[U]|0,ee=p.words[A]|0,re=le*ee,he=re&67108863;M=M+(re/67108864|0)|0,he=he+G|0,G=he&67108863,M=M+(he>>>26)|0,k+=M>>>26,M&=67108863}m.words[O]=G,E=M,M=k}return E!==0?m.words[O]=E:m.length--,m._strip()}function z(B,p,m){return D(B,p,m)}s.prototype.mulTo=function(p,m){var E,k=this.length+p.length;return this.length===10&&p.length===10?E=H(this,p,m):k<63?E=C(this,p,m):k<1024?E=D(this,p,m):E=z(this,p,m),E},s.prototype.mul=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),this.mulTo(p,m)},s.prototype.mulf=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),z(this,p,m)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){var m=p<0;m&&(p=-p),n(typeof p=="number"),n(p<67108864);for(var E=0,k=0;k<this.length;k++){var O=(this.words[k]|0)*p,M=(O&67108863)+(E&67108863);E>>=26,E+=O/67108864|0,E+=M>>>26,this.words[k]=M&67108863}return E!==0&&(this.words[k]=E,this.length++),m?this.ineg():this},s.prototype.muln=function(p){return this.clone().imuln(p)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(p){var m=x(p);if(m.length===0)return new s(1);for(var E=this,k=0;k<m.length&&m[k]===0;k++,E=E.sqr());if(++k<m.length)for(var O=E.sqr();k<m.length;k++,O=O.sqr())m[k]!==0&&(E=E.mul(O));return E},s.prototype.iushln=function(p){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26,k=67108863>>>26-m<<26-m,O;if(m!==0){var M=0;for(O=0;O<this.length;O++){var G=this.words[O]&k,P=(this.words[O]|0)-G<<m;this.words[O]=P|M,M=G>>>26-m}M&&(this.words[O]=M,this.length++)}if(E!==0){for(O=this.length-1;O>=0;O--)this.words[O+E]=this.words[O];for(O=0;O<E;O++)this.words[O]=0;this.length+=E}return this._strip()},s.prototype.ishln=function(p){return n(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,m,E){n(typeof p=="number"&&p>=0);var k;m?k=(m-m%26)/26:k=0;var O=p%26,M=Math.min((p-O)/26,this.length),G=67108863^67108863>>>O<<O,P=E;if(k-=M,k=Math.max(0,k),P){for(var A=0;A<M;A++)P.words[A]=this.words[A];P.length=M}if(M!==0)if(this.length>M)for(this.length-=M,A=0;A<this.length;A++)this.words[A]=this.words[A+M];else this.words[0]=0,this.length=1;var U=0;for(A=this.length-1;A>=0&&(U!==0||A>=k);A--){var le=this.words[A]|0;this.words[A]=U<<26-O|le>>>O,U=le&G}return P&&U!==0&&(P.words[P.length++]=U),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(p,m,E){return n(this.negative===0),this.iushrn(p,m,E)},s.prototype.shln=function(p){return this.clone().ishln(p)},s.prototype.ushln=function(p){return this.clone().iushln(p)},s.prototype.shrn=function(p){return this.clone().ishrn(p)},s.prototype.ushrn=function(p){return this.clone().iushrn(p)},s.prototype.testn=function(p){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26,k=1<<m;if(this.length<=E)return!1;var O=this.words[E];return!!(O&k)},s.prototype.imaskn=function(p){n(typeof p=="number"&&p>=0);var m=p%26,E=(p-m)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=E)return this;if(m!==0&&E++,this.length=Math.min(E,this.length),m!==0){var k=67108863^67108863>>>m<<m;this.words[this.length-1]&=k}return this._strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return n(typeof p=="number"),n(p<67108864),p<0?this.isubn(-p):this.negative!==0?this.length===1&&(this.words[0]|0)<=p?(this.words[0]=p-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(p),this.negative=1,this):this._iaddn(p)},s.prototype._iaddn=function(p){this.words[0]+=p;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},s.prototype.isubn=function(p){if(n(typeof p=="number"),n(p<67108864),p<0)return this.iaddn(-p);if(this.negative!==0)return this.negative=0,this.iaddn(p),this.negative=1,this;if(this.words[0]-=p,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},s.prototype.addn=function(p){return this.clone().iaddn(p)},s.prototype.subn=function(p){return this.clone().isubn(p)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(p,m,E){var k=p.length+E,O;this._expand(k);var M,G=0;for(O=0;O<p.length;O++){M=(this.words[O+E]|0)+G;var P=(p.words[O]|0)*m;M-=P&67108863,G=(M>>26)-(P/67108864|0),this.words[O+E]=M&67108863}for(;O<this.length-E;O++)M=(this.words[O+E]|0)+G,G=M>>26,this.words[O+E]=M&67108863;if(G===0)return this._strip();for(n(G===-1),G=0,O=0;O<this.length;O++)M=-(this.words[O]|0)+G,G=M>>26,this.words[O]=M&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(p,m){var E=this.length-p.length,k=this.clone(),O=p,M=O.words[O.length-1]|0,G=this._countBits(M);E=26-G,E!==0&&(O=O.ushln(E),k.iushln(E),M=O.words[O.length-1]|0);var P=k.length-O.length,A;if(m!=="mod"){A=new s(null),A.length=P+1,A.words=new Array(A.length);for(var U=0;U<A.length;U++)A.words[U]=0}var le=k.clone()._ishlnsubmul(O,1,P);le.negative===0&&(k=le,A&&(A.words[P]=1));for(var ee=P-1;ee>=0;ee--){var re=(k.words[O.length+ee]|0)*67108864+(k.words[O.length+ee-1]|0);for(re=Math.min(re/M|0,67108863),k._ishlnsubmul(O,re,ee);k.negative!==0;)re--,k.negative=0,k._ishlnsubmul(O,1,ee),k.isZero()||(k.negative^=1);A&&(A.words[ee]=re)}return A&&A._strip(),k._strip(),m!=="div"&&E!==0&&k.iushrn(E),{div:A||null,mod:k}},s.prototype.divmod=function(p,m,E){if(n(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var k,O,M;return this.negative!==0&&p.negative===0?(M=this.neg().divmod(p,m),m!=="mod"&&(k=M.div.neg()),m!=="div"&&(O=M.mod.neg(),E&&O.negative!==0&&O.iadd(p)),{div:k,mod:O}):this.negative===0&&p.negative!==0?(M=this.divmod(p.neg(),m),m!=="mod"&&(k=M.div.neg()),{div:k,mod:M.mod}):this.negative&p.negative?(M=this.neg().divmod(p.neg(),m),m!=="div"&&(O=M.mod.neg(),E&&O.negative!==0&&O.isub(p)),{div:M.div,mod:O}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?m==="div"?{div:this.divn(p.words[0]),mod:null}:m==="mod"?{div:null,mod:new s(this.modrn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modrn(p.words[0]))}:this._wordDiv(p,m)},s.prototype.div=function(p){return this.divmod(p,"div",!1).div},s.prototype.mod=function(p){return this.divmod(p,"mod",!1).mod},s.prototype.umod=function(p){return this.divmod(p,"mod",!0).mod},s.prototype.divRound=function(p){var m=this.divmod(p);if(m.mod.isZero())return m.div;var E=m.div.negative!==0?m.mod.isub(p):m.mod,k=p.ushrn(1),O=p.andln(1),M=E.cmp(k);return M<0||O===1&&M===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},s.prototype.modrn=function(p){var m=p<0;m&&(p=-p),n(p<=67108863);for(var E=(1<<26)%p,k=0,O=this.length-1;O>=0;O--)k=(E*k+(this.words[O]|0))%p;return m?-k:k},s.prototype.modn=function(p){return this.modrn(p)},s.prototype.idivn=function(p){var m=p<0;m&&(p=-p),n(p<=67108863);for(var E=0,k=this.length-1;k>=0;k--){var O=(this.words[k]|0)+E*67108864;this.words[k]=O/p|0,E=O%p}return this._strip(),m?this.ineg():this},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){n(p.negative===0),n(!p.isZero());var m=this,E=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),O=new s(0),M=new s(0),G=new s(1),P=0;m.isEven()&&E.isEven();)m.iushrn(1),E.iushrn(1),++P;for(var A=E.clone(),U=m.clone();!m.isZero();){for(var le=0,ee=1;!(m.words[0]&ee)&&le<26;++le,ee<<=1);if(le>0)for(m.iushrn(le);le-- >0;)(k.isOdd()||O.isOdd())&&(k.iadd(A),O.isub(U)),k.iushrn(1),O.iushrn(1);for(var re=0,he=1;!(E.words[0]&he)&&re<26;++re,he<<=1);if(re>0)for(E.iushrn(re);re-- >0;)(M.isOdd()||G.isOdd())&&(M.iadd(A),G.isub(U)),M.iushrn(1),G.iushrn(1);m.cmp(E)>=0?(m.isub(E),k.isub(M),O.isub(G)):(E.isub(m),M.isub(k),G.isub(O))}return{a:M,b:G,gcd:E.iushln(P)}},s.prototype._invmp=function(p){n(p.negative===0),n(!p.isZero());var m=this,E=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),O=new s(0),M=E.clone();m.cmpn(1)>0&&E.cmpn(1)>0;){for(var G=0,P=1;!(m.words[0]&P)&&G<26;++G,P<<=1);if(G>0)for(m.iushrn(G);G-- >0;)k.isOdd()&&k.iadd(M),k.iushrn(1);for(var A=0,U=1;!(E.words[0]&U)&&A<26;++A,U<<=1);if(A>0)for(E.iushrn(A);A-- >0;)O.isOdd()&&O.iadd(M),O.iushrn(1);m.cmp(E)>=0?(m.isub(E),k.isub(O)):(E.isub(m),O.isub(k))}var le;return m.cmpn(1)===0?le=k:le=O,le.cmpn(0)<0&&le.iadd(p),le},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var m=this.clone(),E=p.clone();m.negative=0,E.negative=0;for(var k=0;m.isEven()&&E.isEven();k++)m.iushrn(1),E.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;E.isEven();)E.iushrn(1);var O=m.cmp(E);if(O<0){var M=m;m=E,E=M}else if(O===0||E.cmpn(1)===0)break;m.isub(E)}while(!0);return E.iushln(k)},s.prototype.invm=function(p){return this.egcd(p).a.umod(p)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(p){return this.words[0]&p},s.prototype.bincn=function(p){n(typeof p=="number");var m=p%26,E=(p-m)/26,k=1<<m;if(this.length<=E)return this._expand(E+1),this.words[E]|=k,this;for(var O=k,M=E;O!==0&&M<this.length;M++){var G=this.words[M]|0;G+=O,O=G>>>26,G&=67108863,this.words[M]=G}return O!==0&&(this.words[M]=O,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var m=p<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var E;if(this.length>1)E=1;else{m&&(p=-p),n(p<=67108863,"Number is too big");var k=this.words[0]|0;E=k===p?0:k<p?-1:1}return this.negative!==0?-E|0:E},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var m=this.ucmp(p);return this.negative!==0?-m|0:m},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var m=0,E=this.length-1;E>=0;E--){var k=this.words[E]|0,O=p.words[E]|0;if(k!==O){k<O?m=-1:k>O&&(m=1);break}}return m},s.prototype.gtn=function(p){return this.cmpn(p)===1},s.prototype.gt=function(p){return this.cmp(p)===1},s.prototype.gten=function(p){return this.cmpn(p)>=0},s.prototype.gte=function(p){return this.cmp(p)>=0},s.prototype.ltn=function(p){return this.cmpn(p)===-1},s.prototype.lt=function(p){return this.cmp(p)===-1},s.prototype.lten=function(p){return this.cmpn(p)<=0},s.prototype.lte=function(p){return this.cmp(p)<=0},s.prototype.eqn=function(p){return this.cmpn(p)===0},s.prototype.eq=function(p){return this.cmp(p)===0},s.red=function(p){return new ne(p)},s.prototype.toRed=function(p){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(p){return this.red=p,this},s.prototype.forceRed=function(p){return n(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return n(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var V={k256:null,p224:null,p192:null,p25519:null};function Z(B,p){this.name=B,this.p=new s(p,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}Z.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},Z.prototype.ireduce=function(p){var m=p,E;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),E=m.bitLength();while(E>this.n);var k=E<this.n?-1:m.ucmp(this.p);return k===0?(m.words[0]=0,m.length=1):k>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},Z.prototype.split=function(p,m){p.iushrn(this.n,0,m)},Z.prototype.imulK=function(p){return p.imul(this.k)};function K(){Z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(K,Z),K.prototype.split=function(p,m){for(var E=4194303,k=Math.min(p.length,9),O=0;O<k;O++)m.words[O]=p.words[O];if(m.length=k,p.length<=9){p.words[0]=0,p.length=1;return}var M=p.words[9];for(m.words[m.length++]=M&E,O=10;O<p.length;O++){var G=p.words[O]|0;p.words[O-10]=(G&E)<<4|M>>>22,M=G}M>>>=22,p.words[O-10]=M,M===0&&p.length>10?p.length-=10:p.length-=9},K.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var m=0,E=0;E<p.length;E++){var k=p.words[E]|0;m+=k*977,p.words[E]=m&67108863,m=k*64+(m/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function W(){Z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(W,Z);function oe(){Z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(oe,Z);function ce(){Z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(ce,Z),ce.prototype.imulK=function(p){for(var m=0,E=0;E<p.length;E++){var k=(p.words[E]|0)*19+m,O=k&67108863;k>>>=26,p.words[E]=O,m=k}return m!==0&&(p.words[p.length++]=m),p},s._prime=function(p){if(V[p])return V[p];var m;if(p==="k256")m=new K;else if(p==="p224")m=new W;else if(p==="p192")m=new oe;else if(p==="p25519")m=new ce;else throw new Error("Unknown prime "+p);return V[p]=m,m};function ne(B){if(typeof B=="string"){var p=s._prime(B);this.m=p.p,this.prime=p}else n(B.gtn(1),"modulus must be greater than 1"),this.m=B,this.prime=null}ne.prototype._verify1=function(p){n(p.negative===0,"red works only with positives"),n(p.red,"red works only with red numbers")},ne.prototype._verify2=function(p,m){n((p.negative|m.negative)===0,"red works only with positives"),n(p.red&&p.red===m.red,"red works only with red numbers")},ne.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):(h(p,p.umod(this.m)._forceRed(this)),p)},ne.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},ne.prototype.add=function(p,m){this._verify2(p,m);var E=p.add(m);return E.cmp(this.m)>=0&&E.isub(this.m),E._forceRed(this)},ne.prototype.iadd=function(p,m){this._verify2(p,m);var E=p.iadd(m);return E.cmp(this.m)>=0&&E.isub(this.m),E},ne.prototype.sub=function(p,m){this._verify2(p,m);var E=p.sub(m);return E.cmpn(0)<0&&E.iadd(this.m),E._forceRed(this)},ne.prototype.isub=function(p,m){this._verify2(p,m);var E=p.isub(m);return E.cmpn(0)<0&&E.iadd(this.m),E},ne.prototype.shl=function(p,m){return this._verify1(p),this.imod(p.ushln(m))},ne.prototype.imul=function(p,m){return this._verify2(p,m),this.imod(p.imul(m))},ne.prototype.mul=function(p,m){return this._verify2(p,m),this.imod(p.mul(m))},ne.prototype.isqr=function(p){return this.imul(p,p.clone())},ne.prototype.sqr=function(p){return this.mul(p,p)},ne.prototype.sqrt=function(p){if(p.isZero())return p.clone();var m=this.m.andln(3);if(n(m%2===1),m===3){var E=this.m.add(new s(1)).iushrn(2);return this.pow(p,E)}for(var k=this.m.subn(1),O=0;!k.isZero()&&k.andln(1)===0;)O++,k.iushrn(1);n(!k.isZero());var M=new s(1).toRed(this),G=M.redNeg(),P=this.m.subn(1).iushrn(1),A=this.m.bitLength();for(A=new s(2*A*A).toRed(this);this.pow(A,P).cmp(G)!==0;)A.redIAdd(G);for(var U=this.pow(A,k),le=this.pow(p,k.addn(1).iushrn(1)),ee=this.pow(p,k),re=O;ee.cmp(M)!==0;){for(var he=ee,ye=0;he.cmp(M)!==0;ye++)he=he.redSqr();n(ye<re);var be=this.pow(U,new s(1).iushln(re-ye-1));le=le.redMul(be),U=be.redSqr(),ee=ee.redMul(U),re=ye}return le},ne.prototype.invm=function(p){var m=p._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},ne.prototype.pow=function(p,m){if(m.isZero())return new s(1).toRed(this);if(m.cmpn(1)===0)return p.clone();var E=4,k=new Array(1<<E);k[0]=new s(1).toRed(this),k[1]=p;for(var O=2;O<k.length;O++)k[O]=this.mul(k[O-1],p);var M=k[0],G=0,P=0,A=m.bitLength()%26;for(A===0&&(A=26),O=m.length-1;O>=0;O--){for(var U=m.words[O],le=A-1;le>=0;le--){var ee=U>>le&1;if(M!==k[0]&&(M=this.sqr(M)),ee===0&&G===0){P=0;continue}G<<=1,G|=ee,P++,!(P!==E&&(O!==0||le!==0))&&(M=this.mul(M,k[G]),P=0,G=0)}A=26}return M},ne.prototype.convertTo=function(p){var m=p.umod(this.m);return m===p?m.clone():m},ne.prototype.convertFrom=function(p){var m=p.clone();return m.red=null,m},s.mont=function(p){return new ue(p)};function ue(B){ne.call(this,B),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(ue,ne),ue.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},ue.prototype.convertFrom=function(p){var m=this.imod(p.mul(this.rinv));return m.red=null,m},ue.prototype.imul=function(p,m){if(p.isZero()||m.isZero())return p.words[0]=0,p.length=1,p;var E=p.imul(m),k=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=E.isub(k).iushrn(this.shift),M=O;return O.cmp(this.m)>=0?M=O.isub(this.m):O.cmpn(0)<0&&(M=O.iadd(this.m)),M._forceRed(this)},ue.prototype.mul=function(p,m){if(p.isZero()||m.isZero())return new s(0)._forceRed(this);var E=p.mul(m),k=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=E.isub(k).iushrn(this.shift),M=O;return O.cmp(this.m)>=0?M=O.isub(this.m):O.cmpn(0)<0&&(M=O.iadd(this.m)),M._forceRed(this)},ue.prototype.invm=function(p){var m=this.imod(p._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(r,Qr)})(_b);var vb=_b.exports;const Gs=no(vb);function P0(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function HV(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function td(r,...e){if(!HV(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function zV(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");P0(r.outputLen),P0(r.blockLen)}function ll(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function rS(r,e){td(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Gc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function GV(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function Sm(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ui(r,e){return r<<32-e|r>>>e}const DE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function KV(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function $E(r){for(let e=0;e<r.length;e++)r[e]=KV(r[e])}function jV(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Bp(r){return typeof r=="string"&&(r=jV(r)),td(r),r}function WV(...r){let e=0;for(let n=0;n<r.length;n++){const i=r[n];td(i),e+=i.length}const t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){const s=r[n];t.set(s,i),i+=s.length}return t}let Eb=class{clone(){return this._cloneInto()}};function xb(r){const e=n=>r().update(Bp(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function nS(r=32){if(Gc&&typeof Gc.getRandomValues=="function")return Gc.getRandomValues(new Uint8Array(r));if(Gc&&typeof Gc.randomBytes=="function")return Gc.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function VV(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),a=Number(t&s),u=n?4:0,l=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+l,a,n)}function qV(r,e,t){return r&e^~r&t}function ZV(r,e,t){return r&e^r&t^e&t}class iS extends Eb{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Sm(this.buffer)}update(e){ll(this);const{view:t,buffer:n,blockLen:i}=this;e=Bp(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=Sm(e);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ll(this),rS(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let g=o;g<i;g++)t[g]=0;VV(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=Sm(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<l;g++)a.setUint32(4*g,h[g],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}}const Ud=BigInt(2**32-1),H1=BigInt(32);function sS(r,e=!1){return e?{h:Number(r&Ud),l:Number(r>>H1&Ud)}:{h:Number(r>>H1&Ud)|0,l:Number(r&Ud)|0}}function oS(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){const{h:s,l:o}=sS(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}const QV=(r,e)=>BigInt(r>>>0)<<H1|BigInt(e>>>0),JV=(r,e,t)=>r>>>t,YV=(r,e,t)=>r<<32-t|e>>>t,XV=(r,e,t)=>r>>>t|e<<32-t,eq=(r,e,t)=>r<<32-t|e>>>t,tq=(r,e,t)=>r<<64-t|e>>>t-32,rq=(r,e,t)=>r>>>t-32|e<<64-t,nq=(r,e)=>e,iq=(r,e)=>r,aS=(r,e,t)=>r<<t|e>>>32-t,cS=(r,e,t)=>e<<t|r>>>32-t,uS=(r,e,t)=>e<<t-32|r>>>64-t,lS=(r,e,t)=>r<<t-32|e>>>64-t;function sq(r,e,t,n){const i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}const oq=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),aq=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,cq=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),uq=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,lq=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),fq=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0,tt={fromBig:sS,split:oS,toBig:QV,shrSH:JV,shrSL:YV,rotrSH:XV,rotrSL:eq,rotrBH:tq,rotrBL:rq,rotr32H:nq,rotr32L:iq,rotlSH:aS,rotlSL:cS,rotlBH:uS,rotlBL:lS,add:sq,add3L:oq,add3H:aq,add4L:cq,add4H:uq,add5H:fq,add5L:lq},[hq,dq]=tt.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))),lo=new Uint32Array(80),fo=new Uint32Array(80);let pq=class extends iS{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(){const{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:l,El:h,Fh:g,Fl:b,Gh:w,Gl:I,Hh:S,Hl:x}=this;return[e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x]}set(e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=h|0,this.Fh=g|0,this.Fl=b|0,this.Gh=w|0,this.Gl=I|0,this.Hh=S|0,this.Hl=x|0}process(e,t){for(let D=0;D<16;D++,t+=4)lo[D]=e.getUint32(t),fo[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){const z=lo[D-15]|0,V=fo[D-15]|0,Z=tt.rotrSH(z,V,1)^tt.rotrSH(z,V,8)^tt.shrSH(z,V,7),K=tt.rotrSL(z,V,1)^tt.rotrSL(z,V,8)^tt.shrSL(z,V,7),W=lo[D-2]|0,oe=fo[D-2]|0,ce=tt.rotrSH(W,oe,19)^tt.rotrBH(W,oe,61)^tt.shrSH(W,oe,6),ne=tt.rotrSL(W,oe,19)^tt.rotrBL(W,oe,61)^tt.shrSL(W,oe,6),ue=tt.add4L(K,ne,fo[D-7],fo[D-16]),B=tt.add4H(ue,Z,ce,lo[D-7],lo[D-16]);lo[D]=B|0,fo[D]=ue|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:l,Dl:h,Eh:g,El:b,Fh:w,Fl:I,Gh:S,Gl:x,Hh:C,Hl:H}=this;for(let D=0;D<80;D++){const z=tt.rotrSH(g,b,14)^tt.rotrSH(g,b,18)^tt.rotrBH(g,b,41),V=tt.rotrSL(g,b,14)^tt.rotrSL(g,b,18)^tt.rotrBL(g,b,41),Z=g&w^~g&S,K=b&I^~b&x,W=tt.add5L(H,V,K,dq[D],fo[D]),oe=tt.add5H(W,C,z,Z,hq[D],lo[D]),ce=W|0,ne=tt.rotrSH(n,i,28)^tt.rotrBH(n,i,34)^tt.rotrBH(n,i,39),ue=tt.rotrSL(n,i,28)^tt.rotrBL(n,i,34)^tt.rotrBL(n,i,39),B=n&s^n&a^s&a,p=i&o^i&u^o&u;C=S|0,H=x|0,S=w|0,x=I|0,w=g|0,I=b|0,{h:g,l:b}=tt.add(l|0,h|0,oe|0,ce|0),l=a|0,h=u|0,a=s|0,u=o|0,s=n|0,o=i|0;const m=tt.add3L(ce,ue,p);n=tt.add3H(m,oe,ne,B),i=m|0}({h:n,l:i}=tt.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=tt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=tt.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:h}=tt.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:g,l:b}=tt.add(this.Eh|0,this.El|0,g|0,b|0),{h:w,l:I}=tt.add(this.Fh|0,this.Fl|0,w|0,I|0),{h:S,l:x}=tt.add(this.Gh|0,this.Gl|0,S|0,x|0),{h:C,l:H}=tt.add(this.Hh|0,this.Hl|0,C|0,H|0),this.set(n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H)}roundClean(){lo.fill(0),fo.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)}};const gq=xb(()=>new pq);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pp=BigInt(0),Mp=BigInt(1),yq=BigInt(2);function fc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function rd(r){if(!fc(r))throw new Error("Uint8Array expected")}function Qs(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}const mq=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function hc(r){rd(r);let e="";for(let t=0;t<r.length;t++)e+=mq[r[t]];return e}function ru(r){const e=r.toString(16);return e.length&1?"0"+e:e}function Rb(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Pp:BigInt("0x"+r)}const bs={_0:48,_9:57,A:65,F:70,a:97,f:102};function FE(r){if(r>=bs._0&&r<=bs._9)return r-bs._0;if(r>=bs.A&&r<=bs.F)return r-(bs.A-10);if(r>=bs.a&&r<=bs.f)return r-(bs.a-10)}function fl(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){const o=FE(r.charCodeAt(s)),a=FE(r.charCodeAt(s+1));if(o===void 0||a===void 0){const u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+a}return n}function ic(r){return Rb(hc(r))}function hu(r){return rd(r),Rb(hc(Uint8Array.from(r).reverse()))}function hl(r,e){return fl(r.toString(16).padStart(e*2,"0"))}function ah(r,e){return hl(r,e).reverse()}function wq(r){return fl(ru(r))}function Sr(r,e,t){let n;if(typeof e=="string")try{n=fl(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(fc(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");const i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}function dc(...r){let e=0;for(let n=0;n<r.length;n++){const i=r[n];rd(i),e+=i.length}const t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){const s=r[n];t.set(s,i),i+=s.length}return t}function bq(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function _q(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}const km=r=>typeof r=="bigint"&&Pp<=r;function Lp(r,e,t){return km(r)&&km(e)&&km(t)&&e<=r&&r<t}function ci(r,e,t,n){if(!Lp(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function fS(r){let e;for(e=0;r>Pp;r>>=Mp,e+=1);return e}function Aq(r,e){return r>>BigInt(e)&Mp}function vq(r,e,t){return r|(t?Mp:Pp)<<BigInt(e)}const Ib=r=>(yq<<BigInt(r-1))-Mp,Tm=r=>new Uint8Array(r),HE=r=>Uint8Array.from(r);function hS(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Tm(r),i=Tm(r),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>t(i,n,...g),u=(g=Tm())=>{i=a(HE([0]),g),n=a(),g.length!==0&&(i=a(HE([1]),g),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){n=a();const w=n.slice();b.push(w),g+=n.length}return dc(...b)};return(g,b)=>{o(),u(g);let w;for(;!(w=b(l()));)u();return o(),w}}const Eq={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"||fc(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Pl(r,e,t={}){const n=(i,s,o)=>{const a=Eq[s];if(typeof a!="function")throw new Error("invalid validator function");const u=r[i];if(!(o&&u===void 0)&&!a(u,r))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(t))n(i,s,!0);return r}const xq=()=>{throw new Error("not implemented")};function ch(r){const e=new WeakMap;return(t,...n)=>{const i=e.get(t);if(i!==void 0)return i;const s=r(t,...n);return e.set(t,s),s}}const Rq=Object.freeze(Object.defineProperty({__proto__:null,aInRange:ci,abool:Qs,abytes:rd,bitGet:Aq,bitLen:fS,bitMask:Ib,bitSet:vq,bytesToHex:hc,bytesToNumberBE:ic,bytesToNumberLE:hu,concatBytes:dc,createHmacDrbg:hS,ensureBytes:Sr,equalBytes:bq,hexToBytes:fl,hexToNumber:Rb,inRange:Lp,isBytes:fc,memoized:ch,notImplemented:xq,numberToBytesBE:hl,numberToBytesLE:ah,numberToHexUnpadded:ru,numberToVarBytesBE:wq,utf8ToBytes:_q,validateObject:Pl},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fr=BigInt(0),ir=BigInt(1),ma=BigInt(2),Iq=BigInt(3),z1=BigInt(4),zE=BigInt(5),GE=BigInt(8);function Qt(r,e){const t=r%e;return t>=Fr?t:e+t}function Sq(r,e,t){if(e<Fr)throw new Error("invalid exponent, negatives unsupported");if(t<=Fr)throw new Error("invalid modulus");if(t===ir)return Fr;let n=ir;for(;e>Fr;)e&ir&&(n=n*r%t),r=r*r%t,e>>=ir;return n}function br(r,e,t){let n=r;for(;e-- >Fr;)n*=n,n%=t;return n}function G1(r,e){if(r===Fr)throw new Error("invert: expected non-zero number");if(e<=Fr)throw new Error("invert: expected positive modulus, got "+e);let t=Qt(r,e),n=e,i=Fr,s=ir;for(;t!==Fr;){const a=n/t,u=n%t,l=i-s*a;n=t,t=u,i=s,s=l}if(n!==ir)throw new Error("invert: does not exist");return Qt(i,e)}function kq(r){const e=(r-ir)/ma;let t,n,i;for(t=r-ir,n=0;t%ma===Fr;t/=ma,n++);for(i=ma;i<r&&Sq(i,e,r)!==r-ir;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const o=(r+ir)/z1;return function(u,l){const h=u.pow(l,o);if(!u.eql(u.sqr(h),l))throw new Error("Cannot find square root");return h}}const s=(t+ir)/ma;return function(a,u){if(a.pow(u,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),t),g=a.pow(u,s),b=a.pow(u,t);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let w=1;for(let S=a.sqr(b);w<l&&!a.eql(S,a.ONE);w++)S=a.sqr(S);const I=a.pow(h,ir<<BigInt(l-w-1));h=a.sqr(I),g=a.mul(g,I),b=a.mul(b,h),l=w}return g}}function Tq(r){if(r%z1===Iq){const e=(r+ir)/z1;return function(n,i){const s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%GE===zE){const e=(r-zE)/GE;return function(n,i){const s=n.mul(i,ma),o=n.pow(s,e),a=n.mul(i,o),u=n.mul(n.mul(a,ma),o),l=n.mul(a,n.sub(u,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return kq(r)}const Oq=(r,e)=>(Qt(r,e)&ir)===ir,Nq=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Cq(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Nq.reduce((n,i)=>(n[i]="function",n),e);return Pl(r,t)}function Bq(r,e,t){if(t<Fr)throw new Error("invalid exponent, negatives unsupported");if(t===Fr)return r.ONE;if(t===ir)return e;let n=r.ONE,i=e;for(;t>Fr;)t&ir&&(n=r.mul(n,i)),i=r.sqr(i),t>>=ir;return n}function Pq(r,e){const t=new Array(e.length),n=e.reduce((s,o,a)=>r.is0(o)?s:(t[a]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,a)=>r.is0(o)?s:(t[a]=r.mul(s,t[a]),r.mul(s,o)),i),t}function dS(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Up(r,e,t=!1,n={}){if(r<=Fr)throw new Error("invalid field: expected ORDER > 0, got "+r);const{nBitLength:i,nByteLength:s}=dS(r,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:r,isLE:t,BITS:i,BYTES:s,MASK:Ib(i),ZERO:Fr,ONE:ir,create:u=>Qt(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return Fr<=u&&u<r},is0:u=>u===Fr,isOdd:u=>(u&ir)===ir,neg:u=>Qt(-u,r),eql:(u,l)=>u===l,sqr:u=>Qt(u*u,r),add:(u,l)=>Qt(u+l,r),sub:(u,l)=>Qt(u-l,r),mul:(u,l)=>Qt(u*l,r),pow:(u,l)=>Bq(a,u,l),div:(u,l)=>Qt(u*G1(l,r),r),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>G1(u,r),sqrt:n.sqrt||(u=>(o||(o=Tq(r)),o(a,u))),invertBatch:u=>Pq(a,u),cmov:(u,l,h)=>h?l:u,toBytes:u=>t?ah(u,s):hl(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return t?hu(u):ic(u)}});return Object.freeze(a)}function pS(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function gS(r){const e=pS(r);return e+Math.ceil(e/2)}function Mq(r,e,t=!1){const n=r.length,i=pS(e),s=gS(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);const o=t?hu(r):ic(r),a=Qt(o,e-ir)+ir;return t?ah(a,i):hl(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const KE=BigInt(0),Dd=BigInt(1);function Om(r,e){const t=e.negate();return r?t:e}function yS(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Nm(r,e){yS(r,e);const t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function Lq(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function Uq(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}const Cm=new WeakMap,mS=new WeakMap;function Bm(r){return mS.get(r)||1}function wS(r,e){return{constTimeNegate:Om,hasPrecomputes(t){return Bm(t)!==1},unsafeLadder(t,n,i=r.ZERO){let s=t;for(;n>KE;)n&Dd&&(i=i.add(s)),s=s.double(),n>>=Dd;return i},precomputeWindow(t,n){const{windows:i,windowSize:s}=Nm(n,e),o=[];let a=t,u=a;for(let l=0;l<i;l++){u=a,o.push(u);for(let h=1;h<s;h++)u=u.add(a),o.push(u);a=u.double()}return o},wNAF(t,n,i){const{windows:s,windowSize:o}=Nm(t,e);let a=r.ZERO,u=r.BASE;const l=BigInt(2**t-1),h=2**t,g=BigInt(t);for(let b=0;b<s;b++){const w=b*o;let I=Number(i&l);i>>=g,I>o&&(I-=h,i+=Dd);const S=w,x=w+Math.abs(I)-1,C=b%2!==0,H=I<0;I===0?u=u.add(Om(C,n[S])):a=a.add(Om(H,n[x]))}return{p:a,f:u}},wNAFUnsafe(t,n,i,s=r.ZERO){const{windows:o,windowSize:a}=Nm(t,e),u=BigInt(2**t-1),l=2**t,h=BigInt(t);for(let g=0;g<o;g++){const b=g*a;if(i===KE)break;let w=Number(i&u);if(i>>=h,w>a&&(w-=l,i+=Dd),w===0)continue;let I=n[b+Math.abs(w)-1];w<0&&(I=I.negate()),s=s.add(I)}return s},getPrecomputes(t,n,i){let s=Cm.get(n);return s||(s=this.precomputeWindow(n,t),t!==1&&Cm.set(n,i(s))),s},wNAFCached(t,n,i){const s=Bm(t);return this.wNAF(s,this.getPrecomputes(s,t,i),n)},wNAFCachedUnsafe(t,n,i,s){const o=Bm(t);return o===1?this.unsafeLadder(t,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),n,s)},setWindowSize(t,n){yS(n,e),mS.set(t,n),Cm.delete(t)}}}function bS(r,e,t,n){if(Lq(t,r),Uq(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const i=r.ZERO,s=fS(BigInt(t.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,u=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let h=i;for(let g=l;g>=0;g-=o){u.fill(i);for(let w=0;w<n.length;w++){const I=n[w],S=Number(I>>BigInt(g)&BigInt(a));u[S]=u[S].add(t[w])}let b=i;for(let w=u.length-1,I=i;w>0;w--)I=I.add(u[w]),b=b.add(I);if(h=h.add(b),g!==0)for(let w=0;w<o;w++)h=h.double()}return h}function Sb(r){return Cq(r.Fp),Pl(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...dS(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gi=BigInt(0),En=BigInt(1),$d=BigInt(2),Dq=BigInt(8),$q={zip215:!0};function Fq(r){const e=Sb(r);return Pl(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Hq(r){const e=Fq(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:u}=e,l=$d<<BigInt(a*8)-En,h=t.create,g=Up(e.n,e.nBitLength),b=e.uvRatio||((E,k)=>{try{return{isValid:!0,value:t.sqrt(E*t.inv(k))}}catch{return{isValid:!1,value:gi}}}),w=e.adjustScalarBytes||(E=>E),I=e.domain||((E,k,O)=>{if(Qs("phflag",O),k.length||O)throw new Error("Contexts/pre-hash are not supported");return E});function S(E,k){ci("coordinate "+E,k,gi,l)}function x(E){if(!(E instanceof D))throw new Error("ExtendedPoint expected")}const C=ch((E,k)=>{const{ex:O,ey:M,ez:G}=E,P=E.is0();k==null&&(k=P?Dq:t.inv(G));const A=h(O*k),U=h(M*k),le=h(G*k);if(P)return{x:gi,y:En};if(le!==En)throw new Error("invZ was invalid");return{x:A,y:U}}),H=ch(E=>{const{a:k,d:O}=e;if(E.is0())throw new Error("bad point: ZERO");const{ex:M,ey:G,ez:P,et:A}=E,U=h(M*M),le=h(G*G),ee=h(P*P),re=h(ee*ee),he=h(U*k),ye=h(ee*h(he+le)),be=h(re+h(O*h(U*le)));if(ye!==be)throw new Error("bad point: equation left != right (1)");const je=h(M*G),$e=h(P*A);if(je!==$e)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(k,O,M,G){this.ex=k,this.ey=O,this.ez=M,this.et=G,S("x",k),S("y",O),S("z",M),S("t",G),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(k){if(k instanceof D)throw new Error("extended point not allowed");const{x:O,y:M}=k||{};return S("x",O),S("y",M),new D(O,M,En,h(O*M))}static normalizeZ(k){const O=t.invertBatch(k.map(M=>M.ez));return k.map((M,G)=>M.toAffine(O[G])).map(D.fromAffine)}static msm(k,O){return bS(D,g,k,O)}_setWindowSize(k){Z.setWindowSize(this,k)}assertValidity(){H(this)}equals(k){x(k);const{ex:O,ey:M,ez:G}=this,{ex:P,ey:A,ez:U}=k,le=h(O*U),ee=h(P*G),re=h(M*U),he=h(A*G);return le===ee&&re===he}is0(){return this.equals(D.ZERO)}negate(){return new D(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:k}=e,{ex:O,ey:M,ez:G}=this,P=h(O*O),A=h(M*M),U=h($d*h(G*G)),le=h(k*P),ee=O+M,re=h(h(ee*ee)-P-A),he=le+A,ye=he-U,be=le-A,je=h(re*ye),$e=h(he*be),Oe=h(re*be),Xe=h(ye*he);return new D(je,$e,Xe,Oe)}add(k){x(k);const{a:O,d:M}=e,{ex:G,ey:P,ez:A,et:U}=this,{ex:le,ey:ee,ez:re,et:he}=k;if(O===BigInt(-1)){const Et=h((P-G)*(ee+le)),St=h((P+G)*(ee-le)),Ar=h(St-Et);if(Ar===gi)return this.double();const ft=h(A*$d*he),xt=h(U*$d*re),Yt=xt+ft,bt=St+Et,kt=xt-ft,Xr=h(Yt*Ar),Lt=h(bt*kt),N=h(Yt*kt),_=h(Ar*bt);return new D(Xr,Lt,_,N)}const ye=h(G*le),be=h(P*ee),je=h(U*M*he),$e=h(A*re),Oe=h((G+P)*(le+ee)-ye-be),Xe=$e-je,qe=$e+je,et=h(be-O*ye),Jt=h(Oe*Xe),lt=h(qe*et),Mt=h(Oe*et),oo=h(Xe*qe);return new D(Jt,lt,oo,Mt)}subtract(k){return this.add(k.negate())}wNAF(k){return Z.wNAFCached(this,k,D.normalizeZ)}multiply(k){const O=k;ci("scalar",O,En,n);const{p:M,f:G}=this.wNAF(O);return D.normalizeZ([M,G])[0]}multiplyUnsafe(k,O=D.ZERO){const M=k;return ci("scalar",M,gi,n),M===gi?V:this.is0()||M===En?this:Z.wNAFCachedUnsafe(this,M,D.normalizeZ,O)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return Z.unsafeLadder(this,n).is0()}toAffine(k){return C(this,k)}clearCofactor(){const{h:k}=e;return k===En?this:this.multiplyUnsafe(k)}static fromHex(k,O=!1){const{d:M,a:G}=e,P=t.BYTES;k=Sr("pointHex",k,P),Qs("zip215",O);const A=k.slice(),U=k[P-1];A[P-1]=U&-129;const le=hu(A),ee=O?l:t.ORDER;ci("pointHex.y",le,gi,ee);const re=h(le*le),he=h(re-En),ye=h(M*re-G);let{isValid:be,value:je}=b(he,ye);if(!be)throw new Error("Point.fromHex: invalid y coordinate");const $e=(je&En)===En,Oe=(U&128)!==0;if(!O&&je===gi&&Oe)throw new Error("Point.fromHex: x=0 and x_0=1");return Oe!==$e&&(je=h(-je)),D.fromAffine({x:je,y:le})}static fromPrivateKey(k){return oe(k).point}toRawBytes(){const{x:k,y:O}=this.toAffine(),M=ah(O,t.BYTES);return M[M.length-1]|=k&En?128:0,M}toHex(){return hc(this.toRawBytes())}}D.BASE=new D(e.Gx,e.Gy,En,h(e.Gx*e.Gy)),D.ZERO=new D(gi,En,En,gi);const{BASE:z,ZERO:V}=D,Z=wS(D,a*8);function K(E){return Qt(E,n)}function W(E){return K(hu(E))}function oe(E){const k=t.BYTES;E=Sr("private key",E,k);const O=Sr("hashed private key",s(E),2*k),M=w(O.slice(0,k)),G=O.slice(k,2*k),P=W(M),A=z.multiply(P),U=A.toRawBytes();return{head:M,prefix:G,scalar:P,point:A,pointBytes:U}}function ce(E){return oe(E).pointBytes}function ne(E=new Uint8Array,...k){const O=dc(...k);return W(s(I(O,Sr("context",E),!!i)))}function ue(E,k,O={}){E=Sr("message",E),i&&(E=i(E));const{prefix:M,scalar:G,pointBytes:P}=oe(k),A=ne(O.context,M,E),U=z.multiply(A).toRawBytes(),le=ne(O.context,U,P,E),ee=K(A+le*G);ci("signature.s",ee,gi,n);const re=dc(U,ah(ee,t.BYTES));return Sr("result",re,t.BYTES*2)}const B=$q;function p(E,k,O,M=B){const{context:G,zip215:P}=M,A=t.BYTES;E=Sr("signature",E,2*A),k=Sr("message",k),O=Sr("publicKey",O,A),P!==void 0&&Qs("zip215",P),i&&(k=i(k));const U=hu(E.slice(A,2*A));let le,ee,re;try{le=D.fromHex(O,P),ee=D.fromHex(E.slice(0,A),P),re=z.multiplyUnsafe(U)}catch{return!1}if(!P&&le.isSmallOrder())return!1;const he=ne(G,ee.toRawBytes(),le.toRawBytes(),k);return ee.add(le.multiplyUnsafe(he)).subtract(re).clearCofactor().equals(D.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:ce,sign:ue,verify:p,ExtendedPoint:D,utils:{getExtendedPublicKey:oe,randomPrivateKey:()=>o(t.BYTES),precompute(E=8,k=D.BASE){return k._setWindowSize(E),k.multiply(BigInt(3)),k}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kb=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),jE=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const zq=BigInt(1),WE=BigInt(2);BigInt(3);const Gq=BigInt(5),Kq=BigInt(8);function jq(r){const e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=kb,a=r*r%s*r%s,u=br(a,WE,s)*a%s,l=br(u,zq,s)*r%s,h=br(l,Gq,s)*l%s,g=br(h,e,s)*h%s,b=br(g,t,s)*g%s,w=br(b,n,s)*b%s,I=br(w,i,s)*w%s,S=br(I,i,s)*w%s,x=br(S,e,s)*h%s;return{pow_p_5_8:br(x,WE,s)*r%s,b2:a}}function Wq(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Vq(r,e){const t=kb,n=Qt(e*e*e,t),i=Qt(n*n*e,t),s=jq(r*i).pow_p_5_8;let o=Qt(r*n*s,t);const a=Qt(e*o*o,t),u=o,l=Qt(o*jE,t),h=a===r,g=a===Qt(-r,t),b=a===Qt(-r*jE,t);return h&&(o=u),(g||b)&&(o=l),Oq(o,t)&&(o=Qt(-o,t)),{isValid:h||g,value:o}}const qq=Up(kb,void 0,!0),Zq={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:qq,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Kq,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:gq,randomBytes:nS,adjustScalarBytes:Wq,uvRatio:Vq},Ml=Hq(Zq);var K1={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,e){var t=Ab,n=t.Buffer;function i(o,a){for(var u in o)a[u]=o[u]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?r.exports=t:(i(t,e),e.Buffer=s);function s(o,a,u){return n(o,a,u)}s.prototype=Object.create(n.prototype),i(n,s),s.from=function(o,a,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,u)},s.alloc=function(o,a,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var l=n(o);return a!==void 0?typeof u=="string"?l.fill(a,u):l.fill(a):l.fill(0),l},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}})(K1,K1.exports);var Qq=K1.exports,Fd=Qq.Buffer;function Jq(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var n=0;n<r.length;n++){var i=r.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var o=r.length,a=r.charAt(0),u=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function h(w){if((Array.isArray(w)||w instanceof Uint8Array)&&(w=Fd.from(w)),!Fd.isBuffer(w))throw new TypeError("Expected Buffer");if(w.length===0)return"";for(var I=0,S=0,x=0,C=w.length;x!==C&&w[x]===0;)x++,I++;for(var H=(C-x)*l+1>>>0,D=new Uint8Array(H);x!==C;){for(var z=w[x],V=0,Z=H-1;(z!==0||V<S)&&Z!==-1;Z--,V++)z+=256*D[Z]>>>0,D[Z]=z%o>>>0,z=z/o>>>0;if(z!==0)throw new Error("Non-zero carry");S=V,x++}for(var K=H-S;K!==H&&D[K]===0;)K++;for(var W=a.repeat(I);K<H;++K)W+=r.charAt(D[K]);return W}function g(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return Fd.alloc(0);for(var I=0,S=0,x=0;w[I]===a;)S++,I++;for(var C=(w.length-I)*u+1>>>0,H=new Uint8Array(C);I<w.length;){var D=w.charCodeAt(I);if(D>255)return;var z=e[D];if(z===255)return;for(var V=0,Z=C-1;(z!==0||V<x)&&Z!==-1;Z--,V++)z+=o*H[Z]>>>0,H[Z]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");x=V,I++}for(var K=C-x;K!==C&&H[K]===0;)K++;var W=Fd.allocUnsafe(S+(C-K));W.fill(0,0,S);for(var oe=S;K!==C;)W[oe++]=H[K++];return W}function b(w){var I=g(w);if(I)return I;throw new Error("Non-base"+o+" character")}return{encode:h,decodeUnsafe:g,decode:b}}var Yq=Jq,Xq=Yq,eZ="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",_S=Xq(eZ);const kr=no(_S),tZ=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]),ho=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),po=new Uint32Array(64);let rZ=class extends iS{constructor(){super(64,32,8,!1),this.A=ho[0]|0,this.B=ho[1]|0,this.C=ho[2]|0,this.D=ho[3]|0,this.E=ho[4]|0,this.F=ho[5]|0,this.G=ho[6]|0,this.H=ho[7]|0}get(){const{A:e,B:t,C:n,D:i,E:s,F:o,G:a,H:u}=this;return[e,t,n,i,s,o,a,u]}set(e,t,n,i,s,o,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(e,t){for(let g=0;g<16;g++,t+=4)po[g]=e.getUint32(t,!1);for(let g=16;g<64;g++){const b=po[g-15],w=po[g-2],I=Ui(b,7)^Ui(b,18)^b>>>3,S=Ui(w,17)^Ui(w,19)^w>>>10;po[g]=S+po[g-7]+I+po[g-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:u,G:l,H:h}=this;for(let g=0;g<64;g++){const b=Ui(a,6)^Ui(a,11)^Ui(a,25),w=h+b+qV(a,u,l)+tZ[g]+po[g]|0,S=(Ui(n,2)^Ui(n,13)^Ui(n,22))+ZV(n,i,s)|0;h=l,l=u,u=a,a=o+w|0,o=s,s=i,i=n,n=w+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,u,l,h)}roundClean(){po.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const j1=xb(()=>new rZ);var Vr={};function Ks(r,e,t){return e<=r&&r<=t}function Dp(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function nZ(r){for(var e=String(r),t=e.length,n=0,i=[];n<t;){var s=e.charCodeAt(n);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(n===t-1)i.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var a=s&1023,u=o&1023;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}function iZ(r){for(var e="",t=0;t<r.length;++t){var n=r[t];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return e}var M0=-1;function Tb(r){this.tokens=[].slice.call(r)}Tb.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():M0},prepend:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var e=r;e.length;)this.tokens.push(e.shift());else this.tokens.push(r)}};var dl=-1;function Pm(r,e){if(r)throw TypeError("Decoder error");return e||65533}var L0="utf-8";function U0(r,e){if(!(this instanceof U0))return new U0(r,e);if(r=r!==void 0?String(r).toLowerCase():L0,r!==L0)throw new Error("Encoding not supported. Only utf-8 is supported");e=Dp(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}U0.prototype={decode:function(e,t){var n;typeof e=="object"&&e instanceof ArrayBuffer?n=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):n=new Uint8Array(0),t=Dp(t),this._streaming||(this._decoder=new sZ({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var i=new Tb(n),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==dl);)o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===dl)break;o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o))}while(!i.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),iZ(s)}};function D0(r,e){if(!(this instanceof D0))return new D0(r,e);if(r=r!==void 0?String(r).toLowerCase():L0,r!==L0)throw new Error("Encoding not supported. Only utf-8 is supported");e=Dp(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}D0.prototype={encode:function(e,t){e=e?String(e):"",t=Dp(t),this._streaming||(this._encoder=new oZ(this._options)),this._streaming=!!t.stream;for(var n=[],i=new Tb(nZ(e)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==dl);)Array.isArray(s)?n.push.apply(n,s):n.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==dl;)Array.isArray(s)?n.push.apply(n,s):n.push(s);this._encoder=null}return new Uint8Array(n)}};function sZ(r){var e=r.fatal,t=0,n=0,i=0,s=128,o=191;this.handler=function(a,u){if(u===M0&&i!==0)return i=0,Pm(e);if(u===M0)return dl;if(i===0){if(Ks(u,0,127))return u;if(Ks(u,194,223))i=1,t=u-192;else if(Ks(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,t=u-224;else if(Ks(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,t=u-240;else return Pm(e);return t=t<<6*i,null}if(!Ks(u,s,o))return t=i=n=0,s=128,o=191,a.prepend(u),Pm(e);if(s=128,o=191,n+=1,t+=u-128<<6*(i-n),n!==i)return null;var l=t;return t=i=n=0,l}}function oZ(r){r.fatal,this.handler=function(e,t){if(t===M0)return dl;if(Ks(t,0,127))return t;var n,i;Ks(t,128,2047)?(n=1,i=192):Ks(t,2048,65535)?(n=2,i=224):Ks(t,65536,1114111)&&(n=3,i=240);for(var s=[(t>>6*n)+i];n>0;){var o=t>>6*(n-1);s.push(128|o&63),n-=1}return s}}const aZ=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:U0,TextEncoder:D0},Symbol.toStringTag,{value:"Module"})),cZ=gp(aZ);var uZ=Qr&&Qr.__createBinding||(Object.create?function(r,e,t,n){n===void 0&&(n=t),Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[t]}})}:function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}),lZ=Qr&&Qr.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),ds=Qr&&Qr.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},fZ=Qr&&Qr.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.hasOwnProperty.call(r,t)&&uZ(e,r,t);return lZ(e,r),e},AS=Qr&&Qr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Vr,"__esModule",{value:!0});var vS=Vr.deserializeUnchecked=kS=Vr.deserialize=SS=Vr.serialize=Vr.BinaryReader=Vr.BinaryWriter=Vr.BorshError=Vr.baseDecode=Vr.baseEncode=void 0;const Go=AS(vb),ES=AS(_S),hZ=fZ(cZ),dZ=typeof TextDecoder!="function"?hZ.TextDecoder:TextDecoder,pZ=new dZ("utf-8",{fatal:!0});function gZ(r){return typeof r=="string"&&(r=Qe.from(r,"utf8")),ES.default.encode(Qe.from(r))}Vr.baseEncode=gZ;function yZ(r){return Qe.from(ES.default.decode(r))}Vr.baseDecode=yZ;const Mm=1024;class gn extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Vr.BorshError=gn;class xS{constructor(){this.buf=Qe.alloc(Mm),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Qe.concat([this.buf,Qe.alloc(Mm)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Qe.from(new Go.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Qe.from(new Go.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Qe.from(new Go.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Qe.from(new Go.default(e).toArray("le",64)))}writeBuffer(e){this.buf=Qe.concat([Qe.from(this.buf.subarray(0,this.length)),e,Qe.alloc(Mm)]),this.length+=e.length}writeString(e){this.maybeResize();const t=Qe.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Qe.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(const n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}}Vr.BinaryWriter=xS;function ps(r,e,t){const n=t.value;t.value=function(...i){try{return n.apply(this,i)}catch(s){if(s instanceof RangeError){const o=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new gn("Reached the end of buffer when deserializing")}throw s}}}class Zn{constructor(e){this.buf=e,this.offset=0}readU8(){const e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){const e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){const e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){const e=this.readBuffer(8);return new Go.default(e,"le")}readU128(){const e=this.readBuffer(16);return new Go.default(e,"le")}readU256(){const e=this.readBuffer(32);return new Go.default(e,"le")}readU512(){const e=this.readBuffer(64);return new Go.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new gn(`Expected buffer length ${e} isn't within bounds`);const t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){const e=this.readU32(),t=this.readBuffer(e);try{return pZ.decode(t)}catch(n){throw new gn(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){const t=this.readU32(),n=Array();for(let i=0;i<t;++i)n.push(e());return n}}ds([ps],Zn.prototype,"readU8",null);ds([ps],Zn.prototype,"readU16",null);ds([ps],Zn.prototype,"readU32",null);ds([ps],Zn.prototype,"readU64",null);ds([ps],Zn.prototype,"readU128",null);ds([ps],Zn.prototype,"readU256",null);ds([ps],Zn.prototype,"readU512",null);ds([ps],Zn.prototype,"readString",null);ds([ps],Zn.prototype,"readFixedArray",null);ds([ps],Zn.prototype,"readArray",null);Vr.BinaryReader=Zn;function RS(r){return r.charAt(0).toUpperCase()+r.slice(1)}function wa(r,e,t,n,i){try{if(typeof n=="string")i[`write${RS(n)}`](t);else if(n instanceof Array)if(typeof n[0]=="number"){if(t.length!==n[0])throw new gn(`Expecting byte array of length ${n[0]}, but got ${t.length} bytes`);i.writeFixedArray(t)}else if(n.length===2&&typeof n[1]=="number"){if(t.length!==n[1])throw new gn(`Expecting byte array of length ${n[1]}, but got ${t.length} bytes`);for(let s=0;s<n[1];s++)wa(r,null,t[s],n[0],i)}else i.writeArray(t,s=>{wa(r,e,s,n[0],i)});else if(n.kind!==void 0)switch(n.kind){case"option":{t==null?i.writeU8(0):(i.writeU8(1),wa(r,e,t,n.type,i));break}case"map":{i.writeU32(t.size),t.forEach((s,o)=>{wa(r,e,o,n.key,i),wa(r,e,s,n.value,i)});break}default:throw new gn(`FieldType ${n} unrecognized`)}else IS(r,t,i)}catch(s){throw s instanceof gn&&s.addToFieldPath(e),s}}function IS(r,e,t){if(typeof e.borshSerialize=="function"){e.borshSerialize(t);return}const n=r.get(e.constructor);if(!n)throw new gn(`Class ${e.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([i,s])=>{wa(r,i,e[i],s,t)});else if(n.kind==="enum"){const i=e[n.field];for(let s=0;s<n.values.length;++s){const[o,a]=n.values[s];if(o===i){t.writeU8(s),wa(r,o,e[o],a,t);break}}}else throw new gn(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function mZ(r,e,t=xS){const n=new t;return IS(r,e,n),n.toArray()}var SS=Vr.serialize=mZ;function ba(r,e,t,n){try{if(typeof t=="string")return n[`read${RS(t)}`]();if(t instanceof Array){if(typeof t[0]=="number")return n.readFixedArray(t[0]);if(typeof t[1]=="number"){const i=[];for(let s=0;s<t[1];s++)i.push(ba(r,null,t[0],n));return i}else return n.readArray(()=>ba(r,e,t[0],n))}if(t.kind==="option")return n.readU8()?ba(r,e,t.type,n):void 0;if(t.kind==="map"){let i=new Map;const s=n.readU32();for(let o=0;o<s;o++){const a=ba(r,e,t.key,n),u=ba(r,e,t.value,n);i.set(a,u)}return i}return Ob(r,t,n)}catch(i){throw i instanceof gn&&i.addToFieldPath(e),i}}function Ob(r,e,t){if(typeof e.borshDeserialize=="function")return e.borshDeserialize(t);const n=r.get(e);if(!n)throw new gn(`Class ${e.name} is missing in schema`);if(n.kind==="struct"){const i={};for(const[s,o]of r.get(e).fields)i[s]=ba(r,s,o,t);return new e(i)}if(n.kind==="enum"){const i=t.readU8();if(i>=n.values.length)throw new gn(`Enum index: ${i} is out of range`);const[s,o]=n.values[i],a=ba(r,s,o,t);return new e({[s]:a})}throw new gn(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}function wZ(r,e,t,n=Zn){const i=new n(t),s=Ob(r,e,i);if(i.offset<t.length)throw new gn(`Unexpected ${t.length-i.offset} bytes after deserialized data`);return s}var kS=Vr.deserialize=wZ;function bZ(r,e,t,n=Zn){const i=new n(t);return Ob(r,e,i)}vS=Vr.deserializeUnchecked=bZ;var ie={};Object.defineProperty(ie,"__esModule",{value:!0});ie.s16=ie.s8=ie.nu64be=ie.u48be=ie.u40be=ie.u32be=ie.u24be=ie.u16be=Kr=ie.nu64=ie.u48=ie.u40=Be=ie.u32=ie.u24=ai=ie.u16=mt=ie.u8=Wo=ie.offset=ie.greedy=ie.Constant=ie.UTF8=ie.CString=ie.Blob=ie.Boolean=ie.BitField=ie.BitStructure=ie.VariantLayout=ie.Union=ie.UnionLayoutDiscriminator=ie.UnionDiscriminator=ie.Structure=ie.Sequence=ie.DoubleBE=ie.Double=ie.FloatBE=ie.Float=ie.NearInt64BE=ie.NearInt64=ie.NearUInt64BE=ie.NearUInt64=ie.IntBE=ie.Int=ie.UIntBE=ie.UInt=ie.OffsetLayout=ie.GreedyCount=ie.ExternalLayout=ie.bindConstructorLayout=ie.nameWithProperty=ie.Layout=ie.uint8ArrayToBuffer=ie.checkUint8Array=void 0;ie.constant=ie.utf8=ie.cstr=Kt=ie.blob=ie.unionLayoutDiscriminator=ie.union=Jr=ie.seq=ie.bits=Pe=ie.struct=ie.f64be=ie.f64=ie.f32be=ie.f32=ie.ns64be=ie.s48be=ie.s40be=ie.s32be=ie.s24be=ie.s16be=jn=ie.ns64=ie.s48=ie.s40=ie.s32=ie.s24=void 0;const Nb=Ab;function Ll(r){if(!(r instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}ie.checkUint8Array=Ll;function vt(r){return Ll(r),Nb.Buffer.from(r.buffer,r.byteOffset,r.length)}ie.uint8ArrayToBuffer=vt;let Ot=class{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};ie.Layout=Ot;function Cb(r,e){return e.property?r+"["+e.property+"]":r}ie.nameWithProperty=Cb;function _Z(r,e){if(typeof r!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(r,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Ot))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=e,e.boundConstructor_=r,e.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(r,"decode",{value(t,n){return e.decode(t,n)},writable:!0})}ie.bindConstructorLayout=_Z;let On=class extends Ot{isCount(){throw new Error("ExternalLayout is abstract")}};ie.ExternalLayout=On;let TS=class extends On{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){Ll(e);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}};ie.GreedyCount=TS;let Bb=class extends On{constructor(e,t=0,n){if(!(e instanceof Ot))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof li||this.layout instanceof Si}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};ie.OffsetLayout=Bb;let li=class extends Ot{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return vt(e).readUIntLE(t,this.span)}encode(e,t,n=0){return vt(t).writeUIntLE(e,n,this.span),this.span}};ie.UInt=li;let Si=class extends Ot{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return vt(e).readUIntBE(t,this.span)}encode(e,t,n=0){return vt(t).writeUIntBE(e,n,this.span),this.span}};ie.UIntBE=Si;let Sc=class extends Ot{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return vt(e).readIntLE(t,this.span)}encode(e,t,n=0){return vt(t).writeIntLE(e,n,this.span),this.span}};ie.Int=Sc;let Ul=class extends Ot{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return vt(e).readIntBE(t,this.span)}encode(e,t,n=0){return vt(t).writeIntBE(e,n,this.span),this.span}};ie.IntBE=Ul;const W1=Math.pow(2,32);function $p(r){const e=Math.floor(r/W1),t=r-e*W1;return{hi32:e,lo32:t}}function Fp(r,e){return r*W1+e}let OS=class extends Ot{constructor(e){super(8,e)}decode(e,t=0){const n=vt(e),i=n.readUInt32LE(t),s=n.readUInt32LE(t+4);return Fp(s,i)}encode(e,t,n=0){const i=$p(e),s=vt(t);return s.writeUInt32LE(i.lo32,n),s.writeUInt32LE(i.hi32,n+4),8}};ie.NearUInt64=OS;let NS=class extends Ot{constructor(e){super(8,e)}decode(e,t=0){const n=vt(e),i=n.readUInt32BE(t),s=n.readUInt32BE(t+4);return Fp(i,s)}encode(e,t,n=0){const i=$p(e),s=vt(t);return s.writeUInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};ie.NearUInt64BE=NS;let CS=class extends Ot{constructor(e){super(8,e)}decode(e,t=0){const n=vt(e),i=n.readUInt32LE(t),s=n.readInt32LE(t+4);return Fp(s,i)}encode(e,t,n=0){const i=$p(e),s=vt(t);return s.writeUInt32LE(i.lo32,n),s.writeInt32LE(i.hi32,n+4),8}};ie.NearInt64=CS;let BS=class extends Ot{constructor(e){super(8,e)}decode(e,t=0){const n=vt(e),i=n.readInt32BE(t),s=n.readUInt32BE(t+4);return Fp(i,s)}encode(e,t,n=0){const i=$p(e),s=vt(t);return s.writeInt32BE(i.hi32,n),s.writeUInt32BE(i.lo32,n+4),8}};ie.NearInt64BE=BS;let PS=class extends Ot{constructor(e){super(4,e)}decode(e,t=0){return vt(e).readFloatLE(t)}encode(e,t,n=0){return vt(t).writeFloatLE(e,n),4}};ie.Float=PS;let MS=class extends Ot{constructor(e){super(4,e)}decode(e,t=0){return vt(e).readFloatBE(t)}encode(e,t,n=0){return vt(t).writeFloatBE(e,n),4}};ie.FloatBE=MS;let LS=class extends Ot{constructor(e){super(8,e)}decode(e,t=0){return vt(e).readDoubleLE(t)}encode(e,t,n=0){return vt(t).writeDoubleLE(e,n),8}};ie.Double=LS;let US=class extends Ot{constructor(e){super(8,e)}decode(e,t=0){return vt(e).readDoubleBE(t)}encode(e,t,n=0){return vt(t).writeDoubleBE(e,n),8}};ie.DoubleBE=US;let DS=class extends Ot{constructor(e,t,n){if(!(e instanceof Ot))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof On&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(t instanceof On)&&0<e.span&&(i=t*e.span),super(i,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,i=this.count;if(i instanceof On&&(i=i.decode(e,t)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let s=0;for(;s<i;)n+=this.elementLayout.getSpan(e,t+n),++s}return n}decode(e,t=0){const n=[];let i=0,s=this.count;for(s instanceof On&&(s=s.decode(e,t));i<s;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return n}encode(e,t,n=0){const i=this.elementLayout,s=e.reduce((o,a)=>o+i.encode(a,t,n+o),0);return this.count instanceof On&&this.count.encode(e.length,t,n),s}};ie.Sequence=DS;let $S=class extends Ot{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Ot,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t=0){Ll(e);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};ie.Structure=$S;let Pb=class{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,n){throw new Error("UnionDiscriminator is abstract")}};ie.UnionDiscriminator=Pb;let $0=class extends Pb{constructor(e,t){if(!(e instanceof On&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};ie.UnionLayoutDiscriminator=$0;let Mb=class extends Ot{constructor(e,t,n){let i;if(e instanceof li||e instanceof Si)i=new $0(new Bb(e));else if(e instanceof On&&e.isCount())i=new $0(e);else if(e instanceof Pb)i=e;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Ot))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&(e instanceof li||e instanceof Si)&&(s+=i.layout.span)),super(s,n),this.discriminator=i,this.usesPrefixDiscriminator=e instanceof li||e instanceof Si,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw new Error("unable to infer src variant")}decode(e,t=0){let n;const i=this.discriminator,s=i.decode(e,t),o=this.registry[s];if(o===void 0){const a=this.defaultLayout;let u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[a.property]=a.decode(e,t+u)}else n=o.decode(e,t);return n}encode(e,t,n=0){const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new FS(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t=0){let n;return e instanceof Uint8Array?n=this.discriminator.decode(e,t):n=e,this.registry[n]}};ie.Union=Mb;let FS=class extends Ot{constructor(e,t,n,i){if(!(e instanceof Mb))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Ot))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(e,t+n)),n+i}decode(e,t=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};ie.VariantLayout=FS;function Qc(r){return 0>r&&(r+=4294967296),r}let Lb=class extends Ot{constructor(e,t,n){if(!(e instanceof li||e instanceof Si))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&n===void 0&&(n=t,t=!1),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(s){return i=Qc(s),this},this._packedGetValue=function(){return i}}decode(e,t=0){const n=this.makeDestinationObject(),i=this.word.decode(e,t);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(e));return n}encode(e,t,n=0){const i=this.word.decode(t,n);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=e[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new Ub(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new HS(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}};ie.BitStructure=Lb;let Ub=class{constructor(e,t,n){if(!(e instanceof Lb))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const i=8*e.span,s=e.fields.reduce((o,a)=>o+a.bits,0);if(t+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=Qc(this.valueMask<<this.start),this.property=n}decode(e,t){const n=this.container._packedGetValue();return Qc(n&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==Qc(e&this.valueMask))throw new TypeError(Cb("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=Qc(e<<this.start);this.container._packedSetValue(Qc(t&~this.wordMask)|n)}};ie.BitField=Ub;let HS=class extends Ub{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e=="boolean"&&(e=+e),super.encode(e)}};ie.Boolean=HS;let zS=class extends Ot{constructor(e,t){if(!(e instanceof On&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof On||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),vt(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof On&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw new TypeError(Cb("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(n+i>t.length)throw new RangeError("encoding overruns Uint8Array");const s=vt(e);return vt(t).write(s.toString("hex"),n,i,"hex"),this.length instanceof On&&this.length.encode(i,t,n),i}};ie.Blob=zS;let GS=class extends Ot{constructor(e){super(-1,e)}getSpan(e,t=0){Ll(e);let n=t;for(;n<e.length&&e[n]!==0;)n+=1;return 1+n-t}decode(e,t=0){const n=this.getSpan(e,t);return vt(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));const i=Nb.Buffer.from(e,"utf8"),s=i.length;if(n+s>t.length)throw new RangeError("encoding overruns Buffer");const o=vt(t);return i.copy(o,n),o[n+s]=0,s+1}};ie.CString=GS;let KS=class extends Ot{constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return Ll(e),e.length-t}decode(e,t=0){const n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return vt(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){typeof e!="string"&&(e=String(e));const i=Nb.Buffer.from(e,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(vt(t),n),s}};ie.UTF8=KS;let jS=class extends Ot{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};ie.Constant=jS;ie.greedy=(r,e)=>new TS(r,e);var Wo=ie.offset=(r,e,t)=>new Bb(r,e,t),mt=ie.u8=r=>new li(1,r),ai=ie.u16=r=>new li(2,r);ie.u24=r=>new li(3,r);var Be=ie.u32=r=>new li(4,r);ie.u40=r=>new li(5,r);ie.u48=r=>new li(6,r);var Kr=ie.nu64=r=>new OS(r);ie.u16be=r=>new Si(2,r);ie.u24be=r=>new Si(3,r);ie.u32be=r=>new Si(4,r);ie.u40be=r=>new Si(5,r);ie.u48be=r=>new Si(6,r);ie.nu64be=r=>new NS(r);ie.s8=r=>new Sc(1,r);ie.s16=r=>new Sc(2,r);ie.s24=r=>new Sc(3,r);ie.s32=r=>new Sc(4,r);ie.s40=r=>new Sc(5,r);ie.s48=r=>new Sc(6,r);var jn=ie.ns64=r=>new CS(r);ie.s16be=r=>new Ul(2,r);ie.s24be=r=>new Ul(3,r);ie.s32be=r=>new Ul(4,r);ie.s40be=r=>new Ul(5,r);ie.s48be=r=>new Ul(6,r);ie.ns64be=r=>new BS(r);ie.f32=r=>new PS(r);ie.f32be=r=>new MS(r);ie.f64=r=>new LS(r);ie.f64be=r=>new US(r);var Pe=ie.struct=(r,e,t)=>new $S(r,e,t);ie.bits=(r,e,t)=>new Lb(r,e,t);var Jr=ie.seq=(r,e,t)=>new DS(r,e,t);ie.union=(r,e,t)=>new Mb(r,e,t);ie.unionLayoutDiscriminator=(r,e)=>new $0(r,e);var Kt=ie.blob=(r,e)=>new zS(r,e);ie.cstr=r=>new GS(r);ie.utf8=(r,e)=>new KS(r,e);ie.constant=(r,e)=>new jS(r,e);var nd={};Object.defineProperty(nd,"__esModule",{value:!0});function AZ(r){{const e=Qe.from(r);e.reverse();const t=e.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}var vZ=nd.toBigIntLE=AZ;function EZ(r){{const e=r.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}nd.toBigIntBE=EZ;function xZ(r,e){{const t=r.toString(16),n=Qe.from(t.padStart(e*2,"0").slice(0,e*2),"hex");return n.reverse(),n}}var WS=nd.toBufferLE=xZ;function RZ(r,e){{const t=r.toString(16);return Qe.from(t.padStart(e*2,"0").slice(0,e*2),"hex")}}nd.toBufferBE=RZ;let IZ=class extends TypeError{constructor(e,t){let n;const{message:i,explanation:s,...o}=e,{path:a}=e,u=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}};function SZ(r){return id(r)&&typeof r[Symbol.iterator]=="function"}function id(r){return typeof r=="object"&&r!=null}function F0(r){return id(r)&&!Array.isArray(r)}function Ti(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function kZ(r){const{done:e,value:t}=r.next();return e?void 0:t}function TZ(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:i,branch:s}=e,{type:o}=t,{refinement:a,message:u=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Ti(n)}\``}=r;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...r,message:u}}function*VE(r,e,t,n){SZ(r)||(r=[r]);for(const i of r){const s=TZ(i,e,t,n);s&&(yield s)}}function*Db(r,e,t={}){const{path:n=[],branch:i=[r],coerce:s=!1,mask:o=!1}=t,a={path:n,branch:i,mask:o};s&&(r=e.coercer(r,a));let u="valid";for(const l of e.validator(r,a))l.explanation=t.message,u="not_valid",yield[l,void 0];for(let[l,h,g]of e.entries(r,a)){const b=Db(h,g,{path:l===void 0?n:[...n,l],branch:l===void 0?i:[...i,h],coerce:s,mask:o,message:t.message});for(const w of b)w[0]?(u=w[0].refinement!=null?"not_refined":"not_valid",yield[w[0],void 0]):s&&(h=w[1],l===void 0?r=h:r instanceof Map?r.set(l,h):r instanceof Set?r.add(h):id(r)&&(h!==void 0||l in r)&&(r[l]=h))}if(u!=="not_valid")for(const l of e.refiner(r,a))l.explanation=t.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,r])}let gs=class{constructor(e){const{type:t,schema:n,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(u,l)=>{const h=i(u,l);return VE(h,l,this,u)}:this.validator=()=>[],s?this.refiner=(u,l)=>{const h=s(u,l);return VE(h,l,this,u)}:this.refiner=()=>[]}assert(e,t){return VS(e,this,t)}create(e,t){return Ae(e,this,t)}is(e){return qS(e,this)}mask(e,t){return OZ(e,this,t)}validate(e,t={}){return sd(e,this,t)}};function VS(r,e,t){const n=sd(r,e,{message:t});if(n[0])throw n[0]}function Ae(r,e,t){const n=sd(r,e,{coerce:!0,message:t});if(n[0])throw n[0];return n[1]}function OZ(r,e,t){const n=sd(r,e,{coerce:!0,mask:!0,message:t});if(n[0])throw n[0];return n[1]}function qS(r,e){return!sd(r,e)[0]}function sd(r,e,t={}){const n=Db(r,e,t),i=kZ(n);return i[0]?[new IZ(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function kc(r,e){return new gs({type:r,schema:null,validator:e})}function NZ(){return kc("any",()=>!0)}function Re(r){return new gs({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Ti(e)}`}})}function hs(){return kc("boolean",r=>typeof r=="boolean")}function $b(r){return kc("instance",e=>e instanceof r||`Expected a \`${r.name}\` instance, but received: ${Ti(e)}`)}function nr(r){const e=Ti(r),t=typeof r;return new gs({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${e}\`, but received: ${Ti(n)}`}})}function CZ(){return kc("never",()=>!1)}function Ie(r){return new gs({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function X(){return kc("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${Ti(r)}`)}function Fe(r){return new gs({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function ZS(r,e){return new gs({type:"record",schema:null,*entries(t){if(id(t))for(const n in t){const i=t[n];yield[n,n,r],yield[n,i,e]}},validator(t){return F0(t)||`Expected an object, but received: ${Ti(t)}`},coercer(t){return F0(t)?{...t}:t}})}function _e(){return kc("string",r=>typeof r=="string"||`Expected a string, but received: ${Ti(r)}`)}function Fb(r){const e=CZ();return new gs({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const n=Math.max(r.length,t.length);for(let i=0;i<n;i++)yield[i,t[i],r[i]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${Ti(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function ge(r){const e=Object.keys(r);return new gs({type:"type",schema:r,*entries(t){if(id(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return F0(t)||`Expected an object, but received: ${Ti(t)}`},coercer(t){return F0(t)?{...t}:t}})}function vn(r){const e=r.map(t=>t.type).join(" | ");return new gs({type:"union",schema:null,coercer(t,n){for(const i of r){const[s,o]=i.validate(t,{coerce:!0,mask:n.mask});if(!s)return o}return t},validator(t,n){const i=[];for(const s of r){const[...o]=Db(t,s,n),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Ti(t)}`,...i]}})}function Dl(){return kc("unknown",()=>!0)}function od(r,e,t){return new gs({...r,coercer:(n,i)=>qS(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}var Hd,BZ=new Uint8Array(16);function QS(){if(!Hd&&(Hd=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Hd))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Hd(BZ)}const PZ=/^(?:[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 Hp(r){return typeof r=="string"&&PZ.test(r)}var Gr=[];for(var Lm=0;Lm<256;++Lm)Gr.push((Lm+256).toString(16).substr(1));function zp(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(Gr[r[e+0]]+Gr[r[e+1]]+Gr[r[e+2]]+Gr[r[e+3]]+"-"+Gr[r[e+4]]+Gr[r[e+5]]+"-"+Gr[r[e+6]]+Gr[r[e+7]]+"-"+Gr[r[e+8]]+Gr[r[e+9]]+"-"+Gr[r[e+10]]+Gr[r[e+11]]+Gr[r[e+12]]+Gr[r[e+13]]+Gr[r[e+14]]+Gr[r[e+15]]).toLowerCase();if(!Hp(t))throw TypeError("Stringified UUID is invalid");return t}var qE,Um,Dm=0,$m=0;function MZ(r,e,t){var n=e&&t||0,i=e||new Array(16);r=r||{};var s=r.node||qE,o=r.clockseq!==void 0?r.clockseq:Um;if(s==null||o==null){var a=r.random||(r.rng||QS)();s==null&&(s=qE=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Um=(a[6]<<8|a[7])&16383)}var u=r.msecs!==void 0?r.msecs:Date.now(),l=r.nsecs!==void 0?r.nsecs:$m+1,h=u-Dm+(l-$m)/1e4;if(h<0&&r.clockseq===void 0&&(o=o+1&16383),(h<0||u>Dm)&&r.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Dm=u,$m=l,Um=o,u+=122192928e5;var g=((u&268435455)*1e4+l)%4294967296;i[n++]=g>>>24&255,i[n++]=g>>>16&255,i[n++]=g>>>8&255,i[n++]=g&255;var b=u/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=b&255,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=o&255;for(var w=0;w<6;++w)i[n+w]=s[w];return e||zp(i)}function JS(r){if(!Hp(r))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function LZ(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var UZ="6ba7b810-9dad-11d1-80b4-00c04fd430c8",DZ="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function YS(r,e,t){function n(i,s,o,a){if(typeof i=="string"&&(i=LZ(i)),typeof s=="string"&&(s=JS(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(s),u.set(i,s.length),u=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){a=a||0;for(var l=0;l<16;++l)o[a+l]=u[l];return o}return zp(u)}try{n.name=r}catch{}return n.DNS=UZ,n.URL=DZ,n}function $Z(r){if(typeof r=="string"){var e=unescape(encodeURIComponent(r));r=new Uint8Array(e.length);for(var t=0;t<e.length;++t)r[t]=e.charCodeAt(t)}return FZ(HZ(zZ(r),r.length*8))}function FZ(r){for(var e=[],t=r.length*32,n="0123456789abcdef",i=0;i<t;i+=8){var s=r[i>>5]>>>i%32&255,o=parseInt(n.charAt(s>>>4&15)+n.charAt(s&15),16);e.push(o)}return e}function XS(r){return(r+64>>>9<<4)+14+1}function HZ(r,e){r[e>>5]|=128<<e%32,r[XS(e)-1]=e;for(var t=1732584193,n=-271733879,i=-1732584194,s=271733878,o=0;o<r.length;o+=16){var a=t,u=n,l=i,h=s;t=tn(t,n,i,s,r[o],7,-680876936),s=tn(s,t,n,i,r[o+1],12,-389564586),i=tn(i,s,t,n,r[o+2],17,606105819),n=tn(n,i,s,t,r[o+3],22,-1044525330),t=tn(t,n,i,s,r[o+4],7,-176418897),s=tn(s,t,n,i,r[o+5],12,1200080426),i=tn(i,s,t,n,r[o+6],17,-1473231341),n=tn(n,i,s,t,r[o+7],22,-45705983),t=tn(t,n,i,s,r[o+8],7,1770035416),s=tn(s,t,n,i,r[o+9],12,-1958414417),i=tn(i,s,t,n,r[o+10],17,-42063),n=tn(n,i,s,t,r[o+11],22,-1990404162),t=tn(t,n,i,s,r[o+12],7,1804603682),s=tn(s,t,n,i,r[o+13],12,-40341101),i=tn(i,s,t,n,r[o+14],17,-1502002290),n=tn(n,i,s,t,r[o+15],22,1236535329),t=rn(t,n,i,s,r[o+1],5,-165796510),s=rn(s,t,n,i,r[o+6],9,-1069501632),i=rn(i,s,t,n,r[o+11],14,643717713),n=rn(n,i,s,t,r[o],20,-373897302),t=rn(t,n,i,s,r[o+5],5,-701558691),s=rn(s,t,n,i,r[o+10],9,38016083),i=rn(i,s,t,n,r[o+15],14,-660478335),n=rn(n,i,s,t,r[o+4],20,-405537848),t=rn(t,n,i,s,r[o+9],5,568446438),s=rn(s,t,n,i,r[o+14],9,-1019803690),i=rn(i,s,t,n,r[o+3],14,-187363961),n=rn(n,i,s,t,r[o+8],20,1163531501),t=rn(t,n,i,s,r[o+13],5,-1444681467),s=rn(s,t,n,i,r[o+2],9,-51403784),i=rn(i,s,t,n,r[o+7],14,1735328473),n=rn(n,i,s,t,r[o+12],20,-1926607734),t=nn(t,n,i,s,r[o+5],4,-378558),s=nn(s,t,n,i,r[o+8],11,-2022574463),i=nn(i,s,t,n,r[o+11],16,1839030562),n=nn(n,i,s,t,r[o+14],23,-35309556),t=nn(t,n,i,s,r[o+1],4,-1530992060),s=nn(s,t,n,i,r[o+4],11,1272893353),i=nn(i,s,t,n,r[o+7],16,-155497632),n=nn(n,i,s,t,r[o+10],23,-1094730640),t=nn(t,n,i,s,r[o+13],4,681279174),s=nn(s,t,n,i,r[o],11,-358537222),i=nn(i,s,t,n,r[o+3],16,-722521979),n=nn(n,i,s,t,r[o+6],23,76029189),t=nn(t,n,i,s,r[o+9],4,-640364487),s=nn(s,t,n,i,r[o+12],11,-421815835),i=nn(i,s,t,n,r[o+15],16,530742520),n=nn(n,i,s,t,r[o+2],23,-995338651),t=sn(t,n,i,s,r[o],6,-198630844),s=sn(s,t,n,i,r[o+7],10,1126891415),i=sn(i,s,t,n,r[o+14],15,-1416354905),n=sn(n,i,s,t,r[o+5],21,-57434055),t=sn(t,n,i,s,r[o+12],6,1700485571),s=sn(s,t,n,i,r[o+3],10,-1894986606),i=sn(i,s,t,n,r[o+10],15,-1051523),n=sn(n,i,s,t,r[o+1],21,-2054922799),t=sn(t,n,i,s,r[o+8],6,1873313359),s=sn(s,t,n,i,r[o+15],10,-30611744),i=sn(i,s,t,n,r[o+6],15,-1560198380),n=sn(n,i,s,t,r[o+13],21,1309151649),t=sn(t,n,i,s,r[o+4],6,-145523070),s=sn(s,t,n,i,r[o+11],10,-1120210379),i=sn(i,s,t,n,r[o+2],15,718787259),n=sn(n,i,s,t,r[o+9],21,-343485551),t=Ko(t,a),n=Ko(n,u),i=Ko(i,l),s=Ko(s,h)}return[t,n,i,s]}function zZ(r){if(r.length===0)return[];for(var e=r.length*8,t=new Uint32Array(XS(e)),n=0;n<e;n+=8)t[n>>5]|=(r[n/8]&255)<<n%32;return t}function Ko(r,e){var t=(r&65535)+(e&65535),n=(r>>16)+(e>>16)+(t>>16);return n<<16|t&65535}function GZ(r,e){return r<<e|r>>>32-e}function Gp(r,e,t,n,i,s){return Ko(GZ(Ko(Ko(e,r),Ko(n,s)),i),t)}function tn(r,e,t,n,i,s,o){return Gp(e&t|~e&n,r,e,i,s,o)}function rn(r,e,t,n,i,s,o){return Gp(e&n|t&~n,r,e,i,s,o)}function nn(r,e,t,n,i,s,o){return Gp(e^t^n,r,e,i,s,o)}function sn(r,e,t,n,i,s,o){return Gp(t^(e|~n),r,e,i,s,o)}var KZ=YS("v3",48,$Z);function jZ(r,e,t){r=r||{};var n=r.random||(r.rng||QS)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var i=0;i<16;++i)e[t+i]=n[i];return e}return zp(n)}function WZ(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function Fm(r,e){return r<<e|r>>>32-e}function VZ(r){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var i=0;i<n.length;++i)r.push(n.charCodeAt(i))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var s=r.length/4+2,o=Math.ceil(s/16),a=new Array(o),u=0;u<o;++u){for(var l=new Uint32Array(16),h=0;h<16;++h)l[h]=r[u*64+h*4]<<24|r[u*64+h*4+1]<<16|r[u*64+h*4+2]<<8|r[u*64+h*4+3];a[u]=l}a[o-1][14]=(r.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(r.length-1)*8&4294967295;for(var g=0;g<o;++g){for(var b=new Uint32Array(80),w=0;w<16;++w)b[w]=a[g][w];for(var I=16;I<80;++I)b[I]=Fm(b[I-3]^b[I-8]^b[I-14]^b[I-16],1);for(var S=t[0],x=t[1],C=t[2],H=t[3],D=t[4],z=0;z<80;++z){var V=Math.floor(z/20),Z=Fm(S,5)+WZ(V,x,C,H)+D+e[V]+b[z]>>>0;D=H,H=C,C=Fm(x,30)>>>0,x=S,S=Z}t[0]=t[0]+S>>>0,t[1]=t[1]+x>>>0,t[2]=t[2]+C>>>0,t[3]=t[3]+H>>>0,t[4]=t[4]+D>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var qZ=YS("v5",80,VZ);const ZZ="00000000-0000-0000-0000-000000000000";function QZ(r){if(!Hp(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}const JZ=Object.freeze(Object.defineProperty({__proto__:null,NIL:ZZ,parse:JS,stringify:zp,v1:MZ,v3:KZ,v4:jZ,v5:qZ,validate:Hp,version:QZ},Symbol.toStringTag,{value:"Module"})),ek=gp(JZ),YZ=ek.v4,XZ=function(r,e,t,n){if(typeof r!="string")throw new TypeError(r+" must be a string");n=n||{};const i=typeof n.version=="number"?n.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const s={method:r};if(i===2&&(s.jsonrpc="2.0"),e){if(typeof e!="object"&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");s.params=e}if(typeof t>"u"){const o=typeof n.generator=="function"?n.generator:function(){return YZ()};s.id=o(s,n)}else i===2&&t===null?n.notificationIdNull&&(s.id=null):s.id=t;return s};var eQ=XZ;const tQ=ek.v4,rQ=eQ,uh=function(r,e){if(!(this instanceof uh))return new uh(r,e);e||(e={}),this.options={reviver:typeof e.reviver<"u"?e.reviver:null,replacer:typeof e.replacer<"u"?e.replacer:null,generator:typeof e.generator<"u"?e.generator:function(){return tQ()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=r};var nQ=uh;uh.prototype.request=function(r,e,t,n){const i=this;let s=null;const o=Array.isArray(r)&&typeof e=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&r&&typeof r=="object"&&typeof e=="function")n=e,s=r;else{typeof t=="function"&&(n=t,t=void 0);const l=typeof n=="function";try{s=rQ(r,e,t,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(h){if(l)return n(h);throw h}if(!l)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(l){return n(l)}return this.callServer(u,function(l,h){i._parseResponse(l,h,n)}),s};uh.prototype._parseResponse=function(r,e,t){if(r){t(r);return}if(!e)return t();let n;try{n=JSON.parse(e,this.options.reviver)}catch(i){return t(i)}if(t.length===3)if(Array.isArray(n)){const i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return t(null,n.filter(i),n.filter(s))}else return t(null,n.error,n.result);t(null,n)};const iQ=no(nQ);var tk={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function i(u,l,h){this.fn=u,this.context=l,this.once=h||!1}function s(u,l,h,g,b){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,g||u,b),I=t?t+l:l;return u._events[I]?u._events[I].fn?u._events[I]=[u._events[I],w]:u._events[I].push(w):(u._events[I]=w,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new n:delete u._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,g;if(this._eventsCount===0)return l;for(g in h=this._events)e.call(h,g)&&l.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var b=0,w=g.length,I=new Array(w);b<w;b++)I[b]=g[b].fn;return I},a.prototype.listenerCount=function(l){var h=t?t+l:l,g=this._events[h];return g?g.fn?1:g.length:0},a.prototype.emit=function(l,h,g,b,w,I){var S=t?t+l:l;if(!this._events[S])return!1;var x=this._events[S],C=arguments.length,H,D;if(x.fn){switch(x.once&&this.removeListener(l,x.fn,void 0,!0),C){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,h),!0;case 3:return x.fn.call(x.context,h,g),!0;case 4:return x.fn.call(x.context,h,g,b),!0;case 5:return x.fn.call(x.context,h,g,b,w),!0;case 6:return x.fn.call(x.context,h,g,b,w,I),!0}for(D=1,H=new Array(C-1);D<C;D++)H[D-1]=arguments[D];x.fn.apply(x.context,H)}else{var z=x.length,V;for(D=0;D<z;D++)switch(x[D].once&&this.removeListener(l,x[D].fn,void 0,!0),C){case 1:x[D].fn.call(x[D].context);break;case 2:x[D].fn.call(x[D].context,h);break;case 3:x[D].fn.call(x[D].context,h,g);break;case 4:x[D].fn.call(x[D].context,h,g,b);break;default:if(!H)for(V=1,H=new Array(C-1);V<C;V++)H[V-1]=arguments[V];x[D].fn.apply(x[D].context,H)}}return!0},a.prototype.on=function(l,h,g){return s(this,l,h,g,!1)},a.prototype.once=function(l,h,g){return s(this,l,h,g,!0)},a.prototype.removeListener=function(l,h,g,b){var w=t?t+l:l;if(!this._events[w])return this;if(!h)return o(this,w),this;var I=this._events[w];if(I.fn)I.fn===h&&(!b||I.once)&&(!g||I.context===g)&&o(this,w);else{for(var S=0,x=[],C=I.length;S<C;S++)(I[S].fn!==h||b&&!I[S].once||g&&I[S].context!==g)&&x.push(I[S]);x.length?this._events[w]=x.length===1?x[0]:x:o(this,w)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(tk);var sQ=tk.exports;const rk=no(sQ);var oQ=class extends rk{constructor(e,t,n){super();Q(this,"socket");this.socket=new window.WebSocket(e,n),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=i=>this.emit("message",i.data),this.socket.onerror=i=>this.emit("error",i),this.socket.onclose=i=>{this.emit("close",i.code,i.reason)}}send(e,t,n){const i=n||t;try{this.socket.send(e),i()}catch(s){i(s)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}};function aQ(r,e){return new oQ(r,e)}var cQ=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},uQ=class extends rk{constructor(e,t="ws://localhost:8080",{autoconnect:n=!0,reconnect:i=!0,reconnect_interval:s=1e3,max_reconnects:o=5,...a}={},u,l){super();Q(this,"address");Q(this,"rpc_id");Q(this,"queue");Q(this,"options");Q(this,"autoconnect");Q(this,"ready");Q(this,"reconnect");Q(this,"reconnect_timer_id");Q(this,"reconnect_interval");Q(this,"max_reconnects");Q(this,"rest_options");Q(this,"current_reconnects");Q(this,"generate_request_id");Q(this,"socket");Q(this,"webSocketFactory");Q(this,"dataPack");this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=u||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),l?this.dataPack=l:this.dataPack=new cQ,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,i){return!i&&typeof n=="object"&&(i=n,n=null),new Promise((s,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(e,t),u={jsonrpc:"2.0",method:e,params:t||void 0,id:a};this.socket.send(this.dataPack.encode(u),i,l=>{if(l)return o(l);this.queue[a]={promise:[s,o]},n&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},n))})})}async login(e){const t=await this.call("rpc.login",e);if(!t)throw new Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(e,t){return new Promise((n,i)=>{if(!this.ready)return i(new Error("socket not ready"));const s={jsonrpc:"2.0",method:e,params:t};this.socket.send(this.dataPack.encode(s),o=>{if(o)return i(o);n()})})}async subscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.on",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed subscribing to an event '"+e+"' with: "+t[e]);return t}async unsubscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.off",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed unsubscribing from an event with: "+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:n})=>{n instanceof ArrayBuffer&&(n=Ne.from(n).toString());try{n=this.dataPack.decode(n)}catch{return}if(n.notification&&this.listeners(n.notification).length){if(!Object.keys(n.params).length)return this.emit(n.notification);const i=[n.notification];if(n.params.constructor===Object)i.push(n.params);else for(let s=0;s<n.params.length;s++)i.push(n.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,i)})}if(!this.queue[n.id])return n.method?Promise.resolve().then(()=>{this.emit(n.method,n==null?void 0:n.params)}):void 0;"error"in n=="result"in n&&this.queue[n.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[n.id].timeout&&clearTimeout(this.queue[n.id].timeout),n.error?this.queue[n.id].promise[1](n.error):this.queue[n.id].promise[0](n.result),delete this.queue[n.id]}),this.socket.addEventListener("error",n=>this.emit("error",n)),this.socket.addEventListener("close",({code:n,reason:i})=>{this.ready&&setTimeout(()=>this.emit("close",n,i),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval)))})}};const nk=[],ik=[],sk=[],lQ=BigInt(0),Ef=BigInt(1),fQ=BigInt(2),hQ=BigInt(7),dQ=BigInt(256),pQ=BigInt(113);for(let r=0,e=Ef,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],nk.push(2*(5*n+t)),ik.push((r+1)*(r+2)/2%64);let i=lQ;for(let s=0;s<7;s++)e=(e<<Ef^(e>>hQ)*pQ)%dQ,e&fQ&&(i^=Ef<<(Ef<<BigInt(s))-Ef);sk.push(i)}const[gQ,yQ]=oS(sk,!0),ZE=(r,e,t)=>t>32?uS(r,e,t):aS(r,e,t),QE=(r,e,t)=>t>32?lS(r,e,t):cS(r,e,t);function mQ(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,l=t[u],h=t[u+1],g=ZE(l,h,1)^t[a],b=QE(l,h,1)^t[a+1];for(let w=0;w<50;w+=10)r[o+w]^=g,r[o+w+1]^=b}let i=r[2],s=r[3];for(let o=0;o<24;o++){const a=ik[o],u=ZE(i,s,a),l=QE(i,s,a),h=nk[o];i=r[h],s=r[h+1],r[h]=u,r[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=gQ[n],r[1]^=yQ[n]}t.fill(0)}let wQ=class ok extends Eb{constructor(e,t,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,P0(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=GV(this.state)}keccak(){DE||$E(this.state32),mQ(this.state32,this.rounds),DE||$E(this.state32),this.posOut=0,this.pos=0}update(e){ll(this);const{blockLen:t,state:n}=this;e=Bp(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(t-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,t&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ll(this,!1),td(e),this.finish();const t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return P0(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(rS(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new ok(t,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}};const bQ=(r,e,t)=>xb(()=>new wQ(e,r,t)),JE=bQ(1,136,256/8);let ak=class extends Eb{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,zV(e);const n=Bp(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return ll(this),this.iHash.update(e),this}digestInto(e){ll(this),td(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const ck=(r,e,t)=>new ak(r,e).update(t).digest();ck.create=(r,e)=>new ak(r,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function YE(r){r.lowS!==void 0&&Qs("lowS",r.lowS),r.prehash!==void 0&&Qs("prehash",r.prehash)}function _Q(r){const e=Sb(r);Pl(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:AQ,hexToBytes:vQ}=Rq;class EQ extends Error{constructor(e=""){super(e)}}const Ss={Err:EQ,_tlv:{encode:(r,e)=>{const{Err:t}=Ss;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const n=e.length/2,i=ru(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");const s=n>127?ru(i.length/2|128):"";return ru(r)+s+i+e},decode(r,e){const{Err:t}=Ss;let n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");const i=e[n++],s=!!(i&128);let o=0;if(!s)o=i;else{const u=i&127;if(!u)throw new t("tlv.decode(long): indefinite length not supported");if(u>4)throw new t("tlv.decode(long): byte length is too big");const l=e.subarray(n,n+u);if(l.length!==u)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const h of l)o=o<<8|h;if(n+=u,o<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(r){const{Err:e}=Ss;if(r<js)throw new e("integer: negative integers are not allowed");let t=ru(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){const{Err:e}=Ss;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return AQ(r)}},toSig(r){const{Err:e,_int:t,_tlv:n}=Ss,i=typeof r=="string"?vQ(r):r;rd(i);const{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:u}=n.decode(2,s),{v:l,l:h}=n.decode(2,u);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(r){const{_tlv:e,_int:t}=Ss,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),s=n+i;return e.encode(48,s)}},js=BigInt(0),Lr=BigInt(1);BigInt(2);const XE=BigInt(3);BigInt(4);function xQ(r){const e=_Q(r),{Fp:t}=e,n=Up(e.n,e.nBitLength),i=e.toBytes||((S,x,C)=>{const H=x.toAffine();return dc(Uint8Array.from([4]),t.toBytes(H.x),t.toBytes(H.y))}),s=e.fromBytes||(S=>{const x=S.subarray(1),C=t.fromBytes(x.subarray(0,t.BYTES)),H=t.fromBytes(x.subarray(t.BYTES,2*t.BYTES));return{x:C,y:H}});function o(S){const{a:x,b:C}=e,H=t.sqr(S),D=t.mul(H,S);return t.add(t.add(D,t.mul(S,x)),C)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(S){return Lp(S,Lr,e.n)}function u(S){const{allowedPrivateKeyLengths:x,nByteLength:C,wrapPrivateKey:H,n:D}=e;if(x&&typeof S!="bigint"){if(fc(S)&&(S=hc(S)),typeof S!="string"||!x.includes(S.length))throw new Error("invalid private key");S=S.padStart(C*2,"0")}let z;try{z=typeof S=="bigint"?S:ic(Sr("private key",S,C))}catch{throw new Error("invalid private key, expected hex or "+C+" bytes, got "+typeof S)}return H&&(z=Qt(z,D)),ci("private key",z,Lr,D),z}function l(S){if(!(S instanceof b))throw new Error("ProjectivePoint expected")}const h=ch((S,x)=>{const{px:C,py:H,pz:D}=S;if(t.eql(D,t.ONE))return{x:C,y:H};const z=S.is0();x==null&&(x=z?t.ONE:t.inv(D));const V=t.mul(C,x),Z=t.mul(H,x),K=t.mul(D,x);if(z)return{x:t.ZERO,y:t.ZERO};if(!t.eql(K,t.ONE))throw new Error("invZ was invalid");return{x:V,y:Z}}),g=ch(S=>{if(S.is0()){if(e.allowInfinityPoint&&!t.is0(S.py))return;throw new Error("bad point: ZERO")}const{x,y:C}=S.toAffine();if(!t.isValid(x)||!t.isValid(C))throw new Error("bad point: x or y not FE");const H=t.sqr(C),D=o(x);if(!t.eql(H,D))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class b{constructor(x,C,H){if(this.px=x,this.py=C,this.pz=H,x==null||!t.isValid(x))throw new Error("x required");if(C==null||!t.isValid(C))throw new Error("y required");if(H==null||!t.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(x){const{x:C,y:H}=x||{};if(!x||!t.isValid(C)||!t.isValid(H))throw new Error("invalid affine point");if(x instanceof b)throw new Error("projective point not allowed");const D=z=>t.eql(z,t.ZERO);return D(C)&&D(H)?b.ZERO:new b(C,H,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){const C=t.invertBatch(x.map(H=>H.pz));return x.map((H,D)=>H.toAffine(C[D])).map(b.fromAffine)}static fromHex(x){const C=b.fromAffine(s(Sr("pointHex",x)));return C.assertValidity(),C}static fromPrivateKey(x){return b.BASE.multiply(u(x))}static msm(x,C){return bS(b,n,x,C)}_setWindowSize(x){I.setWindowSize(this,x)}assertValidity(){g(this)}hasEvenY(){const{y:x}=this.toAffine();if(t.isOdd)return!t.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){l(x);const{px:C,py:H,pz:D}=this,{px:z,py:V,pz:Z}=x,K=t.eql(t.mul(C,Z),t.mul(z,D)),W=t.eql(t.mul(H,Z),t.mul(V,D));return K&&W}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:x,b:C}=e,H=t.mul(C,XE),{px:D,py:z,pz:V}=this;let Z=t.ZERO,K=t.ZERO,W=t.ZERO,oe=t.mul(D,D),ce=t.mul(z,z),ne=t.mul(V,V),ue=t.mul(D,z);return ue=t.add(ue,ue),W=t.mul(D,V),W=t.add(W,W),Z=t.mul(x,W),K=t.mul(H,ne),K=t.add(Z,K),Z=t.sub(ce,K),K=t.add(ce,K),K=t.mul(Z,K),Z=t.mul(ue,Z),W=t.mul(H,W),ne=t.mul(x,ne),ue=t.sub(oe,ne),ue=t.mul(x,ue),ue=t.add(ue,W),W=t.add(oe,oe),oe=t.add(W,oe),oe=t.add(oe,ne),oe=t.mul(oe,ue),K=t.add(K,oe),ne=t.mul(z,V),ne=t.add(ne,ne),oe=t.mul(ne,ue),Z=t.sub(Z,oe),W=t.mul(ne,ce),W=t.add(W,W),W=t.add(W,W),new b(Z,K,W)}add(x){l(x);const{px:C,py:H,pz:D}=this,{px:z,py:V,pz:Z}=x;let K=t.ZERO,W=t.ZERO,oe=t.ZERO;const ce=e.a,ne=t.mul(e.b,XE);let ue=t.mul(C,z),B=t.mul(H,V),p=t.mul(D,Z),m=t.add(C,H),E=t.add(z,V);m=t.mul(m,E),E=t.add(ue,B),m=t.sub(m,E),E=t.add(C,D);let k=t.add(z,Z);return E=t.mul(E,k),k=t.add(ue,p),E=t.sub(E,k),k=t.add(H,D),K=t.add(V,Z),k=t.mul(k,K),K=t.add(B,p),k=t.sub(k,K),oe=t.mul(ce,E),K=t.mul(ne,p),oe=t.add(K,oe),K=t.sub(B,oe),oe=t.add(B,oe),W=t.mul(K,oe),B=t.add(ue,ue),B=t.add(B,ue),p=t.mul(ce,p),E=t.mul(ne,E),B=t.add(B,p),p=t.sub(ue,p),p=t.mul(ce,p),E=t.add(E,p),ue=t.mul(B,E),W=t.add(W,ue),ue=t.mul(k,E),K=t.mul(m,K),K=t.sub(K,ue),ue=t.mul(m,B),oe=t.mul(k,oe),oe=t.add(oe,ue),new b(K,W,oe)}subtract(x){return this.add(x.negate())}is0(){return this.equals(b.ZERO)}wNAF(x){return I.wNAFCached(this,x,b.normalizeZ)}multiplyUnsafe(x){const{endo:C,n:H}=e;ci("scalar",x,js,H);const D=b.ZERO;if(x===js)return D;if(this.is0()||x===Lr)return this;if(!C||I.hasPrecomputes(this))return I.wNAFCachedUnsafe(this,x,b.normalizeZ);let{k1neg:z,k1:V,k2neg:Z,k2:K}=C.splitScalar(x),W=D,oe=D,ce=this;for(;V>js||K>js;)V&Lr&&(W=W.add(ce)),K&Lr&&(oe=oe.add(ce)),ce=ce.double(),V>>=Lr,K>>=Lr;return z&&(W=W.negate()),Z&&(oe=oe.negate()),oe=new b(t.mul(oe.px,C.beta),oe.py,oe.pz),W.add(oe)}multiply(x){const{endo:C,n:H}=e;ci("scalar",x,Lr,H);let D,z;if(C){const{k1neg:V,k1:Z,k2neg:K,k2:W}=C.splitScalar(x);let{p:oe,f:ce}=this.wNAF(Z),{p:ne,f:ue}=this.wNAF(W);oe=I.constTimeNegate(V,oe),ne=I.constTimeNegate(K,ne),ne=new b(t.mul(ne.px,C.beta),ne.py,ne.pz),D=oe.add(ne),z=ce.add(ue)}else{const{p:V,f:Z}=this.wNAF(x);D=V,z=Z}return b.normalizeZ([D,z])[0]}multiplyAndAddUnsafe(x,C,H){const D=b.BASE,z=(Z,K)=>K===js||K===Lr||!Z.equals(D)?Z.multiplyUnsafe(K):Z.multiply(K),V=z(this,C).add(z(x,H));return V.is0()?void 0:V}toAffine(x){return h(this,x)}isTorsionFree(){const{h:x,isTorsionFree:C}=e;if(x===Lr)return!0;if(C)return C(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:x,clearCofactor:C}=e;return x===Lr?this:C?C(b,this):this.multiplyUnsafe(e.h)}toRawBytes(x=!0){return Qs("isCompressed",x),this.assertValidity(),i(b,this,x)}toHex(x=!0){return Qs("isCompressed",x),hc(this.toRawBytes(x))}}b.BASE=new b(e.Gx,e.Gy,t.ONE),b.ZERO=new b(t.ZERO,t.ONE,t.ZERO);const w=e.nBitLength,I=wS(b,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function RQ(r){const e=Sb(r);return Pl(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function IQ(r){const e=RQ(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(p){return Qt(p,n)}function a(p){return G1(p,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:g}=xQ({...e,toBytes(p,m,E){const k=m.toAffine(),O=t.toBytes(k.x),M=dc;return Qs("isCompressed",E),E?M(Uint8Array.from([m.hasEvenY()?2:3]),O):M(Uint8Array.from([4]),O,t.toBytes(k.y))},fromBytes(p){const m=p.length,E=p[0],k=p.subarray(1);if(m===i&&(E===2||E===3)){const O=ic(k);if(!Lp(O,Lr,t.ORDER))throw new Error("Point is not on curve");const M=h(O);let G;try{G=t.sqrt(M)}catch(U){const le=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+le)}const P=(G&Lr)===Lr;return(E&1)===1!==P&&(G=t.neg(G)),{x:O,y:G}}else if(m===s&&E===4){const O=t.fromBytes(k.subarray(0,t.BYTES)),M=t.fromBytes(k.subarray(t.BYTES,2*t.BYTES));return{x:O,y:M}}else{const O=i,M=s;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+M+", got "+m)}}}),b=p=>hc(hl(p,e.nByteLength));function w(p){const m=n>>Lr;return p>m}function I(p){return w(p)?o(-p):p}const S=(p,m,E)=>ic(p.slice(m,E));class x{constructor(m,E,k){this.r=m,this.s=E,this.recovery=k,this.assertValidity()}static fromCompact(m){const E=e.nByteLength;return m=Sr("compactSignature",m,E*2),new x(S(m,0,E),S(m,E,2*E))}static fromDER(m){const{r:E,s:k}=Ss.toSig(Sr("DER",m));return new x(E,k)}assertValidity(){ci("r",this.r,Lr,n),ci("s",this.s,Lr,n)}addRecoveryBit(m){return new x(this.r,this.s,m)}recoverPublicKey(m){const{r:E,s:k,recovery:O}=this,M=Z(Sr("msgHash",m));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const G=O===2||O===3?E+e.n:E;if(G>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=O&1?"03":"02",A=u.fromHex(P+b(G)),U=a(G),le=o(-M*U),ee=o(k*U),re=u.BASE.multiplyAndAddUnsafe(A,le,ee);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return fl(this.toDERHex())}toDERHex(){return Ss.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return fl(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}const C={isValidPrivateKey(p){try{return l(p),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const p=gS(e.n);return Mq(e.randomBytes(p),e.n)},precompute(p=8,m=u.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function H(p,m=!0){return u.fromPrivateKey(p).toRawBytes(m)}function D(p){const m=fc(p),E=typeof p=="string",k=(m||E)&&p.length;return m?k===i||k===s:E?k===2*i||k===2*s:p instanceof u}function z(p,m,E=!0){if(D(p))throw new Error("first arg must be private key");if(!D(m))throw new Error("second arg must be public key");return u.fromHex(m).multiply(l(p)).toRawBytes(E)}const V=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const m=ic(p),E=p.length*8-e.nBitLength;return E>0?m>>BigInt(E):m},Z=e.bits2int_modN||function(p){return o(V(p))},K=Ib(e.nBitLength);function W(p){return ci("num < 2^"+e.nBitLength,p,js,K),hl(p,e.nByteLength)}function oe(p,m,E=ce){if(["recovered","canonical"].some(ye=>ye in E))throw new Error("sign() legacy options not supported");const{hash:k,randomBytes:O}=e;let{lowS:M,prehash:G,extraEntropy:P}=E;M==null&&(M=!0),p=Sr("msgHash",p),YE(E),G&&(p=Sr("prehashed msgHash",k(p)));const A=Z(p),U=l(m),le=[W(U),W(A)];if(P!=null&&P!==!1){const ye=P===!0?O(t.BYTES):P;le.push(Sr("extraEntropy",ye))}const ee=dc(...le),re=A;function he(ye){const be=V(ye);if(!g(be))return;const je=a(be),$e=u.BASE.multiply(be).toAffine(),Oe=o($e.x);if(Oe===js)return;const Xe=o(je*o(re+Oe*U));if(Xe===js)return;let qe=($e.x===Oe?0:2)|Number($e.y&Lr),et=Xe;return M&&w(Xe)&&(et=I(Xe),qe^=1),new x(Oe,et,qe)}return{seed:ee,k2sig:he}}const ce={lowS:e.lowS,prehash:!1},ne={lowS:e.lowS,prehash:!1};function ue(p,m,E=ce){const{seed:k,k2sig:O}=oe(p,m,E),M=e;return hS(M.hash.outputLen,M.nByteLength,M.hmac)(k,O)}u.BASE._setWindowSize(8);function B(p,m,E,k=ne){var qe;const O=p;m=Sr("msgHash",m),E=Sr("publicKey",E);const{lowS:M,prehash:G,format:P}=k;if(YE(k),"strict"in k)throw new Error("options.strict was renamed to lowS");if(P!==void 0&&P!=="compact"&&P!=="der")throw new Error("format must be compact or der");const A=typeof O=="string"||fc(O),U=!A&&!P&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!A&&!U)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let le,ee;try{if(U&&(le=new x(O.r,O.s)),A){try{P!=="compact"&&(le=x.fromDER(O))}catch(et){if(!(et instanceof Ss.Err))throw et}!le&&P!=="der"&&(le=x.fromCompact(O))}ee=u.fromHex(E)}catch{return!1}if(!le||M&&le.hasHighS())return!1;G&&(m=e.hash(m));const{r:re,s:he}=le,ye=Z(m),be=a(he),je=o(ye*be),$e=o(re*be),Oe=(qe=u.BASE.multiplyAndAddUnsafe(ee,je,$e))==null?void 0:qe.toAffine();return Oe?o(Oe.x)===re:!1}return{CURVE:e,getPublicKey:H,getSharedSecret:z,sign:ue,verify:B,ProjectivePoint:u,Signature:x,utils:C}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function SQ(r){return{hash:r,hmac:(e,...t)=>ck(r,e,WV(...t)),randomBytes:nS}}function kQ(r,e){const t=n=>IQ({...r,...SQ(n)});return{...t(e),create:t}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const uk=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),e2=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),TQ=BigInt(1),V1=BigInt(2),t2=(r,e)=>(r+e/V1)/e;function OQ(r){const e=uk,t=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),l=r*r*r%e,h=l*l*r%e,g=br(h,t,e)*h%e,b=br(g,t,e)*h%e,w=br(b,V1,e)*l%e,I=br(w,i,e)*w%e,S=br(I,s,e)*I%e,x=br(S,a,e)*S%e,C=br(x,u,e)*x%e,H=br(C,a,e)*S%e,D=br(H,t,e)*h%e,z=br(D,o,e)*I%e,V=br(z,n,e)*l%e,Z=br(V,V1,e);if(!q1.eql(q1.sqr(Z),r))throw new Error("Cannot find square root");return Z}const q1=Up(uk,void 0,void 0,{sqrt:OQ}),Kp=kQ({a:BigInt(0),b:BigInt(7),Fp:q1,n:e2,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=e2,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-TQ*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),a=t2(s*r,e),u=t2(-n*r,e);let l=Qt(r-a*t-u*i,e),h=Qt(-a*n-u*s,e);const g=l>o,b=h>o;if(g&&(l=e-l),b&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:l,k2neg:b,k2:h}}}},j1);BigInt(0);Kp.ProjectivePoint;const NQ=Ml.utils.randomPrivateKey,r2=()=>{const r=Ml.utils.randomPrivateKey(),e=H0(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},H0=Ml.getPublicKey;function n2(r){try{return Ml.ExtendedPoint.fromHex(r),!0}catch{return!1}}const Hb=(r,e)=>Ml.sign(r,e.slice(0,32)),CQ=Ml.verify,st=r=>Ne.isBuffer(r)?r:r instanceof Uint8Array?Ne.from(r.buffer,r.byteOffset,r.byteLength):Ne.from(r);let zb=class{constructor(e){Object.assign(this,e)}encode(){return Ne.from(SS(Ff,this))}static decode(e){return kS(Ff,this,e)}static decodeUnchecked(e){return vS(Ff,this,e)}};class BQ extends zb{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const Ff=new Map;var lk;const fk=32,os=32;function PQ(r){return r._bn!==void 0}let i2=1;class me extends zb{constructor(e){if(super({}),this._bn=void 0,PQ(e))this._bn=e._bn;else{if(typeof e=="string"){const t=kr.decode(e);if(t.length!=os)throw new Error("Invalid public key input");this._bn=new Gs(t)}else this._bn=new Gs(e);if(this._bn.byteLength()>os)throw new Error("Invalid public key input")}}static unique(){const e=new me(i2);return i2+=1,new me(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return kr.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(Ne);if(e.length===os)return e;const t=Ne.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,n){const i=Ne.concat([e.toBuffer(),Ne.from(t),n.toBuffer()]),s=j1(i);return new me(s)}static createProgramAddressSync(e,t){let n=Ne.alloc(0);e.forEach(function(s){if(s.length>fk)throw new TypeError("Max seed length exceeded");n=Ne.concat([n,st(s)])}),n=Ne.concat([n,t.toBuffer(),Ne.from("ProgramDerivedAddress")]);const i=j1(n);if(n2(i))throw new Error("Invalid seeds, address must fall off the curve");return new me(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,i;for(;n!=0;){try{const s=e.concat(Ne.from([n]));i=this.createProgramAddressSync(s,t)}catch(s){if(s instanceof TypeError)throw s;n--;continue}return[i,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new me(e);return n2(t.toBytes())}}lk=me;me.default=new lk("11111111111111111111111111111111");Ff.set(me,{kind:"struct",fields:[["_bn","u256"]]});class MQ{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=st(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=st(NQ()),this._publicKey=st(H0(this._secretKey))}get publicKey(){return new me(this._publicKey)}get secretKey(){return Ne.concat([this._secretKey,this._publicKey],64)}}const LQ=new me("BPFLoader1111111111111111111111111111111111"),Vo=1232,jp=127,lh=64;class Gb extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Gb.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Kb extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Kb.prototype,"name",{value:"TransactionExpiredTimeoutError"});class nu extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(nu.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class fh{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((s,o)=>{n.set(s.toBase58(),o)});const i=s=>{const o=n.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}}const ut=(r="publicKey")=>Kt(32,r),UQ=(r="signature")=>Kt(64,r),Ra=(r="string")=>{const e=Pe([Be("length"),Be("lengthPadding"),Kt(Wo(Be(),-8),"chars")],r),t=e.decode.bind(e),n=e.encode.bind(e),i=e;return i.decode=(s,o)=>t(s,o).chars.toString(),i.encode=(s,o,a)=>{const u={chars:Ne.from(s,"utf8")};return n(u,o,a)},i.alloc=s=>Be().span+Be().span+Ne.from(s,"utf8").length,i},DQ=(r="authorized")=>Pe([ut("staker"),ut("withdrawer")],r),$Q=(r="lockup")=>Pe([jn("unixTimestamp"),jn("epoch"),ut("custodian")],r),FQ=(r="voteInit")=>Pe([ut("nodePubkey"),ut("authorizedVoter"),ut("authorizedWithdrawer"),mt("commission")],r),HQ=(r="voteAuthorizeWithSeedArgs")=>Pe([Be("voteAuthorizationType"),ut("currentAuthorityDerivedKeyOwnerPubkey"),Ra("currentAuthorityDerivedKeySeed"),ut("newAuthorized")],r);function hk(r,e){const t=i=>{if(i.span>=0)return i.span;if(typeof i.alloc=="function")return i.alloc(e[i.property]);if("count"in i&&"elementLayout"in i){const s=e[i.property];if(Array.isArray(s))return s.length*t(i.elementLayout)}else if("fields"in i)return hk({layout:i},e[i.property]);return 0};let n=0;return r.layout.fields.forEach(i=>{n+=t(i)}),n}function In(r){let e=0,t=0;for(;;){let n=r.shift();if(e|=(n&127)<<t*7,t+=1,!(n&128))break}return e}function Wn(r,e){let t=e;for(;;){let n=t&127;if(t>>=7,t==0){r.push(n);break}else n|=128,r.push(n)}}function At(r,e){if(!r)throw new Error(e||"Assertion failed")}class Wp{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const n=new Map,i=o=>{const a=o.toBase58();let u=n.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(a,u)),u},s=i(t);s.isSigner=!0,s.isWritable=!0;for(const o of e){i(o.programId).isInvoked=!0;for(const a of o.keys){const u=i(a.pubkey);u.isSigner||(u.isSigner=a.isSigner),u.isWritable||(u.isWritable=a.isWritable)}}return new Wp(t,n)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];At(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,u])=>u.isSigner&&u.isWritable),n=e.filter(([,u])=>u.isSigner&&!u.isWritable),i=e.filter(([,u])=>!u.isSigner&&u.isWritable),s=e.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:s.length};{At(t.length>0,"Expected at least one writable signer key");const[u]=t[0];At(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([u])=>new me(u)),...n.map(([u])=>new me(u)),...i.map(([u])=>new me(u)),...s.map(([u])=>new me(u))];return[o,a]}extractTableLookup(e){const[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&i.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:i},{writable:n,readonly:s}]}drainKeysFoundInLookupTable(e,t){const n=new Array,i=new Array;for(const[s,o]of this.keyMetaMap.entries())if(t(o)){const a=new me(s),u=e.findIndex(l=>l.equals(a));u>=0&&(At(u<256,"Max lookup table index exceeded"),n.push(u),i.push(a),this.keyMetaMap.delete(s))}return[n,i]}}const dk="Reached end of buffer unexpectedly";function Ji(r){if(r.length===0)throw new Error(dk);return r.shift()}function Sn(r,...e){const[t]=e;if(e.length===2?t+(e[1]??0)>r.length:t>=r.length)throw new Error(dk);return r.splice(...e)}class Oi{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new me(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:kr.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new fh(this.staticAccountKeys)}static compile(e){const t=Wp.compile(e.instructions,e.payerKey),[n,i]=t.getMessageComponents(),o=new fh(i).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:kr.encode(a.data)}));return new Oi({header:n,accountKeys:i,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const n=e-t,s=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<s}else{const n=t-this.header.numReadonlySignedAccounts;return e<n}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){const e=this.accountKeys.length;let t=[];Wn(t,e);const n=this.instructions.map(g=>{const{accounts:b,programIdIndex:w}=g,I=Array.from(kr.decode(g.data));let S=[];Wn(S,b.length);let x=[];return Wn(x,I.length),{programIdIndex:w,keyIndicesCount:Ne.from(S),keyIndices:b,dataLength:Ne.from(x),data:I}});let i=[];Wn(i,n.length);let s=Ne.alloc(Vo);Ne.from(i).copy(s);let o=i.length;n.forEach(g=>{const w=Pe([mt("programIdIndex"),Kt(g.keyIndicesCount.length,"keyIndicesCount"),Jr(mt("keyIndex"),g.keyIndices.length,"keyIndices"),Kt(g.dataLength.length,"dataLength"),Jr(mt("userdatum"),g.data.length,"data")]).encode(g,s,o);o+=w}),s=s.slice(0,o);const a=Pe([Kt(1,"numRequiredSignatures"),Kt(1,"numReadonlySignedAccounts"),Kt(1,"numReadonlyUnsignedAccounts"),Kt(t.length,"keyCount"),Jr(ut("key"),e,"keys"),ut("recentBlockhash")]),u={numRequiredSignatures:Ne.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Ne.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Ne.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Ne.from(t),keys:this.accountKeys.map(g=>st(g.toBytes())),recentBlockhash:kr.decode(this.recentBlockhash)};let l=Ne.alloc(2048);const h=a.encode(u,l);return s.copy(l,h),l.slice(0,h+s.length)}static from(e){let t=[...e];const n=Ji(t);if(n!==(n&jp))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=Ji(t),s=Ji(t),o=In(t);let a=[];for(let b=0;b<o;b++){const w=Sn(t,0,os);a.push(new me(Ne.from(w)))}const u=Sn(t,0,os),l=In(t);let h=[];for(let b=0;b<l;b++){const w=Ji(t),I=In(t),S=Sn(t,0,I),x=In(t),C=Sn(t,0,x),H=kr.encode(Ne.from(C));h.push({programIdIndex:w,accounts:S,data:H})}const g={header:{numRequiredSignatures:n,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:kr.encode(Ne.from(u)),accountKeys:a,instructions:h};return new Oi(g)}}class pc{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new fh(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(e>=n){const i=e-n,s=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return i<s}else if(e>=this.header.numRequiredSignatures){const i=e-t,o=n-t-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=t-this.header.numReadonlySignedAccounts;return e<i}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const n of this.addressTableLookups){const i=e.find(s=>s.key.equals(n.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const s of n.writableIndexes)if(s<i.state.addresses.length)t.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`);for(const s of n.readonlyIndexes)if(s<i.state.addresses.length)t.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){const t=Wp.compile(e.instructions,e.payerKey),n=new Array,i={writable:new Array,readonly:new Array},s=e.addressLookupTableAccounts||[];for(const h of s){const g=t.extractTableLookup(h);if(g!==void 0){const[b,{writable:w,readonly:I}]=g;n.push(b),i.writable.push(...w),i.readonly.push(...I)}}const[o,a]=t.getMessageComponents(),l=new fh(a,i).compileInstructions(e.instructions);return new pc({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:l,addressTableLookups:n})}serialize(){const e=Array();Wn(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),n=Array();Wn(n,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();Wn(s,this.addressTableLookups.length);const o=Pe([mt("prefix"),Pe([mt("numRequiredSignatures"),mt("numReadonlySignedAccounts"),mt("numReadonlyUnsignedAccounts")],"header"),Kt(e.length,"staticAccountKeysLength"),Jr(ut(),this.staticAccountKeys.length,"staticAccountKeys"),ut("recentBlockhash"),Kt(n.length,"instructionsLength"),Kt(t.length,"serializedInstructions"),Kt(s.length,"addressTableLookupsLength"),Kt(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(Vo),l=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(h=>h.toBytes()),recentBlockhash:kr.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},a);return a.slice(0,l)}serializeInstructions(){let e=0;const t=new Uint8Array(Vo);for(const n of this.compiledInstructions){const i=Array();Wn(i,n.accountKeyIndexes.length);const s=Array();Wn(s,n.data.length);const o=Pe([mt("programIdIndex"),Kt(i.length,"encodedAccountKeyIndexesLength"),Jr(mt(),n.accountKeyIndexes.length,"accountKeyIndexes"),Kt(s.length,"encodedDataLength"),Kt(n.data.length,"data")]);e+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(Vo);for(const n of this.addressTableLookups){const i=Array();Wn(i,n.writableIndexes.length);const s=Array();Wn(s,n.readonlyIndexes.length);const o=Pe([ut("accountKey"),Kt(i.length,"encodedWritableIndexesLength"),Jr(mt(),n.writableIndexes.length,"writableIndexes"),Kt(s.length,"encodedReadonlyIndexesLength"),Jr(mt(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const n=Ji(t),i=n&jp;At(n!==i,"Expected versioned message but received legacy message");const s=i;At(s===0,`Expected versioned message with version 0 but found version ${s}`);const o={numRequiredSignatures:Ji(t),numReadonlySignedAccounts:Ji(t),numReadonlyUnsignedAccounts:Ji(t)},a=[],u=In(t);for(let I=0;I<u;I++)a.push(new me(Sn(t,0,os)));const l=kr.encode(Sn(t,0,os)),h=In(t),g=[];for(let I=0;I<h;I++){const S=Ji(t),x=In(t),C=Sn(t,0,x),H=In(t),D=new Uint8Array(Sn(t,0,H));g.push({programIdIndex:S,accountKeyIndexes:C,data:D})}const b=In(t),w=[];for(let I=0;I<b;I++){const S=new me(Sn(t,0,os)),x=In(t),C=Sn(t,0,x),H=In(t),D=Sn(t,0,H);w.push({accountKey:S,writableIndexes:C,readonlyIndexes:D})}return new pc({header:o,staticAccountKeys:a,recentBlockhash:l,compiledInstructions:g,addressTableLookups:w})}}const jb={deserializeMessageVersion(r){const e=r[0],t=e&jp;return t===e?"legacy":t},deserialize:r=>{const e=jb.deserializeMessageVersion(r);if(e==="legacy")return Oi.from(r);if(e===0)return pc.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let vs=function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r}({});const zQ=Ne.alloc(lh).fill(0);class Bt{constructor(e){this.keys=void 0,this.programId=void 0,this.data=Ne.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}let Tt=class Z1{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{const{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new Bt(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let S=0;S<t.length;S++)if(t[S].programId===void 0)throw new Error(`Transaction instruction index ${S} has undefined program id`);const i=[],s=[];t.forEach(S=>{S.keys.forEach(C=>{s.push({...C})});const x=S.programId.toString();i.includes(x)||i.push(x)}),i.forEach(S=>{s.push({pubkey:new me(S),isSigner:!1,isWritable:!1})});const o=[];s.forEach(S=>{const x=S.pubkey.toString(),C=o.findIndex(H=>H.pubkey.toString()===x);C>-1?(o[C].isWritable=o[C].isWritable||S.isWritable,o[C].isSigner=o[C].isSigner||S.isSigner):o.push(S)}),o.sort(function(S,x){if(S.isSigner!==x.isSigner)return S.isSigner?-1:1;if(S.isWritable!==x.isWritable)return S.isWritable?-1:1;const C={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return S.pubkey.toBase58().localeCompare(x.pubkey.toBase58(),"en",C)});const a=o.findIndex(S=>S.pubkey.equals(n));if(a>-1){const[S]=o.splice(a,1);S.isSigner=!0,S.isWritable=!0,o.unshift(S)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const S of this.signatures){const x=o.findIndex(C=>C.pubkey.equals(S.publicKey));if(x>-1)o[x].isSigner||(o[x].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${S.publicKey.toString()}`)}let u=0,l=0,h=0;const g=[],b=[];o.forEach(({pubkey:S,isSigner:x,isWritable:C})=>{x?(g.push(S.toString()),u+=1,C||(l+=1)):(b.push(S.toString()),C||(h+=1))});const w=g.concat(b),I=t.map(S=>{const{data:x,programId:C}=S;return{programIdIndex:w.indexOf(C.toString()),accounts:S.keys.map(H=>w.indexOf(H.pubkey.toString())),data:kr.encode(x)}});return I.forEach(S=>{At(S.programIdIndex>=0),S.accounts.forEach(x=>At(x>=0))}),new Oi({header:{numRequiredSignatures:u,numReadonlySignedAccounts:l,numReadonlyUnsignedAccounts:h},accountKeys:w,recentBlockhash:e,instructions:I})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((i,s)=>t[s].equals(i.publicKey))||(this.signatures=t.map(n=>({signature:null,publicKey:n}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(n=>{const i=n.toString();return t.has(i)?!1:(t.add(i),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const s of e){const o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}this.signatures=n.map(s=>({signature:null,publicKey:s.publicKey}));const i=this._compile();this._partialSign(i,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const s of e){const o=s.publicKey.toString();t.has(o)||(t.add(o),n.push(s))}const i=this._compile();this._partialSign(i,...n)}_partialSign(e,...t){const n=e.serialize();t.forEach(i=>{const s=Hb(n,i.secretKey);this._addSignature(i.publicKey,st(s))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){At(t.length===64);const n=this.signatures.findIndex(i=>e.equals(i.publicKey));if(n<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=Ne.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const n={};for(const{signature:i,publicKey:s}of this.signatures)i===null?t&&(n.missing||(n.missing=[])).push(s):CQ(i,e,s.toBytes())||(n.invalid||(n.invalid=[])).push(s);return n.invalid||n.missing?n:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(n){const s=this._getMessageSignednessErrors(i,t);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
19
+ Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),s.missing&&(o+=`
20
+ Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(e){const{signatures:t}=this,n=[];Wn(n,t.length);const i=n.length+t.length*64+e.length,s=Ne.alloc(i);return At(t.length<256),Ne.from(n).copy(s,0),t.forEach(({signature:o},a)=>{o!==null&&(At(o.length===64,"signature has invalid length"),Ne.from(o).copy(s,n.length+a*64))}),e.copy(s,n.length+t.length*64),At(s.length<=Vo,`Transaction too large: ${s.length} > ${Vo}`),s}get keys(){return At(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return At(this.instructions.length===1),this.instructions[0].programId}get data(){return At(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e];const n=In(t);let i=[];for(let s=0;s<n;s++){const o=Sn(t,0,lh);i.push(kr.encode(Ne.from(o)))}return Z1.populate(Oi.from(t),i)}static populate(e,t=[]){const n=new Z1;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((i,s)=>{const o={signature:i==kr.encode(zQ)?null:kr.decode(i),publicKey:e.accountKeys[s]};n.signatures.push(o)}),e.instructions.forEach(i=>{const s=i.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:n.signatures.some(u=>u.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});n.instructions.push(new Bt({keys:s,programId:e.accountKeys[i.programIdIndex],data:kr.decode(i.data)}))}),n._message=e,n._json=n.toJSON(),n}};class Wb{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){const{header:n,compiledInstructions:i,recentBlockhash:s}=e,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:u}=n,l=o-a;At(l>0,"Message header is invalid");const h=e.staticAccountKeys.length-o-u;At(h>=0,"Message header is invalid");const g=e.getAccountKeys(t),b=g.get(0);if(b===void 0)throw new Error("Failed to decompile message because no account keys were found");const w=[];for(const I of i){const S=[];for(const C of I.accountKeyIndexes){const H=g.get(C);if(H===void 0)throw new Error(`Failed to find key for account key index ${C}`);const D=C<o;let z;D?z=C<l:C<g.staticAccountKeys.length?z=C-o<h:z=C-g.staticAccountKeys.length<g.accountKeysFromLookups.writable.length,S.push({pubkey:H,isSigner:C<n.numRequiredSignatures,isWritable:z})}const x=g.get(I.programIdIndex);if(x===void 0)throw new Error(`Failed to find program id for program id index ${I.programIdIndex}`);w.push(new Bt({programId:x,data:st(I.data),keys:S}))}return new Wb({payerKey:b,instructions:w,recentBlockhash:s})}compileToLegacyMessage(){return Oi.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return pc.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class Vb{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)At(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const n=[];for(let i=0;i<e.header.numRequiredSignatures;i++)n.push(new Uint8Array(lh));this.signatures=n}this.message=e}serialize(){const e=this.message.serialize(),t=Array();Wn(t,this.signatures.length);const n=Pe([Kt(t.length,"encodedSignaturesLength"),Jr(UQ(),this.signatures.length,"signatures"),Kt(e.length,"serializedMessage")]),i=new Uint8Array(2048),s=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,s)}static deserialize(e){let t=[...e];const n=[],i=In(t);for(let o=0;o<i;o++)n.push(new Uint8Array(Sn(t,0,lh)));const s=jb.deserialize(new Uint8Array(t));return new Vb(s,n)}sign(e){const t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of e){const s=n.findIndex(o=>o.equals(i.publicKey));At(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=Hb(t,i.secretKey)}}addSignature(e,t){At(t.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(e));At(i>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=t}}const GQ=160,KQ=64,jQ=GQ/KQ,pk=1e3/jQ,Zi=new me("SysvarC1ock11111111111111111111111111111111"),WQ=new me("SysvarEpochSchedu1e111111111111111111111111"),VQ=new me("Sysvar1nstructions1111111111111111111111111"),o0=new me("SysvarRecentB1ockHashes11111111111111111111"),pl=new me("SysvarRent111111111111111111111111111111111"),qQ=new me("SysvarRewards111111111111111111111111111111"),ZQ=new me("SysvarS1otHashes111111111111111111111111111"),QQ=new me("SysvarS1otHistory11111111111111111111111111"),a0=new me("SysvarStakeHistory1111111111111111111111111");class na extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:i}){const s=i?`Logs:
21
+ ${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(e){case"send":a=`Transaction ${t} resulted in an error.
22
+ ${n}. `+s+o;break;case"simulate":a=`Simulation failed.
23
+ Message: ${n}.
24
+ `+s+o;break;default:a=`Unknown action '${(u=>u)(e)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const s=i.meta.logMessages;this.transactionLogs=s,t(s)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}const JQ={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class De extends Error{constructor({code:e,message:t,data:n},i){super(i!=null?`${i}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}}async function Q1(r,e,t,n){const i=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},s=await r.sendTransaction(e,t,i);let o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:s,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,u=a.keys[0].pubkey;o=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:e.nonceInfo.nonce,signature:s},n&&n.commitment)).value}else(n==null?void 0:n.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await r.confirmTransaction(s,n&&n.commitment)).value;if(o.err)throw s!=null?new na({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function _a(r){return new Promise(e=>setTimeout(e,r))}function gt(r,e){const t=r.layout.span>=0?r.layout.span:hk(r,e),n=Ne.alloc(t),i=Object.assign({instruction:r.index},e);return r.layout.encode(i,n),n}function It(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.instruction!==r.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${r.index}`);return t}const gk=Kr("lamportsPerSignature"),yk=Pe([Be("version"),Be("state"),ut("authorizedPubkey"),ut("nonce"),Pe([gk],"feeCalculator")]),J1=yk.span;class Vp{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=yk.decode(st(e),0);return new Vp({authorizedPubkey:new me(t.authorizedPubkey),nonce:new me(t.nonce).toString(),feeCalculator:t.feeCalculator})}}const YQ=r=>{const e=r.decode.bind(r),t=r.encode.bind(r);return{decode:e,encode:t}},XQ=r=>e=>{const t=Kt(r,e),{encode:n,decode:i}=YQ(t),s=t;return s.decode=(o,a)=>{const u=i(o,a);return vZ(Ne.from(u))},s.encode=(o,a,u)=>{const l=WS(o,r);return n(l,a,u)},s},gl=XQ(8);class eJ{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Be("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Ht))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a SystemInstruction");return i}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:n,programId:i}=It(Ht.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new me(i)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=It(Ht.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:n,programId:i}=It(Ht.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new me(i)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=It(Ht.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,space:i,programId:s}=It(Ht.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new me(t),seed:n,space:i,programId:new me(s)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=It(Ht.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new me(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,programId:i}=It(Ht.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new me(t),seed:n,programId:new me(i)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:n,lamports:i,space:s,programId:o}=It(Ht.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new me(t),seed:n,lamports:i,space:s,programId:new me(o)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=It(Ht.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new me(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),It(Ht.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=It(Ht.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=It(Ht.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new me(t)}}static checkProgramId(e){if(!e.equals(Nr.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Ht=Object.freeze({Create:{index:0,layout:Pe([Be("instruction"),jn("lamports"),jn("space"),ut("programId")])},Assign:{index:1,layout:Pe([Be("instruction"),ut("programId")])},Transfer:{index:2,layout:Pe([Be("instruction"),gl("lamports")])},CreateWithSeed:{index:3,layout:Pe([Be("instruction"),ut("base"),Ra("seed"),jn("lamports"),jn("space"),ut("programId")])},AdvanceNonceAccount:{index:4,layout:Pe([Be("instruction")])},WithdrawNonceAccount:{index:5,layout:Pe([Be("instruction"),jn("lamports")])},InitializeNonceAccount:{index:6,layout:Pe([Be("instruction"),ut("authorized")])},AuthorizeNonceAccount:{index:7,layout:Pe([Be("instruction"),ut("authorized")])},Allocate:{index:8,layout:Pe([Be("instruction"),jn("space")])},AllocateWithSeed:{index:9,layout:Pe([Be("instruction"),ut("base"),Ra("seed"),jn("space"),ut("programId")])},AssignWithSeed:{index:10,layout:Pe([Be("instruction"),ut("base"),Ra("seed"),ut("programId")])},TransferWithSeed:{index:11,layout:Pe([Be("instruction"),gl("lamports"),Ra("seed"),ut("programId")])},UpgradeNonceAccount:{index:12,layout:Pe([Be("instruction")])}});class Nr{constructor(){}static createAccount(e){const t=Ht.Create,n=gt(t,{lamports:e.lamports,space:e.space,programId:st(e.programId.toBuffer())});return new Bt({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if("basePubkey"in e){const i=Ht.TransferWithSeed;t=gt(i,{lamports:BigInt(e.lamports),seed:e.seed,programId:st(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=Ht.Transfer;t=gt(i,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Bt({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){const i=Ht.AssignWithSeed;t=gt(i,{base:st(e.basePubkey.toBuffer()),seed:e.seed,programId:st(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=Ht.Assign;t=gt(i,{programId:st(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Bt({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Ht.CreateWithSeed,n=gt(t,{base:st(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:st(e.programId.toBuffer())});let i=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||i.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Bt({keys:i,programId:this.programId,data:n})}static createNonceAccount(e){const t=new Tt;"basePubkey"in e&&"seed"in e?t.add(Nr.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:J1,programId:this.programId})):t.add(Nr.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:J1,programId:this.programId}));const n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){const t=Ht.InitializeNonceAccount,n=gt(t,{authorized:st(e.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:o0,isSigner:!1,isWritable:!1},{pubkey:pl,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Bt(i)}static nonceAdvance(e){const t=Ht.AdvanceNonceAccount,n=gt(t),i={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:o0,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Bt(i)}static nonceWithdraw(e){const t=Ht.WithdrawNonceAccount,n=gt(t,{lamports:e.lamports});return new Bt({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:o0,isSigner:!1,isWritable:!1},{pubkey:pl,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){const t=Ht.AuthorizeNonceAccount,n=gt(t,{authorized:st(e.newAuthorizedPubkey.toBuffer())});return new Bt({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if("basePubkey"in e){const i=Ht.AllocateWithSeed;t=gt(i,{base:st(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:st(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=Ht.Allocate;t=gt(i,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Bt({keys:n,programId:this.programId,data:t})}}Nr.programId=new me("11111111111111111111111111111111");const tJ=Vo-300;class gc{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/gc.chunkSize)+1+1)}static async load(e,t,n,i,s){{const g=await e.getMinimumBalanceForRentExemption(s.length),b=await e.getAccountInfo(n.publicKey,"confirmed");let w=null;if(b!==null){if(b.executable)return console.error("Program load failed, account is already executable"),!1;b.data.length!==s.length&&(w=w||new Tt,w.add(Nr.allocate({accountPubkey:n.publicKey,space:s.length}))),b.owner.equals(i)||(w=w||new Tt,w.add(Nr.assign({accountPubkey:n.publicKey,programId:i}))),b.lamports<g&&(w=w||new Tt,w.add(Nr.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:g-b.lamports})))}else w=new Tt().add(Nr.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:g>0?g:1,space:s.length,programId:i}));w!==null&&await Q1(e,w,[t,n],{commitment:"confirmed"})}const o=Pe([Be("instruction"),Be("offset"),Be("bytesLength"),Be("bytesLengthPadding"),Jr(mt("byte"),Wo(Be(),-8),"bytes")]),a=gc.chunkSize;let u=0,l=s,h=[];for(;l.length>0;){const g=l.slice(0,a),b=Ne.alloc(a+16);o.encode({instruction:0,offset:u,bytes:g,bytesLength:0,bytesLengthPadding:0},b);const w=new Tt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:b});h.push(Q1(e,w,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await _a(1e3/4),u+=a,l=l.slice(a)}await Promise.all(h);{const g=Pe([Be("instruction")]),b=Ne.alloc(g.span);g.encode({instruction:1},b);const w=new Tt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:pl,isSigner:!1,isWritable:!1}],programId:i,data:b}),I="processed",S=await e.sendTransaction(w,[t,n],{preflightCommitment:I}),{context:x,value:C}=await e.confirmTransaction({signature:S,lastValidBlockHeight:w.lastValidBlockHeight,blockhash:w.recentBlockhash},I);if(C.err)throw new Error(`Transaction ${S} failed (${JSON.stringify(C)})`);for(;;){try{if(await e.getSlot({commitment:I})>x.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(pk/2)))}}return!0}}gc.chunkSize=tJ;const rJ=new me("BPFLoader2111111111111111111111111111111111");class nJ{static getMinNumSignatures(e){return gc.getMinNumSignatures(e)}static load(e,t,n,i,s){return gc.load(e,t,n,s,i)}}function iJ(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Hm,s2;function sJ(){if(s2)return Hm;s2=1;var r=Object.prototype.toString,e=Object.keys||function(n){var i=[];for(var s in n)i.push(s);return i};function t(n,i){var s,o,a,u,l,h,g;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return t(n.toJSON(),i);if(g=r.call(n),g==="[object Array]"){for(a="[",o=n.length-1,s=0;s<o;s++)a+=t(n[s],!0)+",";return o>-1&&(a+=t(n[s],!0)),a+"]"}else if(g==="[object Object]"){for(u=e(n).sort(),o=u.length,a="",s=0;s<o;)l=u[s],h=t(n[l],!1),h!==void 0&&(a&&(a+=","),a+=JSON.stringify(l)+":"+h),s++;return"{"+a+"}"}else return JSON.stringify(n);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return Hm=function(n){var i=t(n,!1);if(i!==void 0)return""+i},Hm}var oJ=sJ(),o2=iJ(oJ);const xf=32;function zm(r){let e=0;for(;r>1;)r/=2,e++;return e}function aJ(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}class mk{constructor(e,t,n,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=zm(aJ(e+xf+1))-zm(xf)-1,n=this.getSlotsInEpoch(t),i=e-(n-xf);return[t,i]}else{const t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),i=this.firstNormalEpoch+n,s=t%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*xf:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+zm(xf)):this.slotsPerEpoch}}var cJ=globalThis.fetch;class uJ extends uQ{constructor(e,t,n){const i=s=>{const o=aQ(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,e,t,n),this.underlyingSocket=void 0}call(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function lJ(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${r.index}`);return t}const a2=56;class Y1{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=lJ(fJ,e),n=e.length-a2;At(n>=0,"lookup table is invalid"),At(n%32===0,"lookup table is invalid");const i=n/32,{addresses:s}=Pe([Jr(ut(),i,"addresses")]).decode(e.slice(a2));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new me(t.authority[0]):void 0,addresses:s.map(o=>new me(o))}}}const fJ={index:1,layout:Pe([Be("typeIndex"),gl("deactivationSlot"),Kr("lastExtendedSlot"),mt("lastExtendedStartIndex"),mt(),Jr(ut(),Wo(mt(),-1),"authority")])},hJ=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function dJ(r){const e=r.match(hJ);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);const[t,n,i,s]=e,o=r.startsWith("https:")?"wss:":"ws:",a=i==null?null:parseInt(i.slice(1),10),u=a==null?"":`:${a+1}`;return`${o}//${n}${u}${s}`}const or=od($b(me),_e(),r=>new me(r)),wk=Fb([_e(),nr("base64")]),qb=od($b(Ne),wk,r=>Ne.from(r[0],"base64")),bk=30*1e3;function pJ(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function $t(r){let e,t;if(typeof r=="string")e=r;else if(r){const{commitment:n,...i}=r;e=n,t=i}return{commitment:e,config:t}}function c2(r){return r.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function _k(r){return vn([ge({jsonrpc:nr("2.0"),id:_e(),result:r}),ge({jsonrpc:nr("2.0"),id:_e(),error:ge({code:Dl(),message:_e(),data:Fe(NZ())})})])}const gJ=_k(Dl());function it(r){return od(_k(r),gJ,e=>"error"in e?e:{...e,result:Ae(e.result,r)})}function vr(r){return it(ge({context:ge({slot:X()}),value:r}))}function qp(r){return ge({context:ge({slot:X()}),value:r})}function Gm(r,e){return r===0?new pc({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new me(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:kr.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new Oi(e)}const yJ=ge({foundation:X(),foundationTerm:X(),initial:X(),taper:X(),terminal:X()}),mJ=it(Re(Ie(ge({epoch:X(),effectiveSlot:X(),amount:X(),postBalance:X(),commission:Fe(Ie(X()))})))),wJ=Re(ge({slot:X(),prioritizationFee:X()})),bJ=ge({total:X(),validator:X(),foundation:X(),epoch:X()}),_J=ge({epoch:X(),slotIndex:X(),slotsInEpoch:X(),absoluteSlot:X(),blockHeight:Fe(X()),transactionCount:Fe(X())}),AJ=ge({slotsPerEpoch:X(),leaderScheduleSlotOffset:X(),warmup:hs(),firstNormalEpoch:X(),firstNormalSlot:X()}),vJ=ZS(_e(),Re(X())),Tc=Ie(vn([ge({}),_e()])),EJ=ge({err:Tc}),xJ=nr("receivedSignature"),RJ=ge({"solana-core":_e(),"feature-set":Fe(X())}),IJ=ge({program:_e(),programId:or,parsed:Dl()}),SJ=ge({programId:or,accounts:Re(or),data:_e()}),u2=vr(ge({err:Ie(vn([ge({}),_e()])),logs:Ie(Re(_e())),accounts:Fe(Ie(Re(Ie(ge({executable:hs(),owner:_e(),lamports:X(),data:Re(_e()),rentEpoch:Fe(X())}))))),unitsConsumed:Fe(X()),returnData:Fe(Ie(ge({programId:_e(),data:Fb([_e(),nr("base64")])}))),innerInstructions:Fe(Ie(Re(ge({index:X(),instructions:Re(vn([IJ,SJ]))}))))})),kJ=vr(ge({byIdentity:ZS(_e(),Re(X())),range:ge({firstSlot:X(),lastSlot:X()})}));function TJ(r,e,t,n,i,s){const o=t||cJ;let a;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return n&&(u=async(h,g)=>{const b=await new Promise((w,I)=>{try{n(h,g,(S,x)=>w([S,x]))}catch(S){I(S)}});return await o(...b)}),new iQ(async(h,g)=>{const b={method:"POST",body:h,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},TY)};try{let w=5,I,S=500;for(;u?I=await u(r,b):I=await o(r,b),!(I.status!==429||i===!0||(w-=1,w===0));)console.error(`Server responded with ${I.status} ${I.statusText}. Retrying after ${S}ms delay...`),await _a(S),S*=2;const x=await I.text();I.ok?g(null,x):g(new Error(`${I.status} ${I.statusText}: ${x}`))}catch(w){w instanceof Error&&g(w)}},{})}function OJ(r){return(e,t)=>new Promise((n,i)=>{r.request(e,t,(s,o)=>{if(s){i(s);return}n(o)})})}function NJ(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);const i=e.map(s=>r.request(s.methodName,s.args));r.request(i,(s,o)=>{if(s){n(s);return}t(o)})})}const CJ=it(yJ),BJ=it(bJ),PJ=it(wJ),MJ=it(_J),LJ=it(AJ),UJ=it(vJ),DJ=it(X()),$J=vr(ge({total:X(),circulating:X(),nonCirculating:X(),nonCirculatingAccounts:Re(or)})),X1=ge({amount:_e(),uiAmount:Ie(X()),decimals:X(),uiAmountString:Fe(_e())}),FJ=vr(Re(ge({address:or,amount:_e(),uiAmount:Ie(X()),decimals:X(),uiAmountString:Fe(_e())}))),HJ=vr(Re(ge({pubkey:or,account:ge({executable:hs(),owner:or,lamports:X(),data:qb,rentEpoch:X()})}))),ew=ge({program:_e(),parsed:Dl(),space:X()}),zJ=vr(Re(ge({pubkey:or,account:ge({executable:hs(),owner:or,lamports:X(),data:ew,rentEpoch:X()})}))),GJ=vr(Re(ge({lamports:X(),address:or}))),hh=ge({executable:hs(),owner:or,lamports:X(),data:qb,rentEpoch:X()}),KJ=ge({pubkey:or,account:hh}),jJ=od(vn([$b(Ne),ew]),vn([wk,ew]),r=>Array.isArray(r)?Ae(r,qb):r),tw=ge({executable:hs(),owner:or,lamports:X(),data:jJ,rentEpoch:X()}),WJ=ge({pubkey:or,account:tw}),VJ=ge({state:vn([nr("active"),nr("inactive"),nr("activating"),nr("deactivating")]),active:X(),inactive:X()}),qJ=it(Re(ge({signature:_e(),slot:X(),err:Tc,memo:Ie(_e()),blockTime:Fe(Ie(X()))}))),ZJ=it(Re(ge({signature:_e(),slot:X(),err:Tc,memo:Ie(_e()),blockTime:Fe(Ie(X()))}))),QJ=ge({subscription:X(),result:qp(hh)}),JJ=ge({pubkey:or,account:hh}),YJ=ge({subscription:X(),result:qp(JJ)}),XJ=ge({parent:X(),slot:X(),root:X()}),eY=ge({subscription:X(),result:XJ}),tY=vn([ge({type:vn([nr("firstShredReceived"),nr("completed"),nr("optimisticConfirmation"),nr("root")]),slot:X(),timestamp:X()}),ge({type:nr("createdBank"),parent:X(),slot:X(),timestamp:X()}),ge({type:nr("frozen"),slot:X(),timestamp:X(),stats:ge({numTransactionEntries:X(),numSuccessfulTransactions:X(),numFailedTransactions:X(),maxTransactionsPerEntry:X()})}),ge({type:nr("dead"),slot:X(),timestamp:X(),err:_e()})]),rY=ge({subscription:X(),result:tY}),nY=ge({subscription:X(),result:qp(vn([EJ,xJ]))}),iY=ge({subscription:X(),result:X()}),sY=ge({pubkey:_e(),gossip:Ie(_e()),tpu:Ie(_e()),rpc:Ie(_e()),version:Ie(_e())}),l2=ge({votePubkey:_e(),nodePubkey:_e(),activatedStake:X(),epochVoteAccount:hs(),epochCredits:Re(Fb([X(),X(),X()])),commission:X(),lastVote:X(),rootSlot:Ie(X())}),oY=it(ge({current:Re(l2),delinquent:Re(l2)})),aY=vn([nr("processed"),nr("confirmed"),nr("finalized")]),cY=ge({slot:X(),confirmations:Ie(X()),err:Tc,confirmationStatus:Fe(aY)}),uY=vr(Re(Ie(cY))),lY=it(X()),Ak=ge({accountKey:or,writableIndexes:Re(X()),readonlyIndexes:Re(X())}),Zb=ge({signatures:Re(_e()),message:ge({accountKeys:Re(_e()),header:ge({numRequiredSignatures:X(),numReadonlySignedAccounts:X(),numReadonlyUnsignedAccounts:X()}),instructions:Re(ge({accounts:Re(X()),data:_e(),programIdIndex:X()})),recentBlockhash:_e(),addressTableLookups:Fe(Re(Ak))})}),vk=ge({pubkey:or,signer:hs(),writable:hs(),source:Fe(vn([nr("transaction"),nr("lookupTable")]))}),Ek=ge({accountKeys:Re(vk),signatures:Re(_e())}),xk=ge({parsed:Dl(),program:_e(),programId:or}),Rk=ge({accounts:Re(or),data:_e(),programId:or}),fY=vn([Rk,xk]),hY=vn([ge({parsed:Dl(),program:_e(),programId:_e()}),ge({accounts:Re(_e()),data:_e(),programId:_e()})]),Ik=od(fY,hY,r=>"accounts"in r?Ae(r,Rk):Ae(r,xk)),Sk=ge({signatures:Re(_e()),message:ge({accountKeys:Re(vk),instructions:Re(Ik),recentBlockhash:_e(),addressTableLookups:Fe(Ie(Re(Ak)))})}),z0=ge({accountIndex:X(),mint:_e(),owner:Fe(_e()),programId:Fe(_e()),uiTokenAmount:X1}),kk=ge({writable:Re(or),readonly:Re(or)}),Zp=ge({err:Tc,fee:X(),innerInstructions:Fe(Ie(Re(ge({index:X(),instructions:Re(ge({accounts:Re(X()),data:_e(),programIdIndex:X()}))})))),preBalances:Re(X()),postBalances:Re(X()),logMessages:Fe(Ie(Re(_e()))),preTokenBalances:Fe(Ie(Re(z0))),postTokenBalances:Fe(Ie(Re(z0))),loadedAddresses:Fe(kk),computeUnitsConsumed:Fe(X())}),Qb=ge({err:Tc,fee:X(),innerInstructions:Fe(Ie(Re(ge({index:X(),instructions:Re(Ik)})))),preBalances:Re(X()),postBalances:Re(X()),logMessages:Fe(Ie(Re(_e()))),preTokenBalances:Fe(Ie(Re(z0))),postTokenBalances:Fe(Ie(Re(z0))),loadedAddresses:Fe(kk),computeUnitsConsumed:Fe(X())}),$l=vn([nr(0),nr("legacy")]),Oc=ge({pubkey:_e(),lamports:X(),postBalance:Ie(X()),rewardType:Ie(_e()),commission:Fe(Ie(X()))}),dY=it(Ie(ge({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(ge({transaction:Zb,meta:Ie(Zp),version:Fe($l)})),rewards:Fe(Re(Oc)),blockTime:Ie(X()),blockHeight:Ie(X())}))),pY=it(Ie(ge({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),rewards:Fe(Re(Oc)),blockTime:Ie(X()),blockHeight:Ie(X())}))),gY=it(Ie(ge({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(ge({transaction:Ek,meta:Ie(Zp),version:Fe($l)})),rewards:Fe(Re(Oc)),blockTime:Ie(X()),blockHeight:Ie(X())}))),yY=it(Ie(ge({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(ge({transaction:Sk,meta:Ie(Qb),version:Fe($l)})),rewards:Fe(Re(Oc)),blockTime:Ie(X()),blockHeight:Ie(X())}))),mY=it(Ie(ge({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(ge({transaction:Ek,meta:Ie(Qb),version:Fe($l)})),rewards:Fe(Re(Oc)),blockTime:Ie(X()),blockHeight:Ie(X())}))),wY=it(Ie(ge({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),rewards:Fe(Re(Oc)),blockTime:Ie(X()),blockHeight:Ie(X())}))),bY=it(Ie(ge({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),transactions:Re(ge({transaction:Zb,meta:Ie(Zp)})),rewards:Fe(Re(Oc)),blockTime:Ie(X())}))),f2=it(Ie(ge({blockhash:_e(),previousBlockhash:_e(),parentSlot:X(),signatures:Re(_e()),blockTime:Ie(X())}))),Km=it(Ie(ge({slot:X(),meta:Ie(Zp),blockTime:Fe(Ie(X())),transaction:Zb,version:Fe($l)}))),zd=it(Ie(ge({slot:X(),transaction:Sk,meta:Ie(Qb),blockTime:Fe(Ie(X())),version:Fe($l)}))),_Y=vr(ge({blockhash:_e(),lastValidBlockHeight:X()})),AY=vr(hs()),vY=ge({slot:X(),numTransactions:X(),numSlots:X(),samplePeriodSecs:X()}),EY=it(Re(vY)),xY=vr(Ie(ge({feeCalculator:ge({lamportsPerSignature:X()})}))),RY=it(_e()),IY=it(_e()),SY=ge({err:Tc,logs:Re(_e()),signature:_e()}),kY=ge({result:qp(SY),subscription:X()}),TY={"solana-client":"js/1.0.0-maintenance"};class Tk{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const l={};return async h=>{const{commitment:g,config:b}=$t(h),w=this._buildArgs([],g,void 0,b),I=o2(w);return l[I]=l[I]??(async()=>{try{const S=await this._rpcRequest("getBlockHeight",w),x=Ae(S,it(X()));if("error"in x)throw new De(x.error,"failed to get block height information");return x.result}finally{delete l[I]}})(),await l[I]}})();let n,i,s,o,a,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,i=t.httpHeaders,s=t.fetch,o=t.fetchMiddleware,a=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=pJ(e),this._rpcWsEndpoint=n||dJ(e),this._rpcClient=TJ(e,i,s,o,a,u),this._rpcRequest=OJ(this._rpcClient),this._rpcBatchRequest=NJ(this._rpcClient),this._rpcWebSocket=new uJ(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgs([e.toBase58()],n,void 0,i),o=await this._rpcRequest("getBalance",s),a=Ae(o,vr(X()));if("error"in a)throw new De(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+n)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),n=Ae(t,it(Ie(X())));if("error"in n)throw new De(n.error,`failed to get block time for slot ${e}`);return n.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=Ae(e,it(X()));if("error"in t)throw new De(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=Ae(e,DJ);if("error"in t)throw new De(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[t]),i=Ae(n,$J);if("error"in i)throw new De(i.error,"failed to get supply");return i.result}async getTokenSupply(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenSupply",n),s=Ae(i,vr(X1));if("error"in s)throw new De(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenAccountBalance",n),s=Ae(i,vr(X1));if("error"in s)throw new De(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(e,t,n){const{commitment:i,config:s}=$t(n);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const a=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",a),l=Ae(u,HJ);if("error"in l)throw new De(l.error,`failed to get token accounts owned by account ${e.toBase58()}`);return l.result}async getParsedTokenAccountsByOwner(e,t,n){let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});const s=this._buildArgs(i,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),a=Ae(o,zJ);if("error"in a)throw new De(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],i=await this._rpcRequest("getLargestAccounts",n),s=Ae(i,GJ);if("error"in s)throw new De(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(e,t){const n=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenLargestAccounts",n),s=Ae(i,FJ);if("error"in s)throw new De(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgs([e.toBase58()],n,"base64",i),o=await this._rpcRequest("getAccountInfo",s),a=Ae(o,vr(Ie(hh)));if("error"in a)throw new De(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),a=Ae(o,vr(Ie(tw)));if("error"in a)throw new De(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(n){throw new Error("failed to get info about account "+e.toBase58()+": "+n)}}async getMultipleParsedAccounts(e,t){const{commitment:n,config:i}=$t(t),s=e.map(l=>l.toBase58()),o=this._buildArgs([s],n,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",o),u=Ae(a,vr(Re(Ie(tw))));if("error"in u)throw new De(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:n,config:i}=$t(t),s=e.map(l=>l.toBase58()),o=this._buildArgs([s],n,"base64",i),a=await this._rpcRequest("getMultipleAccounts",o),u=Ae(a,vr(Re(Ie(hh))));if("error"in u)throw new De(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){const{commitment:i,config:s}=$t(t),o=this._buildArgs([e.toBase58()],i,void 0,{...s,epoch:n??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getStakeActivation",o),u=Ae(a,it(VJ));if("error"in u)throw new De(u.error,`failed to get Stake Activation ${e.toBase58()}`);return u.result}async getProgramAccounts(e,t){const{commitment:n,config:i}=$t(t),{encoding:s,...o}=i||{},a=this._buildArgs([e.toBase58()],n,s||"base64",{...o,...o.filters?{filters:c2(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",a),l=Re(KJ),h=o.withContext===!0?Ae(u,vr(l)):Ae(u,it(l));if("error"in h)throw new De(h.error,`failed to get accounts owned by program ${e.toBase58()}`);return h.result}async getParsedProgramAccounts(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgs([e.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),a=Ae(o,it(Re(WJ)));if("error"in a)throw new De(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){var s;let n;if(typeof e=="string")n=e;else{const o=e;if((s=o.abortSignal)!=null&&s.aborted)return Promise.reject(o.abortSignal.reason);n=o.signature}let i;try{i=kr.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return At(i.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener("abort",()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,i,s=!1;const o=new Promise((u,l)=>{try{n=this.onSignature(t,(g,b)=>{n=void 0;const w={context:b,value:g};u({__type:vs.PROCESSED,response:w})},e);const h=new Promise(g=>{n==null?g():i=this._onSubscriptionStateChange(n,b=>{b==="subscribed"&&g()})});(async()=>{if(await h,s)return;const g=await this.getSignatureStatus(t);if(s||g==null)return;const{context:b,value:w}=g;if(w!=null)if(w!=null&&w.err)l(w.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(w.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(w.confirmationStatus==="processed"||w.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,u({__type:vs.PROCESSED,response:{context:b,value:w}})}})()}catch(h){l(h)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:i}}){let s=!1;const o=new Promise(g=>{const b=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let w=await b();if(!s){for(;w<=n;)if(await _a(1e3),s||(w=await b(),s))return;g({__type:vs.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),l=this.getCancellationPromise(t);let h;try{const g=await Promise.race([l,u,o]);if(g.__type===vs.PROCESSED)h=g.response;else throw new Gb(i)}finally{s=!0,a()}return h}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let a=!1;const u=new Promise(w=>{let I=s,S=null;const x=async()=>{try{const{context:C,value:H}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:n});return S=C.slot,H==null?void 0:H.nonce}catch{return I}};(async()=>{if(I=await x(),!a)for(;;){if(s!==I){w({__type:vs.NONCE_INVALID,slotInWhichNonceDidAdvance:S});return}if(await _a(2e3),a||(I=await x(),a))return}})()}),{abortConfirmation:l,confirmationPromise:h}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),g=this.getCancellationPromise(t);let b;try{const w=await Promise.race([g,h,u]);if(w.__type===vs.PROCESSED)b=w.response;else{let I;for(;;){const S=await this.getSignatureStatus(o);if(S==null)break;if(S.context.slot<(w.slotInWhichNonceDidAdvance??n)){await _a(400);continue}I=S;break}if(I!=null&&I.value){const S=e||"finalized",{confirmationStatus:x}=I.value;switch(S){case"processed":case"recent":if(x!=="processed"&&x!=="confirmed"&&x!=="finalized")throw new nu(o);break;case"confirmed":case"single":case"singleGossip":if(x!=="confirmed"&&x!=="finalized")throw new nu(o);break;case"finalized":case"max":case"root":if(x!=="finalized")throw new nu(o);break;default:}b={context:I.context,value:{err:I.value.err}}}else throw new nu(o)}}finally{a=!0,l()}return b}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n;const i=new Promise(u=>{let l=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{l=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:vs.TIMED_OUT,timeoutMs:l}),l)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const u=await Promise.race([o,i]);if(u.__type===vs.PROCESSED)a=u.response;else throw new Kb(t,u.timeoutMs/1e3)}finally{clearTimeout(n),s()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=Ae(e,it(Re(sY)));if("error"in t)throw new De(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getVoteAccounts",t),i=Ae(n,oY);if("error"in i)throw new De(i.error,"failed to get vote accounts");return i.result}async getSlot(e){const{commitment:t,config:n}=$t(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlot",i),o=Ae(s,it(X()));if("error"in o)throw new De(o.error,"failed to get slot");return o.result}async getSlotLeader(e){const{commitment:t,config:n}=$t(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getSlotLeader",i),o=Ae(s,it(_e()));if("error"in o)throw new De(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){const n=[e,t],i=await this._rpcRequest("getSlotLeaders",n),s=Ae(i,it(Re(or)));if("error"in s)throw new De(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(e,t){const{context:n,value:i}=await this.getSignatureStatuses([e],t);At(i.length===1);const s=i[0];return{context:n,value:s}}async getSignatureStatuses(e,t){const n=[e];t&&n.push(t);const i=await this._rpcRequest("getSignatureStatuses",n),s=Ae(i,uY);if("error"in s)throw new De(s.error,"failed to get signature status");return s.result}async getTransactionCount(e){const{commitment:t,config:n}=$t(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getTransactionCount",i),o=Ae(s,it(X()));if("error"in o)throw new De(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getInflationGovernor",t),i=Ae(n,CJ);if("error"in i)throw new De(i.error,"failed to get inflation");return i.result}async getInflationReward(e,t,n){const{commitment:i,config:s}=$t(n),o=this._buildArgs([e.map(l=>l.toBase58())],i,void 0,{...s,epoch:t??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getInflationReward",o),u=Ae(a,mJ);if("error"in u)throw new De(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=Ae(e,BJ);if("error"in t)throw new De(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:n}=$t(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getEpochInfo",i),o=Ae(s,MJ);if("error"in o)throw new De(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=Ae(e,LJ);if("error"in t)throw new De(t.error,"failed to get epoch schedule");const n=t.result;return new mk(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=Ae(e,UJ);if("error"in t)throw new De(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const n=this._buildArgs([e],t),i=await this._rpcRequest("getMinimumBalanceForRentExemption",n),s=Ae(i,lY);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(e){const{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),n=Ae(t,EY);if("error"in n)throw new De(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(e,t){const n=this._buildArgs([e],t),i=await this._rpcRequest("getFeeCalculatorForBlockhash",n),s=Ae(i,xY);if("error"in s)throw new De(s.error,"failed to get fee calculator");const{context:o,value:a}=s.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const n=st(e.serialize()).toString("base64"),i=this._buildArgs([n],t),s=await this._rpcRequest("getFeeForMessage",i),o=Ae(s,vr(Ie(X())));if("error"in o)throw new De(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){var o;const t=(o=e==null?void 0:e.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),n=t!=null&&t.length?[t]:[],i=await this._rpcRequest("getRecentPrioritizationFees",n),s=Ae(i,PJ);if("error"in s)throw new De(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:n}=$t(e),i=this._buildArgs([],t,void 0,n),s=await this._rpcRequest("getLatestBlockhash",i),o=Ae(s,_Y);if("error"in o)throw new De(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgs([e],n,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),a=Ae(o,AY);if("error"in a)throw new De(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=Ae(e,it(RJ));if("error"in t)throw new De(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=Ae(e,it(_e()));if("error"in t)throw new De(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=Ae(o,gY);if("error"in a)throw a.error;return a.result}case"none":{const a=Ae(o,pY);if("error"in a)throw a.error;return a.result}default:{const a=Ae(o,dY);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:l,meta:h,version:g})=>({meta:h,transaction:{...l,message:Gm(g,l.message)},version:g}))}:null}}}catch(a){throw new De(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=Ae(o,mY);if("error"in a)throw a.error;return a.result}case"none":{const a=Ae(o,wY);if("error"in a)throw a.error;return a.result}default:{const a=Ae(o,yY);if("error"in a)throw a.error;return a.result}}}catch(a){throw new De(a,"failed to get block")}}async getBlockProduction(e){let t,n;if(typeof e=="string")n=e;else if(e){const{commitment:a,...u}=e;n=a,t=u}const i=this._buildArgs([],n,"base64",t),s=await this._rpcRequest("getBlockProduction",i),o=Ae(s,kJ);if("error"in o)throw new De(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgsAtLeastConfirmed([e],n,void 0,i),o=await this._rpcRequest("getTransaction",s),a=Ae(o,Km);if("error"in a)throw new De(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:Gm(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:n,config:i}=$t(t),s=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),a=Ae(o,zd);if("error"in a)throw new De(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:n,config:i}=$t(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{const l=Ae(u,zd);if("error"in l)throw new De(l.error,"failed to get transactions");return l.result})}async getTransactions(e,t){const{commitment:n,config:i}=$t(t),s=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{const l=Ae(u,Km);if("error"in l)throw new De(l.error,"failed to get transactions");const h=l.result;return h&&{...h,transaction:{...h.transaction,message:Gm(h.version,h.transaction.message)}}})}async getConfirmedBlock(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getBlock",n),s=Ae(i,bY);if("error"in s)throw new De(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");const a={...o,transactions:o.transactions.map(({transaction:u,meta:l})=>{const h=new Oi(u.message);return{meta:l,transaction:{...u,message:h}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:l})=>({meta:l,transaction:Tt.populate(u.message,u.signatures)}))}}async getBlocks(e,t,n){const i=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),s=await this._rpcRequest("getBlocks",i),o=Ae(s,it(Re(X())));if("error"in o)throw new De(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=Ae(i,f2);if("error"in s)throw new De(s.error,"failed to get block");const o=s.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),s=Ae(i,f2);if("error"in s)throw new De(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getTransaction",n),s=Ae(i,Km);if("error"in s)throw new De(s.error,"failed to get transaction");const o=s.result;if(!o)return o;const a=new Oi(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Tt.populate(a,u)}}async getParsedConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),i=await this._rpcRequest("getTransaction",n),s=Ae(i,zd);if("error"in s)throw new De(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(e,t){const n=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(o=>{const a=Ae(o,zd);if("error"in a)throw new De(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,n){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(t--,!(t<=0||t<s));)try{const u=await this.getConfirmedBlockSignatures(t,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(n++,!(n>o));)try{const u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(e,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){const i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=Ae(s,qJ);if("error"in o)throw new De(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,n){const i=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),s=await this._rpcRequest("getSignaturesForAddress",i),o=Ae(s,ZJ);if("error"in o)throw new De(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){const{context:n,value:i}=await this.getAccountInfoAndContext(e,t);let s=null;return i!==null&&(s=new Y1({key:e,state:Y1.deserialize(i.data)})),{context:n,value:s}}async getNonceAndContext(e,t){const{context:n,value:i}=await this.getAccountInfoAndContext(e,t);let s=null;return i!==null&&(s=Vp.fromAccountData(i.data)),{context:n,value:s}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+n)})}async requestAirdrop(e,t){const n=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),i=Ae(n,RY);if("error"in i)throw new De(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await _a(100);const n=Date.now()-this._blockhashInfo.lastFetch>=bk;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let i=0;i<50;i++){const s=await this.getLatestBlockhash("finalized");if(n!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await _a(pk/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:n}=$t(e),i=this._buildArgs([],t,"base64",n),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=Ae(s,vr(X()));if("error"in o)throw new De(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,n){if("message"in e){const S=e.serialize(),x=Ne.from(S).toString("base64");if(Array.isArray(t)||n!==void 0)throw new Error("Invalid arguments");const C=t||{};C.encoding="base64","commitment"in C||(C.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(C.innerInstructions=t.innerInstructions);const H=[x,C],D=await this._rpcRequest("simulateTransaction",H),z=Ae(D,u2);if("error"in z)throw new Error("failed to simulate transaction: "+z.error.message);return z.result}let i;if(e instanceof Tt){let I=e;i=new Tt,i.feePayer=I.feePayer,i.instructions=e.instructions,i.nonceInfo=I.nonceInfo,i.signatures=I.signatures}else i=Tt.populate(e),i._message=i._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(i.nonceInfo&&s)i.sign(...s);else{let I=this._disableBlockhashCaching;for(;;){const S=await this._blockhashWithExpiryBlockHeight(I);if(i.lastValidBlockHeight=S.lastValidBlockHeight,i.recentBlockhash=S.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");const x=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(x)&&!this._blockhashInfo.transactionSignatures.includes(x)){this._blockhashInfo.simulatedSignatures.push(x);break}else I=!0}}const o=i._compile(),a=o.serialize(),l=i._serialize(a).toString("base64"),h={encoding:"base64",commitment:this.commitment};if(n){const I=(Array.isArray(n)?n:o.nonProgramIds()).map(S=>S.toBase58());h.accounts={encoding:"base64",addresses:I}}s&&(h.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(h.innerInstructions=t.innerInstructions);const g=[l,h],b=await this._rpcRequest("simulateTransaction",g),w=Ae(b,u2);if("error"in w){let I;if("data"in w.error&&(I=w.error.data.logs,I&&Array.isArray(I))){const S=`
25
+ `,x=S+I.join(S);console.error(w.error.message,x)}throw new na({action:"simulate",signature:"",transactionMessage:w.error.message,logs:I})}return w.result}async sendTransaction(e,t,n){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(e.nonceInfo)e.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...i),!e.signature)throw new Error("!signature");const u=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const s=e.serialize();return await this.sendRawTransaction(s,n)}async sendRawTransaction(e,t){const n=st(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){const n={encoding:"base64"},i=t&&t.skipPreflight,s=i===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),i&&(n.skipPreflight=i),s&&(n.preflightCommitment=s);const o=[e,n],a=await this._rpcRequest("sendTransaction",o),u=Ae(a,IY);if("error"in u){let l;throw"data"in u.error&&(l=u.error.data.logs),new na({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:l})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,n])=>{this._setSubscription(t,{...n,state:"pending"})})}_setSubscription(e,t){var i;const n=(i=this._subscriptionsByHash[e])==null?void 0:i.state;if(this._subscriptionsByHash[e]=t,n!==t.state){const s=this._subscriptionStateChangeCallbacksByHash[e];s&&s.forEach(o=>{try{o(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){var s;const n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};const i=(s=this._subscriptionStateChangeCallbacksByHash)[n]||(s[n]=new Set);return i.add(t),()=>{i.delete(t),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const i=this._subscriptionsByHash[n];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[n],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:o}=i;try{this._setSubscription(n,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(o,s);this._setSubscription(n,{...i,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=i.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:s,error:a}),!t())return;this._setSubscription(n,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:s,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(n,{...i,state:"unsubscribing"}),this._setSubscription(n,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!t())return;this._setSubscription(n,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(i=>{try{i(...t)}catch(s){console.error(s)}})}_wsOnAccountNotification(e){const{result:t,subscription:n}=Ae(e,QJ);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){const n=this._nextClientSubscriptionId++,i=o2([e.method,t]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:s.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const o=this._subscriptionsByHash[i];At(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){const{commitment:i,config:s}=$t(n),o=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:n}=Ae(e,YJ);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,i){const{commitment:s,config:o}=$t(n),a=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:c2(i)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,n){const i=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:n}=Ae(e,kY);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:n}=Ae(e,eY);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:n}=Ae(e,rY);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,i){const s=t||this._commitment;if(s||n||i){let o={};n&&(o.encoding=n),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,n,i){const s=t||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,i)}_wsOnSignatureNotification(e){const{result:t,subscription:n}=Ae(e,nY);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,n){const i=this._buildArgs([e],n||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){t(o.result,a);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(e,t,n){const{commitment:i,...s}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([e],i,void 0,s),a=this._makeSubscription({callback:(u,l)=>{t(u,l);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:n}=Ae(e,iY);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class sc{constructor(e){this._keypair=void 0,this._keypair=e??r2()}static generate(){return new sc(r2())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const n=e.slice(32,64);if(!t||!t.skipValidation){const i=e.slice(0,32),s=H0(i);for(let o=0;o<32;o++)if(n[o]!==s[o])throw new Error("provided secretKey is invalid")}return new sc({publicKey:n,secretKey:e})}static fromSeed(e){const t=H0(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new sc({publicKey:t,secretKey:n})}get publicKey(){return new me(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Ws=Object.freeze({CreateLookupTable:{index:0,layout:Pe([Be("instruction"),gl("recentSlot"),mt("bumpSeed")])},FreezeLookupTable:{index:1,layout:Pe([Be("instruction")])},ExtendLookupTable:{index:2,layout:Pe([Be("instruction"),gl(),Jr(ut(),Wo(Be(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Pe([Be("instruction")])},CloseLookupTable:{index:4,layout:Pe([Be("instruction")])}});class OY{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Be("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Ws))if(o.index==n){i=s;break}if(!i)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return i}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=It(Ws.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=It(Ws.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(n=>new me(n))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Jb.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class Jb{constructor(){}static createLookupTable(e){const[t,n]=me.findProgramAddressSync([e.authority.toBuffer(),WS(BigInt(e.recentSlot),8)],this.programId),i=Ws.CreateLookupTable,s=gt(i,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Nr.programId,isSigner:!1,isWritable:!1}];return[new Bt({programId:this.programId,keys:o,data:s}),t]}static freezeLookupTable(e){const t=Ws.FreezeLookupTable,n=gt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Bt({programId:this.programId,keys:i,data:n})}static extendLookupTable(e){const t=Ws.ExtendLookupTable,n=gt(t,{addresses:e.addresses.map(s=>s.toBytes())}),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&i.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Nr.programId,isSigner:!1,isWritable:!1}),new Bt({programId:this.programId,keys:i,data:n})}static deactivateLookupTable(e){const t=Ws.DeactivateLookupTable,n=gt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Bt({programId:this.programId,keys:i,data:n})}static closeLookupTable(e){const t=Ws.CloseLookupTable,n=gt(t),i=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new Bt({programId:this.programId,keys:i,data:n})}}Jb.programId=new me("AddressLookupTab1e1111111111111111111111111");class NY{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=mt("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Yi))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return i}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:n}=It(Yi.RequestUnits,e.data);return{units:t,additionalFee:n}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=It(Yi.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=It(Yi.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=It(Yi.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Yb.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Yi=Object.freeze({RequestUnits:{index:0,layout:Pe([mt("instruction"),Be("units"),Be("additionalFee")])},RequestHeapFrame:{index:1,layout:Pe([mt("instruction"),Be("bytes")])},SetComputeUnitLimit:{index:2,layout:Pe([mt("instruction"),Be("units")])},SetComputeUnitPrice:{index:3,layout:Pe([mt("instruction"),gl("microLamports")])}});class Yb{constructor(){}static requestUnits(e){const t=Yi.RequestUnits,n=gt(t,e);return new Bt({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){const t=Yi.RequestHeapFrame,n=gt(t,e);return new Bt({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){const t=Yi.SetComputeUnitLimit,n=gt(t,e);return new Bt({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){const t=Yi.SetComputeUnitPrice,n=gt(t,{microLamports:BigInt(e.microLamports)});return new Bt({keys:[],programId:this.programId,data:n})}}Yb.programId=new me("ComputeBudget111111111111111111111111111111");const h2=64,d2=32,p2=64,g2=Pe([mt("numSignatures"),mt("padding"),ai("signatureOffset"),ai("signatureInstructionIndex"),ai("publicKeyOffset"),ai("publicKeyInstructionIndex"),ai("messageDataOffset"),ai("messageDataSize"),ai("messageInstructionIndex")]);class Qp{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,instructionIndex:s}=e;At(t.length===d2,`Public Key must be ${d2} bytes but received ${t.length} bytes`),At(i.length===p2,`Signature must be ${p2} bytes but received ${i.length} bytes`);const o=g2.span,a=o+t.length,u=a+i.length,l=1,h=Ne.alloc(u+n.length),g=s??65535;return g2.encode({numSignatures:l,padding:0,signatureOffset:a,signatureInstructionIndex:g,publicKeyOffset:o,publicKeyInstructionIndex:g,messageDataOffset:u,messageDataSize:n.length,messageInstructionIndex:g},h),h.fill(t,o),h.fill(i,a),h.fill(n,u),new Bt({keys:[],programId:Qp.programId,data:h})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;At(t.length===h2,`Private key must be ${h2} bytes but received ${t.length} bytes`);try{const s=sc.fromSecretKey(t),o=s.publicKey.toBytes(),a=Hb(n,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:a,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}Qp.programId=new me("Ed25519SigVerify111111111111111111111111111");const CY=(r,e)=>{const t=Kp.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};Kp.utils.isValidPrivateKey;const BY=Kp.getPublicKey,y2=32,jm=20,m2=64,PY=11,Wm=Pe([mt("numSignatures"),ai("signatureOffset"),mt("signatureInstructionIndex"),ai("ethAddressOffset"),mt("ethAddressInstructionIndex"),ai("messageDataOffset"),ai("messageDataSize"),mt("messageInstructionIndex"),Kt(20,"ethAddress"),Kt(64,"signature"),mt("recoveryId")]);class du{constructor(){}static publicKeyToEthAddress(e){At(e.length===m2,`Public key must be ${m2} bytes but received ${e.length} bytes`);try{return Ne.from(JE(st(e))).slice(-jm)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,recoveryId:s,instructionIndex:o}=e;return du.createInstructionWithEthAddress({ethAddress:du.publicKeyToEthAddress(t),message:n,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:n,signature:i,recoveryId:s,instructionIndex:o=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=Ne.from(t.substr(2),"hex"):a=Ne.from(t,"hex"):a=t,At(a.length===jm,`Address must be ${jm} bytes but received ${a.length} bytes`);const u=1+PY,l=u,h=u+a.length,g=h+i.length+1,b=1,w=Ne.alloc(Wm.span+n.length);return Wm.encode({numSignatures:b,signatureOffset:h,signatureInstructionIndex:o,ethAddressOffset:l,ethAddressInstructionIndex:o,messageDataOffset:g,messageDataSize:n.length,messageInstructionIndex:o,signature:st(i),ethAddress:st(a),recoveryId:s},w),w.fill(st(n),Wm.span),new Bt({keys:[],programId:du.programId,data:w})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;At(t.length===y2,`Private key must be ${y2} bytes but received ${t.length} bytes`);try{const s=st(t),o=BY(s,!1).slice(1),a=Ne.from(JE(st(n))),[u,l]=CY(a,s);return this.createInstructionWithPublicKey({publicKey:o,message:n,signature:u,recoveryId:l,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}du.programId=new me("KeccakSecp256k11111111111111111111111111111");var Ok;const Nk=new me("StakeConfig11111111111111111111111111111111");class Ck{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class ad{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}}Ok=ad;ad.default=new Ok(0,0,me.default);class MY{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Be("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Dr))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a StakeInstruction");return i}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:n}=It(Dr.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new Ck(new me(t.staker),new me(t.withdrawer)),lockup:new ad(n.unixTimestamp,n.epoch,new me(n.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),It(Dr.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:n}=It(Dr.Authorize,e.data),i={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new me(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(i.custodianPubkey=e.keys[3].pubkey),i}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:n,authoritySeed:i,authorityOwner:s}=It(Dr.AuthorizeWithSeed,e.data),o={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:i,authorityOwner:new me(s),newAuthorizedPubkey:new me(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(o.custodianPubkey=e.keys[3].pubkey),o}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=It(Dr.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),It(Dr.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=It(Dr.Withdraw,e.data),n={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(n.custodianPubkey=e.keys[5].pubkey),n}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),It(Dr.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(Jp.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Dr=Object.freeze({Initialize:{index:0,layout:Pe([Be("instruction"),DQ(),$Q()])},Authorize:{index:1,layout:Pe([Be("instruction"),ut("newAuthorized"),Be("stakeAuthorizationType")])},Delegate:{index:2,layout:Pe([Be("instruction")])},Split:{index:3,layout:Pe([Be("instruction"),jn("lamports")])},Withdraw:{index:4,layout:Pe([Be("instruction"),jn("lamports")])},Deactivate:{index:5,layout:Pe([Be("instruction")])},Merge:{index:7,layout:Pe([Be("instruction")])},AuthorizeWithSeed:{index:8,layout:Pe([Be("instruction"),ut("newAuthorized"),Be("stakeAuthorizationType"),Ra("authoritySeed"),ut("authorityOwner")])}}),LY=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Jp{constructor(){}static initialize(e){const{stakePubkey:t,authorized:n,lockup:i}=e,s=i||ad.default,o=Dr.Initialize,a=gt(o,{authorized:{staker:st(n.staker.toBuffer()),withdrawer:st(n.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:st(s.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:pl,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Bt(u)}static createAccountWithSeed(e){const t=new Tt;t.add(Nr.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static createAccount(e){const t=new Tt;t.add(Nr.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:n,authorized:i,lockup:s}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:n,votePubkey:i}=e,s=Dr.Delegate,o=gt(s);return new Tt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:a0,isSigner:!1,isWritable:!1},{pubkey:Nk,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){const{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=e,a=Dr.Authorize,u=gt(a,{newAuthorized:st(i.toBuffer()),stakeAuthorizationType:s.index}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),new Tt().add({keys:l,programId:this.programId,data:u})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:n,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:u}=e,l=Dr.AuthorizeWithSeed,h=gt(l,{newAuthorized:st(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:i,authorityOwner:st(s.toBuffer())}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1}];return u&&g.push({pubkey:u,isSigner:!0,isWritable:!1}),new Tt().add({keys:g,programId:this.programId,data:h})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:i,lamports:s}=e,o=Dr.Split,a=gt(o,{lamports:s});return new Bt({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e,t){const n=new Tt;return n.add(Nr.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){const{stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:a,lamports:u}=e,l=new Tt;return l.add(Nr.allocate({accountPubkey:s,basePubkey:o,seed:a,space:this.space,programId:this.programId})),t&&t>0&&l.add(Nr.transfer({fromPubkey:e.authorizedPubkey,toPubkey:s,lamports:t})),l.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:i}=e,s=Dr.Merge,o=gt(s);return new Tt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:a0,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:n,toPubkey:i,lamports:s,custodianPubkey:o}=e,a=Dr.Withdraw,u=gt(a,{lamports:s}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:a0,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),new Tt().add({keys:l,programId:this.programId,data:u})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:n}=e,i=Dr.Deactivate,s=gt(i);return new Tt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}Jp.programId=new me("Stake11111111111111111111111111111111111111");Jp.space=200;class Bk{constructor(e,t,n,i){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=n,this.commission=i}}class UY{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=Be("instruction").decode(e.data);let i;for(const[s,o]of Object.entries(Xi))if(o.index==n){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a VoteInstruction");return i}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=It(Xi.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new Bk(new me(t.nodePubkey),new me(t.authorizedVoter),new me(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:n}=It(Xi.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new me(t),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:n,newAuthorized:i,voteAuthorizationType:s}}=It(Xi.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new me(t),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new me(i),voteAuthorizationType:{index:s},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=It(Xi.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Fl.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Xi=Object.freeze({InitializeAccount:{index:0,layout:Pe([Be("instruction"),FQ()])},Authorize:{index:1,layout:Pe([Be("instruction"),ut("newAuthorized"),Be("voteAuthorizationType")])},Withdraw:{index:3,layout:Pe([Be("instruction"),jn("lamports")])},UpdateValidatorIdentity:{index:4,layout:Pe([Be("instruction")])},AuthorizeWithSeed:{index:10,layout:Pe([Be("instruction"),HQ()])}}),DY=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Fl{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:n,voteInit:i}=e,s=Xi.InitializeAccount,o=gt(s,{voteInit:{nodePubkey:st(i.nodePubkey.toBuffer()),authorizedVoter:st(i.authorizedVoter.toBuffer()),authorizedWithdrawer:st(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:pl,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Bt(a)}static createAccount(e){const t=new Tt;return t.add(Nr.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){const{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:i,voteAuthorizationType:s}=e,o=Xi.Authorize,a=gt(o,{newAuthorized:st(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Tt().add({keys:u,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:a}=e,u=Xi.AuthorizeWithSeed,l=gt(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:st(n.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:st(s.toBuffer()),voteAuthorizationType:o.index}}),h=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Tt().add({keys:h,programId:this.programId,data:l})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:i,toPubkey:s}=e,o=Xi.Withdraw,a=gt(o,{lamports:i}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Tt().add({keys:u,programId:this.programId,data:a})}static safeWithdraw(e,t,n){if(e.lamports>t-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return Fl.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:i}=e,s=Xi.UpdateValidatorIdentity,o=gt(s),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Tt().add({keys:a,programId:this.programId,data:o})}}Fl.programId=new me("Vote111111111111111111111111111111111111111");Fl.space=3762;const Pk=new me("Va1idator1nfo111111111111111111111111111111"),$Y=ge({name:_e(),website:Fe(_e()),details:Fe(_e()),iconUrl:Fe(_e()),keybaseUsername:Fe(_e())});class Xb{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(In(t)!==2)return null;const i=[];for(let s=0;s<2;s++){const o=new me(Sn(t,0,os)),a=Ji(t)===1;i.push({publicKey:o,isSigner:a})}if(i[0].publicKey.equals(Pk)&&i[1].isSigner){const s=Ra().decode(Ne.from(t)),o=JSON.parse(s);return VS(o,$Y),new Xb(i[1].publicKey,o)}return null}}const FY=new me("Vote111111111111111111111111111111111111111"),HY=Pe([ut("nodePubkey"),ut("authorizedWithdrawer"),mt("commission"),Kr(),Jr(Pe([Kr("slot"),Be("confirmationCount")]),Wo(Be(),-8),"votes"),mt("rootSlotValid"),Kr("rootSlot"),Kr(),Jr(Pe([Kr("epoch"),ut("authorizedVoter")]),Wo(Be(),-8),"authorizedVoters"),Pe([Jr(Pe([ut("authorizedPubkey"),Kr("epochOfLastAuthorizedSwitch"),Kr("targetEpoch")]),32,"buf"),Kr("idx"),mt("isEmpty")],"priorVoters"),Kr(),Jr(Pe([Kr("epoch"),Kr("credits"),Kr("prevCredits")]),Wo(Be(),-8),"epochCredits"),Pe([Kr("slot"),Kr("timestamp")],"lastTimestamp")]);class e_{constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const n=HY.decode(st(e),4);let i=n.rootSlot;return n.rootSlotValid||(i=null),new e_({nodePubkey:new me(n.nodePubkey),authorizedWithdrawer:new me(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:i,authorizedVoters:n.authorizedVoters.map(zY),priorVoters:GY(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function zY({authorizedVoter:r,epoch:e}){return{epoch:e,authorizedVoter:new me(r)}}function w2({authorizedPubkey:r,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new me(r),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function GY({buf:r,idx:e,isEmpty:t}){return t?[]:[...r.slice(e+1).map(w2),...r.slice(0,e).map(w2)]}const b2={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function KY(r,e){const t=e===!1?"http":"https";if(!r)return b2[t].devnet;const n=b2[t][r];if(!n)throw new Error(`Unknown ${t} cluster: ${r}`);return n}async function jY(r,e,t,n){let i,s;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(i=t,s=n):s=t;const o=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},a=await r.sendRawTransaction(e,o),u=s&&s.commitment,h=(await(i?r.confirmTransaction(i,u):r.confirmTransaction(a,u))).value;if(h.err)throw a!=null?new na({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(h)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(h)})`);return a}const WY=1e9,VY=Object.freeze(Object.defineProperty({__proto__:null,Account:MQ,AddressLookupTableAccount:Y1,AddressLookupTableInstruction:OY,AddressLookupTableProgram:Jb,Authorized:Ck,BLOCKHASH_CACHE_TIMEOUT_MS:bk,BPF_LOADER_DEPRECATED_PROGRAM_ID:LQ,BPF_LOADER_PROGRAM_ID:rJ,BpfLoader:nJ,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Yi,ComputeBudgetInstruction:NY,ComputeBudgetProgram:Yb,Connection:Tk,Ed25519Program:Qp,Enum:BQ,EpochSchedule:mk,FeeCalculatorLayout:gk,Keypair:sc,LAMPORTS_PER_SOL:WY,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Ws,Loader:gc,Lockup:ad,MAX_SEED_LENGTH:fk,Message:Oi,MessageAccountKeys:fh,MessageV0:pc,NONCE_ACCOUNT_LENGTH:J1,NonceAccount:Vp,PACKET_DATA_SIZE:Vo,PUBLIC_KEY_LENGTH:os,PublicKey:me,SIGNATURE_LENGTH_IN_BYTES:lh,SOLANA_SCHEMA:Ff,STAKE_CONFIG_ID:Nk,STAKE_INSTRUCTION_LAYOUTS:Dr,SYSTEM_INSTRUCTION_LAYOUTS:Ht,SYSVAR_CLOCK_PUBKEY:Zi,SYSVAR_EPOCH_SCHEDULE_PUBKEY:WQ,SYSVAR_INSTRUCTIONS_PUBKEY:VQ,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:o0,SYSVAR_RENT_PUBKEY:pl,SYSVAR_REWARDS_PUBKEY:qQ,SYSVAR_SLOT_HASHES_PUBKEY:ZQ,SYSVAR_SLOT_HISTORY_PUBKEY:QQ,SYSVAR_STAKE_HISTORY_PUBKEY:a0,Secp256k1Program:du,SendTransactionError:na,SolanaJSONRPCError:De,SolanaJSONRPCErrorCode:JQ,StakeAuthorizationLayout:LY,StakeInstruction:MY,StakeProgram:Jp,Struct:zb,SystemInstruction:eJ,SystemProgram:Nr,Transaction:Tt,TransactionExpiredBlockheightExceededError:Gb,TransactionExpiredNonceInvalidError:nu,TransactionExpiredTimeoutError:Kb,TransactionInstruction:Bt,TransactionMessage:Wb,TransactionStatus:vs,VALIDATOR_INFO_KEY:Pk,VERSION_PREFIX_MASK:jp,VOTE_PROGRAM_ID:FY,ValidatorInfo:Xb,VersionedMessage:jb,VersionedTransaction:Vb,VoteAccount:e_,VoteAuthorizationLayout:DY,VoteInit:Bk,VoteInstruction:UY,VoteProgram:Fl,clusterApiUrl:KY,sendAndConfirmRawTransaction:jY,sendAndConfirmTransaction:Q1},Symbol.toStringTag,{value:"Module"}));var t_={exports:{}};const qY=/[\p{Lu}]/u,ZY=/[\p{Ll}]/u,_2=/^[\p{Lu}](?![\p{Lu}])/gu,Mk=/([\p{Alpha}\p{N}_]|$)/u,Lk=/[_.\- ]+/,QY=new RegExp("^"+Lk.source),A2=new RegExp(Lk.source+Mk.source,"gu"),v2=new RegExp("\\d+"+Mk.source,"gu"),JY=(r,e,t)=>{let n=!1,i=!1,s=!1;for(let o=0;o<r.length;o++){const a=r[o];n&&qY.test(a)?(r=r.slice(0,o)+"-"+r.slice(o),n=!1,s=i,i=!0,o++):i&&s&&ZY.test(a)?(r=r.slice(0,o-1)+"-"+r.slice(o-1),s=i,i=!1,n=!0):(n=e(a)===a&&t(a)!==a,s=i,i=t(a)===a&&e(a)!==a)}return r},YY=(r,e)=>(_2.lastIndex=0,r.replace(_2,t=>e(t))),XY=(r,e)=>(A2.lastIndex=0,v2.lastIndex=0,r.replace(A2,(t,n)=>e(n)).replace(v2,t=>e(t))),Uk=(r,e)=>{if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(r)?r=r.map(s=>s.trim()).filter(s=>s.length).join("-"):r=r.trim(),r.length===0)return"";const t=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),n=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return r.length===1?e.pascalCase?n(r):t(r):(r!==t(r)&&(r=JY(r,t,n)),r=r.replace(QY,""),e.preserveConsecutiveUppercase?r=YY(r,t):r=t(r),e.pascalCase&&(r=n(r.charAt(0))+r.slice(1)),XY(r,n))};t_.exports=Uk;t_.exports.default=Uk;var eX=t_.exports;const tX=no(eX);var Je={},Se={};let Nt=class{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}decode(e,t){throw new Error("Layout is abstract")}encode(e,t,n){throw new Error("Layout is abstract")}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};Se.Layout=Nt;function r_(r,e){return e.property?r+"["+e.property+"]":r}Se.nameWithProperty=r_;function rX(r,e){if(typeof r!="function")throw new TypeError("Class must be constructor");if(r.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Nt))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=e,e.boundConstructor_=r,e.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value:function(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(r,"decode",{value:function(t,n){return e.decode(t,n)},writable:!0})}Se.bindConstructorLayout=rX;let Nn=class extends Nt{isCount(){throw new Error("ExternalLayout is abstract")}};class Dk extends Nn{constructor(e,t){if(e===void 0&&(e=1),!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t){t===void 0&&(t=0);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}}let n_=class extends Nn{constructor(e,t,n){if(!(e instanceof Nt))throw new TypeError("layout must be a Layout");if(t===void 0)t=0;else if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof ys||this.layout instanceof io}decode(e,t){return t===void 0&&(t=0),this.layout.decode(e,t+this.offset)}encode(e,t,n){return n===void 0&&(n=0),this.layout.encode(e,t,n+this.offset)}},ys=class extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntLE(e,n,this.span),this.span}},io=class extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntBE(e,n,this.span),this.span}};class Nc extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeIntLE(e,n,this.span),this.span}}class Hl extends Nt{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeIntBE(e,n,this.span),this.span}}const rw=Math.pow(2,32);function Yp(r){const e=Math.floor(r/rw),t=r-e*rw;return{hi32:e,lo32:t}}function Xp(r,e){return r*rw+e}let nX=class extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readUInt32LE(t+4);return Xp(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=Yp(e);return t.writeUInt32LE(i.lo32,n),t.writeUInt32LE(i.hi32,n+4),8}};class iX extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32BE(t),i=e.readUInt32BE(t+4);return Xp(n,i)}encode(e,t,n){n===void 0&&(n=0);const i=Yp(e);return t.writeUInt32BE(i.hi32,n),t.writeUInt32BE(i.lo32,n+4),8}}let sX=class extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readInt32LE(t+4);return Xp(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=Yp(e);return t.writeUInt32LE(i.lo32,n),t.writeInt32LE(i.hi32,n+4),8}};class oX extends Nt{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readInt32BE(t),i=e.readUInt32BE(t+4);return Xp(n,i)}encode(e,t,n){n===void 0&&(n=0);const i=Yp(e);return t.writeInt32BE(i.hi32,n),t.writeUInt32BE(i.lo32,n+4),8}}class $k extends Nt{constructor(e){super(4,e)}decode(e,t){return t===void 0&&(t=0),e.readFloatLE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeFloatLE(e,n),4}}class Fk extends Nt{constructor(e){super(4,e)}decode(e,t){return t===void 0&&(t=0),e.readFloatBE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeFloatBE(e,n),4}}class Hk extends Nt{constructor(e){super(8,e)}decode(e,t){return t===void 0&&(t=0),e.readDoubleLE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeDoubleLE(e,n),8}}class zk extends Nt{constructor(e){super(8,e)}decode(e,t){return t===void 0&&(t=0),e.readDoubleBE(t)}encode(e,t,n){return n===void 0&&(n=0),t.writeDoubleBE(e,n),8}}class Gk extends Nt{constructor(e,t,n){if(!(e instanceof Nt))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof Nn&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(t instanceof Nn)&&0<e.span&&(i=t*e.span),super(i,n),this.elementLayout=e,this.count=t}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0,i=this.count;if(i instanceof Nn&&(i=i.decode(e,t)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let s=0;for(;s<i;)n+=this.elementLayout.getSpan(e,t+n),++s}return n}decode(e,t){t===void 0&&(t=0);const n=[];let i=0,s=this.count;for(s instanceof Nn&&(s=s.decode(e,t));i<s;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return n}encode(e,t,n){n===void 0&&(n=0);const i=this.elementLayout,s=e.reduce((o,a)=>o+i.encode(a,t,n+o),0);return this.count instanceof Nn&&this.count.encode(e.length,t,n),s}}let Kk=class extends Nt{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Nt,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t){t===void 0&&(t=0);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n){n===void 0&&(n=0);const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}},i_=class{constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},G0=class extends i_{constructor(e,t){if(!(e instanceof Nn&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}},s_=class extends Nt{constructor(e,t,n){const i=e instanceof ys||e instanceof io;if(i)e=new G0(new n_(e));else if(e instanceof Nn&&e.isCount())e=new G0(e);else if(!(e instanceof i_))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Nt))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&i&&(s+=e.layout.span)),super(s,n),this.discriminator=e,this.usesPrefixDiscriminator=i,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(e.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&e.hasOwnProperty(this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||e.hasOwnProperty(t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(e.hasOwnProperty(n.property))return n}throw new Error("unable to infer src variant")}decode(e,t){t===void 0&&(t=0);let n;const i=this.discriminator,s=i.decode(e,t);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[o.property]=this.defaultLayout.decode(e,t+a)}else n=o.decode(e,t);return n}encode(e,t,n){n===void 0&&(n=0);const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new jk(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t){let n=e;return Qe.isBuffer(e)&&(t===void 0&&(t=0),n=this.discriminator.decode(e,t)),this.registry[n]}},jk=class extends Nt{constructor(e,t,n,i){if(!(e instanceof s_))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Nt))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(e,t+n)}decode(e,t){const n=this.makeDestinationObject();if(t===void 0&&(t=0),this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n){n===void 0&&(n=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!e.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};function Jc(r){return 0>r&&(r+=4294967296),r}class o_ extends Nt{constructor(e,t,n){if(!(e instanceof ys||e instanceof io))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&n===void 0&&(n=t,t=void 0),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(s){return i=Jc(s),this},this._packedGetValue=function(){return i}}decode(e,t){const n=this.makeDestinationObject();t===void 0&&(t=0);const i=this.word.decode(e,t);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(i));return n}encode(e,t,n){n===void 0&&(n=0);const i=this.word.decode(t,n);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=e[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new Hf(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new Wk(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}}class Hf{constructor(e,t,n){if(!(e instanceof o_))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const i=8*e.span,s=e.fields.reduce((o,a)=>o+a.bits,0);if(t+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=Jc(this.valueMask<<this.start),this.property=n}decode(){const e=this.container._packedGetValue();return Jc(e&this.wordMask)>>>this.start}encode(e){if(!Number.isInteger(e)||e!==Jc(e&this.valueMask))throw new TypeError(r_("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=Jc(e<<this.start);this.container._packedSetValue(Jc(t&~this.wordMask)|n)}}let Wk=class extends Hf{constructor(e,t){super(e,1,t)}decode(e,t){return!!Hf.prototype.decode.call(this,e,t)}encode(e){return typeof e=="boolean"&&(e=+e),Hf.prototype.encode.call(this,e)}},Vk=class extends Nt{constructor(e,t){if(!(e instanceof Nn&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof Nn||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t){t===void 0&&(t=0);let n=this.span;return 0>n&&(n=this.length.decode(e,t)),e.slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof Nn&&(i=e.length),!(Qe.isBuffer(e)&&i===e.length))throw new TypeError(r_("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(n+i>t.length)throw new RangeError("encoding overruns Buffer");return t.write(e.toString("hex"),n,i,"hex"),this.length instanceof Nn&&this.length.encode(i,t,n),i}};class qk extends Nt{constructor(e){super(-1,e)}getSpan(e,t){if(!Qe.isBuffer(e))throw new TypeError("b must be a Buffer");t===void 0&&(t=0);let n=t;for(;n<e.length&&e[n]!==0;)n+=1;return 1+n-t}decode(e,t,n){t===void 0&&(t=0);let i=this.getSpan(e,t);return e.slice(t,t+i-1).toString("utf-8")}encode(e,t,n){n===void 0&&(n=0),typeof e!="string"&&(e=e.toString());const i=new Qe(e,"utf8"),s=i.length;if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(t,n),t[n+s]=0,s+1}}class Zk extends Nt{constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t){if(!Qe.isBuffer(e))throw new TypeError("b must be a Buffer");return t===void 0&&(t=0),e.length-t}decode(e,t,n){t===void 0&&(t=0);let i=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");return e.slice(t,t+i).toString("utf-8")}encode(e,t,n){n===void 0&&(n=0),typeof e!="string"&&(e=e.toString());const i=new Qe(e,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(t,n),s}}class Qk extends Nt{constructor(e,t){super(0,t),this.value=e}decode(e,t,n){return this.value}encode(e,t,n){return 0}}Se.ExternalLayout=Nn;Se.GreedyCount=Dk;Se.OffsetLayout=n_;Se.UInt=ys;Se.UIntBE=io;Se.Int=Nc;Se.IntBE=Hl;Se.Float=$k;Se.FloatBE=Fk;Se.Double=Hk;Se.DoubleBE=zk;Se.Sequence=Gk;Se.Structure=Kk;Se.UnionDiscriminator=i_;Se.UnionLayoutDiscriminator=G0;Se.Union=s_;Se.VariantLayout=jk;Se.BitStructure=o_;Se.BitField=Hf;Se.Boolean=Wk;Se.Blob=Vk;Se.CString=qk;Se.UTF8=Zk;Se.Constant=Qk;Se.greedy=(r,e)=>new Dk(r,e);Se.offset=(r,e,t)=>new n_(r,e,t);Se.u8=r=>new ys(1,r);Se.u16=r=>new ys(2,r);Se.u24=r=>new ys(3,r);Se.u32=r=>new ys(4,r);Se.u40=r=>new ys(5,r);Se.u48=r=>new ys(6,r);Se.nu64=r=>new nX(r);Se.u16be=r=>new io(2,r);Se.u24be=r=>new io(3,r);Se.u32be=r=>new io(4,r);Se.u40be=r=>new io(5,r);Se.u48be=r=>new io(6,r);Se.nu64be=r=>new iX(r);Se.s8=r=>new Nc(1,r);Se.s16=r=>new Nc(2,r);Se.s24=r=>new Nc(3,r);Se.s32=r=>new Nc(4,r);Se.s40=r=>new Nc(5,r);Se.s48=r=>new Nc(6,r);Se.ns64=r=>new sX(r);Se.s16be=r=>new Hl(2,r);Se.s24be=r=>new Hl(3,r);Se.s32be=r=>new Hl(4,r);Se.s40be=r=>new Hl(5,r);Se.s48be=r=>new Hl(6,r);Se.ns64be=r=>new oX(r);Se.f32=r=>new $k(r);Se.f32be=r=>new Fk(r);Se.f64=r=>new Hk(r);Se.f64be=r=>new zk(r);Se.struct=(r,e,t)=>new Kk(r,e,t);Se.bits=(r,e,t)=>new o_(r,e,t);Se.seq=(r,e,t)=>new Gk(r,e,t);Se.union=(r,e,t)=>new s_(r,e,t);Se.unionLayoutDiscriminator=(r,e)=>new G0(r,e);Se.blob=(r,e)=>new Vk(r,e);Se.cstr=r=>new qk(r);Se.utf8=(r,e)=>new Zk(r,e);Se.const=(r,e)=>new Qk(r,e);const aX=gp(VY);(function(r){var e=Qr&&Qr.__importDefault||function(ue){return ue&&ue.__esModule?ue:{default:ue}};Object.defineProperty(r,"__esModule",{value:!0}),r.struct=r.f64=r.f32=r.i32=r.u32=r.i16=r.u16=r.i8=r.u8=void 0,r.u64=a,r.i64=u,r.u128=l,r.i128=h,r.u256=g,r.i256=b,r.publicKey=I,r.option=x,r.bool=C,r.vec=z,r.tagged=V,r.vecU8=Z,r.str=K,r.rustEnum=W,r.array=oe,r.map=ne;const t=Se,n=aX,i=e(vb);var s=Se;Object.defineProperty(r,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(r,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(r,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(r,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(r,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(r,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(r,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(r,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(r,"struct",{enumerable:!0,get:function(){return s.struct}});class o extends t.Layout{constructor(B,p,m){super(B,m),this.blob=(0,t.blob)(B),this.signed=p}decode(B,p=0){const m=new i.default(this.blob.decode(B,p),10,"le");return this.signed?m.fromTwos(this.span*8).clone():m}encode(B,p,m=0){return this.signed&&(B=B.toTwos(this.span*8)),this.blob.encode(B.toArrayLike(Qe,"le",this.span),p,m)}}function a(ue){return new o(8,!1,ue)}function u(ue){return new o(8,!0,ue)}function l(ue){return new o(16,!1,ue)}function h(ue){return new o(16,!0,ue)}function g(ue){return new o(32,!1,ue)}function b(ue){return new o(32,!0,ue)}class w extends t.Layout{constructor(B,p,m,E){super(B.span,E),this.layout=B,this.decoder=p,this.encoder=m}decode(B,p){return this.decoder(this.layout.decode(B,p))}encode(B,p,m){return this.layout.encode(this.encoder(B),p,m)}getSpan(B,p){return this.layout.getSpan(B,p)}}function I(ue){return new w((0,t.blob)(32),B=>new n.PublicKey(B),B=>B.toBuffer(),ue)}class S extends t.Layout{constructor(B,p){super(-1,p),this.layout=B,this.discriminator=(0,t.u8)()}encode(B,p,m=0){return B==null?this.discriminator.encode(0,p,m):(this.discriminator.encode(1,p,m),this.layout.encode(B,p,m+1)+1)}decode(B,p=0){const m=this.discriminator.decode(B,p);if(m===0)return null;if(m===1)return this.layout.decode(B,p+1);throw new Error("Invalid option "+this.property)}getSpan(B,p=0){const m=this.discriminator.decode(B,p);if(m===0)return 1;if(m===1)return this.layout.getSpan(B,p+1)+1;throw new Error("Invalid option "+this.property)}}function x(ue,B){return new S(ue,B)}function C(ue){return new w((0,t.u8)(),H,D,ue)}function H(ue){if(ue===0)return!1;if(ue===1)return!0;throw new Error("Invalid bool: "+ue)}function D(ue){return ue?1:0}function z(ue,B){const p=(0,t.u32)("length"),m=(0,t.struct)([p,(0,t.seq)(ue,(0,t.offset)(p,-p.span),"values")]);return new w(m,({values:E})=>E,E=>({values:E}),B)}function V(ue,B,p){const m=(0,t.struct)([a("tag"),B.replicate("data")]);function E({tag:k,data:O}){if(!k.eq(ue))throw new Error("Invalid tag, expected: "+ue.toString("hex")+", got: "+k.toString("hex"));return O}return new w(m,E,k=>({tag:ue,data:k}),p)}function Z(ue){const B=(0,t.u32)("length"),p=(0,t.struct)([B,(0,t.blob)((0,t.offset)(B,-B.span),"data")]);return new w(p,({data:m})=>m,m=>({data:m}),ue)}function K(ue){return new w(Z(),B=>B.toString("utf-8"),B=>Qe.from(B,"utf-8"),ue)}function W(ue,B,p){const m=(0,t.union)(p??(0,t.u8)(),B);return ue.forEach((E,k)=>m.addVariant(k,E,E.property)),m}function oe(ue,B,p){const m=(0,t.struct)([(0,t.seq)(ue,B,"values")]);return new w(m,({values:E})=>E,E=>({values:E}),p)}class ce extends t.Layout{constructor(B,p,m){super(B.span+p.span,m),this.keyLayout=B,this.valueLayout=p}decode(B,p){p=p||0;const m=this.keyLayout.decode(B,p),E=this.valueLayout.decode(B,p+this.keyLayout.getSpan(B,p));return[m,E]}encode(B,p,m){m=m||0;const E=this.keyLayout.encode(B[0],p,m),k=this.valueLayout.encode(B[1],p,m+E);return E+k}getSpan(B,p){return this.keyLayout.getSpan(B,p)+this.valueLayout.getSpan(B,p)}}function ne(ue,B,p){const m=(0,t.u32)("length"),E=(0,t.struct)([m,(0,t.seq)(new ce(ue,B),(0,t.offset)(m,-m.span),"values")]);return new w(E,({values:k})=>new Map(k),k=>({values:Array.from(k.entries())}),p)}})(Je);/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const cX=4,E2=0,x2=1,uX=2;function zl(r){let e=r.length;for(;--e>=0;)r[e]=0}const lX=0,Jk=1,fX=2,hX=3,dX=258,a_=29,cd=256,dh=cd+1+a_,pu=30,c_=19,Yk=2*dh+1,Ia=15,Vm=16,pX=7,u_=256,Xk=16,eT=17,tT=18,nw=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),c0=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),gX=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),rT=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yX=512,ks=new Array((dh+2)*2);zl(ks);const zf=new Array(pu*2);zl(zf);const ph=new Array(yX);zl(ph);const gh=new Array(dX-hX+1);zl(gh);const l_=new Array(a_);zl(l_);const K0=new Array(pu);zl(K0);function qm(r,e,t,n,i){this.static_tree=r,this.extra_bits=e,this.extra_base=t,this.elems=n,this.max_length=i,this.has_stree=r&&r.length}let nT,iT,sT;function Zm(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}const oT=r=>r<256?ph[r]:ph[256+(r>>>7)],yh=(r,e)=>{r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255},Cn=(r,e,t)=>{r.bi_valid>Vm-t?(r.bi_buf|=e<<r.bi_valid&65535,yh(r,r.bi_buf),r.bi_buf=e>>Vm-r.bi_valid,r.bi_valid+=t-Vm):(r.bi_buf|=e<<r.bi_valid&65535,r.bi_valid+=t)},es=(r,e,t)=>{Cn(r,t[e*2],t[e*2+1])},aT=(r,e)=>{let t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1},mX=r=>{r.bi_valid===16?(yh(r,r.bi_buf),r.bi_buf=0,r.bi_valid=0):r.bi_valid>=8&&(r.pending_buf[r.pending++]=r.bi_buf&255,r.bi_buf>>=8,r.bi_valid-=8)},wX=(r,e)=>{const t=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,u=e.stat_desc.max_length;let l,h,g,b,w,I,S=0;for(b=0;b<=Ia;b++)r.bl_count[b]=0;for(t[r.heap[r.heap_max]*2+1]=0,l=r.heap_max+1;l<Yk;l++)h=r.heap[l],b=t[t[h*2+1]*2+1]+1,b>u&&(b=u,S++),t[h*2+1]=b,!(h>n)&&(r.bl_count[b]++,w=0,h>=a&&(w=o[h-a]),I=t[h*2],r.opt_len+=I*(b+w),s&&(r.static_len+=I*(i[h*2+1]+w)));if(S!==0){do{for(b=u-1;r.bl_count[b]===0;)b--;r.bl_count[b]--,r.bl_count[b+1]+=2,r.bl_count[u]--,S-=2}while(S>0);for(b=u;b!==0;b--)for(h=r.bl_count[b];h!==0;)g=r.heap[--l],!(g>n)&&(t[g*2+1]!==b&&(r.opt_len+=(b-t[g*2+1])*t[g*2],t[g*2+1]=b),h--)}},cT=(r,e,t)=>{const n=new Array(Ia+1);let i=0,s,o;for(s=1;s<=Ia;s++)i=i+t[s-1]<<1,n[s]=i;for(o=0;o<=e;o++){let a=r[o*2+1];a!==0&&(r[o*2]=aT(n[a]++,a))}},bX=()=>{let r,e,t,n,i;const s=new Array(Ia+1);for(t=0,n=0;n<a_-1;n++)for(l_[n]=t,r=0;r<1<<nw[n];r++)gh[t++]=n;for(gh[t-1]=n,i=0,n=0;n<16;n++)for(K0[n]=i,r=0;r<1<<c0[n];r++)ph[i++]=n;for(i>>=7;n<pu;n++)for(K0[n]=i<<7,r=0;r<1<<c0[n]-7;r++)ph[256+i++]=n;for(e=0;e<=Ia;e++)s[e]=0;for(r=0;r<=143;)ks[r*2+1]=8,r++,s[8]++;for(;r<=255;)ks[r*2+1]=9,r++,s[9]++;for(;r<=279;)ks[r*2+1]=7,r++,s[7]++;for(;r<=287;)ks[r*2+1]=8,r++,s[8]++;for(cT(ks,dh+1,s),r=0;r<pu;r++)zf[r*2+1]=5,zf[r*2]=aT(r,5);nT=new qm(ks,nw,cd+1,dh,Ia),iT=new qm(zf,c0,0,pu,Ia),sT=new qm(new Array(0),gX,0,c_,pX)},uT=r=>{let e;for(e=0;e<dh;e++)r.dyn_ltree[e*2]=0;for(e=0;e<pu;e++)r.dyn_dtree[e*2]=0;for(e=0;e<c_;e++)r.bl_tree[e*2]=0;r.dyn_ltree[u_*2]=1,r.opt_len=r.static_len=0,r.sym_next=r.matches=0},lT=r=>{r.bi_valid>8?yh(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},R2=(r,e,t,n)=>{const i=e*2,s=t*2;return r[i]<r[s]||r[i]===r[s]&&n[e]<=n[t]},Qm=(r,e,t)=>{const n=r.heap[t];let i=t<<1;for(;i<=r.heap_len&&(i<r.heap_len&&R2(e,r.heap[i+1],r.heap[i],r.depth)&&i++,!R2(e,n,r.heap[i],r.depth));)r.heap[t]=r.heap[i],t=i,i<<=1;r.heap[t]=n},I2=(r,e,t)=>{let n,i,s=0,o,a;if(r.sym_next!==0)do n=r.pending_buf[r.sym_buf+s++]&255,n+=(r.pending_buf[r.sym_buf+s++]&255)<<8,i=r.pending_buf[r.sym_buf+s++],n===0?es(r,i,e):(o=gh[i],es(r,o+cd+1,e),a=nw[o],a!==0&&(i-=l_[o],Cn(r,i,a)),n--,o=oT(n),es(r,o,t),a=c0[o],a!==0&&(n-=K0[o],Cn(r,n,a)));while(s<r.sym_next);es(r,u_,e)},iw=(r,e)=>{const t=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,u=-1,l;for(r.heap_len=0,r.heap_max=Yk,o=0;o<s;o++)t[o*2]!==0?(r.heap[++r.heap_len]=u=o,r.depth[o]=0):t[o*2+1]=0;for(;r.heap_len<2;)l=r.heap[++r.heap_len]=u<2?++u:0,t[l*2]=1,r.depth[l]=0,r.opt_len--,i&&(r.static_len-=n[l*2+1]);for(e.max_code=u,o=r.heap_len>>1;o>=1;o--)Qm(r,t,o);l=s;do o=r.heap[1],r.heap[1]=r.heap[r.heap_len--],Qm(r,t,1),a=r.heap[1],r.heap[--r.heap_max]=o,r.heap[--r.heap_max]=a,t[l*2]=t[o*2]+t[a*2],r.depth[l]=(r.depth[o]>=r.depth[a]?r.depth[o]:r.depth[a])+1,t[o*2+1]=t[a*2+1]=l,r.heap[1]=l++,Qm(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],wX(r,e),cT(t,u,r.bl_count)},S2=(r,e,t)=>{let n,i=-1,s,o=e[0*2+1],a=0,u=7,l=4;for(o===0&&(u=138,l=3),e[(t+1)*2+1]=65535,n=0;n<=t;n++)s=o,o=e[(n+1)*2+1],!(++a<u&&s===o)&&(a<l?r.bl_tree[s*2]+=a:s!==0?(s!==i&&r.bl_tree[s*2]++,r.bl_tree[Xk*2]++):a<=10?r.bl_tree[eT*2]++:r.bl_tree[tT*2]++,a=0,i=s,o===0?(u=138,l=3):s===o?(u=6,l=3):(u=7,l=4))},k2=(r,e,t)=>{let n,i=-1,s,o=e[0*2+1],a=0,u=7,l=4;for(o===0&&(u=138,l=3),n=0;n<=t;n++)if(s=o,o=e[(n+1)*2+1],!(++a<u&&s===o)){if(a<l)do es(r,s,r.bl_tree);while(--a!==0);else s!==0?(s!==i&&(es(r,s,r.bl_tree),a--),es(r,Xk,r.bl_tree),Cn(r,a-3,2)):a<=10?(es(r,eT,r.bl_tree),Cn(r,a-3,3)):(es(r,tT,r.bl_tree),Cn(r,a-11,7));a=0,i=s,o===0?(u=138,l=3):s===o?(u=6,l=3):(u=7,l=4)}},_X=r=>{let e;for(S2(r,r.dyn_ltree,r.l_desc.max_code),S2(r,r.dyn_dtree,r.d_desc.max_code),iw(r,r.bl_desc),e=c_-1;e>=3&&r.bl_tree[rT[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e},AX=(r,e,t,n)=>{let i;for(Cn(r,e-257,5),Cn(r,t-1,5),Cn(r,n-4,4),i=0;i<n;i++)Cn(r,r.bl_tree[rT[i]*2+1],3);k2(r,r.dyn_ltree,e-1),k2(r,r.dyn_dtree,t-1)},vX=r=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&r.dyn_ltree[t*2]!==0)return E2;if(r.dyn_ltree[9*2]!==0||r.dyn_ltree[10*2]!==0||r.dyn_ltree[13*2]!==0)return x2;for(t=32;t<cd;t++)if(r.dyn_ltree[t*2]!==0)return x2;return E2};let T2=!1;const EX=r=>{T2||(bX(),T2=!0),r.l_desc=new Zm(r.dyn_ltree,nT),r.d_desc=new Zm(r.dyn_dtree,iT),r.bl_desc=new Zm(r.bl_tree,sT),r.bi_buf=0,r.bi_valid=0,uT(r)},fT=(r,e,t,n)=>{Cn(r,(lX<<1)+(n?1:0),3),lT(r),yh(r,t),yh(r,~t),t&&r.pending_buf.set(r.window.subarray(e,e+t),r.pending),r.pending+=t},xX=r=>{Cn(r,Jk<<1,3),es(r,u_,ks),mX(r)},RX=(r,e,t,n)=>{let i,s,o=0;r.level>0?(r.strm.data_type===uX&&(r.strm.data_type=vX(r)),iw(r,r.l_desc),iw(r,r.d_desc),o=_X(r),i=r.opt_len+3+7>>>3,s=r.static_len+3+7>>>3,s<=i&&(i=s)):i=s=t+5,t+4<=i&&e!==-1?fT(r,e,t,n):r.strategy===cX||s===i?(Cn(r,(Jk<<1)+(n?1:0),3),I2(r,ks,zf)):(Cn(r,(fX<<1)+(n?1:0),3),AX(r,r.l_desc.max_code+1,r.d_desc.max_code+1,o+1),I2(r,r.dyn_ltree,r.dyn_dtree)),uT(r),n&&lT(r)},IX=(r,e,t)=>(r.pending_buf[r.sym_buf+r.sym_next++]=e,r.pending_buf[r.sym_buf+r.sym_next++]=e>>8,r.pending_buf[r.sym_buf+r.sym_next++]=t,e===0?r.dyn_ltree[t*2]++:(r.matches++,e--,r.dyn_ltree[(gh[t]+cd+1)*2]++,r.dyn_dtree[oT(e)*2]++),r.sym_next===r.sym_end);var SX=EX,kX=fT,TX=RX,OX=IX,NX=xX,CX={_tr_init:SX,_tr_stored_block:kX,_tr_flush_block:TX,_tr_tally:OX,_tr_align:NX};const BX=(r,e,t,n)=>{let i=r&65535|0,s=r>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do i=i+e[n++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0};var mh=BX;const PX=()=>{let r,e=[];for(var t=0;t<256;t++){r=t;for(var n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e},MX=new Uint32Array(PX()),LX=(r,e,t,n)=>{const i=MX,s=n+t;r^=-1;for(let o=n;o<s;o++)r=r>>>8^i[(r^e[o])&255];return r^-1};var Ur=LX,yl={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ud={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:UX,_tr_stored_block:sw,_tr_flush_block:DX,_tr_tally:qo,_tr_align:$X}=CX,{Z_NO_FLUSH:Zo,Z_PARTIAL_FLUSH:FX,Z_FULL_FLUSH:HX,Z_FINISH:ui,Z_BLOCK:O2,Z_OK:Wr,Z_STREAM_END:N2,Z_STREAM_ERROR:as,Z_DATA_ERROR:zX,Z_BUF_ERROR:Jm,Z_DEFAULT_COMPRESSION:GX,Z_FILTERED:KX,Z_HUFFMAN_ONLY:Gd,Z_RLE:jX,Z_FIXED:WX,Z_DEFAULT_STRATEGY:VX,Z_UNKNOWN:qX,Z_DEFLATED:eg}=ud,ZX=9,QX=15,JX=8,YX=29,XX=256,ow=XX+1+YX,eee=30,tee=19,ree=2*ow+1,nee=15,ht=3,jo=258,cs=jo+ht+1,iee=32,ml=42,f_=57,aw=69,cw=73,uw=91,lw=103,Sa=113,Cf=666,yn=1,Gl=2,yc=3,Kl=4,see=3,ka=(r,e)=>(r.msg=yl[e],e),C2=r=>r*2-(r>4?9:0),vo=r=>{let e=r.length;for(;--e>=0;)r[e]=0},oee=r=>{let e,t,n,i=r.w_size;e=r.hash_size,n=e;do t=r.head[--n],r.head[n]=t>=i?t-i:0;while(--e);e=i,n=e;do t=r.prev[--n],r.prev[n]=t>=i?t-i:0;while(--e)};let aee=(r,e,t)=>(e<<r.hash_shift^t)&r.hash_mask,Qo=aee;const $n=r=>{const e=r.state;let t=e.pending;t>r.avail_out&&(t=r.avail_out),t!==0&&(r.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),r.next_out),r.next_out+=t,e.pending_out+=t,r.total_out+=t,r.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},Vn=(r,e)=>{DX(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,$n(r.strm)},Rt=(r,e)=>{r.pending_buf[r.pending++]=e},Rf=(r,e)=>{r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255},fw=(r,e,t,n)=>{let i=r.avail_in;return i>n&&(i=n),i===0?0:(r.avail_in-=i,e.set(r.input.subarray(r.next_in,r.next_in+i),t),r.state.wrap===1?r.adler=mh(r.adler,e,i,t):r.state.wrap===2&&(r.adler=Ur(r.adler,e,i,t)),r.next_in+=i,r.total_in+=i,i)},hT=(r,e)=>{let t=r.max_chain_length,n=r.strstart,i,s,o=r.prev_length,a=r.nice_match;const u=r.strstart>r.w_size-cs?r.strstart-(r.w_size-cs):0,l=r.window,h=r.w_mask,g=r.prev,b=r.strstart+jo;let w=l[n+o-1],I=l[n+o];r.prev_length>=r.good_match&&(t>>=2),a>r.lookahead&&(a=r.lookahead);do if(i=e,!(l[i+o]!==I||l[i+o-1]!==w||l[i]!==l[n]||l[++i]!==l[n+1])){n+=2,i++;do;while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<b);if(s=jo-(b-n),n=b-jo,s>o){if(r.match_start=e,o=s,s>=a)break;w=l[n+o-1],I=l[n+o]}}while((e=g[e&h])>u&&--t!==0);return o<=r.lookahead?o:r.lookahead},wl=r=>{const e=r.w_size;let t,n,i;do{if(n=r.window_size-r.lookahead-r.strstart,r.strstart>=e+(e-cs)&&(r.window.set(r.window.subarray(e,e+e-n),0),r.match_start-=e,r.strstart-=e,r.block_start-=e,r.insert>r.strstart&&(r.insert=r.strstart),oee(r),n+=e),r.strm.avail_in===0)break;if(t=fw(r.strm,r.window,r.strstart+r.lookahead,n),r.lookahead+=t,r.lookahead+r.insert>=ht)for(i=r.strstart-r.insert,r.ins_h=r.window[i],r.ins_h=Qo(r,r.ins_h,r.window[i+1]);r.insert&&(r.ins_h=Qo(r,r.ins_h,r.window[i+ht-1]),r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++,r.insert--,!(r.lookahead+r.insert<ht)););}while(r.lookahead<cs&&r.strm.avail_in!==0)},dT=(r,e)=>{let t=r.pending_buf_size-5>r.w_size?r.w_size:r.pending_buf_size-5,n,i,s,o=0,a=r.strm.avail_in;do{if(n=65535,s=r.bi_valid+42>>3,r.strm.avail_out<s||(s=r.strm.avail_out-s,i=r.strstart-r.block_start,n>i+r.strm.avail_in&&(n=i+r.strm.avail_in),n>s&&(n=s),n<t&&(n===0&&e!==ui||e===Zo||n!==i+r.strm.avail_in)))break;o=e===ui&&n===i+r.strm.avail_in?1:0,sw(r,0,0,o),r.pending_buf[r.pending-4]=n,r.pending_buf[r.pending-3]=n>>8,r.pending_buf[r.pending-2]=~n,r.pending_buf[r.pending-1]=~n>>8,$n(r.strm),i&&(i>n&&(i=n),r.strm.output.set(r.window.subarray(r.block_start,r.block_start+i),r.strm.next_out),r.strm.next_out+=i,r.strm.avail_out-=i,r.strm.total_out+=i,r.block_start+=i,n-=i),n&&(fw(r.strm,r.strm.output,r.strm.next_out,n),r.strm.next_out+=n,r.strm.avail_out-=n,r.strm.total_out+=n)}while(o===0);return a-=r.strm.avail_in,a&&(a>=r.w_size?(r.matches=2,r.window.set(r.strm.input.subarray(r.strm.next_in-r.w_size,r.strm.next_in),0),r.strstart=r.w_size,r.insert=r.strstart):(r.window_size-r.strstart<=a&&(r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,r.insert>r.strstart&&(r.insert=r.strstart)),r.window.set(r.strm.input.subarray(r.strm.next_in-a,r.strm.next_in),r.strstart),r.strstart+=a,r.insert+=a>r.w_size-r.insert?r.w_size-r.insert:a),r.block_start=r.strstart),r.high_water<r.strstart&&(r.high_water=r.strstart),o?Kl:e!==Zo&&e!==ui&&r.strm.avail_in===0&&r.strstart===r.block_start?Gl:(s=r.window_size-r.strstart,r.strm.avail_in>s&&r.block_start>=r.w_size&&(r.block_start-=r.w_size,r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,s+=r.w_size,r.insert>r.strstart&&(r.insert=r.strstart)),s>r.strm.avail_in&&(s=r.strm.avail_in),s&&(fw(r.strm,r.window,r.strstart,s),r.strstart+=s,r.insert+=s>r.w_size-r.insert?r.w_size-r.insert:s),r.high_water<r.strstart&&(r.high_water=r.strstart),s=r.bi_valid+42>>3,s=r.pending_buf_size-s>65535?65535:r.pending_buf_size-s,t=s>r.w_size?r.w_size:s,i=r.strstart-r.block_start,(i>=t||(i||e===ui)&&e!==Zo&&r.strm.avail_in===0&&i<=s)&&(n=i>s?s:i,o=e===ui&&r.strm.avail_in===0&&n===i?1:0,sw(r,r.block_start,n,o),r.block_start+=n,$n(r.strm)),o?yc:yn)},Ym=(r,e)=>{let t,n;for(;;){if(r.lookahead<cs){if(wl(r),r.lookahead<cs&&e===Zo)return yn;if(r.lookahead===0)break}if(t=0,r.lookahead>=ht&&(r.ins_h=Qo(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),t!==0&&r.strstart-t<=r.w_size-cs&&(r.match_length=hT(r,t)),r.match_length>=ht)if(n=qo(r,r.strstart-r.match_start,r.match_length-ht),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=ht){r.match_length--;do r.strstart++,r.ins_h=Qo(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart;while(--r.match_length!==0);r.strstart++}else r.strstart+=r.match_length,r.match_length=0,r.ins_h=r.window[r.strstart],r.ins_h=Qo(r,r.ins_h,r.window[r.strstart+1]);else n=qo(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(n&&(Vn(r,!1),r.strm.avail_out===0))return yn}return r.insert=r.strstart<ht-1?r.strstart:ht-1,e===ui?(Vn(r,!0),r.strm.avail_out===0?yc:Kl):r.sym_next&&(Vn(r,!1),r.strm.avail_out===0)?yn:Gl},Kc=(r,e)=>{let t,n,i;for(;;){if(r.lookahead<cs){if(wl(r),r.lookahead<cs&&e===Zo)return yn;if(r.lookahead===0)break}if(t=0,r.lookahead>=ht&&(r.ins_h=Qo(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),r.prev_length=r.match_length,r.prev_match=r.match_start,r.match_length=ht-1,t!==0&&r.prev_length<r.max_lazy_match&&r.strstart-t<=r.w_size-cs&&(r.match_length=hT(r,t),r.match_length<=5&&(r.strategy===KX||r.match_length===ht&&r.strstart-r.match_start>4096)&&(r.match_length=ht-1)),r.prev_length>=ht&&r.match_length<=r.prev_length){i=r.strstart+r.lookahead-ht,n=qo(r,r.strstart-1-r.prev_match,r.prev_length-ht),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=i&&(r.ins_h=Qo(r,r.ins_h,r.window[r.strstart+ht-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart);while(--r.prev_length!==0);if(r.match_available=0,r.match_length=ht-1,r.strstart++,n&&(Vn(r,!1),r.strm.avail_out===0))return yn}else if(r.match_available){if(n=qo(r,0,r.window[r.strstart-1]),n&&Vn(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return yn}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(n=qo(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart<ht-1?r.strstart:ht-1,e===ui?(Vn(r,!0),r.strm.avail_out===0?yc:Kl):r.sym_next&&(Vn(r,!1),r.strm.avail_out===0)?yn:Gl},cee=(r,e)=>{let t,n,i,s;const o=r.window;for(;;){if(r.lookahead<=jo){if(wl(r),r.lookahead<=jo&&e===Zo)return yn;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=ht&&r.strstart>0&&(i=r.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=r.strstart+jo;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);r.match_length=jo-(s-i),r.match_length>r.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=ht?(t=qo(r,1,r.match_length-ht),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(t=qo(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),t&&(Vn(r,!1),r.strm.avail_out===0))return yn}return r.insert=0,e===ui?(Vn(r,!0),r.strm.avail_out===0?yc:Kl):r.sym_next&&(Vn(r,!1),r.strm.avail_out===0)?yn:Gl},uee=(r,e)=>{let t;for(;;){if(r.lookahead===0&&(wl(r),r.lookahead===0)){if(e===Zo)return yn;break}if(r.match_length=0,t=qo(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,t&&(Vn(r,!1),r.strm.avail_out===0))return yn}return r.insert=0,e===ui?(Vn(r,!0),r.strm.avail_out===0?yc:Kl):r.sym_next&&(Vn(r,!1),r.strm.avail_out===0)?yn:Gl};function Di(r,e,t,n,i){this.good_length=r,this.max_lazy=e,this.nice_length=t,this.max_chain=n,this.func=i}const Bf=[new Di(0,0,0,0,dT),new Di(4,4,8,4,Ym),new Di(4,5,16,8,Ym),new Di(4,6,32,32,Ym),new Di(4,4,16,16,Kc),new Di(8,16,32,32,Kc),new Di(8,16,128,128,Kc),new Di(8,32,128,256,Kc),new Di(32,128,258,1024,Kc),new Di(32,258,258,4096,Kc)],lee=r=>{r.window_size=2*r.w_size,vo(r.head),r.max_lazy_match=Bf[r.level].max_lazy,r.good_match=Bf[r.level].good_length,r.nice_match=Bf[r.level].nice_length,r.max_chain_length=Bf[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=ht-1,r.match_available=0,r.ins_h=0};function fee(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=eg,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(ree*2),this.dyn_dtree=new Uint16Array((2*eee+1)*2),this.bl_tree=new Uint16Array((2*tee+1)*2),vo(this.dyn_ltree),vo(this.dyn_dtree),vo(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(nee+1),this.heap=new Uint16Array(2*ow+1),vo(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*ow+1),vo(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const ld=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.status!==ml&&e.status!==f_&&e.status!==aw&&e.status!==cw&&e.status!==uw&&e.status!==lw&&e.status!==Sa&&e.status!==Cf?1:0},pT=r=>{if(ld(r))return ka(r,as);r.total_in=r.total_out=0,r.data_type=qX;const e=r.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?f_:e.wrap?ml:Sa,r.adler=e.wrap===2?0:1,e.last_flush=-2,UX(e),Wr},gT=r=>{const e=pT(r);return e===Wr&&lee(r.state),e},hee=(r,e)=>ld(r)||r.state.wrap!==2?as:(r.state.gzhead=e,Wr),yT=(r,e,t,n,i,s)=>{if(!r)return as;let o=1;if(e===GX&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>ZX||t!==eg||n<8||n>15||e<0||e>9||s<0||s>WX||n===8&&o!==1)return ka(r,as);n===8&&(n=9);const a=new fee;return r.state=a,a.strm=r,a.status=ml,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+ht-1)/ht),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=e,a.strategy=s,a.method=t,gT(r)},dee=(r,e)=>yT(r,e,eg,QX,JX,VX),pee=(r,e)=>{if(ld(r)||e>O2||e<0)return r?ka(r,as):as;const t=r.state;if(!r.output||r.avail_in!==0&&!r.input||t.status===Cf&&e!==ui)return ka(r,r.avail_out===0?Jm:as);const n=t.last_flush;if(t.last_flush=e,t.pending!==0){if($n(r),r.avail_out===0)return t.last_flush=-1,Wr}else if(r.avail_in===0&&C2(e)<=C2(n)&&e!==ui)return ka(r,Jm);if(t.status===Cf&&r.avail_in!==0)return ka(r,Jm);if(t.status===ml&&t.wrap===0&&(t.status=Sa),t.status===ml){let i=eg+(t.w_bits-8<<4)<<8,s=-1;if(t.strategy>=Gd||t.level<2?s=0:t.level<6?s=1:t.level===6?s=2:s=3,i|=s<<6,t.strstart!==0&&(i|=iee),i+=31-i%31,Rf(t,i),t.strstart!==0&&(Rf(t,r.adler>>>16),Rf(t,r.adler&65535)),r.adler=1,t.status=Sa,$n(r),t.pending!==0)return t.last_flush=-1,Wr}if(t.status===f_){if(r.adler=0,Rt(t,31),Rt(t,139),Rt(t,8),t.gzhead)Rt(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),Rt(t,t.gzhead.time&255),Rt(t,t.gzhead.time>>8&255),Rt(t,t.gzhead.time>>16&255),Rt(t,t.gzhead.time>>24&255),Rt(t,t.level===9?2:t.strategy>=Gd||t.level<2?4:0),Rt(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(Rt(t,t.gzhead.extra.length&255),Rt(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(r.adler=Ur(r.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=aw;else if(Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,0),Rt(t,t.level===9?2:t.strategy>=Gd||t.level<2?4:0),Rt(t,see),t.status=Sa,$n(r),t.pending!==0)return t.last_flush=-1,Wr}if(t.status===aw){if(t.gzhead.extra){let i=t.pending,s=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+s>t.pending_buf_size;){let a=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>i&&(r.adler=Ur(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex+=a,$n(r),t.pending!==0)return t.last_flush=-1,Wr;i=0,s-=a}let o=new Uint8Array(t.gzhead.extra);t.pending_buf.set(o.subarray(t.gzindex,t.gzindex+s),t.pending),t.pending+=s,t.gzhead.hcrc&&t.pending>i&&(r.adler=Ur(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex=0}t.status=cw}if(t.status===cw){if(t.gzhead.name){let i=t.pending,s;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>i&&(r.adler=Ur(r.adler,t.pending_buf,t.pending-i,i)),$n(r),t.pending!==0)return t.last_flush=-1,Wr;i=0}t.gzindex<t.gzhead.name.length?s=t.gzhead.name.charCodeAt(t.gzindex++)&255:s=0,Rt(t,s)}while(s!==0);t.gzhead.hcrc&&t.pending>i&&(r.adler=Ur(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex=0}t.status=uw}if(t.status===uw){if(t.gzhead.comment){let i=t.pending,s;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>i&&(r.adler=Ur(r.adler,t.pending_buf,t.pending-i,i)),$n(r),t.pending!==0)return t.last_flush=-1,Wr;i=0}t.gzindex<t.gzhead.comment.length?s=t.gzhead.comment.charCodeAt(t.gzindex++)&255:s=0,Rt(t,s)}while(s!==0);t.gzhead.hcrc&&t.pending>i&&(r.adler=Ur(r.adler,t.pending_buf,t.pending-i,i))}t.status=lw}if(t.status===lw){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&($n(r),t.pending!==0))return t.last_flush=-1,Wr;Rt(t,r.adler&255),Rt(t,r.adler>>8&255),r.adler=0}if(t.status=Sa,$n(r),t.pending!==0)return t.last_flush=-1,Wr}if(r.avail_in!==0||t.lookahead!==0||e!==Zo&&t.status!==Cf){let i=t.level===0?dT(t,e):t.strategy===Gd?uee(t,e):t.strategy===jX?cee(t,e):Bf[t.level].func(t,e);if((i===yc||i===Kl)&&(t.status=Cf),i===yn||i===yc)return r.avail_out===0&&(t.last_flush=-1),Wr;if(i===Gl&&(e===FX?$X(t):e!==O2&&(sw(t,0,0,!1),e===HX&&(vo(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),$n(r),r.avail_out===0))return t.last_flush=-1,Wr}return e!==ui?Wr:t.wrap<=0?N2:(t.wrap===2?(Rt(t,r.adler&255),Rt(t,r.adler>>8&255),Rt(t,r.adler>>16&255),Rt(t,r.adler>>24&255),Rt(t,r.total_in&255),Rt(t,r.total_in>>8&255),Rt(t,r.total_in>>16&255),Rt(t,r.total_in>>24&255)):(Rf(t,r.adler>>>16),Rf(t,r.adler&65535)),$n(r),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Wr:N2)},gee=r=>{if(ld(r))return as;const e=r.state.status;return r.state=null,e===Sa?ka(r,zX):Wr},yee=(r,e)=>{let t=e.length;if(ld(r))return as;const n=r.state,i=n.wrap;if(i===2||i===1&&n.status!==ml||n.lookahead)return as;if(i===1&&(r.adler=mh(r.adler,e,t,0)),n.wrap=0,t>=n.w_size){i===0&&(vo(n.head),n.strstart=0,n.block_start=0,n.insert=0);let u=new Uint8Array(n.w_size);u.set(e.subarray(t-n.w_size,t),0),e=u,t=n.w_size}const s=r.avail_in,o=r.next_in,a=r.input;for(r.avail_in=t,r.next_in=0,r.input=e,wl(n);n.lookahead>=ht;){let u=n.strstart,l=n.lookahead-(ht-1);do n.ins_h=Qo(n,n.ins_h,n.window[u+ht-1]),n.prev[u&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=u,u++;while(--l);n.strstart=u,n.lookahead=ht-1,wl(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=ht-1,n.match_available=0,r.next_in=o,r.input=a,r.avail_in=s,n.wrap=i,Wr};var mee=dee,wee=yT,bee=gT,_ee=pT,Aee=hee,vee=pee,Eee=gee,xee=yee,Ree="pako deflate (from Nodeca project)",Gf={deflateInit:mee,deflateInit2:wee,deflateReset:bee,deflateResetKeep:_ee,deflateSetHeader:Aee,deflate:vee,deflateEnd:Eee,deflateSetDictionary:xee,deflateInfo:Ree};const Iee=(r,e)=>Object.prototype.hasOwnProperty.call(r,e);var See=function(r){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const n in t)Iee(t,n)&&(r[n]=t[n])}}return r},kee=r=>{let e=0;for(let n=0,i=r.length;n<i;n++)e+=r[n].length;const t=new Uint8Array(e);for(let n=0,i=0,s=r.length;n<s;n++){let o=r[n];t.set(o,i),i+=o.length}return t},tg={assign:See,flattenChunks:kee};let mT=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{mT=!1}const wh=new Uint8Array(256);for(let r=0;r<256;r++)wh[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;wh[254]=wh[254]=1;var Tee=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let e,t,n,i,s,o=r.length,a=0;for(i=0;i<o;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),a+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(a),s=0,i=0;s<a;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),t<128?e[s++]=t:t<2048?(e[s++]=192|t>>>6,e[s++]=128|t&63):t<65536?(e[s++]=224|t>>>12,e[s++]=128|t>>>6&63,e[s++]=128|t&63):(e[s++]=240|t>>>18,e[s++]=128|t>>>12&63,e[s++]=128|t>>>6&63,e[s++]=128|t&63);return e};const Oee=(r,e)=>{if(e<65534&&r.subarray&&mT)return String.fromCharCode.apply(null,r.length===e?r:r.subarray(0,e));let t="";for(let n=0;n<e;n++)t+=String.fromCharCode(r[n]);return t};var Nee=(r,e)=>{const t=e||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,e));let n,i;const s=new Array(t*2);for(i=0,n=0;n<t;){let o=r[n++];if(o<128){s[i++]=o;continue}let a=wh[o];if(a>4){s[i++]=65533,n+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&n<t;)o=o<<6|r[n++]&63,a--;if(a>1){s[i++]=65533;continue}o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|o&1023)}return Oee(s,i)},Cee=(r,e)=>{e=e||r.length,e>r.length&&(e=r.length);let t=e-1;for(;t>=0&&(r[t]&192)===128;)t--;return t<0||t===0?e:t+wh[r[t]]>e?t:e},bh={string2buf:Tee,buf2string:Nee,utf8border:Cee};function Bee(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var wT=Bee;const bT=Object.prototype.toString,{Z_NO_FLUSH:Pee,Z_SYNC_FLUSH:Mee,Z_FULL_FLUSH:Lee,Z_FINISH:Uee,Z_OK:j0,Z_STREAM_END:Dee,Z_DEFAULT_COMPRESSION:$ee,Z_DEFAULT_STRATEGY:Fee,Z_DEFLATED:Hee}=ud;function h_(r){this.options=tg.assign({level:$ee,method:Hee,chunkSize:16384,windowBits:15,memLevel:8,strategy:Fee},r||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wT,this.strm.avail_out=0;let t=Gf.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==j0)throw new Error(yl[t]);if(e.header&&Gf.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=bh.string2buf(e.dictionary):bT.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,t=Gf.deflateSetDictionary(this.strm,n),t!==j0)throw new Error(yl[t]);this._dict_set=!0}}h_.prototype.push=function(r,e){const t=this.strm,n=this.options.chunkSize;let i,s;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?Uee:Pee,typeof r=="string"?t.input=bh.string2buf(r):bT.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),(s===Mee||s===Lee)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(i=Gf.deflate(t,s),i===Dee)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),i=Gf.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===j0;if(t.avail_out===0){this.onData(t.output);continue}if(s>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};h_.prototype.onData=function(r){this.chunks.push(r)};h_.prototype.onEnd=function(r){r===j0&&(this.result=tg.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};const Kd=16209,zee=16191;var Gee=function(e,t){let n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H,D,z,V,Z,K,W,oe,ce;const ne=e.state;n=e.next_in,oe=e.input,i=n+(e.avail_in-5),s=e.next_out,ce=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),u=ne.dmax,l=ne.wsize,h=ne.whave,g=ne.wnext,b=ne.window,w=ne.hold,I=ne.bits,S=ne.lencode,x=ne.distcode,C=(1<<ne.lenbits)-1,H=(1<<ne.distbits)-1;e:do{I<15&&(w+=oe[n++]<<I,I+=8,w+=oe[n++]<<I,I+=8),D=S[w&C];t:for(;;){if(z=D>>>24,w>>>=z,I-=z,z=D>>>16&255,z===0)ce[s++]=D&65535;else if(z&16){V=D&65535,z&=15,z&&(I<z&&(w+=oe[n++]<<I,I+=8),V+=w&(1<<z)-1,w>>>=z,I-=z),I<15&&(w+=oe[n++]<<I,I+=8,w+=oe[n++]<<I,I+=8),D=x[w&H];r:for(;;){if(z=D>>>24,w>>>=z,I-=z,z=D>>>16&255,z&16){if(Z=D&65535,z&=15,I<z&&(w+=oe[n++]<<I,I+=8,I<z&&(w+=oe[n++]<<I,I+=8)),Z+=w&(1<<z)-1,Z>u){e.msg="invalid distance too far back",ne.mode=Kd;break e}if(w>>>=z,I-=z,z=s-o,Z>z){if(z=Z-z,z>h&&ne.sane){e.msg="invalid distance too far back",ne.mode=Kd;break e}if(K=0,W=b,g===0){if(K+=l-z,z<V){V-=z;do ce[s++]=b[K++];while(--z);K=s-Z,W=ce}}else if(g<z){if(K+=l+g-z,z-=g,z<V){V-=z;do ce[s++]=b[K++];while(--z);if(K=0,g<V){z=g,V-=z;do ce[s++]=b[K++];while(--z);K=s-Z,W=ce}}}else if(K+=g-z,z<V){V-=z;do ce[s++]=b[K++];while(--z);K=s-Z,W=ce}for(;V>2;)ce[s++]=W[K++],ce[s++]=W[K++],ce[s++]=W[K++],V-=3;V&&(ce[s++]=W[K++],V>1&&(ce[s++]=W[K++]))}else{K=s-Z;do ce[s++]=ce[K++],ce[s++]=ce[K++],ce[s++]=ce[K++],V-=3;while(V>2);V&&(ce[s++]=ce[K++],V>1&&(ce[s++]=ce[K++]))}}else if(z&64){e.msg="invalid distance code",ne.mode=Kd;break e}else{D=x[(D&65535)+(w&(1<<z)-1)];continue r}break}}else if(z&64)if(z&32){ne.mode=zee;break e}else{e.msg="invalid literal/length code",ne.mode=Kd;break e}else{D=S[(D&65535)+(w&(1<<z)-1)];continue t}break}}while(n<i&&s<a);V=I>>3,n-=V,I-=V<<3,w&=(1<<I)-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=s<a?257+(a-s):257-(s-a),ne.hold=w,ne.bits=I};const jc=15,B2=852,P2=592,M2=0,Xm=1,L2=2,Kee=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),jee=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Wee=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Vee=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),qee=(r,e,t,n,i,s,o,a)=>{const u=a.bits;let l=0,h=0,g=0,b=0,w=0,I=0,S=0,x=0,C=0,H=0,D,z,V,Z,K,W=null,oe;const ce=new Uint16Array(jc+1),ne=new Uint16Array(jc+1);let ue=null,B,p,m;for(l=0;l<=jc;l++)ce[l]=0;for(h=0;h<n;h++)ce[e[t+h]]++;for(w=u,b=jc;b>=1&&ce[b]===0;b--);if(w>b&&(w=b),b===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,a.bits=1,0;for(g=1;g<b&&ce[g]===0;g++);for(w<g&&(w=g),x=1,l=1;l<=jc;l++)if(x<<=1,x-=ce[l],x<0)return-1;if(x>0&&(r===M2||b!==1))return-1;for(ne[1]=0,l=1;l<jc;l++)ne[l+1]=ne[l]+ce[l];for(h=0;h<n;h++)e[t+h]!==0&&(o[ne[e[t+h]]++]=h);if(r===M2?(W=ue=o,oe=20):r===Xm?(W=Kee,ue=jee,oe=257):(W=Wee,ue=Vee,oe=0),H=0,h=0,l=g,K=s,I=w,S=0,V=-1,C=1<<w,Z=C-1,r===Xm&&C>B2||r===L2&&C>P2)return 1;for(;;){B=l-S,o[h]+1<oe?(p=0,m=o[h]):o[h]>=oe?(p=ue[o[h]-oe],m=W[o[h]-oe]):(p=96,m=0),D=1<<l-S,z=1<<I,g=z;do z-=D,i[K+(H>>S)+z]=B<<24|p<<16|m|0;while(z!==0);for(D=1<<l-1;H&D;)D>>=1;if(D!==0?(H&=D-1,H+=D):H=0,h++,--ce[l]===0){if(l===b)break;l=e[t+o[h]]}if(l>w&&(H&Z)!==V){for(S===0&&(S=w),K+=g,I=l-S,x=1<<I;I+S<b&&(x-=ce[I+S],!(x<=0));)I++,x<<=1;if(C+=1<<I,r===Xm&&C>B2||r===L2&&C>P2)return 1;V=H&Z,i[V]=w<<24|I<<16|K-s|0}}return H!==0&&(i[K+H]=l-S<<24|64<<16|0),a.bits=w,0};var Kf=qee;const Zee=0,_T=1,AT=2,{Z_FINISH:U2,Z_BLOCK:Qee,Z_TREES:jd,Z_OK:mc,Z_STREAM_END:Jee,Z_NEED_DICT:Yee,Z_STREAM_ERROR:fi,Z_DATA_ERROR:vT,Z_MEM_ERROR:ET,Z_BUF_ERROR:Xee,Z_DEFLATED:D2}=ud,rg=16180,$2=16181,F2=16182,H2=16183,z2=16184,G2=16185,K2=16186,j2=16187,W2=16188,V2=16189,W0=16190,_s=16191,e1=16192,q2=16193,t1=16194,Z2=16195,Q2=16196,J2=16197,Y2=16198,Wd=16199,Vd=16200,X2=16201,ex=16202,tx=16203,rx=16204,nx=16205,r1=16206,ix=16207,sx=16208,qt=16209,xT=16210,RT=16211,ete=852,tte=592,rte=15,nte=rte,ox=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function ite(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Cc=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.mode<rg||e.mode>RT?1:0},IT=r=>{if(Cc(r))return fi;const e=r.state;return r.total_in=r.total_out=e.total=0,r.msg="",e.wrap&&(r.adler=e.wrap&1),e.mode=rg,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(ete),e.distcode=e.distdyn=new Int32Array(tte),e.sane=1,e.back=-1,mc},ST=r=>{if(Cc(r))return fi;const e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,IT(r)},kT=(r,e)=>{let t;if(Cc(r))return fi;const n=r.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?fi:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=t,n.wbits=e,ST(r))},TT=(r,e)=>{if(!r)return fi;const t=new ite;r.state=t,t.strm=r,t.window=null,t.mode=rg;const n=kT(r,e);return n!==mc&&(r.state=null),n},ste=r=>TT(r,nte);let ax=!0,n1,i1;const ote=r=>{if(ax){n1=new Int32Array(512),i1=new Int32Array(32);let e=0;for(;e<144;)r.lens[e++]=8;for(;e<256;)r.lens[e++]=9;for(;e<280;)r.lens[e++]=7;for(;e<288;)r.lens[e++]=8;for(Kf(_T,r.lens,0,288,n1,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;Kf(AT,r.lens,0,32,i1,0,r.work,{bits:5}),ax=!1}r.lencode=n1,r.lenbits=9,r.distcode=i1,r.distbits=5},OT=(r,e,t,n)=>{let i;const s=r.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(t-s.wsize,t),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(e.subarray(t-n,t-n+i),s.wnext),n-=i,n?(s.window.set(e.subarray(t-n,t),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0},ate=(r,e)=>{let t,n,i,s,o,a,u,l,h,g,b,w,I,S,x=0,C,H,D,z,V,Z,K,W;const oe=new Uint8Array(4);let ce,ne;const ue=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Cc(r)||!r.output||!r.input&&r.avail_in!==0)return fi;t=r.state,t.mode===_s&&(t.mode=e1),o=r.next_out,i=r.output,u=r.avail_out,s=r.next_in,n=r.input,a=r.avail_in,l=t.hold,h=t.bits,g=a,b=u,W=mc;e:for(;;)switch(t.mode){case rg:if(t.wrap===0){t.mode=e1;break}for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&2&&l===35615){t.wbits===0&&(t.wbits=15),t.check=0,oe[0]=l&255,oe[1]=l>>>8&255,t.check=Ur(t.check,oe,2,0),l=0,h=0,t.mode=$2;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){r.msg="incorrect header check",t.mode=qt;break}if((l&15)!==D2){r.msg="unknown compression method",t.mode=qt;break}if(l>>>=4,h-=4,K=(l&15)+8,t.wbits===0&&(t.wbits=K),K>15||K>t.wbits){r.msg="invalid window size",t.mode=qt;break}t.dmax=1<<t.wbits,t.flags=0,r.adler=t.check=1,t.mode=l&512?V2:_s,l=0,h=0;break;case $2:for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.flags=l,(t.flags&255)!==D2){r.msg="unknown compression method",t.mode=qt;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=qt;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Ur(t.check,oe,2,0)),l=0,h=0,t.mode=F2;case F2:for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.head&&(t.head.time=l),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,oe[2]=l>>>16&255,oe[3]=l>>>24&255,t.check=Ur(t.check,oe,4,0)),l=0,h=0,t.mode=H2;case H2:for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Ur(t.check,oe,2,0)),l=0,h=0,t.mode=z2;case z2:if(t.flags&1024){for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&t.wrap&4&&(oe[0]=l&255,oe[1]=l>>>8&255,t.check=Ur(t.check,oe,2,0)),l=0,h=0}else t.head&&(t.head.extra=null);t.mode=G2;case G2:if(t.flags&1024&&(w=t.length,w>a&&(w=a),w&&(t.head&&(K=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(n.subarray(s,s+w),K)),t.flags&512&&t.wrap&4&&(t.check=Ur(t.check,n,w,s)),a-=w,s+=w,t.length-=w),t.length))break e;t.length=0,t.mode=K2;case K2:if(t.flags&2048){if(a===0)break e;w=0;do K=n[s+w++],t.head&&K&&t.length<65536&&(t.head.name+=String.fromCharCode(K));while(K&&w<a);if(t.flags&512&&t.wrap&4&&(t.check=Ur(t.check,n,w,s)),a-=w,s+=w,K)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=j2;case j2:if(t.flags&4096){if(a===0)break e;w=0;do K=n[s+w++],t.head&&K&&t.length<65536&&(t.head.comment+=String.fromCharCode(K));while(K&&w<a);if(t.flags&512&&t.wrap&4&&(t.check=Ur(t.check,n,w,s)),a-=w,s+=w,K)break e}else t.head&&(t.head.comment=null);t.mode=W2;case W2:if(t.flags&512){for(;h<16;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&4&&l!==(t.check&65535)){r.msg="header crc mismatch",t.mode=qt;break}l=0,h=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),r.adler=t.check=0,t.mode=_s;break;case V2:for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}r.adler=t.check=ox(l),l=0,h=0,t.mode=W0;case W0:if(t.havedict===0)return r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,Yee;r.adler=t.check=1,t.mode=_s;case _s:if(e===Qee||e===jd)break e;case e1:if(t.last){l>>>=h&7,h-=h&7,t.mode=r1;break}for(;h<3;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}switch(t.last=l&1,l>>>=1,h-=1,l&3){case 0:t.mode=q2;break;case 1:if(ote(t),t.mode=Wd,e===jd){l>>>=2,h-=2;break e}break;case 2:t.mode=Q2;break;case 3:r.msg="invalid block type",t.mode=qt}l>>>=2,h-=2;break;case q2:for(l>>>=h&7,h-=h&7;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if((l&65535)!==(l>>>16^65535)){r.msg="invalid stored block lengths",t.mode=qt;break}if(t.length=l&65535,l=0,h=0,t.mode=t1,e===jd)break e;case t1:t.mode=Z2;case Z2:if(w=t.length,w){if(w>a&&(w=a),w>u&&(w=u),w===0)break e;i.set(n.subarray(s,s+w),o),a-=w,s+=w,u-=w,o+=w,t.length-=w;break}t.mode=_s;break;case Q2:for(;h<14;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.nlen=(l&31)+257,l>>>=5,h-=5,t.ndist=(l&31)+1,l>>>=5,h-=5,t.ncode=(l&15)+4,l>>>=4,h-=4,t.nlen>286||t.ndist>30){r.msg="too many length or distance symbols",t.mode=qt;break}t.have=0,t.mode=J2;case J2:for(;t.have<t.ncode;){for(;h<3;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.lens[ue[t.have++]]=l&7,l>>>=3,h-=3}for(;t.have<19;)t.lens[ue[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,ce={bits:t.lenbits},W=Kf(Zee,t.lens,0,19,t.lencode,0,t.work,ce),t.lenbits=ce.bits,W){r.msg="invalid code lengths set",t.mode=qt;break}t.have=0,t.mode=Y2;case Y2:for(;t.have<t.nlen+t.ndist;){for(;x=t.lencode[l&(1<<t.lenbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(D<16)l>>>=C,h-=C,t.lens[t.have++]=D;else{if(D===16){for(ne=C+2;h<ne;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(l>>>=C,h-=C,t.have===0){r.msg="invalid bit length repeat",t.mode=qt;break}K=t.lens[t.have-1],w=3+(l&3),l>>>=2,h-=2}else if(D===17){for(ne=C+3;h<ne;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=C,h-=C,K=0,w=3+(l&7),l>>>=3,h-=3}else{for(ne=C+7;h<ne;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=C,h-=C,K=0,w=11+(l&127),l>>>=7,h-=7}if(t.have+w>t.nlen+t.ndist){r.msg="invalid bit length repeat",t.mode=qt;break}for(;w--;)t.lens[t.have++]=K}}if(t.mode===qt)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=qt;break}if(t.lenbits=9,ce={bits:t.lenbits},W=Kf(_T,t.lens,0,t.nlen,t.lencode,0,t.work,ce),t.lenbits=ce.bits,W){r.msg="invalid literal/lengths set",t.mode=qt;break}if(t.distbits=6,t.distcode=t.distdyn,ce={bits:t.distbits},W=Kf(AT,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,ce),t.distbits=ce.bits,W){r.msg="invalid distances set",t.mode=qt;break}if(t.mode=Wd,e===jd)break e;case Wd:t.mode=Vd;case Vd:if(a>=6&&u>=258){r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,Gee(r,b),o=r.next_out,i=r.output,u=r.avail_out,s=r.next_in,n=r.input,a=r.avail_in,l=t.hold,h=t.bits,t.mode===_s&&(t.back=-1);break}for(t.back=0;x=t.lencode[l&(1<<t.lenbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(H&&!(H&240)){for(z=C,V=H,Z=D;x=t.lencode[Z+((l&(1<<z+V)-1)>>z)],C=x>>>24,H=x>>>16&255,D=x&65535,!(z+C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=z,h-=z,t.back+=z}if(l>>>=C,h-=C,t.back+=C,t.length=D,H===0){t.mode=nx;break}if(H&32){t.back=-1,t.mode=_s;break}if(H&64){r.msg="invalid literal/length code",t.mode=qt;break}t.extra=H&15,t.mode=X2;case X2:if(t.extra){for(ne=t.extra;h<ne;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=ex;case ex:for(;x=t.distcode[l&(1<<t.distbits)-1],C=x>>>24,H=x>>>16&255,D=x&65535,!(C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(!(H&240)){for(z=C,V=H,Z=D;x=t.distcode[Z+((l&(1<<z+V)-1)>>z)],C=x>>>24,H=x>>>16&255,D=x&65535,!(z+C<=h);){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}l>>>=z,h-=z,t.back+=z}if(l>>>=C,h-=C,t.back+=C,H&64){r.msg="invalid distance code",t.mode=qt;break}t.offset=D,t.extra=H&15,t.mode=tx;case tx:if(t.extra){for(ne=t.extra;h<ne;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){r.msg="invalid distance too far back",t.mode=qt;break}t.mode=rx;case rx:if(u===0)break e;if(w=b-u,t.offset>w){if(w=t.offset-w,w>t.whave&&t.sane){r.msg="invalid distance too far back",t.mode=qt;break}w>t.wnext?(w-=t.wnext,I=t.wsize-w):I=t.wnext-w,w>t.length&&(w=t.length),S=t.window}else S=i,I=o-t.offset,w=t.length;w>u&&(w=u),u-=w,t.length-=w;do i[o++]=S[I++];while(--w);t.length===0&&(t.mode=Vd);break;case nx:if(u===0)break e;i[o++]=t.length,u--,t.mode=Vd;break;case r1:if(t.wrap){for(;h<32;){if(a===0)break e;a--,l|=n[s++]<<h,h+=8}if(b-=u,r.total_out+=b,t.total+=b,t.wrap&4&&b&&(r.adler=t.check=t.flags?Ur(t.check,i,b,o-b):mh(t.check,i,b,o-b)),b=u,t.wrap&4&&(t.flags?l:ox(l))!==t.check){r.msg="incorrect data check",t.mode=qt;break}l=0,h=0}t.mode=ix;case ix:if(t.wrap&&t.flags){for(;h<32;){if(a===0)break e;a--,l+=n[s++]<<h,h+=8}if(t.wrap&4&&l!==(t.total&4294967295)){r.msg="incorrect length check",t.mode=qt;break}l=0,h=0}t.mode=sx;case sx:W=Jee;break e;case qt:W=vT;break e;case xT:return ET;case RT:default:return fi}return r.next_out=o,r.avail_out=u,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=h,(t.wsize||b!==r.avail_out&&t.mode<qt&&(t.mode<r1||e!==U2))&&OT(r,r.output,r.next_out,b-r.avail_out),g-=r.avail_in,b-=r.avail_out,r.total_in+=g,r.total_out+=b,t.total+=b,t.wrap&4&&b&&(r.adler=t.check=t.flags?Ur(t.check,i,b,r.next_out-b):mh(t.check,i,b,r.next_out-b)),r.data_type=t.bits+(t.last?64:0)+(t.mode===_s?128:0)+(t.mode===Wd||t.mode===t1?256:0),(g===0&&b===0||e===U2)&&W===mc&&(W=Xee),W},cte=r=>{if(Cc(r))return fi;let e=r.state;return e.window&&(e.window=null),r.state=null,mc},ute=(r,e)=>{if(Cc(r))return fi;const t=r.state;return t.wrap&2?(t.head=e,e.done=!1,mc):fi},lte=(r,e)=>{const t=e.length;let n,i,s;return Cc(r)||(n=r.state,n.wrap!==0&&n.mode!==W0)?fi:n.mode===W0&&(i=1,i=mh(i,e,t,0),i!==n.check)?vT:(s=OT(r,e,t,t),s?(n.mode=xT,ET):(n.havedict=1,mc))};var fte=ST,hte=kT,dte=IT,pte=ste,gte=TT,yte=ate,mte=cte,wte=ute,bte=lte,_te="pako inflate (from Nodeca project)",Ts={inflateReset:fte,inflateReset2:hte,inflateResetKeep:dte,inflateInit:pte,inflateInit2:gte,inflate:yte,inflateEnd:mte,inflateGetHeader:wte,inflateSetDictionary:bte,inflateInfo:_te};function Ate(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var vte=Ate;const NT=Object.prototype.toString,{Z_NO_FLUSH:Ete,Z_FINISH:xte,Z_OK:_h,Z_STREAM_END:s1,Z_NEED_DICT:o1,Z_STREAM_ERROR:Rte,Z_DATA_ERROR:cx,Z_MEM_ERROR:Ite}=ud;function fd(r){this.options=tg.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(r&&r.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wT,this.strm.avail_out=0;let t=Ts.inflateInit2(this.strm,e.windowBits);if(t!==_h)throw new Error(yl[t]);if(this.header=new vte,Ts.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=bh.string2buf(e.dictionary):NT.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=Ts.inflateSetDictionary(this.strm,e.dictionary),t!==_h)))throw new Error(yl[t])}fd.prototype.push=function(r,e){const t=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?xte:Ete,NT.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),s=Ts.inflate(t,o),s===o1&&i&&(s=Ts.inflateSetDictionary(t,i),s===_h?s=Ts.inflate(t,o):s===cx&&(s=o1));t.avail_in>0&&s===s1&&t.state.wrap>0&&r[t.next_in]!==0;)Ts.inflateReset(t),s=Ts.inflate(t,o);switch(s){case Rte:case cx:case o1:case Ite:return this.onEnd(s),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||s===s1))if(this.options.to==="string"){let u=bh.utf8border(t.output,t.next_out),l=t.next_out-u,h=bh.buf2string(t.output,u);t.next_out=l,t.avail_out=n-l,l&&t.output.set(t.output.subarray(u,u+l),0),this.onData(h)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(s===_h&&a===0)){if(s===s1)return s=Ts.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};fd.prototype.onData=function(r){this.chunks.push(r)};fd.prototype.onEnd=function(r){r===_h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=tg.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function d_(r,e){const t=new fd(e);if(t.push(r),t.err)throw t.msg||yl[t.err];return t.result}function Ste(r,e){return e=e||{},e.raw=!0,d_(r,e)}var kte=fd,Tte=d_,Ote=Ste,Nte=d_,Cte=ud,Bte={Inflate:kte,inflate:Tte,inflateRaw:Ote,ungzip:Nte,constants:Cte};const{Inflate:tue,inflate:Pte,inflateRaw:rue,ungzip:nue}=Bte;var Mte=Pte,CT={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function i(u,l,h){this.fn=u,this.context=l,this.once=h||!1}function s(u,l,h,g,b){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,g||u,b),I=t?t+l:l;return u._events[I]?u._events[I].fn?u._events[I]=[u._events[I],w]:u._events[I].push(w):(u._events[I]=w,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new n:delete u._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,g;if(this._eventsCount===0)return l;for(g in h=this._events)e.call(h,g)&&l.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var b=0,w=g.length,I=new Array(w);b<w;b++)I[b]=g[b].fn;return I},a.prototype.listenerCount=function(l){var h=t?t+l:l,g=this._events[h];return g?g.fn?1:g.length:0},a.prototype.emit=function(l,h,g,b,w,I){var S=t?t+l:l;if(!this._events[S])return!1;var x=this._events[S],C=arguments.length,H,D;if(x.fn){switch(x.once&&this.removeListener(l,x.fn,void 0,!0),C){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,h),!0;case 3:return x.fn.call(x.context,h,g),!0;case 4:return x.fn.call(x.context,h,g,b),!0;case 5:return x.fn.call(x.context,h,g,b,w),!0;case 6:return x.fn.call(x.context,h,g,b,w,I),!0}for(D=1,H=new Array(C-1);D<C;D++)H[D-1]=arguments[D];x.fn.apply(x.context,H)}else{var z=x.length,V;for(D=0;D<z;D++)switch(x[D].once&&this.removeListener(l,x[D].fn,void 0,!0),C){case 1:x[D].fn.call(x[D].context);break;case 2:x[D].fn.call(x[D].context,h);break;case 3:x[D].fn.call(x[D].context,h,g);break;case 4:x[D].fn.call(x[D].context,h,g,b);break;default:if(!H)for(V=1,H=new Array(C-1);V<C;V++)H[V-1]=arguments[V];x[D].fn.apply(x[D].context,H)}}return!0},a.prototype.on=function(l,h,g){return s(this,l,h,g,!1)},a.prototype.once=function(l,h,g){return s(this,l,h,g,!0)},a.prototype.removeListener=function(l,h,g,b){var w=t?t+l:l;if(!this._events[w])return this;if(!h)return o(this,w),this;var I=this._events[w];if(I.fn)I.fn===h&&(!b||I.once)&&(!g||I.context===g)&&o(this,w);else{for(var S=0,x=[],C=I.length;S<C;S++)(I[S].fn!==h||b&&!I[S].once||g&&I[S].context!==g)&&x.push(I[S]);x.length?this._events[w]=x.length===1?x[0]:x:o(this,w)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(CT);var Lte=CT.exports;const Ute=no(Lte);function Dte(r,e){return Array.apply(0,new Array(Math.ceil(r.length/e))).map((t,n)=>r.slice(n*e,(n+1)*e))}const pa=r=>"version"in r;function $te(r){return new TextDecoder("utf-8").decode(r)}function ux(r){return kr.encode(r)}function BT(r){return Ne.from(r,"base64")}function Ao(r){return"accounts"in r}async function Fte(r){const e=(await me.findProgramAddress([],r))[0];return await me.createWithSeed(e,Hte(),r)}function Hte(){return"anchor:idl"}const zte=Je.struct([Je.publicKey("authority"),Je.vecU8("data")]);function Gte(r){return zte.decode(r)}function Kte(r){const e=["name","path","account","relations","generic"],t=s=>s.split(".").map(tX).join("."),n=s=>{for(const o in s){const a=s[o];e.includes(o)?s[o]=Array.isArray(a)?a.map(t):t(a):typeof a=="object"&&n(a)}},i=structuredClone(r);return n(i),i}function iu(r,e,t,n){return r!=null&&r.length?r[0].name?t(r):n(r):e()}function jte(r){const e=new Map;return r.errors&&r.errors.forEach(t=>{var n;let i=(n=t.msg)!==null&&n!==void 0?n:t.name;e.set(t.code,i)}),e}function Wte(r,...e){if(r.args.length!=e.length)throw new Error("Invalid argument length");const t={};let n=0;return r.args.forEach(i=>{t[i.name]=e[n],n+=1}),t}function PT(r,e={}){r.forEach(t=>{if(Ao(t))PT(t.accounts,e[t.name]);else if(!e[t.name])throw new Error(`Account \`${t.name}\` not provided.`)})}function Ri(r){return r instanceof me?r:new me(r)}class Vte extends TypeError{constructor(e,t){let n;const{message:i,...s}=e,{path:o}=e,a=o.length===0?i:"At path: "+o.join(".")+" -- "+i;super(a),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,s),this.name=this.constructor.name,this.failures=()=>{var u;return(u=n)!=null?u:n=[e,...t()]}}}function qte(r){return gu(r)&&typeof r[Symbol.iterator]=="function"}function gu(r){return typeof r=="object"&&r!=null}function ia(r){return typeof r=="string"?JSON.stringify(r):""+r}function Zte(r){const{done:e,value:t}=r.next();return e?void 0:t}function Qte(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:i,branch:s}=e,{type:o}=t,{refinement:a,message:u="Expected a value of type `"+o+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+ia(n)+"`"}=r;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...r,message:u}}function*lx(r,e,t,n){qte(r)||(r=[r]);for(const i of r){const s=Qte(i,e,t,n);s&&(yield s)}}function*p_(r,e,t){t===void 0&&(t={});const{path:n=[],branch:i=[r],coerce:s=!1,mask:o=!1}=t,a={path:n,branch:i};if(s&&(r=e.coercer(r,a),o&&e.type!=="type"&&gu(e.schema)&&gu(r)&&!Array.isArray(r)))for(const l in r)e.schema[l]===void 0&&delete r[l];let u=!0;for(const l of e.validator(r,a))u=!1,yield[l,void 0];for(let[l,h,g]of e.entries(r,a)){const b=p_(h,g,{path:l===void 0?n:[...n,l],branch:l===void 0?i:[...i,h],coerce:s,mask:o});for(const w of b)w[0]?(u=!1,yield[w[0],void 0]):s&&(h=w[1],l===void 0?r=h:r instanceof Map?r.set(l,h):r instanceof Set?r.add(h):gu(r)&&(r[l]=h))}if(u)for(const l of e.refiner(r,a))u=!1,yield[l,void 0];u&&(yield[void 0,r])}class aa{constructor(e){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:t,schema:n,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(u,l)=>{const h=i(u,l);return lx(h,l,this,u)}:this.validator=()=>[],s?this.refiner=(u,l)=>{const h=s(u,l);return lx(h,l,this,u)}:this.refiner=()=>[]}assert(e){return Jte(e,this)}create(e){return g_(e,this)}is(e){return MT(e,this)}mask(e){return Yte(e,this)}validate(e,t){return t===void 0&&(t={}),hd(e,this,t)}}function Jte(r,e){const t=hd(r,e);if(t[0])throw t[0]}function g_(r,e){const t=hd(r,e,{coerce:!0});if(t[0])throw t[0];return t[1]}function Yte(r,e){const t=hd(r,e,{coerce:!0,mask:!0});if(t[0])throw t[0];return t[1]}function MT(r,e){return!hd(r,e)[0]}function hd(r,e,t){t===void 0&&(t={});const n=p_(r,e,t),i=Zte(n);return i[0]?[new Vte(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function dd(r,e){return new aa({type:r,schema:null,validator:e})}function Xte(){return dd("any",()=>!0)}function a1(r){return new aa({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||"Expected an array value, but received: "+ia(e)}})}function ere(){return dd("boolean",r=>typeof r=="boolean")}function fx(r){const e=ia(r);return new aa({type:"literal",schema:r,validator(t){return t===r||"Expected the literal `"+e+"`, but received: "+ia(t)}})}function qd(r){return new aa({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function u0(){return dd("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+ia(r))}function l0(r){return new aa({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function Ta(){return dd("string",r=>typeof r=="string"||"Expected a string, but received: "+ia(r))}function Jo(r){const e=Object.keys(r);return new aa({type:"type",schema:r,*entries(t){if(gu(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return gu(t)||"Expected an object, but received: "+ia(t)}})}function LT(r){const e=r.map(t=>t.type).join(" | ");return new aa({type:"union",schema:null,coercer(t,n){return(r.find(s=>{const[o]=s.validate(t,{coerce:!0});return!o})||y_()).coercer(t,n)},validator(t,n){const i=[];for(const s of r){const[...o]=p_(t,s,n),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return["Expected the value to satisfy a union of `"+e+"`, but received: "+ia(t),...i]}})}function y_(){return dd("unknown",()=>!0)}function tre(r,e,t){return new aa({...r,coercer:(n,i)=>MT(n,e)?r.coercer(t(n,i),i):r.coercer(n,i)})}const hx=99;async function rre(r,e,t){if(e.length<=hx)return await dx(r,e,t);{const n=Dte(e,hx);return(await Promise.all(n.map(s=>dx(r,s,t)))).flat()}}async function dx(r,e,t){const n=t??r.commitment,{value:i,context:s}=await r.getMultipleAccountsInfoAndContext(e,n);return i.map((a,u)=>a===null?null:{publicKey:e[u],account:a,context:s})}async function nre(r,e,t,n,i){var s;t&&t.length>0&&e.sign(...t);const o=e._compile(),a=o.serialize(),l=e._serialize(a).toString("base64"),h={encoding:"base64",commitment:n??r.commitment};if(i){const I=(Array.isArray(i)?i:o.nonProgramIds()).map(S=>S.toBase58());h.accounts={encoding:"base64",addresses:I}}t&&t.length>0&&(h.sigVerify=!0);const g=[l,h],b=await r._rpcRequest("simulateTransaction",g),w=g_(b,are);if("error"in w){let I;if("data"in w.error&&(I=(s=w.error.data)===null||s===void 0?void 0:s.logs,I&&Array.isArray(I))){const S=`
26
+ `,x=S+I.join(S);console.error(w.error.message,x)}throw new na("failed to simulate transaction: "+w.error.message,I)}return w.result}function ire(r){return tre(UT(r),sre,e=>"error"in e?e:{...e,result:g_(e.result,r)})}const sre=UT(y_());function UT(r){return LT([Jo({jsonrpc:fx("2.0"),id:Ta(),result:r}),Jo({jsonrpc:fx("2.0"),id:Ta(),error:Jo({code:y_(),message:Ta(),data:l0(Xte())})})])}function ore(r){return ire(Jo({context:Jo({slot:u0()}),value:r}))}const are=ore(Jo({err:qd(LT([Jo({}),Ta()])),logs:qd(a1(Ta())),accounts:l0(qd(a1(qd(Jo({executable:ere(),owner:Ta(),lamports:u0(),data:a1(Ta()),rentEpoch:l0(u0())}))))),unitsConsumed:l0(u0())}));class Ah{constructor(e,t,n=Ah.defaultOptions()){this.connection=e,this.wallet=t,this.opts=n,this.publicKey=t==null?void 0:t.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(e,t=Ah.defaultOptions()){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(e,t,n){var i,s,o,a;if(n===void 0&&(n=this.opts),pa(e))t&&e.sign(t);else if(e.feePayer=(i=e.feePayer)!==null&&i!==void 0?i:this.wallet.publicKey,e.recentBlockhash=(await this.connection.getLatestBlockhash(n.preflightCommitment)).blockhash,t)for(const l of t)e.partialSign(l);e=await this.wallet.signTransaction(e);const u=e.serialize();try{return await px(this.connection,u,n)}catch(l){if(l instanceof hw){const h=ux(pa(e)?((s=e.signatures)===null||s===void 0?void 0:s[0])||new Uint8Array:(o=e.signature)!==null&&o!==void 0?o:new Uint8Array),g=pa(e)?0:void 0,b=await this.connection.getTransaction(h,{commitment:"confirmed",maxSupportedTransactionVersion:g});if(b){const w=(a=b.meta)===null||a===void 0?void 0:a.logMessages;throw w?new na(l.message,w):l}else throw l}else throw l}}async sendAll(e,t){var n,i,s;t===void 0&&(t=this.opts);const o=(await this.connection.getLatestBlockhash(t.preflightCommitment)).blockhash;let a=e.map(h=>{var g,b;if(pa(h.tx)){let w=h.tx;return h.signers&&w.sign(h.signers),w}else{let w=h.tx,I=(g=h.signers)!==null&&g!==void 0?g:[];return w.feePayer=(b=w.feePayer)!==null&&b!==void 0?b:this.wallet.publicKey,w.recentBlockhash=o,I.forEach(S=>{w.partialSign(S)}),w}});const u=await this.wallet.signAllTransactions(a),l=[];for(let h=0;h<a.length;h+=1){const g=u[h],b=g.serialize();try{l.push(await px(this.connection,b,t))}catch(w){if(w instanceof hw){const I=ux(pa(g)?((n=g.signatures)===null||n===void 0?void 0:n[0])||new Uint8Array:(i=g.signature)!==null&&i!==void 0?i:new Uint8Array),S=pa(g)?0:void 0,x=await this.connection.getTransaction(I,{commitment:"confirmed",maxSupportedTransactionVersion:S});if(x){const C=(s=x.meta)===null||s===void 0?void 0:s.logMessages;throw C?new na(w.message,C):w}else throw w}else throw w}}return l}async simulate(e,t,n,i){let s=(await this.connection.getLatestBlockhash(n??this.connection.commitment)).blockhash,o;if(pa(e)?(t&&t.length>0&&(e.sign(t),e=await this.wallet.signTransaction(e)),o=await this.connection.simulateTransaction(e,{commitment:n})):(e.feePayer=e.feePayer||this.wallet.publicKey,e.recentBlockhash=s,t&&t.length>0&&(e=await this.wallet.signTransaction(e)),o=await nre(this.connection,e,t,n,i)),o.value.err)throw new cre(o.value);return o.value}}class cre extends Error{constructor(e,t){super(t),this.simulationResponse=e}}async function px(r,e,t){const n=t?{skipPreflight:t.skipPreflight,preflightCommitment:t.preflightCommitment||t.commitment,maxRetries:t.maxRetries,minContextSlot:t.minContextSlot}:{};let i;const s=Date.now();for(;Date.now()-s<6e4;)try{const o=await r.sendRawTransaction(e,n);if(t!=null&&t.blockhash)if(n.maxRetries===0){const a=AbortSignal.timeout(15e3);i=(await r.confirmTransaction({abortSignal:a,signature:o,...t.blockhash},t&&t.commitment)).value}else i=(await r.confirmTransaction({signature:o,...t.blockhash},t&&t.commitment)).value;else i=(await r.confirmTransaction(o,t&&t.commitment)).value;if(i.err)throw new hw(`Raw transaction ${o} failed (${JSON.stringify(i)})`);return o}catch(o){if(o.name==="TimeoutError")continue;throw o}throw Error("Transaction failed to confirm in 60s")}class hw extends Error{constructor(e){super(e)}}function dw(){return Ah.local()}var ure=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ul<"u"?ul:typeof self<"u"?self:{},te={};Object.defineProperty(te,"__esModule",{value:!0});var DT=te.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=PO=te.ANCHOR_ERROR__REQUIRE_VIOLATED=BO=te.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=CO=te.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=NO=te.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=OO=te.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=TO=te.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=kO=te.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=SO=te.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=IO=te.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=RO=te.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=xO=te.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=EO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=vO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=AO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=_O=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=bO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=wO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=mO=te.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=yO=te.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=gO=te.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=pO=te.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=dO=te.ANCHOR_ERROR__CONSTRAINT_SPACE=hO=te.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=fO=te.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=lO=te.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=uO=te.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=cO=te.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=aO=te.ANCHOR_ERROR__CONSTRAINT_ZERO=oO=te.ANCHOR_ERROR__CONSTRAINT_ADDRESS=sO=te.ANCHOR_ERROR__CONSTRAINT_CLOSE=iO=te.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=nO=te.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=rO=te.ANCHOR_ERROR__CONSTRAINT_STATE=tO=te.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=eO=te.ANCHOR_ERROR__CONSTRAINT_SEEDS=XT=te.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=YT=te.ANCHOR_ERROR__CONSTRAINT_OWNER=JT=te.ANCHOR_ERROR__CONSTRAINT_RAW=QT=te.ANCHOR_ERROR__CONSTRAINT_SIGNER=ZT=te.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=qT=te.ANCHOR_ERROR__CONSTRAINT_MUT=VT=te.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=WT=te.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=jT=te.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=KT=te.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=GT=te.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=zT=te.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=HT=te.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=FT=te.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,$T=te.ANCHOR_ERROR__DEPRECATED=oN=te.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=sN=te.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=iN=te.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=nN=te.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=rN=te.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=tN=te.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=eN=te.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=XO=te.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=YO=te.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=JO=te.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=QO=te.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=ZO=te.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=qO=te.ANCHOR_ERROR__INVALID_PROGRAM_ID=VO=te.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=WO=te.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=jO=te.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=KO=te.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=GO=te.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=zO=te.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=HO=te.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=FO=te.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=$O=te.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=DO=te.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=UO=te.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=LO=te.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=MO=te.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,FT=te.ANCHOR_ERROR__INSTRUCTION_MISSING=100,HT=te.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,zT=te.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,GT=te.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,KT=te.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,jT=te.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,WT=te.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,VT=te.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,qT=te.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,ZT=te.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,QT=te.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,JT=te.ANCHOR_ERROR__CONSTRAINT_RAW=2003,YT=te.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,XT=te.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,eO=te.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,tO=te.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,rO=te.ANCHOR_ERROR__CONSTRAINT_STATE=2008,nO=te.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,iO=te.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,sO=te.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,oO=te.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,aO=te.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,cO=te.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,uO=te.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,lO=te.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,fO=te.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,hO=te.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,dO=te.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,pO=te.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,gO=te.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,yO=te.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,mO=te.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,wO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,bO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,_O=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,AO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,vO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,EO=te.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,xO=te.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,RO=te.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,IO=te.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,SO=te.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,kO=te.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,TO=te.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,OO=te.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,NO=te.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,CO=te.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,BO=te.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,PO=te.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;DT=te.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var MO=te.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,LO=te.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,UO=te.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,DO=te.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,$O=te.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,FO=te.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,HO=te.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,zO=te.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,GO=te.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,KO=te.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,jO=te.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,WO=te.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,VO=te.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,qO=te.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,ZO=te.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,QO=te.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,JO=te.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,YO=te.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,XO=te.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,eN=te.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,tN=te.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,rN=te.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,nN=te.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,iN=te.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,sN=te.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,oN=te.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;$T=te.ANCHOR_ERROR__DEPRECATED=5e3;const lre=new Map;function aN(r){return lre.get(r)!==void 0}class bo extends Error{constructor(e){super(e),this.name="IdlError"}}class pd{constructor(e){this.stack=e}static parse(e){var t;const n=/^Program (\w*) invoke/,i=/^Program \w* success/,s=[];for(let o=0;o<e.length;o++){if(i.exec(e[o])){s.pop();continue}const a=(t=n.exec(e[o]))===null||t===void 0?void 0:t[1];a&&s.push(new me(a))}return new pd(s)}}class jf extends Error{constructor(e,t,n,i,s,o){super(n.join(`
27
+ `).replace("Program log: ","")),this.errorLogs=n,this.logs=i,this.error={errorCode:e,errorMessage:t,comparedValues:o,origin:s},this._programErrorStack=pd.parse(i)}static parse(e){if(!e)return null;const t=e.findIndex(b=>b.startsWith("Program log: AnchorError"));if(t===-1)return null;const n=e[t],i=[n];let s;if(t+1<e.length){if(e[t+1]==="Program log: Left:"){const b=/^Program log: (.*)$/,w=b.exec(e[t+2])[1],I=b.exec(e[t+4])[1];s=[new me(w),new me(I)],i.push(...e.slice(t+1,t+5))}else if(e[t+1].startsWith("Program log: Left:")){const b=/^Program log: (Left|Right): (.*)$/,w=b.exec(e[t+1])[2],I=b.exec(e[t+2])[2];i.push(...e.slice(t+1,t+3)),s=[w,I]}}const a=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),l=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),g=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n);if(a){const[b,w,I]=a.slice(1,4),S={code:b,number:parseInt(w)};return new jf(S,I,i,e,void 0,s)}else if(l){const[b,w,I,S,x]=l.slice(1,6),C={code:I,number:parseInt(S)},H={file:b,line:parseInt(w)};return new jf(C,x,i,e,H,s)}else if(g){const[b,w,I,S]=g.slice(1,5),x=b,C={code:w,number:parseInt(I)};return new jf(C,S,i,e,x,s)}else return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class V0 extends Error{constructor(e,t,n){super(),this.code=e,this.msg=t,this.logs=n,n&&(this._programErrorStack=pd.parse(n))}static parse(e,t){const n=e.toString();let i;if(n.includes("custom program error:")){let a=n.split("custom program error: ");if(a.length!==2)return null;i=a[1]}else{const a=n.match(/"Custom":([0-9]+)}/g);if(!a||a.length>1)return null;i=a[0].match(/([0-9]+)/g)[0]}let s;try{s=parseInt(i)}catch{return null}let o=t.get(s);return o!==void 0?new V0(s,o,e.logs):(o=fre.get(s),o!==void 0?new V0(s,o,e.logs):null)}get program(){var e;return(e=this._programErrorStack)===null||e===void 0?void 0:e.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var e;return(e=this._programErrorStack)===null||e===void 0?void 0:e.stack}toString(){return this.msg}}function cN(r,e){aN("debug-logs")&&console.log("Translating error:",r);const t=jf.parse(r.logs);if(t)return t;const n=V0.parse(r,e);if(n)return n;if(r.logs){const i={get:function(s,o){return o==="programErrorStack"?s.programErrorStack.stack:o==="program"?s.programErrorStack.stack[r.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return r.programErrorStack=pd.parse(r.logs),new Proxy(r,i)}return r}const ve={InstructionMissing:FT,InstructionFallbackNotFound:HT,InstructionDidNotDeserialize:zT,InstructionDidNotSerialize:GT,IdlInstructionStub:KT,IdlInstructionInvalidProgram:jT,IdlAccountNotEmpty:WT,EventInstructionStub:VT,ConstraintMut:qT,ConstraintHasOne:ZT,ConstraintSigner:QT,ConstraintRaw:JT,ConstraintOwner:YT,ConstraintRentExempt:XT,ConstraintSeeds:eO,ConstraintExecutable:tO,ConstraintState:rO,ConstraintAssociated:nO,ConstraintAssociatedInit:iO,ConstraintClose:sO,ConstraintAddress:oO,ConstraintZero:aO,ConstraintTokenMint:cO,ConstraintTokenOwner:uO,ConstraintMintMintAuthority:lO,ConstraintMintFreezeAuthority:fO,ConstraintMintDecimals:hO,ConstraintSpace:dO,ConstraintAccountIsNone:pO,ConstraintTokenTokenProgram:gO,ConstraintMintTokenProgram:yO,ConstraintAssociatedTokenTokenProgram:mO,ConstraintMintGroupPointerExtension:wO,ConstraintMintGroupPointerExtensionAuthority:bO,ConstraintMintGroupPointerExtensionGroupAddress:_O,ConstraintMintGroupMemberPointerExtension:AO,ConstraintMintGroupMemberPointerExtensionAuthority:vO,ConstraintMintGroupMemberPointerExtensionMemberAddress:EO,ConstraintMintMetadataPointerExtension:xO,ConstraintMintMetadataPointerExtensionAuthority:RO,ConstraintMintMetadataPointerExtensionMetadataAddress:IO,ConstraintMintCloseAuthorityExtension:SO,ConstraintMintCloseAuthorityExtensionAuthority:kO,ConstraintMintPermanentDelegateExtension:TO,ConstraintMintPermanentDelegateExtensionDelegate:OO,ConstraintMintTransferHookExtension:NO,ConstraintMintTransferHookExtensionAuthority:CO,ConstraintMintTransferHookExtensionProgramId:BO,RequireViolated:PO,RequireEqViolated:DT,RequireKeysEqViolated:MO,RequireNeqViolated:LO,RequireKeysNeqViolated:UO,RequireGtViolated:DO,RequireGteViolated:$O,AccountDiscriminatorAlreadySet:FO,AccountDiscriminatorNotFound:HO,AccountDiscriminatorMismatch:zO,AccountDidNotDeserialize:GO,AccountDidNotSerialize:KO,AccountNotEnoughKeys:jO,AccountNotMutable:WO,AccountOwnedByWrongProgram:VO,InvalidProgramId:qO,InvalidProgramExecutable:ZO,AccountNotSigner:QO,AccountNotSystemOwned:JO,AccountNotInitialized:YO,AccountNotProgramData:XO,AccountNotAssociatedTokenAccount:eN,AccountSysvarMismatch:tN,AccountReallocExceedsLimit:rN,AccountDuplicateReallocs:nN,DeclaredProgramIdMismatch:iN,TryingToInitPayerAsProgramAccount:sN,InvalidNumericConversion:oN,Deprecated:$T},fre=new Map([[ve.InstructionMissing,"Instruction discriminator not provided"],[ve.InstructionFallbackNotFound,"Fallback functions are not supported"],[ve.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[ve.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[ve.IdlInstructionStub,"The program was compiled without idl instructions"],[ve.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[ve.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[ve.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[ve.ConstraintMut,"A mut constraint was violated"],[ve.ConstraintHasOne,"A has one constraint was violated"],[ve.ConstraintSigner,"A signer constraint was violated"],[ve.ConstraintRaw,"A raw constraint was violated"],[ve.ConstraintOwner,"An owner constraint was violated"],[ve.ConstraintRentExempt,"A rent exemption constraint was violated"],[ve.ConstraintSeeds,"A seeds constraint was violated"],[ve.ConstraintExecutable,"An executable constraint was violated"],[ve.ConstraintState,"Deprecated Error, feel free to replace with something else"],[ve.ConstraintAssociated,"An associated constraint was violated"],[ve.ConstraintAssociatedInit,"An associated init constraint was violated"],[ve.ConstraintClose,"A close constraint was violated"],[ve.ConstraintAddress,"An address constraint was violated"],[ve.ConstraintZero,"Expected zero account discriminant"],[ve.ConstraintTokenMint,"A token mint constraint was violated"],[ve.ConstraintTokenOwner,"A token owner constraint was violated"],[ve.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[ve.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[ve.ConstraintMintDecimals,"A mint decimals constraint was violated"],[ve.ConstraintSpace,"A space constraint was violated"],[ve.ConstraintAccountIsNone,"A required account for the constraint is None"],[ve.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[ve.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[ve.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[ve.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[ve.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[ve.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[ve.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[ve.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[ve.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[ve.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[ve.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[ve.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[ve.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[ve.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[ve.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[ve.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[ve.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[ve.RequireViolated,"A require expression was violated"],[ve.RequireEqViolated,"A require_eq expression was violated"],[ve.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[ve.RequireNeqViolated,"A require_neq expression was violated"],[ve.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[ve.RequireGtViolated,"A require_gt expression was violated"],[ve.RequireGteViolated,"A require_gte expression was violated"],[ve.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[ve.AccountDiscriminatorNotFound,"No discriminator was found on the account"],[ve.AccountDiscriminatorMismatch,"Account discriminator did not match what was expected"],[ve.AccountDidNotDeserialize,"Failed to deserialize the account"],[ve.AccountDidNotSerialize,"Failed to serialize the account"],[ve.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[ve.AccountNotMutable,"The given account is not mutable"],[ve.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[ve.InvalidProgramId,"Program ID was not as expected"],[ve.InvalidProgramExecutable,"Program account is not executable"],[ve.AccountNotSigner,"The given account did not sign"],[ve.AccountNotSystemOwned,"The given account is not owned by the system program"],[ve.AccountNotInitialized,"The program expected this account to be already initialized"],[ve.AccountNotProgramData,"The given account is not a program data account"],[ve.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[ve.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[ve.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[ve.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[ve.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[ve.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[ve.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[ve.Deprecated,"The API being used is deprecated and should no longer be used"]]);class dt{static fieldLayout(e,t=[],n){const i=e.name;switch(e.type){case"bool":return Je.bool(i);case"u8":return Je.u8(i);case"i8":return Je.i8(i);case"u16":return Je.u16(i);case"i16":return Je.i16(i);case"u32":return Je.u32(i);case"i32":return Je.i32(i);case"f32":return Je.f32(i);case"u64":return Je.u64(i);case"i64":return Je.i64(i);case"f64":return Je.f64(i);case"u128":return Je.u128(i);case"i128":return Je.i128(i);case"u256":return Je.u256(i);case"i256":return Je.i256(i);case"bytes":return Je.vecU8(i);case"string":return Je.str(i);case"pubkey":return Je.publicKey(i);default:{if("option"in e.type)return Je.option(dt.fieldLayout({type:e.type.option},t,n),i);if("vec"in e.type)return Je.vec(dt.fieldLayout({type:e.type.vec},t,n),i);if("array"in e.type){let[s,o]=e.type.array;return o=dt.resolveArrayLen(o,n),Je.array(dt.fieldLayout({type:s},t,n),o,i)}if("defined"in e.type){if(!t)throw new bo("User defined types not provided");const s=e.type.defined.name,o=t.find(a=>a.name===s);if(!o)throw new bo(`Type not found: ${e.name}`);return dt.typeDefLayout({typeDef:o,types:t,genericArgs:n??e.type.defined.generics,name:i})}if("generic"in e.type){const s=n==null?void 0:n.at(0);if((s==null?void 0:s.kind)!=="type")throw new bo(`Invalid generic field: ${e.name}`);return dt.fieldLayout({...e,type:s.type},t)}throw new bo(`Not yet implemented: ${JSON.stringify(e.type)}`)}}}static typeDefLayout({typeDef:e,types:t,name:n,genericArgs:i}){switch(e.type.kind){case"struct":{const s=iu(e.type.fields,()=>[],o=>o.map(a=>{const u=i&&dt.resolveGenericArgs({type:a.type,typeDef:e,genericArgs:i});return dt.fieldLayout(a,t,u)}),o=>o.map((a,u)=>{const l=i&&dt.resolveGenericArgs({type:a,typeDef:e,genericArgs:i});return dt.fieldLayout({name:u.toString(),type:a},t,l)}));return Je.struct(s,n)}case"enum":{const s=e.type.variants.map(o=>{const a=iu(o.fields,()=>[],u=>u.map(l=>{const h=i&&dt.resolveGenericArgs({type:l.type,typeDef:e,genericArgs:i});return dt.fieldLayout(l,t,h)}),u=>u.map((l,h)=>{const g=i&&dt.resolveGenericArgs({type:l,typeDef:e,genericArgs:i});return dt.fieldLayout({name:h.toString(),type:l},t,g)}));return Je.struct(a,o.name)});return n!==void 0?Je.rustEnum(s).replicate(n):Je.rustEnum(s,n)}case"type":return dt.fieldLayout({type:e.type.alias,name:n},t)}}static typeSize(e,t,n){var i;switch(e){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"pubkey":return 32;default:if("option"in e)return 1+dt.typeSize(e.option,t,n);if("coption"in e)return 4+dt.typeSize(e.coption,t,n);if("vec"in e)return 1;if("array"in e){let[s,o]=e.array;return o=dt.resolveArrayLen(o,n),dt.typeSize(s,t,n)*o}if("defined"in e){const s=(i=t.types)===null||i===void 0?void 0:i.find(a=>a.name===e.defined.name);if(!s)throw new bo(`Type not found: ${JSON.stringify(e)}`);const o=a=>{const u=n??e.defined.generics,l=u&&dt.resolveGenericArgs({type:a,typeDef:s,genericArgs:u});return dt.typeSize(a,t,l)};switch(s.type.kind){case"struct":return iu(s.type.fields,()=>[0],a=>a.map(u=>o(u.type)),a=>a.map(u=>o(u))).reduce((a,u)=>a+u,0);case"enum":{const a=s.type.variants.map(u=>iu(u.fields,()=>[0],l=>l.map(h=>o(h.type)),l=>l.map(h=>o(h))).reduce((l,h)=>l+h,0));return Math.max(...a)+1}case"type":return dt.typeSize(s.type.alias,t,n)}}if("generic"in e){const s=n==null?void 0:n.at(0);if((s==null?void 0:s.kind)!=="type")throw new bo(`Invalid generic: ${e.generic}`);return dt.typeSize(s.type,t,n)}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}static resolveArrayLen(e,t){if(typeof e=="number")return e;if(t){const n=t.find(i=>i.kind==="const");(n==null?void 0:n.kind)==="const"&&(e=+n.value)}if(typeof e!="number")throw new bo("Generic array length did not resolve");return e}static resolveGenericArgs({type:e,typeDef:t,genericArgs:n,isDefined:i}){if(typeof e!="object")return null;for(const s in t.generics){const o=t.generics[s];if("generic"in e&&o.name===e.generic)return[n[s]];if("option"in e){const a=dt.resolveGenericArgs({type:e.option,typeDef:t,genericArgs:n,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{option:a[0].type}}]}if("vec"in e){const a=dt.resolveGenericArgs({type:e.vec,typeDef:t,genericArgs:n,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{vec:a[0].type}}]}if("array"in e){const[a,u]=e.array,l=typeof u=="object",h=dt.resolveGenericArgs({type:a,typeDef:t,genericArgs:n,isDefined:i});if(h){for(const g in t.generics.slice(+s)){const b=+s+ +g;l&&t.generics[b].name===u.generic&&h.push(n[b])}if(!i)return h;if(h[0].kind==="type"&&h[1].kind==="const")return[{kind:"type",type:{array:[h[0].type,+h[1].value]}}]}if(l&&o.name===u.generic){const g=n[s];return i?[{kind:"type",type:{array:[a,+g.value]}}]:[g]}return null}if("defined"in e)return e.defined.generics?e.defined.generics.flatMap(a=>{switch(a.kind){case"type":return dt.resolveGenericArgs({type:a.type,typeDef:t,genericArgs:n,isDefined:!0});case"const":return[a]}}).filter(a=>a!==null):null}return null}}class hre{constructor(e){this.idl=e;const t=e.instructions.map(n=>{const i=n.name,s=n.args.map(a=>dt.fieldLayout(a,e.types)),o=Je.struct(s,i);return[i,{discriminator:n.discriminator,layout:o}]});this.ixLayouts=new Map(t)}encode(e,t){const n=Ne.alloc(1e3),i=this.ixLayouts.get(e);if(!i)throw new Error(`Unknown method: ${e}`);const s=i.layout.encode(t,n),o=n.slice(0,s);return Ne.concat([Ne.from(i.discriminator),o])}decode(e,t="hex"){typeof e=="string"&&(e=t==="hex"?Ne.from(e,"hex"):kr.decode(e));for(const[n,i]of this.ixLayouts){const s=e.subarray(0,i.discriminator.length);if(s.equals(Ne.from(i.discriminator)))return{name:n,data:i.layout.decode(e.subarray(s.length))}}return null}format(e,t){return Dn.format(e,t,this.idl)}}class Dn{static format(e,t,n){const i=n.instructions.find(u=>e.name===u.name);if(!i)return console.error("Invalid instruction given"),null;const s=i.args.map(u=>({name:u.name,type:Dn.formatIdlType(u.type),data:Dn.formatIdlData(u,e.data[u.name],n.types)})),o=Dn.flattenIdlAccounts(i.accounts),a=t.map((u,l)=>l<o.length?{name:o[l].name,...u}:{name:void 0,...u});return{args:s,accounts:a}}static formatIdlType(e){if(typeof e=="string")return e;if("option"in e)return`Option<${this.formatIdlType(e.option)}>`;if("coption"in e)return`COption<${this.formatIdlType(e.coption)}>`;if("vec"in e)return`Vec<${this.formatIdlType(e.vec)}>`;if("array"in e)return`Array<${e.array[0]}; ${e.array[1]}>`;if("defined"in e){const t=e.defined.name;if(e.defined.generics){const n=e.defined.generics.map(i=>{switch(i.kind){case"type":return Dn.formatIdlType(i.type);case"const":return i.value}}).join(", ");return`${t}<${n}>`}return t}throw new Error(`Unknown IDL type: ${e}`)}static formatIdlData(e,t,n){if(typeof e.type=="string")return t.toString();if("vec"in e.type)return"["+t.map(i=>this.formatIdlData({name:"",type:e.type.vec},i,n)).join(", ")+"]";if("option"in e.type)return t===null?"null":this.formatIdlData({name:"",type:e.type.option},t,n);if("defined"in e.type){if(!n)throw new Error("User defined types not provided");const i=e.type.defined.name,s=n.find(o=>o.name===i);if(!s)throw new Error(`Type not found: ${i}`);return Dn.formatIdlDataDefined(s,t,n)}return"unknown"}static formatIdlDataDefined(e,t,n){switch(e.type.kind){case"struct":return"{ "+iu(e.type.fields,()=>"",i=>Object.entries(t).map(([s,o])=>{const a=i.find(u=>u.name===s);if(!a)throw new Error(`Field not found: ${s}`);return s+": "+Dn.formatIdlData(a,o,n)}).join(", "),i=>Object.entries(t).map(([s,o])=>s+": "+Dn.formatIdlData({name:"",type:i[s]},o,n)).join(", "))+" }";case"enum":{const i=Object.keys(t)[0],s=e.type.variants.find(a=>a.name===i);if(!s)throw new Error(`Unable to find variant: ${i}`);const o=t[i];return iu(s.fields,()=>i,a=>{const u=Object.keys(o).map(l=>{const h=o[l],g=a.find(b=>b.name===l);if(!g)throw new Error(`Field not found: ${l}`);return l+": "+Dn.formatIdlData(g,h,n)}).join(", ");return`${i} { ${u} }`},a=>{const u=Object.entries(o).map(([l,h])=>l+": "+Dn.formatIdlData({name:"",type:a[l]},h,n)).join(", ");return`${i} { ${u} }`})}case"type":return Dn.formatIdlType(e.type.alias)}}static flattenIdlAccounts(e,t){return e.map(n=>{const i=dre(n.name);if(n.hasOwnProperty("accounts")){const s=t?`${t} > ${i}`:i;return Dn.flattenIdlAccounts(n.accounts,s)}else return{...n,name:t?`${t} > ${i}`:i}}).flat()}}function dre(r){const e=r.replace(/([A-Z])/g," $1");return e.charAt(0).toUpperCase()+e.slice(1)}class pre{constructor(e){if(this.idl=e,!e.accounts){this.accountLayouts=new Map;return}const t=e.types;if(!t)throw new Error("Accounts require `idl.types`");const n=e.accounts.map(i=>{const s=t.find(o=>o.name===i.name);if(!s)throw new Error(`Account not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:dt.typeDefLayout({typeDef:s,types:t})}]});this.accountLayouts=new Map(n)}async encode(e,t){const n=Ne.alloc(1e3),i=this.accountLayouts.get(e);if(!i)throw new Error(`Unknown account: ${e}`);const s=i.layout.encode(t,n),o=n.slice(0,s),a=this.accountDiscriminator(e);return Ne.concat([a,o])}decode(e,t){const n=this.accountDiscriminator(e);if(n.compare(t.slice(0,n.length)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(e,t)}decodeAny(e){for(const[t,n]of this.accountLayouts)if(e.subarray(0,n.discriminator.length).equals(Ne.from(n.discriminator)))return this.decodeUnchecked(t,e);throw new Error("Account not found")}decodeUnchecked(e,t){const n=this.accountDiscriminator(e),i=t.subarray(n.length),s=this.accountLayouts.get(e);if(!s)throw new Error(`Unknown account: ${e}`);return s.layout.decode(i)}memcmp(e,t){const n=this.accountDiscriminator(e);return{offset:0,bytes:kr.encode(t?Ne.concat([n,t]):n)}}size(e){return this.accountDiscriminator(e).length+dt.typeSize({defined:{name:e}},this.idl)}accountDiscriminator(e){var t;const n=(t=this.idl.accounts)===null||t===void 0?void 0:t.find(i=>i.name===e);if(!n)throw new Error(`Account not found: ${e}`);return Ne.from(n.discriminator)}}class gre{constructor(e){if(!e.events){this.layouts=new Map;return}const t=e.types;if(!t)throw new Error("Events require `idl.types`");const n=e.events.map(i=>{const s=t.find(o=>o.name===i.name);if(!s)throw new Error(`Event not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:dt.typeDefLayout({typeDef:s,types:t})}]});this.layouts=new Map(n)}decode(e){let t;try{t=BT(e)}catch{return null}for(const[n,i]of this.layouts){const s=t.subarray(0,i.discriminator.length);if(s.equals(Ne.from(i.discriminator)))return{name:n,data:i.layout.decode(t.subarray(s.length))}}return null}}class yre{constructor(e){const t=e.types;if(!t){this.typeLayouts=new Map;return}const n=t.filter(i=>!i.generics).map(i=>[i.name,dt.typeDefLayout({typeDef:i,types:t})]);this.typeLayouts=new Map(n)}encode(e,t){const n=Ne.alloc(1e3),i=this.typeLayouts.get(e);if(!i)throw new Error(`Unknown type: ${e}`);const s=i.encode(t,n);return n.slice(0,s)}decode(e,t){const n=this.typeLayouts.get(e);if(!n)throw new Error(`Unknown type: ${e}`);return n.decode(t)}}class uN{constructor(e){this.instruction=new hre(e),this.accounts=new pre(e),this.events=new gre(e),this.types=new yre(e)}}class Bn{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}decode(e,t){throw new Error("Layout is abstract")}encode(e,t,n){throw new Error("Layout is abstract")}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}var ng=Bn;function mre(r,e){return e.property?r+"["+e.property+"]":r}class Oa extends Bn{isCount(){throw new Error("ExternalLayout is abstract")}}class lN extends Oa{constructor(e,t,n){if(!(e instanceof Bn))throw new TypeError("layout must be a Layout");if(t===void 0)t=0;else if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof ig||this.layout instanceof fN}decode(e,t){return t===void 0&&(t=0),this.layout.decode(e,t+this.offset)}encode(e,t,n){return n===void 0&&(n=0),this.layout.encode(e,t,n+this.offset)}}class ig extends Bn{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntLE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntLE(e,n,this.span),this.span}}class fN extends Bn{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntBE(t,this.span)}encode(e,t,n){return n===void 0&&(n=0),t.writeUIntBE(e,n,this.span),this.span}}const pw=Math.pow(2,32);function hN(r){const e=Math.floor(r/pw),t=r-e*pw;return{hi32:e,lo32:t}}function dN(r,e){return r*pw+e}class wre extends Bn{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readUInt32LE(t+4);return dN(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=hN(e);return t.writeUInt32LE(i.lo32,n),t.writeUInt32LE(i.hi32,n+4),8}}class bre extends Bn{constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);const n=e.readUInt32LE(t),i=e.readInt32LE(t+4);return dN(i,n)}encode(e,t,n){n===void 0&&(n=0);const i=hN(e);return t.writeUInt32LE(i.lo32,n),t.writeInt32LE(i.hi32,n+4),8}}class _re extends Bn{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((s,o)=>s&&o instanceof Bn,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&n===void 0&&(n=t,t=void 0);for(const s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;try{n=this.fields.reduce((i,s)=>{const o=s.getSpan(e,t);return t+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(e,t){t===void 0&&(t=0);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n){n===void 0&&(n=0);const i=n;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const l=e[a.property];l!==void 0&&(o=a.encode(l,t,n),0>u&&(u=a.getSpan(t,n)))}s=n,n+=u}return s+o-i}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}}class pN{constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class gx extends pN{constructor(e,t){if(!(e instanceof Oa&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}}class gN extends Bn{constructor(e,t,n){const i=e instanceof ig||e instanceof fN;if(i)e=new gx(new lN(e));else if(e instanceof Oa&&e.isCount())e=new gx(e);else if(!(e instanceof pN))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof Bn))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&i&&(s+=e.layout.span)),super(s,n),this.discriminator=e,this.usesPrefixDiscriminator=i,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(e.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&e.hasOwnProperty(this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||e.hasOwnProperty(t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(e.hasOwnProperty(n.property))return n}throw new Error("unable to infer src variant")}decode(e,t){t===void 0&&(t=0);let n;const i=this.discriminator,s=i.decode(e,t);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),n=this.makeDestinationObject(),n[i.property]=s,n[o.property]=this.defaultLayout.decode(e,t+a)}else n=o.decode(e,t);return n}encode(e,t,n){n===void 0&&(n=0);const i=this.getSourceVariant(e);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(e[s.property],t,n),a+o.encode(e[o.property],t,n+a)}return i.encode(e,t,n)}addVariant(e,t,n){const i=new Are(this,e,t,n);return this.registry[e]=i,i}getVariant(e,t){let n=e;return Qe.isBuffer(e)&&(t===void 0&&(t=0),n=this.discriminator.decode(e,t)),this.registry[n]}}class Are extends Bn{constructor(e,t,n,i){if(!(e instanceof gN))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Bn))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=n?n.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,i),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(e,t+n)}decode(e,t){const n=this.makeDestinationObject();if(t===void 0&&(t=0),this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n){n===void 0&&(n=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!e.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,n+i),s+=this.layout.getSpan(t,n+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}class vre extends Bn{constructor(e,t){if(!(e instanceof Oa&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof Oa||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t){t===void 0&&(t=0);let n=this.span;return 0>n&&(n=this.length.decode(e,t)),e.slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof Oa&&(i=e.length),!(Qe.isBuffer(e)&&i===e.length))throw new TypeError(mre("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(n+i>t.length)throw new RangeError("encoding overruns Buffer");return t.write(e.toString("hex"),n,i,"hex"),this.length instanceof Oa&&this.length.encode(i,t,n),i}}var Ere=(r,e,t)=>new lN(r,e,t),xre=r=>new ig(1,r),Vs=r=>new ig(4,r),Rre=r=>new wre(r),eo=r=>new bre(r),Cr=(r,e,t)=>new _re(r,e,t),yN=(r,e,t)=>new gN(r,e,t),gd=(r,e)=>new vre(r,e);class Ire extends ng{constructor(e){super(-1,e),this.property=e,this.layout=Cr([Vs("length"),Vs("lengthPadding"),gd(Ere(Vs(),-8),"chars")],this.property)}encode(e,t,n=0){if(e==null)return this.layout.span;const i={chars:Qe.from(e,"utf8")};return this.layout.encode(i,t,n)}decode(e,t=0){return this.layout.decode(e,t).chars.toString()}getSpan(e,t=0){return Vs().span+Vs().span+new Gs(new Uint8Array(e).slice(t,t+4),10,"le").toNumber()}}function sg(r){return new Ire(r)}function hi(r){return gd(32,r)}const Qn=yN(Vs("instruction"));Qn.addVariant(0,Cr([eo("lamports"),eo("space"),hi("owner")]),"createAccount");Qn.addVariant(1,Cr([hi("owner")]),"assign");Qn.addVariant(2,Cr([eo("lamports")]),"transfer");Qn.addVariant(3,Cr([hi("base"),sg("seed"),eo("lamports"),eo("space"),hi("owner")]),"createAccountWithSeed");Qn.addVariant(4,Cr([hi("authorized")]),"advanceNonceAccount");Qn.addVariant(5,Cr([eo("lamports")]),"withdrawNonceAccount");Qn.addVariant(6,Cr([hi("authorized")]),"initializeNonceAccount");Qn.addVariant(7,Cr([hi("authorized")]),"authorizeNonceAccount");Qn.addVariant(8,Cr([eo("space")]),"allocate");Qn.addVariant(9,Cr([hi("base"),sg("seed"),eo("space"),hi("owner")]),"allocateWithSeed");Qn.addVariant(10,Cr([hi("base"),sg("seed"),hi("owner")]),"assignWithSeed");Qn.addVariant(11,Cr([eo("lamports"),sg("seed"),hi("owner")]),"transferWithSeed");Math.max(...Object.values(Qn.registry).map(r=>r.span));class Sre extends ng{constructor(e,t,n,i){super(e.span,i),this.layout=e,this.decoder=t,this.encoder=n}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,n){return this.layout.encode(this.encoder(e),t,n)}getSpan(e,t){return this.layout.getSpan(e,t)}}function yx(r){return new Sre(gd(32),e=>new me(e),e=>e.toBuffer(),r)}Cr([Vs("version"),Vs("state"),yx("authorizedPubkey"),yx("nonce"),Cr([Rre("lamportsPerSignature")],"feeCalculator")]);new me("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new me("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var mx={exports:{}};(function(r,e){var t=typeof self<"u"?self:ure,n=function(){function s(){this.fetch=!1,this.DOMException=t.DOMException}return s.prototype=t,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function u(p){return p&&DataView.prototype.isPrototypeOf(p)}if(a.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(p){return p&&l.indexOf(Object.prototype.toString.call(p))>-1};function g(p){if(typeof p!="string"&&(p=String(p)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(p))throw new TypeError("Invalid character in header field name");return p.toLowerCase()}function b(p){return typeof p!="string"&&(p=String(p)),p}function w(p){var m={next:function(){var E=p.shift();return{done:E===void 0,value:E}}};return a.iterable&&(m[Symbol.iterator]=function(){return m}),m}function I(p){this.map={},p instanceof I?p.forEach(function(m,E){this.append(E,m)},this):Array.isArray(p)?p.forEach(function(m){this.append(m[0],m[1])},this):p&&Object.getOwnPropertyNames(p).forEach(function(m){this.append(m,p[m])},this)}I.prototype.append=function(p,m){p=g(p),m=b(m);var E=this.map[p];this.map[p]=E?E+", "+m:m},I.prototype.delete=function(p){delete this.map[g(p)]},I.prototype.get=function(p){return p=g(p),this.has(p)?this.map[p]:null},I.prototype.has=function(p){return this.map.hasOwnProperty(g(p))},I.prototype.set=function(p,m){this.map[g(p)]=b(m)},I.prototype.forEach=function(p,m){for(var E in this.map)this.map.hasOwnProperty(E)&&p.call(m,this.map[E],E,this)},I.prototype.keys=function(){var p=[];return this.forEach(function(m,E){p.push(E)}),w(p)},I.prototype.values=function(){var p=[];return this.forEach(function(m){p.push(m)}),w(p)},I.prototype.entries=function(){var p=[];return this.forEach(function(m,E){p.push([E,m])}),w(p)},a.iterable&&(I.prototype[Symbol.iterator]=I.prototype.entries);function S(p){if(p.bodyUsed)return Promise.reject(new TypeError("Already read"));p.bodyUsed=!0}function x(p){return new Promise(function(m,E){p.onload=function(){m(p.result)},p.onerror=function(){E(p.error)}})}function C(p){var m=new FileReader,E=x(m);return m.readAsArrayBuffer(p),E}function H(p){var m=new FileReader,E=x(m);return m.readAsText(p),E}function D(p){for(var m=new Uint8Array(p),E=new Array(m.length),k=0;k<m.length;k++)E[k]=String.fromCharCode(m[k]);return E.join("")}function z(p){if(p.slice)return p.slice(0);var m=new Uint8Array(p.byteLength);return m.set(new Uint8Array(p)),m.buffer}function V(){return this.bodyUsed=!1,this._initBody=function(p){this._bodyInit=p,p?typeof p=="string"?this._bodyText=p:a.blob&&Blob.prototype.isPrototypeOf(p)?this._bodyBlob=p:a.formData&&FormData.prototype.isPrototypeOf(p)?this._bodyFormData=p:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)?this._bodyText=p.toString():a.arrayBuffer&&a.blob&&u(p)?(this._bodyArrayBuffer=z(p.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(p)||h(p))?this._bodyArrayBuffer=z(p):this._bodyText=p=Object.prototype.toString.call(p):this._bodyText="",this.headers.get("content-type")||(typeof p=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var p=S(this);if(p)return p;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?S(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(C)}),this.text=function(){var p=S(this);if(p)return p;if(this._bodyBlob)return H(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(D(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(oe)}),this.json=function(){return this.text().then(JSON.parse)},this}var Z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function K(p){var m=p.toUpperCase();return Z.indexOf(m)>-1?m:p}function W(p,m){m=m||{};var E=m.body;if(p instanceof W){if(p.bodyUsed)throw new TypeError("Already read");this.url=p.url,this.credentials=p.credentials,m.headers||(this.headers=new I(p.headers)),this.method=p.method,this.mode=p.mode,this.signal=p.signal,!E&&p._bodyInit!=null&&(E=p._bodyInit,p.bodyUsed=!0)}else this.url=String(p);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new I(m.headers)),this.method=K(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&E)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(E)}W.prototype.clone=function(){return new W(this,{body:this._bodyInit})};function oe(p){var m=new FormData;return p.trim().split("&").forEach(function(E){if(E){var k=E.split("="),O=k.shift().replace(/\+/g," "),M=k.join("=").replace(/\+/g," ");m.append(decodeURIComponent(O),decodeURIComponent(M))}}),m}function ce(p){var m=new I,E=p.replace(/\r?\n[\t ]+/g," ");return E.split(/\r?\n/).forEach(function(k){var O=k.split(":"),M=O.shift().trim();if(M){var G=O.join(":").trim();m.append(M,G)}}),m}V.call(W.prototype);function ne(p,m){m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in m?m.statusText:"OK",this.headers=new I(m.headers),this.url=m.url||"",this._initBody(p)}V.call(ne.prototype),ne.prototype.clone=function(){return new ne(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new I(this.headers),url:this.url})},ne.error=function(){var p=new ne(null,{status:0,statusText:""});return p.type="error",p};var ue=[301,302,303,307,308];ne.redirect=function(p,m){if(ue.indexOf(m)===-1)throw new RangeError("Invalid status code");return new ne(null,{status:m,headers:{location:p}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,E){this.message=m,this.name=E;var k=Error(m);this.stack=k.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function B(p,m){return new Promise(function(E,k){var O=new W(p,m);if(O.signal&&O.signal.aborted)return k(new o.DOMException("Aborted","AbortError"));var M=new XMLHttpRequest;function G(){M.abort()}M.onload=function(){var P={status:M.status,statusText:M.statusText,headers:ce(M.getAllResponseHeaders()||"")};P.url="responseURL"in M?M.responseURL:P.headers.get("X-Request-URL");var A="response"in M?M.response:M.responseText;E(new ne(A,P))},M.onerror=function(){k(new TypeError("Network request failed"))},M.ontimeout=function(){k(new TypeError("Network request failed"))},M.onabort=function(){k(new o.DOMException("Aborted","AbortError"))},M.open(O.method,O.url,!0),O.credentials==="include"?M.withCredentials=!0:O.credentials==="omit"&&(M.withCredentials=!1),"responseType"in M&&a.blob&&(M.responseType="blob"),O.headers.forEach(function(P,A){M.setRequestHeader(A,P)}),O.signal&&(O.signal.addEventListener("abort",G),M.onreadystatechange=function(){M.readyState===4&&O.signal.removeEventListener("abort",G)}),M.send(typeof O._bodyInit>"u"?null:O._bodyInit)})}return B.polyfill=!0,s.fetch||(s.fetch=B,s.Headers=I,s.Request=W,s.Response=ne),o.Headers=I,o.Request=W,o.Response=ne,o.fetch=B,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,r.exports=e})(mx,mx.exports);Je.rustEnum([Je.struct([],"uninitialized"),Je.struct([Je.option(Je.publicKey(),"authorityAddress")],"buffer"),Je.struct([Je.publicKey("programdataAddress")],"program"),Je.struct([Je.u64("slot"),Je.option(Je.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,Je.u32());const gw="Program log: ",mN="Program data: ",kre=gw.length,Tre=mN.length;class Ore{constructor(e,t,n){this._programId=e,this._provider=t,this._eventParser=new wN(e,n),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(e,t,n){var i;let s=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(e)||this._eventListeners.set(e,[]),this._eventListeners.set(e,((i=this._eventListeners.get(e))!==null&&i!==void 0?i:[]).concat(s)),this._eventCallbacks.set(s,[e,t]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(o,a)=>{if(!o.err)for(const u of this._eventParser.parseLogs(o.logs)){const l=this._eventListeners.get(u.name);l&&l.forEach(h=>{const g=this._eventCallbacks.get(h);if(g){const[,b]=g;b(u.data,a.slot,o.signature)}})}},n)),s}async removeEventListener(e){const t=this._eventCallbacks.get(e);if(!t)throw new Error(`Event listener ${e} doesn't exist!`);const[n]=t;let i=this._eventListeners.get(n);if(!i)throw new Error(`Event listeners don't exist for ${n}!`);if(this._eventCallbacks.delete(e),i=i.filter(s=>s!==e),this._eventListeners.set(n,i),i.length===0&&this._eventListeners.delete(n),this._eventCallbacks.size===0){if(this._eventListeners.size!==0)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);this._onLogsSubscriptionId!==void 0&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class wN{constructor(e,t){this.coder=t,this.programId=e}*parseLogs(e,t=!1){const n=new Cre(e),i=new Nre;let s=n.next();for(;s!==null;){let[o,a,u]=this.handleLog(i,s,t);o&&(yield o),a&&i.push(a),u&&i.pop(),s=n.next()}}handleLog(e,t,n){return e.stack.length>0&&e.program()===this.programId.toString()?this.handleProgramLog(t,n):[null,...this.handleSystemLog(t)]}handleProgramLog(e,t){if(e.startsWith(gw)||e.startsWith(mN)){const n=e.startsWith(gw)?e.slice(kre):e.slice(Tre),i=this.coder.events.decode(n);if(t&&i===null)throw new Error(`Unable to decode event ${n}`);return[i,null,!1]}else return[null,...this.handleSystemLog(e)]}handleSystemLog(e){const t=e.split(":")[0];return t.match(/^Program (.*) success/g)!==null?[null,!0]:t.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:t.includes("invoke")?["cpi",!1]:[null,!1]}}class Nre{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(e){this.stack.push(e)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class Cre{constructor(e){this.logs=e}next(){if(this.logs.length===0)return null;let e=this.logs[0];return this.logs=this.logs.slice(1),e}}function og(r,e){var t,n;let i={};const s=r.args?r.args.length:0;if(e.length>s){if(e.length!==s+1)throw new Error(`provided too many arguments ${e} to instruction ${r==null?void 0:r.name} expecting: ${(n=(t=r.args)===null||t===void 0?void 0:t.map(o=>o.name))!==null&&n!==void 0?n:[]}`);i=e.pop()}return[e,i]}class q0{static build(e,t,n){if(e.name==="_inner")throw new bo("the _inner name is reserved");const i=(...s)=>{const[o,a]=og(e,[...s]);PT(e.accounts,a.accounts),Bre(e,...s);const u=i.accounts(a.accounts);return a.remainingAccounts!==void 0&&u.push(...a.remainingAccounts),aN("debug-logs")&&console.log("Outgoing account metas:",u),new Bt({keys:u,programId:n,data:t(e.name,Wte(e,...o))})};return i.accounts=s=>q0.accountsArray(s,e.accounts,n,e.name),i}static accountsArray(e,t,n,i){return e?t.map(s=>{if(Ao(s)){const h=e[s.name];return q0.accountsArray(h,s.accounts,n,i).flat()}let o;try{o=Ri(e[s.name])}catch{throw new Error(`Wrong input type for account "${s.name}" in the instruction accounts object${i!==void 0?' for instruction "'+i+'"':""}. Expected PublicKey or string.`)}const a=s.optional&&o.equals(n),u=!!(s.writable&&!a),l=!!(s.signer&&!a);return{pubkey:o,isWritable:u,isSigner:l}}).flat():[]}}function Bre(r,...e){}class Pre{static build(e,t){return(...i)=>{var s,o,a;const[,u]=og(e,[...i]),l=new Tt;if(u.preInstructions&&u.instructions)throw new Error("instructions is deprecated, use preInstructions");return(s=u.preInstructions)===null||s===void 0||s.forEach(h=>l.add(h)),(o=u.instructions)===null||o===void 0||o.forEach(h=>l.add(h)),l.add(t(...i)),(a=u.postInstructions)===null||a===void 0||a.forEach(h=>l.add(h)),l}}}class Mre{static build(e,t,n,i){return async(...o)=>{var a;const u=t(...o),[,l]=og(e,[...o]);if(i.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await i.sendAndConfirm(u,(a=l.signers)!==null&&a!==void 0?a:[],l.options)}catch(h){throw cN(h,n)}}}}class Lre{static build(e,t,n,i){var s;return((s=e.accounts)!==null&&s!==void 0?s:[]).reduce((o,a)=>(o[a.name]=new Ure(e,a,n,i,t),o),{})}}class Ure{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(e,t,n,i,s){this._idlAccount=t,this._programId=n,this._provider=i??dw(),this._coder=s??new uN(e),this._size=this._coder.accounts.size(t.name)}async fetchNullable(e,t){const{data:n}=await this.fetchNullableAndContext(e,t);return n}async fetchNullableAndContext(e,t){const n=await this.getAccountInfoAndContext(e,t),{value:i,context:s}=n;return{data:i&&i.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,i.data):null,context:s}}async fetch(e,t){const{data:n}=await this.fetchNullableAndContext(e,t);if(n===null)throw new Error(`Account does not exist or has no data ${e.toString()}`);return n}async fetchAndContext(e,t){const{data:n,context:i}=await this.fetchNullableAndContext(e,t);if(n===null)throw new Error(`Account does not exist ${e.toString()}`);return{data:n,context:i}}async fetchMultiple(e,t){return(await this.fetchMultipleAndContext(e,t)).map(i=>i?i.data:null)}async fetchMultipleAndContext(e,t){return(await rre(this._provider.connection,e.map(i=>Ri(i)),t)).map(i=>{if(i==null)return null;const{account:s,context:o}=i;return{data:this._coder.accounts.decode(this._idlAccount.name,s.data),context:o}})}async all(e){const t=this.coder.accounts.memcmp(this._idlAccount.name,e instanceof Qe?e:void 0),n=[];return(t==null?void 0:t.offset)!=null&&(t==null?void 0:t.bytes)!=null&&n.push({memcmp:{offset:t.offset,bytes:t.bytes}}),(t==null?void 0:t.dataSize)!=null&&n.push({dataSize:t.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...n,...Array.isArray(e)?e:[]]})).map(({pubkey:s,account:o})=>({publicKey:s,account:this._coder.accounts.decode(this._idlAccount.name,o.data)}))}subscribe(e,t){const n=If.get(e.toString());if(n)return n.ee;const i=new Ute;e=Ri(e);const s=this._provider.connection.onAccountChange(e,o=>{const a=this._coder.accounts.decode(this._idlAccount.name,o.data);i.emit("change",a)},t);return If.set(e.toString(),{ee:i,listener:s}),i}async unsubscribe(e){let t=If.get(e.toString());if(!t){console.warn("Address is not subscribed");return}If&&await this._provider.connection.removeAccountChangeListener(t.listener).then(()=>{If.delete(e.toString())}).catch(console.error)}async createInstruction(e,t){const n=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Nr.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:e.publicKey,space:t??n,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(t??n),programId:this._programId})}async getAccountInfo(e,t){return await this._provider.connection.getAccountInfo(Ri(e),t)}async getAccountInfoAndContext(e,t){return await this._provider.connection.getAccountInfoAndContext(Ri(e),t)}}const If=new Map;class Dre{static build(e,t,n,i,s,o,a){return async(...l)=>{var h;const g=t(...l),[,b]=og(e,[...l]);let w;if(i.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{w=await i.simulate(g,b.signers,(h=b.options)===null||h===void 0?void 0:h.commitment)}catch(x){throw cN(x,n)}if(w===void 0)throw new Error("Unable to simulate transaction");const I=w.logs;if(!I)throw new Error("Simulated logs not found");const S=[];if(a.events){let x=new wN(o,s);for(const C of x.parseLogs(I))S.push(C)}return{events:S,raw:I}}}}function c1(r){return new bN(gd(8),e=>Fre.fromBuffer(e),e=>e.toBuffer(),r)}function Zd(r){return new bN(gd(32),e=>new me(e),e=>e.toBuffer(),r)}function u1(r,e){return new $re(r,e)}class bN extends ng{constructor(e,t,n,i){super(e.span,i),this.layout=e,this.decoder=t,this.encoder=n}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,n){return this.layout.encode(this.encoder(e),t,n)}getSpan(e,t){return this.layout.getSpan(e,t)}}class $re extends ng{constructor(e,t){super(-1,t),this.layout=e,this.discriminator=Vs()}encode(e,t,n=0){return e==null?this.layout.span+this.discriminator.encode(0,t,n):(this.discriminator.encode(1,t,n),this.layout.encode(e,t,n+4)+4)}decode(e,t=0){const n=this.discriminator.decode(e,t);if(n===0)return null;if(n===1)return this.layout.decode(e,t+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(e,t=0){return this.layout.getSpan(e,t+4)+4}}let Fre=class _N extends Gs{toBuffer(){const e=super.toArray().reverse(),t=Qe.from(e);if(t.length===8)return t;if(t.length>=8)throw new Error("u64 too large");const n=Qe.alloc(8);return t.copy(n),n}static fromBuffer(e){if(e.length!==8)throw new Error(`Invalid buffer length: ${e.length}`);return new _N([...e].reverse().map(t=>`00${t.toString(16)}`.slice(-2)).join(""),16)}};const Hre=Cr([Zd("mint"),Zd("owner"),c1("amount"),u1(Zd(),"delegate"),(r=>{const e=yN(xre("discriminator"),null,r);return e.addVariant(0,Cr([]),"uninitialized"),e.addVariant(1,Cr([]),"initialized"),e.addVariant(2,Cr([]),"frozen"),e})("state"),u1(c1(),"isNative"),c1("delegatedAmount"),u1(Zd(),"closeAuthority")]);function zre(r){return Hre.decode(r)}class Gre{constructor(e,t,n,i,s,o,a,u){this._args=e,this._accounts=t,this._provider=n,this._programId=i,this._idlIx=s,this._idlTypes=a,this._customResolver=u,this._accountStore=new Kre(n,o,i)}args(e){this._args=e}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let e=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(e++,e===16){const t=o=>Ao(o)?o.accounts.some(t):!!(o.address||o.pda||o.relations),n=(o,a=[],u=[])=>{for(const l of o)Ao(l)?u.push(...n(l.accounts,[...a,l.name])):u.push([...a,l.name]);return u},i=this._idlIx.accounts.filter(t),s=n(i).filter(o=>!this.get(o)).map(o=>o.reduce((a,u)=>a+"."+u)).map(o=>`\`${o}\``).join(", ");throw new Error(["Reached maximum depth for account resolution.",`Unresolved accounts: ${s}`].join(" "))}}resolveOptionals(e){Object.assign(this._accounts,this.resolveOptionalsHelper(e,this._idlIx.accounts))}get(e){const t=e.reduce((n,i)=>n&&n[i],this._accounts);if(t&&t.toBase58)return t}set(e,t){let n=this._accounts;e.forEach((i,s)=>{var o;s===e.length-1&&(n[i]=t),n[i]=(o=n[i])!==null&&o!==void 0?o:{},n=n[i]})}resolveOptionalsHelper(e,t){const n={};for(const i of t){const s=i.name,o=e[s];o!==void 0&&(AN(o)?Ao(i)?n[s]=this.resolveOptionalsHelper(o,i.accounts):n[s]=vN(o):o!==null?n[s]=Ri(o):i.optional&&(n[s]=this._programId))}return n}async resolveCustom(){if(this._customResolver){const{accounts:e,resolved:t}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=e,t}return 0}resolveEventCpi(e,t=[]){for(const n in e){const i=e[n];Ao(i)&&this.resolveEventCpi(i.accounts,[...t,i.name]);const s=+n+1;if(s===e.length)return;const o=e[n].name,a=e[s].name;if(o==="eventAuthority"&&a==="program"){const u=[...t,o],l=[...t,a];this.get(u)||this.set(u,me.findProgramAddressSync([Qe.from("__event_authority")],this._programId)[0]),this.get(l)||this.set(l,this._programId);return}}}resolveConst(e,t=[]){for(const n of e){const i=n.name;if(Ao(n))this.resolveConst(n.accounts,[...t,i]);else{const s=n;if((s.signer||s.address)&&!this.get([...t,i])){if(s.signer){if(!this._provider.wallet)throw new Error("This function requires the `Provider` interface implementor to have a `wallet` field.");this.set([...t,i],this._provider.wallet.publicKey)}s.address&&this.set([...t,i],Ri(s.address))}}}}async resolvePdasAndRelations(e,t=[]){let n=0;for(const i of e){const s=i.name;if(Ao(i))n+=await this.resolvePdasAndRelations(i.accounts,[...t,s]);else{const o=i;if((o.pda||o.relations)&&!this.get([...t,s])){n++;try{if(o.pda){const a=await Promise.all(o.pda.seeds.map(h=>this.toBuffer(h,t)));if(a.some(h=>!h))continue;const u=await this.parseProgramId(o,t),[l]=me.findProgramAddressSync(a,u);this.set([...t,s],l)}}catch{}try{if(o.relations){const a=this.get([...t,o.relations[0]]);if(a){const u=await this._accountStore.fetchAccount({publicKey:a});this.set([...t,s],u[s])}}}catch{}}}}return n}async parseProgramId(e,t=[]){var n;if(!(!((n=e.pda)===null||n===void 0)&&n.program))return this._programId;const i=await this.toBuffer(e.pda.program,t);if(!i)throw new Error(`Program seed not resolved: ${e.name}`);return new me(i)}async toBuffer(e,t=[]){switch(e.kind){case"const":return this.toBufferConst(e);case"arg":return await this.toBufferArg(e);case"account":return await this.toBufferAccount(e,t);default:throw new Error(`Unexpected seed: ${e}`)}}toBufferConst(e){return this.toBufferValue("bytes",e.value)}async toBufferArg(e){const[t,...n]=e.path.split("."),i=this._idlIx.args.findIndex(a=>a.name===t);if(i===-1)throw new Error(`Unable to find argument for seed: ${t}`);const s=n.reduce((a,u)=>(a??{})[u],this._args[i]);if(s===void 0)return;const o=this.getType(this._idlIx.args[i].type,n);return this.toBufferValue(o,s)}async toBufferAccount(e,t=[]){const[n,...i]=e.path.split("."),s=this.get([...t,n]);if(!s)return;if(!i.length)return this.toBufferValue("pubkey",s);if(!e.account)throw new Error(`Seed account is required in order to resolve type: ${e.path}`);let a=await this._accountStore.fetchAccount({publicKey:s,name:e.account}),u=i;for(;u.length>0;)a=a[u[0]],u=u.slice(1);if(a===void 0)return;const l=this.getType({defined:{name:e.account}},i);return this.toBufferValue(l,a)}toBufferValue(e,t){switch(e){case"u8":case"i8":return Qe.from([t]);case"u16":case"i16":return new Gs(t).toArrayLike(Qe,"le",2);case"u32":case"i32":return new Gs(t).toArrayLike(Qe,"le",4);case"u64":case"i64":return new Gs(t).toArrayLike(Qe,"le",8);case"u128":case"i128":return new Gs(t).toArrayLike(Qe,"le",16);case"u256":case"i256":return new Gs(t).toArrayLike(Qe,"le",32);case"string":return Qe.from(t);case"pubkey":return t.toBuffer();case"bytes":return Qe.from(t);default:if(e!=null&&e.array)return Qe.from(t);throw new Error(`Unexpected seed type: ${e}`)}}getType(e,t=[]){var n;const i=(n=e==null?void 0:e.defined)===null||n===void 0?void 0:n.name;if(i){if(i==="tokenAccount")switch(t.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw new Error(`Unknown token account path: ${t}`)}const s=this._idlTypes.find(h=>h.name===i);if(!s)throw new Error(`Type not found: ${i}`);const[o,...a]=t,l=s.type.fields.find(h=>h.name===o);if(!l)throw new Error(`Field not found: ${o}`);return this.getType(l.type,a)}return e}}class Kre{constructor(e,t,n){this._provider=e,this._cache=new Map,this._idls={},this._idls[n.toBase58()]=t}async fetchAccount({publicKey:e,name:t}){const n=e.toBase58();if(!this._cache.has(n)){const i=await this._provider.connection.getAccountInfo(e);if(i===null)throw new Error(`Account not found: ${n}`);if(t==="tokenAccount"){const s=zre(i.data);this._cache.set(n,s)}else{const s=await this.getAccountsNs(i.owner);if(s){const o=Object.values(s)[0];if(o){const a=o.coder.accounts.decodeAny(i.data);this._cache.set(n,a)}}}}return this._cache.get(n)}async getAccountsNs(e){const t=e.toBase58();if(!this._idls[t]){const n=await bl.fetchIdl(e,this._provider);if(n){const i=new bl(n,this._provider);this._idls[t]=i.account}}return this._idls[t]}}class jre{static build(e,t,n,i,s,o,a,u,l,h,g){return(...b)=>new Wre(b,i,s,o,a,u,e,t,n,l,h,g)}}function AN(r){return typeof r=="object"&&r!==null&&!("_bn"in r)}function vN(r,e){const t={};for(const n in r){const i=r[n];if(i===null)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");t[n]=AN(i)?vN(i):Ri(i)}return t}class Wre{constructor(e,t,n,i,s,o,a,u,l,h,g,b){this._args=e,this._ixFn=t,this._txFn=n,this._rpcFn=i,this._simulateFn=s,this._viewFn=o,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._resolveAccounts=!0,this._accountsResolver=new Gre(e,this._accounts,a,u,l,h,g,b)}args(e){this._args=e,this._accountsResolver.args(e)}accounts(e){return this.accountsPartial(e)}accountsPartial(e){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(e),this}accountsStrict(e){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(e),this}signers(e){return this._signers=this._signers.concat(e),this}remainingAccounts(e){return this._remainingAccounts=this._remainingAccounts.concat(e),this}preInstructions(e,t=!1){return t?this._preInstructions=e.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(e),this}postInstructions(e){return this._postInstructions=this._postInstructions.concat(e),this}async pubkeys(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._accounts}async instruction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async transaction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async simulate(e){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async view(e){if(this._resolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error(["Method does not support views.","The instruction should return a value, and its accounts must be read-only"].join(" "));return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async rpc(e){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async rpcAndKeys(e){return{signature:await this.rpc(e),pubkeys:await this.pubkeys()}}async prepare(){return{instruction:await this.instruction(),signers:this._signers,pubkeys:await this.pubkeys()}}}class Vre{static build(e,t,n,i){const s=t.accounts.find(u=>u.writable),o=!!t.returns;return s||!o?void 0:async(...u)=>{let l=await n(...u);const h=`Program return: ${e} `;let g=l.raw.find(S=>S.startsWith(h));if(!g)throw new Error("View expected return log");let b=BT(g.slice(h.length)),w=t.returns;if(!w)throw new Error("View expected return type");return dt.fieldLayout({type:w},i.types).decode(b)}}}class qre{static build(e,t,n,i,s){const o={},a={},u={},l={},h={},g={},b=jte(e),w=e.accounts?Lre.build(e,t,n,i):{};return e.instructions.forEach(I=>{const S=q0.build(I,(Z,K)=>t.instruction.encode(Z,K),n),x=Pre.build(I,S),C=Mre.build(I,x,b,i),H=Dre.build(I,x,b,i,t,n,e),D=Vre.build(n,I,H,e),z=jre.build(i,n,I,S,x,C,H,D,w,e.types||[],s==null?void 0:s(I)),V=I.name;a[V]=S,u[V]=x,o[V]=C,l[V]=H,h[V]=z,D&&(g[V]=D)}),[o,a,u,w,l,h,g]}}class bl{get programId(){return this._programId}get idl(){return this._idl}get rawIdl(){return this._rawIdl}get coder(){return this._coder}get provider(){return this._provider}constructor(e,t=dw(),n,i){this._idl=Kte(e),this._rawIdl=e,this._provider=t,this._programId=Ri(e.address),this._coder=n??new uN(this._idl),this._events=new Ore(this._programId,t,this._coder);const[s,o,a,u,l,h,g]=qre.build(this._idl,this._coder,this._programId,t,i);this.rpc=s,this.instruction=o,this.transaction=a,this.account=u,this.simulate=l,this.methods=h,this.views=g}static async at(e,t){const n=Ri(e),i=await bl.fetchIdl(n,t);if(!i)throw new Error(`IDL not found for program: ${e.toString()}`);return new bl(i,t)}static async fetchIdl(e,t){t=t??dw();const n=Ri(e),i=await Fte(n),s=await t.connection.getAccountInfo(i);if(!s)return null;let o=Gte(s.data.slice(8));const a=Mte(o.data);return JSON.parse($te(a))}addEventListener(e,t,n){return this._events.addEventListener(e,t,n)}async removeEventListener(e){return await this._events.removeEventListener(e)}}new me("11111111111111111111111111111111");const Zre="6.13.5";function Qre(r,e,t){const n=e.split("|").map(s=>s.trim());for(let s=0;s<n.length;s++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof r===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${t}`,i.value=r,i}async function dn(r){const e=Object.keys(r);return(await Promise.all(e.map(n=>Promise.resolve(r[n])))).reduce((n,i,s)=>(n[e[s]]=i,n),{})}function ze(r,e,t){for(let n in e){let i=e[n];const s=t?t[n]:null;s&&Qre(i,s,n),Object.defineProperty(r,n,{enumerable:!0,value:i,writable:!1})}}function su(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(su).join(", ")+" ]";if(r instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let n=0;n<r.length;n++)t+=e[r[n]>>4],t+=e[r[n]&15];return t}if(typeof r=="object"&&typeof r.toJSON=="function")return su(r.toJSON());switch(typeof r){case"boolean":case"symbol":return r.toString();case"bigint":return BigInt(r).toString();case"number":return r.toString();case"string":return JSON.stringify(r);case"object":{const e=Object.keys(r);return e.sort(),"{ "+e.map(t=>`${su(t)}: ${su(r[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Zr(r,e){return r&&r.code===e}function m_(r){return Zr(r,"CALL_EXCEPTION")}function Zt(r,e,t){let n=r;{const s=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${su(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];s.push(o+"="+su(a))}}s.push(`code=${e}`),s.push(`version=${Zre}`),s.length&&(r+=" ("+s.join(", ")+")")}let i;switch(e){case"INVALID_ARGUMENT":i=new TypeError(r);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(r);break;default:i=new Error(r)}return ze(i,{code:e}),t&&Object.assign(i,t),i.shortMessage==null&&ze(i,{shortMessage:n}),i}function pe(r,e,t,n){if(!r)throw Zt(e,t,n)}function q(r,e,t,n){pe(r,e,"INVALID_ARGUMENT",{argument:t,value:n})}function EN(r,e,t){t==null&&(t=""),t&&(t=": "+t),pe(r>=e,"missing argument"+t,"MISSING_ARGUMENT",{count:r,expectedCount:e}),pe(r<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:r,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((r,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");r.push(e)}catch{}return r},[]);function ag(r,e,t){if(t==null&&(t=""),r!==e){let n=t,i="new";t&&(n+=".",i+=" "+t),pe(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function xN(r,e,t){if(r instanceof Uint8Array)return t?new Uint8Array(r):r;if(typeof r=="string"&&r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const n=new Uint8Array((r.length-2)/2);let i=2;for(let s=0;s<n.length;s++)n[s]=parseInt(r.substring(i,i+2),16),i+=2;return n}q(!1,"invalid BytesLike value",e||"value",r)}function wt(r,e){return xN(r,e,!1)}function pn(r,e){return xN(r,e,!0)}function zt(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&r.length!==2+2*e||e===!0&&r.length%2!==0)}function w_(r){return zt(r,!0)||r instanceof Uint8Array}const wx="0123456789abcdef";function Ce(r){const e=wt(r);let t="0x";for(let n=0;n<e.length;n++){const i=e[n];t+=wx[(i&240)>>4]+wx[i&15]}return t}function Ir(r){return"0x"+r.map(e=>Ce(e).substring(2)).join("")}function yu(r){return zt(r,!0)?(r.length-2)/2:wt(r).length}function _r(r,e,t){const n=wt(r);return t!=null&&t>n.length&&pe(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:t}),Ce(n.slice(e??0,t??n.length))}function RN(r,e,t){const n=wt(r);pe(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),t?i.set(n,e-n.length):i.set(n,0),Ce(i)}function wc(r,e){return RN(r,e,!0)}function Jre(r,e){return RN(r,e,!1)}const cg=BigInt(0),Ei=BigInt(1),ou=9007199254740991;function Yre(r,e){const t=ug(r,"value"),n=BigInt(ct(e,"width"));if(pe(t>>n===cg,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),t>>n-Ei){const i=(Ei<<n)-Ei;return-((~t&i)+Ei)}return t}function IN(r,e){let t=Me(r,"value");const n=BigInt(ct(e,"width")),i=Ei<<n-Ei;if(t<cg){t=-t,pe(t<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});const s=(Ei<<n)-Ei;return(~t&s)+Ei}else pe(t<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});return t}function Pf(r,e){const t=ug(r,"value"),n=BigInt(ct(e,"bits"));return t&(Ei<<n)-Ei}function Me(r,e){switch(typeof r){case"bigint":return r;case"number":return q(Number.isInteger(r),"underflow",e||"value",r),q(r>=-ou&&r<=ou,"overflow",e||"value",r),BigInt(r);case"string":try{if(r==="")throw new Error("empty string");return r[0]==="-"&&r[1]!=="-"?-BigInt(r.substring(1)):BigInt(r)}catch(t){q(!1,`invalid BigNumberish string: ${t.message}`,e||"value",r)}}q(!1,"invalid BigNumberish value",e||"value",r)}function ug(r,e){const t=Me(r,e);return pe(t>=cg,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),t}const bx="0123456789abcdef";function b_(r){if(r instanceof Uint8Array){let e="0x0";for(const t of r)e+=bx[t>>4],e+=bx[t&15];return BigInt(e)}return Me(r)}function ct(r,e){switch(typeof r){case"bigint":return q(r>=-ou&&r<=ou,"overflow",e||"value",r),Number(r);case"number":return q(Number.isInteger(r),"underflow",e||"value",r),q(r>=-ou&&r<=ou,"overflow",e||"value",r),r;case"string":try{if(r==="")throw new Error("empty string");return ct(BigInt(r),e)}catch(t){q(!1,`invalid numeric string: ${t.message}`,e||"value",r)}}q(!1,"invalid numeric value",e||"value",r)}function Xre(r){return ct(b_(r))}function sa(r,e){let n=ug(r,"value").toString(16);if(e==null)n.length%2&&(n="0"+n);else{const i=ct(e,"width");for(pe(i*2>=n.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:r});n.length<i*2;)n="0"+n}return"0x"+n}function mn(r){const e=ug(r,"value");if(e===cg)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const n=new Uint8Array(t.length/2);for(let i=0;i<n.length;i++){const s=i*2;n[i]=parseInt(t.substring(s,s+2),16)}return n}function au(r){let e=Ce(w_(r)?r:mn(r)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const _x="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const Ax=BigInt(58);function ene(r){const e=wt(r);let t=b_(e),n="";for(;t;)n=_x[Number(t%Ax)]+n,t/=Ax;for(let i=0;i<e.length&&!e[i];i++)n=_x[0]+n;return n}function tne(r){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return wt(e)}function rne(r){const e=wt(r);let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var _u;class SN{constructor(e,t,n){Q(this,"filter");Q(this,"emitter");se(this,_u);F(this,_u,t),ze(this,{emitter:e,filter:n})}async removeListener(){T(this,_u)!=null&&await this.emitter.off(this.filter,T(this,_u))}}_u=new WeakMap;function nne(r,e,t,n,i){q(!1,`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function kN(r,e,t,n,i){if(r==="BAD_PREFIX"||r==="UNEXPECTED_CONTINUE"){let s=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)s++;return s}return r==="OVERRUN"?t.length-e-1:0}function ine(r,e,t,n,i){return r==="OVERLONG"?(q(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),kN(r,e,t))}const sne=Object.freeze({error:nne,ignore:kN,replace:ine});function one(r,e){e==null&&(e=sne.error);const t=wt(r,"bytes"),n=[];let i=0;for(;i<t.length;){const s=t[i++];if(!(s>>7)){n.push(s);continue}let o=null,a=null;if((s&224)===192)o=1,a=127;else if((s&240)===224)o=2,a=2047;else if((s&248)===240)o=3,a=65535;else{(s&192)===128?i+=e("UNEXPECTED_CONTINUE",i-1,t,n):i+=e("BAD_PREFIX",i-1,t,n);continue}if(i-1+o>=t.length){i+=e("OVERRUN",i-1,t,n);continue}let u=s&(1<<8-o-1)-1;for(let l=0;l<o;l++){let h=t[i];if((h&192)!=128){i+=e("MISSING_CONTINUE",i,t,n),u=null;break}u=u<<6|h&63,i++}if(u!==null){if(u>1114111){i+=e("OUT_OF_RANGE",i-1-o,t,n,u);continue}if(u>=55296&&u<=57343){i+=e("UTF16_SURROGATE",i-1-o,t,n,u);continue}if(u<=a){i+=e("OVERLONG",i-1-o,t,n,u);continue}n.push(u)}}return n}function Js(r,e){q(typeof r=="string","invalid string value","str",r);let t=[];for(let n=0;n<r.length;n++){const i=r.charCodeAt(n);if(i<128)t.push(i);else if(i<2048)t.push(i>>6|192),t.push(i&63|128);else if((i&64512)==55296){n++;const s=r.charCodeAt(n);q(n<r.length&&(s&64512)===56320,"invalid surrogate pair","str",r);const o=65536+((i&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(i>>12|224),t.push(i>>6&63|128),t.push(i&63|128)}return new Uint8Array(t)}function ane(r){return r.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Z0(r,e){return ane(one(r,e))}function TN(r){async function e(t,n){pe(n==null||!n.cancelled,"request cancelled before sending","CANCELLED");const i=t.url.split(":")[0].toLowerCase();pe(i==="http"||i==="https",`unsupported protocol ${i}`,"UNSUPPORTED_OPERATION",{info:{protocol:i},operation:"request"}),pe(i==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let s=null;const o=new AbortController,a=setTimeout(()=>{s=Zt("request timeout","TIMEOUT"),o.abort()},t.timeout);n&&n.addListener(()=>{s=Zt("request cancelled","CANCELLED"),o.abort()});const u={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let l;try{l=await fetch(t.url,u)}catch(w){throw clearTimeout(a),s||w}clearTimeout(a);const h={};l.headers.forEach((w,I)=>{h[I.toLowerCase()]=w});const g=await l.arrayBuffer(),b=g==null?null:new Uint8Array(g);return{statusCode:l.status,statusMessage:l.statusText,headers:h,body:b}}return e}const cne=12,une=250;let vx=TN();const lne=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),fne=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let l1=!1;async function ON(r,e){try{const t=r.match(lne);if(!t)throw new Error("invalid data");return new Yo(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?tne(t[3]):dne(t[3]))}catch{return new Yo(599,"BAD REQUEST (invalid data: URI)",{},null,new to(r))}}function NN(r){async function e(t,n){try{const i=t.match(fne);if(!i)throw new Error("invalid link");return new to(`${r}${i[2]}`)}catch{return new Yo(599,"BAD REQUEST (invalid IPFS URI)",{},null,new to(t))}}return e}const Qd={data:ON,ipfs:NN("https://gateway.ipfs.io/ipfs/")},CN=new WeakMap;var Pa,Eo;class hne{constructor(e){se(this,Pa);se(this,Eo);F(this,Pa,[]),F(this,Eo,!1),CN.set(e,()=>{if(!T(this,Eo)){F(this,Eo,!0);for(const t of T(this,Pa))setTimeout(()=>{t()},0);F(this,Pa,[])}})}addListener(e){pe(!T(this,Eo),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,Pa).push(e)}get cancelled(){return T(this,Eo)}checkSignal(){pe(!this.cancelled,"cancelled","CANCELLED",{})}}Pa=new WeakMap,Eo=new WeakMap;function Jd(r){if(r==null)throw new Error("missing signal; should not happen");return r.checkSignal(),r}var Au,vu,wi,Ns,Eu,xu,Mr,Hn,Cs,Ma,La,Ua,Fi,bi,xo,Da,Mf;const cp=class cp{constructor(e){se(this,Da);se(this,Au);se(this,vu);se(this,wi);se(this,Ns);se(this,Eu);se(this,xu);se(this,Mr);se(this,Hn);se(this,Cs);se(this,Ma);se(this,La);se(this,Ua);se(this,Fi);se(this,bi);se(this,xo);F(this,xu,String(e)),F(this,Au,!1),F(this,vu,!0),F(this,wi,{}),F(this,Ns,""),F(this,Eu,3e5),F(this,bi,{slotInterval:une,maxAttempts:cne}),F(this,xo,null)}get url(){return T(this,xu)}set url(e){F(this,xu,String(e))}get body(){return T(this,Mr)==null?null:new Uint8Array(T(this,Mr))}set body(e){if(e==null)F(this,Mr,void 0),F(this,Hn,void 0);else if(typeof e=="string")F(this,Mr,Js(e)),F(this,Hn,"text/plain");else if(e instanceof Uint8Array)F(this,Mr,e),F(this,Hn,"application/octet-stream");else if(typeof e=="object")F(this,Mr,Js(JSON.stringify(e))),F(this,Hn,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,Mr)!=null}get method(){return T(this,Ns)?T(this,Ns):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),F(this,Ns,String(e).toUpperCase())}get headers(){const e=Object.assign({},T(this,wi));return T(this,Cs)&&(e.authorization=`Basic ${rne(Js(T(this,Cs)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&T(this,Hn)&&(e["content-type"]=T(this,Hn)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){T(this,wi)[String(e).toLowerCase()]=String(t)}clearHeaders(){F(this,wi,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const i=t[n++];return{value:[i,e[i]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,Cs)||null}setCredentials(e,t){q(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),F(this,Cs,`${e}:${t}`)}get allowGzip(){return T(this,vu)}set allowGzip(e){F(this,vu,!!e)}get allowInsecureAuthentication(){return!!T(this,Au)}set allowInsecureAuthentication(e){F(this,Au,!!e)}get timeout(){return T(this,Eu)}set timeout(e){q(e>=0,"timeout must be non-zero","timeout",e),F(this,Eu,e)}get preflightFunc(){return T(this,Ma)||null}set preflightFunc(e){F(this,Ma,e)}get processFunc(){return T(this,La)||null}set processFunc(e){F(this,La,e)}get retryFunc(){return T(this,Ua)||null}set retryFunc(e){F(this,Ua,e)}get getUrlFunc(){return T(this,xo)||vx}set getUrlFunc(e){F(this,xo,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,Mr)?Ce(T(this,Mr)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(T(this,bi).slotInterval=e.slotInterval),e.maxAttempts!=null&&(T(this,bi).maxAttempts=e.maxAttempts)}send(){return pe(T(this,Fi)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),F(this,Fi,new hne(this)),Ee(this,Da,Mf).call(this,0,Ex()+this.timeout,0,this,new Yo(0,"",{},null,this))}cancel(){pe(T(this,Fi)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=CN.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();pe(this.method==="GET"&&(t!=="https"||n!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const i=new cp(e);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,F(i,wi,Object.assign({},T(this,wi))),T(this,Mr)&&F(i,Mr,new Uint8Array(T(this,Mr))),F(i,Hn,T(this,Hn)),i}clone(){const e=new cp(this.url);return F(e,Ns,T(this,Ns)),T(this,Mr)&&F(e,Mr,T(this,Mr)),F(e,Hn,T(this,Hn)),F(e,wi,Object.assign({},T(this,wi))),F(e,Cs,T(this,Cs)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),F(e,Ma,T(this,Ma)),F(e,La,T(this,La)),F(e,Ua,T(this,Ua)),F(e,bi,Object.assign({},T(this,bi))),F(e,xo,T(this,xo)),e}static lockConfig(){l1=!0}static getGateway(e){return Qd[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(l1)throw new Error("gateways locked");Qd[e]=t}static registerGetUrl(e){if(l1)throw new Error("gateways locked");vx=e}static createGetUrlFunc(e){return TN()}static createDataGateway(){return ON}static createIpfsGatewayFunc(e){return NN(e)}};Au=new WeakMap,vu=new WeakMap,wi=new WeakMap,Ns=new WeakMap,Eu=new WeakMap,xu=new WeakMap,Mr=new WeakMap,Hn=new WeakMap,Cs=new WeakMap,Ma=new WeakMap,La=new WeakMap,Ua=new WeakMap,Fi=new WeakMap,bi=new WeakMap,xo=new WeakMap,Da=new WeakSet,Mf=async function(e,t,n,i,s){var h,g,b;if(e>=T(this,bi).maxAttempts)return s.makeServerError("exceeded maximum retry limit");pe(Ex()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),n>0&&await pne(n);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Qd){const w=await Qd[a](o.url,Jd(T(i,Fi)));if(w instanceof Yo){let I=w;if(this.processFunc){Jd(T(i,Fi));try{I=await this.processFunc(o,I)}catch(S){(S.throttle==null||typeof S.stall!="number")&&I.makeServerError("error in post-processing function",S).assertOk()}}return I}o=w}this.preflightFunc&&(o=await this.preflightFunc(o));const u=await this.getUrlFunc(o,Jd(T(i,Fi)));let l=new Yo(u.statusCode,u.statusMessage,u.headers,u.body,i);if(l.statusCode===301||l.statusCode===302){try{const w=l.headers.location||"";return Ee(h=o.redirect(w),Da,Mf).call(h,e+1,t,0,i,l)}catch{}return l}else if(l.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,l,e))){const w=l.headers["retry-after"];let I=T(this,bi).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof w=="string"&&w.match(/^[1-9][0-9]*$/)&&(I=parseInt(w)),Ee(g=o.clone(),Da,Mf).call(g,e+1,t,I,i,l)}if(this.processFunc){Jd(T(i,Fi));try{l=await this.processFunc(o,l)}catch(w){(w.throttle==null||typeof w.stall!="number")&&l.makeServerError("error in post-processing function",w).assertOk();let I=T(this,bi).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return w.stall>=0&&(I=w.stall),Ee(b=o.clone(),Da,Mf).call(b,e+1,t,I,i,l)}}return l};let to=cp;var Ch,Bh,Ph,zn,Ru,$a;const H_=class H_{constructor(e,t,n,i,s){se(this,Ch);se(this,Bh);se(this,Ph);se(this,zn);se(this,Ru);se(this,$a);F(this,Ch,e),F(this,Bh,t),F(this,Ph,Object.keys(n).reduce((o,a)=>(o[a.toLowerCase()]=String(n[a]),o),{})),F(this,zn,i==null?null:new Uint8Array(i)),F(this,Ru,s||null),F(this,$a,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,zn)?Ce(T(this,zn)):"null"}>`}get statusCode(){return T(this,Ch)}get statusMessage(){return T(this,Bh)}get headers(){return Object.assign({},T(this,Ph))}get body(){return T(this,zn)==null?null:new Uint8Array(T(this,zn))}get bodyText(){try{return T(this,zn)==null?"":Z0(T(this,zn))}catch{pe(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{pe(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const i=t[n++];return{value:[i,e[i]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let n;e?n=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,n=`CLIENT ESCALATED SERVER ERROR (${e})`);const i=new H_(599,n,this.headers,this.body,T(this,Ru)||void 0);return F(i,$a,{message:e,error:t}),i}throwThrottleError(e,t){t==null?t=-1:q(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const n=new Error(e||"throttling requests");throw ze(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return T(this,zn)!=null}get request(){return T(this,Ru)}ok(){return T(this,$a).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=T(this,$a);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let i=null;try{T(this,zn)&&(i=Z0(T(this,zn)))}catch{}pe(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:n,responseBody:i,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};Ch=new WeakMap,Bh=new WeakMap,Ph=new WeakMap,zn=new WeakMap,Ru=new WeakMap,$a=new WeakMap;let Yo=H_;function Ex(){return new Date().getTime()}function dne(r){return Js(r.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function pne(r){return new Promise(e=>setTimeout(e,r))}function gne(r){let e=r.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function xx(r,e,t){let n=0;for(let i=0;i<t;i++)n=n*256+r[e+i];return n}function Rx(r,e,t,n){const i=[];for(;t<e+1+n;){const s=BN(r,t);i.push(s.result),t+=s.consumed,pe(t<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:r,length:n,offset:e})}return{consumed:1+n,result:i}}function BN(r,e){pe(r.length!==0,"data too short","BUFFER_OVERRUN",{buffer:r,length:0,offset:1});const t=n=>{pe(n<=r.length,"data short segment too short","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n})};if(r[e]>=248){const n=r[e]-247;t(e+1+n);const i=xx(r,e+1,n);return t(e+1+n+i),Rx(r,e,e+1+n,n+i)}else if(r[e]>=192){const n=r[e]-192;return t(e+1+n),Rx(r,e,e+1,n)}else if(r[e]>=184){const n=r[e]-183;t(e+1+n);const i=xx(r,e+1,n);t(e+1+n+i);const s=Ce(r.slice(e+1+n,e+1+n+i));return{consumed:1+n+i,result:s}}else if(r[e]>=128){const n=r[e]-128;t(e+1+n);const i=Ce(r.slice(e+1,e+1+n));return{consumed:1+n,result:i}}return{consumed:1,result:gne(r[e])}}function lg(r){const e=wt(r,"data"),t=BN(e,0);return q(t.consumed===e.length,"unexpected junk after rlp payload","data",r),t.result}function Ix(r){const e=[];for(;r;)e.unshift(r&255),r>>=8;return e}function PN(r){if(Array.isArray(r)){let n=[];if(r.forEach(function(s){n=n.concat(PN(s))}),n.length<=55)return n.unshift(192+n.length),n;const i=Ix(n.length);return i.unshift(247+i.length),i.concat(n)}const e=Array.prototype.slice.call(wt(r,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=Ix(e.length);return t.unshift(183+t.length),t.concat(e)}const Sx="0123456789abcdef";function bc(r){let e="0x";for(const t of PN(r))e+=Sx[t>>4],e+=Sx[t&15];return e}const wn=32,yw=new Uint8Array(wn),yne=["then"],Yd={},MN=new WeakMap;function Aa(r){return MN.get(r)}function kx(r,e){MN.set(r,e)}function Sf(r,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw t.error=e,t}function mw(r,e,t){return r.indexOf(null)>=0?e.map((n,i)=>n instanceof _l?mw(Aa(n),n,t):n):r.reduce((n,i,s)=>{let o=e.getValue(i);return i in n||(t&&o instanceof _l&&(o=mw(Aa(o),o,t)),n[i]=o),n},{})}var Iu;const cu=class cu extends Array{constructor(...t){const n=t[0];let i=t[1],s=(t[2]||[]).slice(),o=!0;n!==Yd&&(i=t,s=[],o=!1);super(i.length);se(this,Iu);i.forEach((l,h)=>{this[h]=l});const a=s.reduce((l,h)=>(typeof h=="string"&&l.set(h,(l.get(h)||0)+1),l),new Map);if(kx(this,Object.freeze(i.map((l,h)=>{const g=s[h];return g!=null&&a.get(g)===1?g:null}))),F(this,Iu,[]),T(this,Iu)==null&&T(this,Iu),!o)return;Object.freeze(this);const u=new Proxy(this,{get:(l,h,g)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const w=ct(h,"%index");if(w<0||w>=this.length)throw new RangeError("out of result range");const I=l[w];return I instanceof Error&&Sf(`index ${w}`,I),I}if(yne.indexOf(h)>=0)return Reflect.get(l,h,g);const b=l[h];if(b instanceof Function)return function(...w){return b.apply(this===g?l:this,w)};if(!(h in l))return l.getValue.apply(this===g?l:this,[h])}return Reflect.get(l,h,g)}});return kx(u,Aa(this)),u}toArray(t){const n=[];return this.forEach((i,s)=>{i instanceof Error&&Sf(`index ${s}`,i),t&&i instanceof cu&&(i=i.toArray(t)),n.push(i)}),n}toObject(t){const n=Aa(this);return n.reduce((i,s,o)=>(pe(s!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),mw(n,this,t)),{})}slice(t,n){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),n==null&&(n=this.length),n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);const i=Aa(this),s=[],o=[];for(let a=t;a<n;a++)s.push(this[a]),o.push(i[a]);return new cu(Yd,s,o)}filter(t,n){const i=Aa(this),s=[],o=[];for(let a=0;a<this.length;a++){const u=this[a];u instanceof Error&&Sf(`index ${a}`,u),t.call(n,u,a,this)&&(s.push(u),o.push(i[a]))}return new cu(Yd,s,o)}map(t,n){const i=[];for(let s=0;s<this.length;s++){const o=this[s];o instanceof Error&&Sf(`index ${s}`,o),i.push(t.call(n,o,s,this))}return i}getValue(t){const n=Aa(this).indexOf(t);if(n===-1)return;const i=this[n];return i instanceof Error&&Sf(`property ${JSON.stringify(t)}`,i.error),i}static fromItems(t,n){return new cu(Yd,t,n)}};Iu=new WeakMap;let _l=cu;function Tx(r){let e=mn(r);return pe(e.length<=wn,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:wn,offset:e.length}),e.length!==wn&&(e=pn(Ir([yw.slice(e.length%wn),e]))),e}class so{constructor(e,t,n,i){Q(this,"name");Q(this,"type");Q(this,"localName");Q(this,"dynamic");ze(this,{name:e,type:t,localName:n,dynamic:i},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){q(!1,e,this.localName,t)}}var Bs,Fa,Su,f0;class ww{constructor(){se(this,Su);se(this,Bs);se(this,Fa);F(this,Bs,[]),F(this,Fa,0)}get data(){return Ir(T(this,Bs))}get length(){return T(this,Fa)}appendWriter(e){return Ee(this,Su,f0).call(this,pn(e.data))}writeBytes(e){let t=pn(e);const n=t.length%wn;return n&&(t=pn(Ir([t,yw.slice(n)]))),Ee(this,Su,f0).call(this,t)}writeValue(e){return Ee(this,Su,f0).call(this,Tx(e))}writeUpdatableValue(){const e=T(this,Bs).length;return T(this,Bs).push(yw),F(this,Fa,T(this,Fa)+wn),t=>{T(this,Bs)[e]=Tx(t)}}}Bs=new WeakMap,Fa=new WeakMap,Su=new WeakSet,f0=function(e){return T(this,Bs).push(e),F(this,Fa,T(this,Fa)+e.length),e.length};var xn,Gn,Ha,za,Ro,xc,_w,LN;const z_=class z_{constructor(e,t,n){se(this,xc);Q(this,"allowLoose");se(this,xn);se(this,Gn);se(this,Ha);se(this,za);se(this,Ro);ze(this,{allowLoose:!!t}),F(this,xn,pn(e)),F(this,Ha,0),F(this,za,null),F(this,Ro,n??1024),F(this,Gn,0)}get data(){return Ce(T(this,xn))}get dataLength(){return T(this,xn).length}get consumed(){return T(this,Gn)}get bytes(){return new Uint8Array(T(this,xn))}subReader(e){const t=new z_(T(this,xn).slice(T(this,Gn)+e),this.allowLoose,T(this,Ro));return F(t,za,this),t}readBytes(e,t){let n=Ee(this,xc,LN).call(this,0,e,!!t);return Ee(this,xc,_w).call(this,e),F(this,Gn,T(this,Gn)+n.length),n.slice(0,e)}readValue(){return b_(this.readBytes(wn))}readIndex(){return Xre(this.readBytes(wn))}};xn=new WeakMap,Gn=new WeakMap,Ha=new WeakMap,za=new WeakMap,Ro=new WeakMap,xc=new WeakSet,_w=function(e){var t;if(T(this,za))return Ee(t=T(this,za),xc,_w).call(t,e);F(this,Ha,T(this,Ha)+e),pe(T(this,Ro)<1||T(this,Ha)<=T(this,Ro)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,Ro)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:pn(T(this,xn)),offset:T(this,Gn),length:e,info:{bytesRead:T(this,Ha),dataLength:this.dataLength}})},LN=function(e,t,n){let i=Math.ceil(t/wn)*wn;return T(this,Gn)+i>T(this,xn).length&&(this.allowLoose&&n&&T(this,Gn)+t<=T(this,xn).length?i=t:pe(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:pn(T(this,xn)),length:T(this,xn).length,offset:T(this,Gn)+i})),T(this,xn).slice(T(this,Gn),T(this,Gn)+i)};let bw=z_;function Q0(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function __(r,...e){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function mne(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Q0(r.outputLen),Q0(r.blockLen)}function Al(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function UN(r,e){__(r);const t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const f1=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const DN=r=>r instanceof Uint8Array,wne=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),h1=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),$i=(r,e)=>r<<32-e|r>>>e,bne=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!bne)throw new Error("Non little-endian hardware is not supported");function _ne(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function fg(r){if(typeof r=="string"&&(r=_ne(r)),!DN(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Ane(...r){const e=new Uint8Array(r.reduce((n,i)=>n+i.length,0));let t=0;return r.forEach(n=>{if(!DN(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class A_{clone(){return this._cloneInto()}}function v_(r){const e=n=>r().update(fg(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function vne(r=32){if(f1&&typeof f1.getRandomValues=="function")return f1.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}class $N extends A_{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,mne(e);const n=fg(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Al(this),this.iHash.update(e),this}digestInto(e){Al(this),__(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const FN=(r,e,t)=>new $N(r,e).update(t).digest();FN.create=(r,e)=>new $N(r,e);function Ene(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),a=Number(t&s),u=n?4:0,l=n?0:4;r.setUint32(e+u,o,n),r.setUint32(e+l,a,n)}class HN extends A_{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=h1(this.buffer)}update(e){Al(this);const{view:t,buffer:n,blockLen:i}=this;e=fg(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=h1(e);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Al(this),UN(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let g=o;g<i;g++)t[g]=0;Ene(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=h1(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<l;g++)a.setUint32(4*g,h[g],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}}const xne=(r,e,t)=>r&e^~r&t,Rne=(r,e,t)=>r&e^r&t^e&t,Ine=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]),go=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),yo=new Uint32Array(64);class Sne extends HN{constructor(){super(64,32,8,!1),this.A=go[0]|0,this.B=go[1]|0,this.C=go[2]|0,this.D=go[3]|0,this.E=go[4]|0,this.F=go[5]|0,this.G=go[6]|0,this.H=go[7]|0}get(){const{A:e,B:t,C:n,D:i,E:s,F:o,G:a,H:u}=this;return[e,t,n,i,s,o,a,u]}set(e,t,n,i,s,o,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(e,t){for(let g=0;g<16;g++,t+=4)yo[g]=e.getUint32(t,!1);for(let g=16;g<64;g++){const b=yo[g-15],w=yo[g-2],I=$i(b,7)^$i(b,18)^b>>>3,S=$i(w,17)^$i(w,19)^w>>>10;yo[g]=S+yo[g-7]+I+yo[g-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:u,G:l,H:h}=this;for(let g=0;g<64;g++){const b=$i(a,6)^$i(a,11)^$i(a,25),w=h+b+xne(a,u,l)+Ine[g]+yo[g]|0,S=($i(n,2)^$i(n,13)^$i(n,22))+Rne(n,i,s)|0;h=l,l=u,u=a,a=o+w|0,o=s,s=i,i=n,n=w+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,u,l,h)}roundClean(){yo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const zN=v_(()=>new Sne),Xd=BigInt(2**32-1),Aw=BigInt(32);function GN(r,e=!1){return e?{h:Number(r&Xd),l:Number(r>>Aw&Xd)}:{h:Number(r>>Aw&Xd)|0,l:Number(r&Xd)|0}}function KN(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){const{h:s,l:o}=GN(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}const kne=(r,e)=>BigInt(r>>>0)<<Aw|BigInt(e>>>0),Tne=(r,e,t)=>r>>>t,One=(r,e,t)=>r<<32-t|e>>>t,Nne=(r,e,t)=>r>>>t|e<<32-t,Cne=(r,e,t)=>r<<32-t|e>>>t,Bne=(r,e,t)=>r<<64-t|e>>>t-32,Pne=(r,e,t)=>r>>>t-32|e<<64-t,Mne=(r,e)=>e,Lne=(r,e)=>r,jN=(r,e,t)=>r<<t|e>>>32-t,WN=(r,e,t)=>e<<t|r>>>32-t,VN=(r,e,t)=>e<<t-32|r>>>64-t,qN=(r,e,t)=>r<<t-32|e>>>64-t;function Une(r,e,t,n){const i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}const Dne=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),$ne=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Fne=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Hne=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,zne=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),Gne=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0,rt={fromBig:GN,split:KN,toBig:kne,shrSH:Tne,shrSL:One,rotrSH:Nne,rotrSL:Cne,rotrBH:Bne,rotrBL:Pne,rotr32H:Mne,rotr32L:Lne,rotlSH:jN,rotlSL:WN,rotlBH:VN,rotlBL:qN,add:Une,add3L:Dne,add3H:$ne,add4L:Fne,add4H:Hne,add5H:Gne,add5L:zne},[Kne,jne]=rt.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))),mo=new Uint32Array(80),wo=new Uint32Array(80);class Wne extends HN{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(){const{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:l,El:h,Fh:g,Fl:b,Gh:w,Gl:I,Hh:S,Hl:x}=this;return[e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x]}set(e,t,n,i,s,o,a,u,l,h,g,b,w,I,S,x){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=l|0,this.El=h|0,this.Fh=g|0,this.Fl=b|0,this.Gh=w|0,this.Gl=I|0,this.Hh=S|0,this.Hl=x|0}process(e,t){for(let D=0;D<16;D++,t+=4)mo[D]=e.getUint32(t),wo[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){const z=mo[D-15]|0,V=wo[D-15]|0,Z=rt.rotrSH(z,V,1)^rt.rotrSH(z,V,8)^rt.shrSH(z,V,7),K=rt.rotrSL(z,V,1)^rt.rotrSL(z,V,8)^rt.shrSL(z,V,7),W=mo[D-2]|0,oe=wo[D-2]|0,ce=rt.rotrSH(W,oe,19)^rt.rotrBH(W,oe,61)^rt.shrSH(W,oe,6),ne=rt.rotrSL(W,oe,19)^rt.rotrBL(W,oe,61)^rt.shrSL(W,oe,6),ue=rt.add4L(K,ne,wo[D-7],wo[D-16]),B=rt.add4H(ue,Z,ce,mo[D-7],mo[D-16]);mo[D]=B|0,wo[D]=ue|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:l,Dl:h,Eh:g,El:b,Fh:w,Fl:I,Gh:S,Gl:x,Hh:C,Hl:H}=this;for(let D=0;D<80;D++){const z=rt.rotrSH(g,b,14)^rt.rotrSH(g,b,18)^rt.rotrBH(g,b,41),V=rt.rotrSL(g,b,14)^rt.rotrSL(g,b,18)^rt.rotrBL(g,b,41),Z=g&w^~g&S,K=b&I^~b&x,W=rt.add5L(H,V,K,jne[D],wo[D]),oe=rt.add5H(W,C,z,Z,Kne[D],mo[D]),ce=W|0,ne=rt.rotrSH(n,i,28)^rt.rotrBH(n,i,34)^rt.rotrBH(n,i,39),ue=rt.rotrSL(n,i,28)^rt.rotrBL(n,i,34)^rt.rotrBL(n,i,39),B=n&s^n&a^s&a,p=i&o^i&u^o&u;C=S|0,H=x|0,S=w|0,x=I|0,w=g|0,I=b|0,{h:g,l:b}=rt.add(l|0,h|0,oe|0,ce|0),l=a|0,h=u|0,a=s|0,u=o|0,s=n|0,o=i|0;const m=rt.add3L(ce,ue,p);n=rt.add3H(m,oe,ne,B),i=m|0}({h:n,l:i}=rt.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=rt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=rt.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:l,l:h}=rt.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:g,l:b}=rt.add(this.Eh|0,this.El|0,g|0,b|0),{h:w,l:I}=rt.add(this.Fh|0,this.Fl|0,w|0,I|0),{h:S,l:x}=rt.add(this.Gh|0,this.Gl|0,S|0,x|0),{h:C,l:H}=rt.add(this.Hh|0,this.Hl|0,C|0,H|0),this.set(n,i,s,o,a,u,l,h,g,b,w,I,S,x,C,H)}roundClean(){mo.fill(0),wo.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)}}const Vne=v_(()=>new Wne);function qne(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof ul<"u")return ul;throw new Error("unable to locate global object")}const Ox=qne();Ox.crypto||Ox.msCrypto;function Zne(r){switch(r){case"sha256":return zN.create();case"sha512":return Vne.create()}q(!1,"invalid hashing algorithm name","algorithm",r)}const[ZN,QN,JN]=[[],[],[]],Qne=BigInt(0),kf=BigInt(1),Jne=BigInt(2),Yne=BigInt(7),Xne=BigInt(256),eie=BigInt(113);for(let r=0,e=kf,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],ZN.push(2*(5*n+t)),QN.push((r+1)*(r+2)/2%64);let i=Qne;for(let s=0;s<7;s++)e=(e<<kf^(e>>Yne)*eie)%Xne,e&Jne&&(i^=kf<<(kf<<BigInt(s))-kf);JN.push(i)}const[tie,rie]=KN(JN,!0),Nx=(r,e,t)=>t>32?VN(r,e,t):jN(r,e,t),Cx=(r,e,t)=>t>32?qN(r,e,t):WN(r,e,t);function nie(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,l=t[u],h=t[u+1],g=Nx(l,h,1)^t[a],b=Cx(l,h,1)^t[a+1];for(let w=0;w<50;w+=10)r[o+w]^=g,r[o+w+1]^=b}let i=r[2],s=r[3];for(let o=0;o<24;o++){const a=QN[o],u=Nx(i,s,a),l=Cx(i,s,a),h=ZN[o];i=r[h],s=r[h+1],r[h]=u,r[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=tie[n],r[1]^=rie[n]}t.fill(0)}class E_ extends A_{constructor(e,t,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Q0(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=wne(this.state)}keccak(){nie(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Al(this);const{blockLen:t,state:n}=this;e=fg(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(t-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,t&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Al(this,!1),__(e),this.finish();const t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Q0(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(UN(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new E_(t,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const iie=(r,e,t)=>v_(()=>new E_(e,r,t)),sie=iie(1,136,256/8);let YN=!1;const XN=function(r){return sie(r)};let eC=XN;function Tr(r){const e=wt(r,"data");return Ce(eC(e))}Tr._=XN;Tr.lock=function(){YN=!0};Tr.register=function(r){if(YN)throw new TypeError("keccak256 is locked");eC=r};Object.freeze(Tr);const tC=function(r){return Zne("sha256").update(r).digest()};let rC=tC,nC=!1;function jl(r){const e=wt(r,"data");return Ce(rC(e))}jl._=tC;jl.lock=function(){nC=!0};jl.register=function(r){if(nC)throw new Error("sha256 is locked");rC=r};Object.freeze(jl);Object.freeze(jl);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const iC=BigInt(0),hg=BigInt(1),oie=BigInt(2),dg=r=>r instanceof Uint8Array,aie=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function vl(r){if(!dg(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=aie[r[t]];return e}function sC(r){const e=r.toString(16);return e.length&1?`0${e}`:e}function x_(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function El(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const i=n*2,s=r.slice(i,i+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[n]=o}return t}function oc(r){return x_(vl(r))}function R_(r){if(!dg(r))throw new Error("Uint8Array expected");return x_(vl(Uint8Array.from(r).reverse()))}function xl(r,e){return El(r.toString(16).padStart(e*2,"0"))}function I_(r,e){return xl(r,e).reverse()}function cie(r){return El(sC(r))}function mi(r,e,t){let n;if(typeof e=="string")try{n=El(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(dg(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);const i=n.length;if(typeof t=="number"&&i!==t)throw new Error(`${r} expected ${t} bytes, got ${i}`);return n}function vh(...r){const e=new Uint8Array(r.reduce((n,i)=>n+i.length,0));let t=0;return r.forEach(n=>{if(!dg(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}function uie(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function lie(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function fie(r){let e;for(e=0;r>iC;r>>=hg,e+=1);return e}function hie(r,e){return r>>BigInt(e)&hg}const die=(r,e,t)=>r|(t?hg:iC)<<BigInt(e),S_=r=>(oie<<BigInt(r-1))-hg,d1=r=>new Uint8Array(r),Bx=r=>Uint8Array.from(r);function oC(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=d1(r),i=d1(r),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>t(i,n,...g),u=(g=d1())=>{i=a(Bx([0]),g),n=a(),g.length!==0&&(i=a(Bx([1]),g),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){n=a();const w=n.slice();b.push(w),g+=n.length}return vh(...b)};return(g,b)=>{o(),u(g);let w;for(;!(w=b(l()));)u();return o(),w}}const pie={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,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function yd(r,e,t={}){const n=(i,s,o)=>{const a=pie[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const u=r[i];if(!(o&&u===void 0)&&!a(u,r))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(t))n(i,s,!0);return r}const gie=Object.freeze(Object.defineProperty({__proto__:null,bitGet:hie,bitLen:fie,bitMask:S_,bitSet:die,bytesToHex:vl,bytesToNumberBE:oc,bytesToNumberLE:R_,concatBytes:vh,createHmacDrbg:oC,ensureBytes:mi,equalBytes:uie,hexToBytes:El,hexToNumber:x_,numberToBytesBE:xl,numberToBytesLE:I_,numberToHexUnpadded:sC,numberToVarBytesBE:cie,utf8ToBytes:lie,validateObject:yd},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Hr=BigInt(0),xr=BigInt(1),va=BigInt(2),yie=BigInt(3),vw=BigInt(4),Px=BigInt(5),Mx=BigInt(8);BigInt(9);BigInt(16);function kn(r,e){const t=r%e;return t>=Hr?t:e+t}function mie(r,e,t){if(t<=Hr||e<Hr)throw new Error("Expected power/modulo > 0");if(t===xr)return Hr;let n=xr;for(;e>Hr;)e&xr&&(n=n*r%t),r=r*r%t,e>>=xr;return n}function Jn(r,e,t){let n=r;for(;e-- >Hr;)n*=n,n%=t;return n}function Ew(r,e){if(r===Hr||e<=Hr)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=kn(r,e),n=e,i=Hr,s=xr;for(;t!==Hr;){const a=n/t,u=n%t,l=i-s*a;n=t,t=u,i=s,s=l}if(n!==xr)throw new Error("invert: does not exist");return kn(i,e)}function wie(r){const e=(r-xr)/va;let t,n,i;for(t=r-xr,n=0;t%va===Hr;t/=va,n++);for(i=va;i<r&&mie(i,e,r)!==r-xr;i++);if(n===1){const o=(r+xr)/vw;return function(u,l){const h=u.pow(l,o);if(!u.eql(u.sqr(h),l))throw new Error("Cannot find square root");return h}}const s=(t+xr)/va;return function(a,u){if(a.pow(u,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),t),g=a.pow(u,s),b=a.pow(u,t);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let w=1;for(let S=a.sqr(b);w<l&&!a.eql(S,a.ONE);w++)S=a.sqr(S);const I=a.pow(h,xr<<BigInt(l-w-1));h=a.sqr(I),g=a.mul(g,I),b=a.mul(b,h),l=w}return g}}function bie(r){if(r%vw===yie){const e=(r+xr)/vw;return function(n,i){const s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%Mx===Px){const e=(r-Px)/Mx;return function(n,i){const s=n.mul(i,va),o=n.pow(s,e),a=n.mul(i,o),u=n.mul(n.mul(a,va),o),l=n.mul(a,n.sub(u,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return wie(r)}const _ie=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Aie(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=_ie.reduce((n,i)=>(n[i]="function",n),e);return yd(r,t)}function vie(r,e,t){if(t<Hr)throw new Error("Expected power > 0");if(t===Hr)return r.ONE;if(t===xr)return e;let n=r.ONE,i=e;for(;t>Hr;)t&xr&&(n=r.mul(n,i)),i=r.sqr(i),t>>=xr;return n}function Eie(r,e){const t=new Array(e.length),n=e.reduce((s,o,a)=>r.is0(o)?s:(t[a]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,a)=>r.is0(o)?s:(t[a]=r.mul(s,t[a]),r.mul(s,o)),i),t}function aC(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function xie(r,e,t=!1,n={}){if(r<=Hr)throw new Error(`Expected Field ORDER > 0, got ${r}`);const{nBitLength:i,nByteLength:s}=aC(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=bie(r),a=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:S_(i),ZERO:Hr,ONE:xr,create:u=>kn(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Hr<=u&&u<r},is0:u=>u===Hr,isOdd:u=>(u&xr)===xr,neg:u=>kn(-u,r),eql:(u,l)=>u===l,sqr:u=>kn(u*u,r),add:(u,l)=>kn(u+l,r),sub:(u,l)=>kn(u-l,r),mul:(u,l)=>kn(u*l,r),pow:(u,l)=>vie(a,u,l),div:(u,l)=>kn(u*Ew(l,r),r),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>Ew(u,r),sqrt:n.sqrt||(u=>o(a,u)),invertBatch:u=>Eie(a,u),cmov:(u,l,h)=>h?l:u,toBytes:u=>t?I_(u,s):xl(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return t?R_(u):oc(u)}});return Object.freeze(a)}function cC(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function uC(r){const e=cC(r);return e+Math.ceil(e/2)}function Rie(r,e,t=!1){const n=r.length,i=cC(e),s=uC(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const o=t?oc(r):R_(r),a=kn(o,e-xr)+xr;return t?I_(a,i):xl(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Iie=BigInt(0),p1=BigInt(1);function Sie(r,e){const t=(i,s)=>{const o=s.negate();return i?o:s},n=i=>{const s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:t,unsafeLadder(i,s){let o=r.ZERO,a=i;for(;s>Iie;)s&p1&&(o=o.add(a)),a=a.double(),s>>=p1;return o},precomputeWindow(i,s){const{windows:o,windowSize:a}=n(s),u=[];let l=i,h=l;for(let g=0;g<o;g++){h=l,u.push(h);for(let b=1;b<a;b++)h=h.add(l),u.push(h);l=h.double()}return u},wNAF(i,s,o){const{windows:a,windowSize:u}=n(i);let l=r.ZERO,h=r.BASE;const g=BigInt(2**i-1),b=2**i,w=BigInt(i);for(let I=0;I<a;I++){const S=I*u;let x=Number(o&g);o>>=w,x>u&&(x-=b,o+=p1);const C=S,H=S+Math.abs(x)-1,D=I%2!==0,z=x<0;x===0?h=h.add(t(D,s[C])):l=l.add(t(z,s[H]))}return{p:l,f:h}},wNAFCached(i,s,o,a){const u=i._WINDOW_SIZE||1;let l=s.get(i);return l||(l=this.precomputeWindow(i,u),u!==1&&s.set(i,a(l))),this.wNAF(u,l,o)}}}function lC(r){return Aie(r.Fp),yd(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...aC(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kie(r){const e=lC(r);yd(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Tie,hexToBytes:Oie}=gie,Na={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){const{Err:e}=Na;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");const t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Tie(n),l:r.subarray(t+2)}},toSig(r){const{Err:e}=Na,t=typeof r=="string"?Oie(r):r;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=Na._parseInt(t.subarray(2)),{d:o,l:a}=Na._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(r){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,t=l=>{const h=l.toString(16);return h.length&1?`0${h}`:h},n=e(t(r.s)),i=e(t(r.r)),s=n.length/2,o=i.length/2,a=t(s),u=t(o);return`30${t(o+s+4)}02${u}${i}02${a}${n}`}},qs=BigInt(0),oi=BigInt(1);BigInt(2);const Lx=BigInt(3);BigInt(4);function Nie(r){const e=kie(r),{Fp:t}=e,n=e.toBytes||((I,S,x)=>{const C=S.toAffine();return vh(Uint8Array.from([4]),t.toBytes(C.x),t.toBytes(C.y))}),i=e.fromBytes||(I=>{const S=I.subarray(1),x=t.fromBytes(S.subarray(0,t.BYTES)),C=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x,y:C}});function s(I){const{a:S,b:x}=e,C=t.sqr(I),H=t.mul(C,I);return t.add(t.add(H,t.mul(I,S)),x)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(I){return typeof I=="bigint"&&qs<I&&I<e.n}function a(I){if(!o(I))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(I){const{allowedPrivateKeyLengths:S,nByteLength:x,wrapPrivateKey:C,n:H}=e;if(S&&typeof I!="bigint"){if(I instanceof Uint8Array&&(I=vl(I)),typeof I!="string"||!S.includes(I.length))throw new Error("Invalid key");I=I.padStart(x*2,"0")}let D;try{D=typeof I=="bigint"?I:oc(mi("private key",I,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof I}`)}return C&&(D=kn(D,H)),a(D),D}const l=new Map;function h(I){if(!(I instanceof g))throw new Error("ProjectivePoint expected")}class g{constructor(S,x,C){if(this.px=S,this.py=x,this.pz=C,S==null||!t.isValid(S))throw new Error("x required");if(x==null||!t.isValid(x))throw new Error("y required");if(C==null||!t.isValid(C))throw new Error("z required")}static fromAffine(S){const{x,y:C}=S||{};if(!S||!t.isValid(x)||!t.isValid(C))throw new Error("invalid affine point");if(S instanceof g)throw new Error("projective point not allowed");const H=D=>t.eql(D,t.ZERO);return H(x)&&H(C)?g.ZERO:new g(x,C,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(S){const x=t.invertBatch(S.map(C=>C.pz));return S.map((C,H)=>C.toAffine(x[H])).map(g.fromAffine)}static fromHex(S){const x=g.fromAffine(i(mi("pointHex",S)));return x.assertValidity(),x}static fromPrivateKey(S){return g.BASE.multiply(u(S))}_setWindowSize(S){this._WINDOW_SIZE=S,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:S,y:x}=this.toAffine();if(!t.isValid(S)||!t.isValid(x))throw new Error("bad point: x or y not FE");const C=t.sqr(x),H=s(S);if(!t.eql(C,H))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:S}=this.toAffine();if(t.isOdd)return!t.isOdd(S);throw new Error("Field doesn't support isOdd")}equals(S){h(S);const{px:x,py:C,pz:H}=this,{px:D,py:z,pz:V}=S,Z=t.eql(t.mul(x,V),t.mul(D,H)),K=t.eql(t.mul(C,V),t.mul(z,H));return Z&&K}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:S,b:x}=e,C=t.mul(x,Lx),{px:H,py:D,pz:z}=this;let V=t.ZERO,Z=t.ZERO,K=t.ZERO,W=t.mul(H,H),oe=t.mul(D,D),ce=t.mul(z,z),ne=t.mul(H,D);return ne=t.add(ne,ne),K=t.mul(H,z),K=t.add(K,K),V=t.mul(S,K),Z=t.mul(C,ce),Z=t.add(V,Z),V=t.sub(oe,Z),Z=t.add(oe,Z),Z=t.mul(V,Z),V=t.mul(ne,V),K=t.mul(C,K),ce=t.mul(S,ce),ne=t.sub(W,ce),ne=t.mul(S,ne),ne=t.add(ne,K),K=t.add(W,W),W=t.add(K,W),W=t.add(W,ce),W=t.mul(W,ne),Z=t.add(Z,W),ce=t.mul(D,z),ce=t.add(ce,ce),W=t.mul(ce,ne),V=t.sub(V,W),K=t.mul(ce,oe),K=t.add(K,K),K=t.add(K,K),new g(V,Z,K)}add(S){h(S);const{px:x,py:C,pz:H}=this,{px:D,py:z,pz:V}=S;let Z=t.ZERO,K=t.ZERO,W=t.ZERO;const oe=e.a,ce=t.mul(e.b,Lx);let ne=t.mul(x,D),ue=t.mul(C,z),B=t.mul(H,V),p=t.add(x,C),m=t.add(D,z);p=t.mul(p,m),m=t.add(ne,ue),p=t.sub(p,m),m=t.add(x,H);let E=t.add(D,V);return m=t.mul(m,E),E=t.add(ne,B),m=t.sub(m,E),E=t.add(C,H),Z=t.add(z,V),E=t.mul(E,Z),Z=t.add(ue,B),E=t.sub(E,Z),W=t.mul(oe,m),Z=t.mul(ce,B),W=t.add(Z,W),Z=t.sub(ue,W),W=t.add(ue,W),K=t.mul(Z,W),ue=t.add(ne,ne),ue=t.add(ue,ne),B=t.mul(oe,B),m=t.mul(ce,m),ue=t.add(ue,B),B=t.sub(ne,B),B=t.mul(oe,B),m=t.add(m,B),ne=t.mul(ue,m),K=t.add(K,ne),ne=t.mul(E,m),Z=t.mul(p,Z),Z=t.sub(Z,ne),ne=t.mul(p,ue),W=t.mul(E,W),W=t.add(W,ne),new g(Z,K,W)}subtract(S){return this.add(S.negate())}is0(){return this.equals(g.ZERO)}wNAF(S){return w.wNAFCached(this,l,S,x=>{const C=t.invertBatch(x.map(H=>H.pz));return x.map((H,D)=>H.toAffine(C[D])).map(g.fromAffine)})}multiplyUnsafe(S){const x=g.ZERO;if(S===qs)return x;if(a(S),S===oi)return this;const{endo:C}=e;if(!C)return w.unsafeLadder(this,S);let{k1neg:H,k1:D,k2neg:z,k2:V}=C.splitScalar(S),Z=x,K=x,W=this;for(;D>qs||V>qs;)D&oi&&(Z=Z.add(W)),V&oi&&(K=K.add(W)),W=W.double(),D>>=oi,V>>=oi;return H&&(Z=Z.negate()),z&&(K=K.negate()),K=new g(t.mul(K.px,C.beta),K.py,K.pz),Z.add(K)}multiply(S){a(S);let x=S,C,H;const{endo:D}=e;if(D){const{k1neg:z,k1:V,k2neg:Z,k2:K}=D.splitScalar(x);let{p:W,f:oe}=this.wNAF(V),{p:ce,f:ne}=this.wNAF(K);W=w.constTimeNegate(z,W),ce=w.constTimeNegate(Z,ce),ce=new g(t.mul(ce.px,D.beta),ce.py,ce.pz),C=W.add(ce),H=oe.add(ne)}else{const{p:z,f:V}=this.wNAF(x);C=z,H=V}return g.normalizeZ([C,H])[0]}multiplyAndAddUnsafe(S,x,C){const H=g.BASE,D=(V,Z)=>Z===qs||Z===oi||!V.equals(H)?V.multiplyUnsafe(Z):V.multiply(Z),z=D(this,x).add(D(S,C));return z.is0()?void 0:z}toAffine(S){const{px:x,py:C,pz:H}=this,D=this.is0();S==null&&(S=D?t.ONE:t.inv(H));const z=t.mul(x,S),V=t.mul(C,S),Z=t.mul(H,S);if(D)return{x:t.ZERO,y:t.ZERO};if(!t.eql(Z,t.ONE))throw new Error("invZ was invalid");return{x:z,y:V}}isTorsionFree(){const{h:S,isTorsionFree:x}=e;if(S===oi)return!0;if(x)return x(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:S,clearCofactor:x}=e;return S===oi?this:x?x(g,this):this.multiplyUnsafe(e.h)}toRawBytes(S=!0){return this.assertValidity(),n(g,this,S)}toHex(S=!0){return vl(this.toRawBytes(S))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const b=e.nBitLength,w=Sie(g,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}function Cie(r){const e=lC(r);return yd(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Bie(r){const e=Cie(r),{Fp:t,n}=e,i=t.BYTES+1,s=2*t.BYTES+1;function o(m){return qs<m&&m<t.ORDER}function a(m){return kn(m,n)}function u(m){return Ew(m,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:g,isWithinCurveOrder:b}=Nie({...e,toBytes(m,E,k){const O=E.toAffine(),M=t.toBytes(O.x),G=vh;return k?G(Uint8Array.from([E.hasEvenY()?2:3]),M):G(Uint8Array.from([4]),M,t.toBytes(O.y))},fromBytes(m){const E=m.length,k=m[0],O=m.subarray(1);if(E===i&&(k===2||k===3)){const M=oc(O);if(!o(M))throw new Error("Point is not on curve");const G=g(M);let P=t.sqrt(G);const A=(P&oi)===oi;return(k&1)===1!==A&&(P=t.neg(P)),{x:M,y:P}}else if(E===s&&k===4){const M=t.fromBytes(O.subarray(0,t.BYTES)),G=t.fromBytes(O.subarray(t.BYTES,2*t.BYTES));return{x:M,y:G}}else throw new Error(`Point of length ${E} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),w=m=>vl(xl(m,e.nByteLength));function I(m){const E=n>>oi;return m>E}function S(m){return I(m)?a(-m):m}const x=(m,E,k)=>oc(m.slice(E,k));class C{constructor(E,k,O){this.r=E,this.s=k,this.recovery=O,this.assertValidity()}static fromCompact(E){const k=e.nByteLength;return E=mi("compactSignature",E,k*2),new C(x(E,0,k),x(E,k,2*k))}static fromDER(E){const{r:k,s:O}=Na.toSig(mi("DER",E));return new C(k,O)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new C(this.r,this.s,E)}recoverPublicKey(E){const{r:k,s:O,recovery:M}=this,G=K(mi("msgHash",E));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");const P=M===2||M===3?k+e.n:k;if(P>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const A=M&1?"03":"02",U=l.fromHex(A+w(P)),le=u(P),ee=a(-G*le),re=a(O*le),he=l.BASE.multiplyAndAddUnsafe(U,ee,re);if(!he)throw new Error("point at infinify");return he.assertValidity(),he}hasHighS(){return I(this.s)}normalizeS(){return this.hasHighS()?new C(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return El(this.toDERHex())}toDERHex(){return Na.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return El(this.toCompactHex())}toCompactHex(){return w(this.r)+w(this.s)}}const H={isValidPrivateKey(m){try{return h(m),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const m=uC(e.n);return Rie(e.randomBytes(m),e.n)},precompute(m=8,E=l.BASE){return E._setWindowSize(m),E.multiply(BigInt(3)),E}};function D(m,E=!0){return l.fromPrivateKey(m).toRawBytes(E)}function z(m){const E=m instanceof Uint8Array,k=typeof m=="string",O=(E||k)&&m.length;return E?O===i||O===s:k?O===2*i||O===2*s:m instanceof l}function V(m,E,k=!0){if(z(m))throw new Error("first arg must be private key");if(!z(E))throw new Error("second arg must be public key");return l.fromHex(E).multiply(h(m)).toRawBytes(k)}const Z=e.bits2int||function(m){const E=oc(m),k=m.length*8-e.nBitLength;return k>0?E>>BigInt(k):E},K=e.bits2int_modN||function(m){return a(Z(m))},W=S_(e.nBitLength);function oe(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!(qs<=m&&m<W))throw new Error(`bigint expected < 2^${e.nBitLength}`);return xl(m,e.nByteLength)}function ce(m,E,k=ne){if(["recovered","canonical"].some(be=>be in k))throw new Error("sign() legacy options not supported");const{hash:O,randomBytes:M}=e;let{lowS:G,prehash:P,extraEntropy:A}=k;G==null&&(G=!0),m=mi("msgHash",m),P&&(m=mi("prehashed msgHash",O(m)));const U=K(m),le=h(E),ee=[oe(le),oe(U)];if(A!=null){const be=A===!0?M(t.BYTES):A;ee.push(mi("extraEntropy",be))}const re=vh(...ee),he=U;function ye(be){const je=Z(be);if(!b(je))return;const $e=u(je),Oe=l.BASE.multiply(je).toAffine(),Xe=a(Oe.x);if(Xe===qs)return;const qe=a($e*a(he+Xe*le));if(qe===qs)return;let et=(Oe.x===Xe?0:2)|Number(Oe.y&oi),Jt=qe;return G&&I(qe)&&(Jt=S(qe),et^=1),new C(Xe,Jt,et)}return{seed:re,k2sig:ye}}const ne={lowS:e.lowS,prehash:!1},ue={lowS:e.lowS,prehash:!1};function B(m,E,k=ne){const{seed:O,k2sig:M}=ce(m,E,k),G=e;return oC(G.hash.outputLen,G.nByteLength,G.hmac)(O,M)}l.BASE._setWindowSize(8);function p(m,E,k,O=ue){var Oe;const M=m;if(E=mi("msgHash",E),k=mi("publicKey",k),"strict"in O)throw new Error("options.strict was renamed to lowS");const{lowS:G,prehash:P}=O;let A,U;try{if(typeof M=="string"||M instanceof Uint8Array)try{A=C.fromDER(M)}catch(Xe){if(!(Xe instanceof Na.Err))throw Xe;A=C.fromCompact(M)}else if(typeof M=="object"&&typeof M.r=="bigint"&&typeof M.s=="bigint"){const{r:Xe,s:qe}=M;A=new C(Xe,qe)}else throw new Error("PARSE");U=l.fromHex(k)}catch(Xe){if(Xe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(G&&A.hasHighS())return!1;P&&(E=e.hash(E));const{r:le,s:ee}=A,re=K(E),he=u(ee),ye=a(re*he),be=a(le*he),je=(Oe=l.BASE.multiplyAndAddUnsafe(U,ye,be))==null?void 0:Oe.toAffine();return je?a(je.x)===le:!1}return{CURVE:e,getPublicKey:D,getSharedSecret:V,sign:B,verify:p,ProjectivePoint:l,Signature:C,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Pie(r){return{hash:r,hmac:(e,...t)=>FN(r,e,Ane(...t)),randomBytes:vne}}function Mie(r,e){const t=n=>Bie({...r,...Pie(n)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fC=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ux=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Lie=BigInt(1),xw=BigInt(2),Dx=(r,e)=>(r+e/xw)/e;function Uie(r){const e=fC,t=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),l=r*r*r%e,h=l*l*r%e,g=Jn(h,t,e)*h%e,b=Jn(g,t,e)*h%e,w=Jn(b,xw,e)*l%e,I=Jn(w,i,e)*w%e,S=Jn(I,s,e)*I%e,x=Jn(S,a,e)*S%e,C=Jn(x,u,e)*x%e,H=Jn(C,a,e)*S%e,D=Jn(H,t,e)*h%e,z=Jn(D,o,e)*I%e,V=Jn(z,n,e)*l%e,Z=Jn(V,xw,e);if(!Rw.eql(Rw.sqr(Z),r))throw new Error("Cannot find square root");return Z}const Rw=xie(fC,void 0,void 0,{sqrt:Uie}),_o=Mie({a:BigInt(0),b:BigInt(7),Fp:Rw,n:Ux,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=Ux,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Lie*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=BigInt("0x100000000000000000000000000000000"),a=Dx(s*r,e),u=Dx(-n*r,e);let l=kn(r-a*t-u*i,e),h=kn(-a*n-u*s,e);const g=l>o,b=h>o;if(g&&(l=e-l),b&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:l,k2neg:b,k2:h}}}},zN);BigInt(0);_o.ProjectivePoint;const Eh="0x0000000000000000000000000000000000000000",$x="0x0000000000000000000000000000000000000000000000000000000000000000",Fx=BigInt(0),Hx=BigInt(1),zx=BigInt(2),Gx=BigInt(27),Kx=BigInt(28),e0=BigInt(35),Wc={};function jx(r){return wc(mn(r),32)}var ku,Tu,Ou,Ga;const yi=class yi{constructor(e,t,n,i){se(this,ku);se(this,Tu);se(this,Ou);se(this,Ga);ag(e,Wc,"Signature"),F(this,ku,t),F(this,Tu,n),F(this,Ou,i),F(this,Ga,null)}get r(){return T(this,ku)}set r(e){q(yu(e)===32,"invalid r","value",e),F(this,ku,Ce(e))}get s(){return T(this,Tu)}set s(e){q(yu(e)===32,"invalid s","value",e);const t=Ce(e);q(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),F(this,Tu,t)}get v(){return T(this,Ou)}set v(e){const t=ct(e,"value");q(t===27||t===28,"invalid v","v",e),F(this,Ou,t)}get networkV(){return T(this,Ga)}get legacyChainId(){const e=this.networkV;return e==null?null:yi.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=wt(this.s);return this.yParity&&(e[0]|=128),Ce(e)}get compactSerialized(){return Ir([this.r,this.yParityAndS])}get serialized(){return Ir([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new yi(Wc,this.r,this.s,this.v);return this.networkV&&F(e,Ga,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=Me(e,"v");return t==Gx||t==Kx?Fx:(q(t>=e0,"invalid EIP-155 v","v",e),(t-e0)/zx)}static getChainIdV(e,t){return Me(e)*zx+BigInt(35+t-27)}static getNormalizedV(e){const t=Me(e);return t===Fx||t===Gx?27:t===Hx||t===Kx?28:(q(t>=e0,"invalid v","v",e),t&Hx?27:28)}static from(e){function t(l,h){q(l,h,"signature",e)}if(e==null)return new yi(Wc,$x,$x,27);if(typeof e=="string"){const l=wt(e,"signature");if(l.length===64){const h=Ce(l.slice(0,32)),g=l.slice(32,64),b=g[0]&128?28:27;return g[0]&=127,new yi(Wc,h,Ce(g),b)}if(l.length===65){const h=Ce(l.slice(0,32)),g=l.slice(32,64);t((g[0]&128)===0,"non-canonical s");const b=yi.getNormalizedV(l[64]);return new yi(Wc,h,Ce(g),b)}t(!1,"invalid raw signature length")}if(e instanceof yi)return e.clone();const n=e.r;t(n!=null,"missing r");const i=jx(n),s=function(l,h){if(l!=null)return jx(l);if(h!=null){t(zt(h,32),"invalid yParityAndS");const g=wt(h);return g[0]&=127,Ce(g)}t(!1,"missing s")}(e.s,e.yParityAndS);t((wt(s)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(l,h,g){if(l!=null){const b=Me(l);return{networkV:b>=e0?b:void 0,v:yi.getNormalizedV(b)}}if(h!=null)return t(zt(h,32),"invalid yParityAndS"),{v:wt(h)[0]&128?28:27};if(g!=null){switch(ct(g,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),u=new yi(Wc,i,s,a);return o&&F(u,Ga,o),t(e.yParity==null||ct(e.yParity,"sig.yParity")===u.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===u.yParityAndS,"yParityAndS mismatch"),u}};ku=new WeakMap,Tu=new WeakMap,Ou=new WeakMap,Ga=new WeakMap;let Ni=yi;var Ps;const Ea=class Ea{constructor(e){se(this,Ps);q(yu(e)===32,"invalid private key","privateKey","[REDACTED]"),F(this,Ps,Ce(e))}get privateKey(){return T(this,Ps)}get publicKey(){return Ea.computePublicKey(T(this,Ps))}get compressedPublicKey(){return Ea.computePublicKey(T(this,Ps),!0)}sign(e){q(yu(e)===32,"invalid digest length","digest",e);const t=_o.sign(pn(e),pn(T(this,Ps)),{lowS:!0});return Ni.from({r:sa(t.r,32),s:sa(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=Ea.computePublicKey(e);return Ce(_o.getSharedSecret(pn(T(this,Ps)),wt(t),!1))}static computePublicKey(e,t){let n=wt(e,"key");if(n.length===32){const s=_o.getPublicKey(n,!!t);return Ce(s)}if(n.length===64){const s=new Uint8Array(65);s[0]=4,s.set(n,1),n=s}const i=_o.ProjectivePoint.fromHex(n);return Ce(i.toRawBytes(t))}static recoverPublicKey(e,t){q(yu(e)===32,"invalid digest length","digest",e);const n=Ni.from(t);let i=_o.Signature.fromCompact(pn(Ir([n.r,n.s])));i=i.addRecoveryBit(n.yParity);const s=i.recoverPublicKey(pn(e));return q(s!=null,"invalid signautre for digest","signature",t),"0x"+s.toHex(!1)}static addPoints(e,t,n){const i=_o.ProjectivePoint.fromHex(Ea.computePublicKey(e).substring(2)),s=_o.ProjectivePoint.fromHex(Ea.computePublicKey(t).substring(2));return"0x"+i.add(s).toHex(!!n)}};Ps=new WeakMap;let xh=Ea;const Die=BigInt(0),$ie=BigInt(36);function Wx(r){r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let i=0;i<40;i++)t[i]=e[i].charCodeAt(0);const n=wt(Tr(t));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(n[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const k_={};for(let r=0;r<10;r++)k_[String(r)]=String(r);for(let r=0;r<26;r++)k_[String.fromCharCode(65+r)]=String(10+r);const Vx=15;function Fie(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(n=>k_[n]).join("");for(;e.length>=Vx;){let n=e.substring(0,Vx);e=parseInt(n,10)%97+e.substring(n.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const Hie=function(){const r={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];r[t]=BigInt(e)}return r}();function zie(r){r=r.toLowerCase();let e=Die;for(let t=0;t<r.length;t++)e=e*$ie+Hie[r[t]];return e}function Pt(r){if(q(typeof r=="string","invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/)){r.startsWith("0x")||(r="0x"+r);const e=Wx(r);return q(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===r,"bad address checksum","address",r),e}if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){q(r.substring(2,4)===Fie(r),"bad icap checksum","address",r);let e=zie(r.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Wx("0x"+e)}q(!1,"invalid address","address",r)}function Gie(r){const e=Pt(r.from);let n=Me(r.nonce,"tx.nonce").toString(16);return n==="0"?n="0x":n.length%2?n="0x0"+n:n="0x"+n,Pt(_r(Tr(bc([e,n])),12))}function hC(r){return r&&typeof r.getAddress=="function"}async function g1(r,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(pe(typeof r!="string","unconfigured name","UNCONFIGURED_NAME",{value:r}),q(!1,"invalid AddressLike value; did not resolve to a value address","target",r)),Pt(t)}function bn(r,e){if(typeof r=="string")return r.match(/^0x[0-9a-f]{40}$/i)?Pt(r):(pe(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),g1(r,e.resolveName(r)));if(hC(r))return g1(r,r.getAddress());if(r&&typeof r.then=="function")return g1(r,r);q(!1,"unsupported addressable value","target",r)}const Es={};function Te(r,e){let t=!1;return e<0&&(t=!0,e*=-1),new ln(Es,`${t?"":"u"}int${e}`,r,{signed:t,width:e})}function _t(r,e){return new ln(Es,`bytes${e||""}`,r,{size:e})}const qx=Symbol.for("_ethers_typed");var Ka;const xs=class xs{constructor(e,t,n,i){Q(this,"type");Q(this,"value");se(this,Ka);Q(this,"_typedSymbol");i==null&&(i=null),ag(Es,e,"Typed"),ze(this,{_typedSymbol:qx,type:t,value:n}),F(this,Ka,i),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return T(this,Ka)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,Ka)===!0?-1:T(this,Ka)===!1?this.value.length:null}static from(e,t){return new xs(Es,e,t)}static uint8(e){return Te(e,8)}static uint16(e){return Te(e,16)}static uint24(e){return Te(e,24)}static uint32(e){return Te(e,32)}static uint40(e){return Te(e,40)}static uint48(e){return Te(e,48)}static uint56(e){return Te(e,56)}static uint64(e){return Te(e,64)}static uint72(e){return Te(e,72)}static uint80(e){return Te(e,80)}static uint88(e){return Te(e,88)}static uint96(e){return Te(e,96)}static uint104(e){return Te(e,104)}static uint112(e){return Te(e,112)}static uint120(e){return Te(e,120)}static uint128(e){return Te(e,128)}static uint136(e){return Te(e,136)}static uint144(e){return Te(e,144)}static uint152(e){return Te(e,152)}static uint160(e){return Te(e,160)}static uint168(e){return Te(e,168)}static uint176(e){return Te(e,176)}static uint184(e){return Te(e,184)}static uint192(e){return Te(e,192)}static uint200(e){return Te(e,200)}static uint208(e){return Te(e,208)}static uint216(e){return Te(e,216)}static uint224(e){return Te(e,224)}static uint232(e){return Te(e,232)}static uint240(e){return Te(e,240)}static uint248(e){return Te(e,248)}static uint256(e){return Te(e,256)}static uint(e){return Te(e,256)}static int8(e){return Te(e,-8)}static int16(e){return Te(e,-16)}static int24(e){return Te(e,-24)}static int32(e){return Te(e,-32)}static int40(e){return Te(e,-40)}static int48(e){return Te(e,-48)}static int56(e){return Te(e,-56)}static int64(e){return Te(e,-64)}static int72(e){return Te(e,-72)}static int80(e){return Te(e,-80)}static int88(e){return Te(e,-88)}static int96(e){return Te(e,-96)}static int104(e){return Te(e,-104)}static int112(e){return Te(e,-112)}static int120(e){return Te(e,-120)}static int128(e){return Te(e,-128)}static int136(e){return Te(e,-136)}static int144(e){return Te(e,-144)}static int152(e){return Te(e,-152)}static int160(e){return Te(e,-160)}static int168(e){return Te(e,-168)}static int176(e){return Te(e,-176)}static int184(e){return Te(e,-184)}static int192(e){return Te(e,-192)}static int200(e){return Te(e,-200)}static int208(e){return Te(e,-208)}static int216(e){return Te(e,-216)}static int224(e){return Te(e,-224)}static int232(e){return Te(e,-232)}static int240(e){return Te(e,-240)}static int248(e){return Te(e,-248)}static int256(e){return Te(e,-256)}static int(e){return Te(e,-256)}static bytes1(e){return _t(e,1)}static bytes2(e){return _t(e,2)}static bytes3(e){return _t(e,3)}static bytes4(e){return _t(e,4)}static bytes5(e){return _t(e,5)}static bytes6(e){return _t(e,6)}static bytes7(e){return _t(e,7)}static bytes8(e){return _t(e,8)}static bytes9(e){return _t(e,9)}static bytes10(e){return _t(e,10)}static bytes11(e){return _t(e,11)}static bytes12(e){return _t(e,12)}static bytes13(e){return _t(e,13)}static bytes14(e){return _t(e,14)}static bytes15(e){return _t(e,15)}static bytes16(e){return _t(e,16)}static bytes17(e){return _t(e,17)}static bytes18(e){return _t(e,18)}static bytes19(e){return _t(e,19)}static bytes20(e){return _t(e,20)}static bytes21(e){return _t(e,21)}static bytes22(e){return _t(e,22)}static bytes23(e){return _t(e,23)}static bytes24(e){return _t(e,24)}static bytes25(e){return _t(e,25)}static bytes26(e){return _t(e,26)}static bytes27(e){return _t(e,27)}static bytes28(e){return _t(e,28)}static bytes29(e){return _t(e,29)}static bytes30(e){return _t(e,30)}static bytes31(e){return _t(e,31)}static bytes32(e){return _t(e,32)}static address(e){return new xs(Es,"address",e)}static bool(e){return new xs(Es,"bool",!!e)}static bytes(e){return new xs(Es,"bytes",e)}static string(e){return new xs(Es,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new xs(Es,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===qx}static dereference(e,t){if(xs.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};Ka=new WeakMap;let ln=xs;class Kie extends so{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let n=ln.dereference(t,"string");try{n=Pt(n)}catch(i){return this._throwError(i.message,t)}return e.writeValue(n)}decode(e){return Pt(sa(e.readValue(),20))}}class jie extends so{constructor(t){super(t.name,t.type,"_",t.dynamic);Q(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,n){return this.coder.encode(t,n)}decode(t){return this.coder.decode(t)}}function dC(r,e,t){let n=[];if(Array.isArray(t))n=t;else if(t&&typeof t=="object"){let u={};n=e.map(l=>{const h=l.localName;return pe(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),pe(!u[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),u[h]=!0,t[h]})}else q(!1,"invalid tuple value","tuple",t);q(e.length===n.length,"types/value length mismatch","tuple",t);let i=new ww,s=new ww,o=[];e.forEach((u,l)=>{let h=n[l];if(u.dynamic){let g=s.length;u.encode(s,h);let b=i.writeUpdatableValue();o.push(w=>{b(w+g)})}else u.encode(i,h)}),o.forEach(u=>{u(i.length)});let a=r.appendWriter(i);return a+=r.appendWriter(s),a}function pC(r,e){let t=[],n=[],i=r.subReader(0);return e.forEach(s=>{let o=null;if(s.dynamic){let a=r.readIndex(),u=i.subReader(a);try{o=s.decode(u)}catch(l){if(Zr(l,"BUFFER_OVERRUN"))throw l;o=l,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(r)}catch(a){if(Zr(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=s.name,o.name=s.localName,o.type=s.type}if(o==null)throw new Error("investigate");t.push(o),n.push(s.localName||null)}),_l.fromItems(t,n)}class Wie extends so{constructor(t,n,i){const s=t.type+"["+(n>=0?n:"")+"]",o=n===-1||t.dynamic;super("array",s,i,o);Q(this,"coder");Q(this,"length");ze(this,{coder:t,length:n})}defaultValue(){const t=this.coder.defaultValue(),n=[];for(let i=0;i<this.length;i++)n.push(t);return n}encode(t,n){const i=ln.dereference(n,"array");Array.isArray(i)||this._throwError("expected array value",i);let s=this.length;s===-1&&(s=i.length,t.writeValue(i.length)),EN(i.length,s,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<i.length;a++)o.push(this.coder);return dC(t,o,i)}decode(t){let n=this.length;n===-1&&(n=t.readIndex(),pe(n*wn<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:n*wn,length:t.dataLength}));let i=[];for(let s=0;s<n;s++)i.push(new jie(this.coder));return pC(t,i)}}class Vie extends so{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const n=ln.dereference(t,"bool");return e.writeValue(n?1:0)}decode(e){return!!e.readValue()}}class gC extends so{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=pn(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}}class qie extends gC{constructor(e){super("bytes",e)}decode(e){return Ce(super.decode(e))}}class Zie extends so{constructor(t,n){let i="bytes"+String(t);super(i,i,n,!1);Q(this,"size");ze(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,n){let i=pn(ln.dereference(n,this.type));return i.length!==this.size&&this._throwError("incorrect data length",n),t.writeBytes(i)}decode(t){return Ce(t.readBytes(this.size))}}const Qie=new Uint8Array([]);class Jie extends so{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(Qie)}decode(e){return e.readBytes(0),null}}const Yie=BigInt(0),Xie=BigInt(1),ese=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class tse extends so{constructor(t,n,i){const s=(n?"int":"uint")+t*8;super(s,s,i,!1);Q(this,"size");Q(this,"signed");ze(this,{size:t,signed:n},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,n){let i=Me(ln.dereference(n,this.type)),s=Pf(ese,wn*8);if(this.signed){let o=Pf(s,this.size*8-1);(i>o||i<-(o+Xie))&&this._throwError("value out-of-bounds",n),i=IN(i,8*wn)}else(i<Yie||i>Pf(s,this.size*8))&&this._throwError("value out-of-bounds",n);return t.writeValue(i)}decode(t){let n=Pf(t.readValue(),this.size*8);return this.signed&&(n=Yre(n,this.size*8)),n}}class rse extends gC{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Js(ln.dereference(t,"string")))}decode(e){return Z0(super.decode(e))}}class t0 extends so{constructor(t,n){let i=!1;const s=[];t.forEach(a=>{a.dynamic&&(i=!0),s.push(a.type)});const o="tuple("+s.join(",")+")";super("tuple",o,n,i);Q(this,"coders");ze(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(i=>{t.push(i.defaultValue())});const n=this.coders.reduce((i,s)=>{const o=s.localName;return o&&(i[o]||(i[o]=0),i[o]++),i},{});return this.coders.forEach((i,s)=>{let o=i.localName;!o||n[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[s]))}),Object.freeze(t)}encode(t,n){const i=ln.dereference(n,"tuple");return dC(t,this.coders,i)}decode(t){return pC(t,this.coders)}}function _c(r){return Tr(Js(r))}var nse="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const Zx=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Qx=4;function ise(r){let e=0;function t(){return r[e++]<<8|r[e++]}let n=t(),i=1,s=[0,1];for(let V=1;V<n;V++)s.push(i+=t());let o=t(),a=e;e+=o;let u=0,l=0;function h(){return u==0&&(l=l<<8|r[e++],u=8),l>>--u&1}const g=31,b=2**g,w=b>>>1,I=w>>1,S=b-1;let x=0;for(let V=0;V<g;V++)x=x<<1|h();let C=[],H=0,D=b;for(;;){let V=Math.floor(((x-H+1)*i-1)/D),Z=0,K=n;for(;K-Z>1;){let ce=Z+K>>>1;V<s[ce]?K=ce:Z=ce}if(Z==0)break;C.push(Z);let W=H+Math.floor(D*s[Z]/i),oe=H+Math.floor(D*s[Z+1]/i)-1;for(;!((W^oe)&w);)x=x<<1&S|h(),W=W<<1&S,oe=oe<<1&S|1;for(;W&~oe&I;)x=x&w|x<<1&S>>>1|h(),W=W<<1^w,oe=(oe^w)<<1|w|1;H=W,D=1+oe-W}let z=n-4;return C.map(V=>{switch(V-z){case 3:return z+65792+(r[a++]<<16|r[a++]<<8|r[a++]);case 2:return z+256+(r[a++]<<8|r[a++]);case 1:return z+r[a++];default:return V-1}})}function sse(r){let e=0;return()=>r[e++]}function yC(r){return sse(ise(ose(r)))}function ose(r){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((i,s)=>e[i.charCodeAt(0)]=s);let t=r.length,n=new Uint8Array(6*t>>3);for(let i=0,s=0,o=0,a=0;i<t;i++)a=a<<6|e[r.charCodeAt(i)],o+=6,o>=8&&(n[s++]=a>>(o-=8));return n}function ase(r){return r&1?~r>>1:r>>1}function cse(r,e){let t=Array(r);for(let n=0,i=0;n<r;n++)t[n]=i+=ase(e());return t}function Rh(r,e=0){let t=[];for(;;){let n=r(),i=r();if(!i)break;e+=n;for(let s=0;s<i;s++)t.push(e+s);e+=i+1}return t}function mC(r){return Ih(()=>{let e=Rh(r);if(e.length)return e})}function wC(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(use(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(lse(t,r))}return e.flat()}function Ih(r){let e=[];for(;;){let t=r(e.length);if(!t)break;e.push(t)}return e}function bC(r,e,t){let n=Array(r).fill().map(()=>[]);for(let i=0;i<e;i++)cse(r,t).forEach((s,o)=>n[o].push(s));return n}function use(r,e){let t=1+e(),n=e(),i=Ih(e);return bC(i.length,1+r,e).flatMap((o,a)=>{let[u,...l]=o;return Array(i[a]).fill().map((h,g)=>{let b=g*n;return[u+g*t,l.map(w=>w+b)]})})}function lse(r,e){let t=1+e();return bC(t,1+r,e).map(i=>[i[0],i.slice(1)])}function fse(r){let e=[],t=Rh(r);return i(n([]),[]),e;function n(s){let o=r(),a=Ih(()=>{let u=Rh(r).map(l=>t[l]);if(u.length)return n(u)});return{S:o,B:a,Q:s}}function i({S:s,B:o},a,u){if(!(s&4&&u===a[a.length-1])){s&2&&(u=a[a.length-1]),s&1&&e.push(a);for(let l of o)for(let h of l.Q)i(l,[...a,h],u)}}}function hse(r){return r.toString(16).toUpperCase().padStart(2,"0")}function _C(r){return`{${hse(r)}}`}function dse(r){let e=[];for(let t=0,n=r.length;t<n;){let i=r.codePointAt(t);t+=i<65536?1:2,e.push(i)}return e}function Rl(r){let t=r.length;if(t<4096)return String.fromCodePoint(...r);let n=[];for(let i=0;i<t;)n.push(String.fromCodePoint(...r.slice(i,i+=4096)));return n.join("")}function pse(r,e){let t=r.length,n=t-e.length;for(let i=0;n==0&&i<t;i++)n=r[i]-e[i];return n}var gse="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const Sh=44032,J0=4352,Y0=4449,X0=4519,AC=19,vC=21,Il=28,ep=vC*Il,yse=AC*ep,mse=Sh+yse,wse=J0+AC,bse=Y0+vC,_se=X0+Il;function Lf(r){return r>>24&255}function EC(r){return r&16777215}let Iw,Jx,Sw,h0;function Ase(){let r=yC(gse);Iw=new Map(mC(r).flatMap((e,t)=>e.map(n=>[n,t+1<<24]))),Jx=new Set(Rh(r)),Sw=new Map,h0=new Map;for(let[e,t]of wC(r)){if(!Jx.has(e)&&t.length==2){let[n,i]=t,s=h0.get(n);s||(s=new Map,h0.set(n,s)),s.set(i,e)}Sw.set(e,t.reverse())}}function xC(r){return r>=Sh&&r<mse}function vse(r,e){if(r>=J0&&r<wse&&e>=Y0&&e<bse)return Sh+(r-J0)*ep+(e-Y0)*Il;if(xC(r)&&e>X0&&e<_se&&(r-Sh)%Il==0)return r+(e-X0);{let t=h0.get(r);return t&&(t=t.get(e),t)?t:-1}}function RC(r){Iw||Ase();let e=[],t=[],n=!1;function i(s){let o=Iw.get(s);o&&(n=!0,s|=o),e.push(s)}for(let s of r)for(;;){if(s<128)e.push(s);else if(xC(s)){let o=s-Sh,a=o/ep|0,u=o%ep/Il|0,l=o%Il;i(J0+a),i(Y0+u),l>0&&i(X0+l)}else{let o=Sw.get(s);o?t.push(...o):i(s)}if(!t.length)break;s=t.pop()}if(n&&e.length>1){let s=Lf(e[0]);for(let o=1;o<e.length;o++){let a=Lf(e[o]);if(a==0||s<=a){s=a;continue}let u=o-1;for(;;){let l=e[u+1];if(e[u+1]=e[u],e[u]=l,!u||(s=Lf(e[--u]),s<=a))break}s=Lf(e[o])}}return e}function Ese(r){let e=[],t=[],n=-1,i=0;for(let s of r){let o=Lf(s),a=EC(s);if(n==-1)o==0?n=a:e.push(a);else if(i>0&&i>=o)o==0?(e.push(n,...t),t.length=0,n=a):t.push(a),i=o;else{let u=vse(n,a);u>=0?n=u:i==0&&o==0?(e.push(n),n=a):(t.push(a),i=o)}}return n>=0&&e.push(n,...t),e}function IC(r){return RC(r).map(EC)}function xse(r){return Ese(RC(r))}const Yx=45,SC=".",kC=65039,TC=1,tp=r=>Array.from(r);function kh(r,e){return r.P.has(e)||r.Q.has(e)}class Rse extends Array{get is_emoji(){return!0}}let kw,OC,Ca,Tw,NC,mu,y1,Yc,ya,Xx,Ow;function T_(){if(kw)return;let r=yC(nse);const e=()=>Rh(r),t=()=>new Set(e()),n=(h,g)=>g.forEach(b=>h.add(b));kw=new Map(wC(r)),OC=t(),Ca=e(),Tw=new Set(e().map(h=>Ca[h])),Ca=new Set(Ca),NC=t(),t();let i=mC(r),s=r();const o=()=>{let h=new Set;return e().forEach(g=>n(h,i[g])),n(h,e()),h};mu=Ih(h=>{let g=Ih(r).map(b=>b+96);if(g.length){let b=h>=s;g[0]-=32,g=Rl(g),b&&(g=`Restricted[${g}]`);let w=o(),I=o(),S=!r();return{N:g,P:w,Q:I,M:S,R:b}}}),y1=t(),Yc=new Map;let a=e().concat(tp(y1)).sort((h,g)=>h-g);a.forEach((h,g)=>{let b=r(),w=a[g]=b?a[g-b]:{V:[],M:new Map};w.V.push(h),y1.has(h)||Yc.set(h,w)});for(let{V:h,M:g}of new Set(Yc.values())){let b=[];for(let I of h){let S=mu.filter(C=>kh(C,I)),x=b.find(({G:C})=>S.some(H=>C.has(H)));x||(x={G:new Set,V:[]},b.push(x)),x.V.push(I),n(x.G,S)}let w=b.flatMap(I=>tp(I.G));for(let{G:I,V:S}of b){let x=new Set(w.filter(C=>!I.has(C)));for(let C of S)g.set(C,x)}}ya=new Set;let u=new Set;const l=h=>ya.has(h)?u.add(h):ya.add(h);for(let h of mu){for(let g of h.P)l(g);for(let g of h.Q)l(g)}for(let h of ya)!Yc.has(h)&&!u.has(h)&&Yc.set(h,TC);n(ya,IC(ya)),Xx=fse(r).map(h=>Rse.from(h)).sort(pse),Ow=new Map;for(let h of Xx){let g=[Ow];for(let b of h){let w=g.map(I=>{let S=I.get(b);return S||(S=new Map,I.set(b,S)),S});b===kC?g.push(...w):g=w}for(let b of g)b.V=h}}function O_(r){return(CC(r)?"":`${N_(pg([r]))} `)+_C(r)}function N_(r){return`"${r}"‎`}function Ise(r){if(r.length>=4&&r[2]==Yx&&r[3]==Yx)throw new Error(`invalid label extension: "${Rl(r.slice(0,4))}"`)}function Sse(r){for(let t=r.lastIndexOf(95);t>0;)if(r[--t]!==95)throw new Error("underscore allowed only at start")}function kse(r){let e=r[0],t=Zx.get(e);if(t)throw Wf(`leading ${t}`);let n=r.length,i=-1;for(let s=1;s<n;s++){e=r[s];let o=Zx.get(e);if(o){if(i==s)throw Wf(`${t} + ${o}`);i=s+1,t=o}}if(i==n)throw Wf(`trailing ${t}`)}function pg(r,e=1/0,t=_C){let n=[];Tse(r[0])&&n.push("◌"),r.length>e&&(e>>=1,r=[...r.slice(0,e),8230,...r.slice(-e)]);let i=0,s=r.length;for(let o=0;o<s;o++){let a=r[o];CC(a)&&(n.push(Rl(r.slice(i,o))),n.push(t(a)),i=o+1)}return n.push(Rl(r.slice(i,s))),n.join("")}function Tse(r){return T_(),Ca.has(r)}function CC(r){return T_(),NC.has(r)}function Ose(r){return Pse(Nse(r,xse,Use))}function Nse(r,e,t){if(!r)return[];T_();let n=0;return r.split(SC).map(i=>{let s=dse(i),o={input:s,offset:n};n+=s.length+1;try{let a=o.tokens=Lse(s,e,t),u=a.length,l;if(!u)throw new Error("empty label");let h=o.output=a.flat();if(Sse(h),!(o.emoji=u>1||a[0].is_emoji)&&h.every(b=>b<128))Ise(h),l="ASCII";else{let b=a.flatMap(w=>w.is_emoji?[]:w);if(!b.length)l="Emoji";else{if(Ca.has(h[0]))throw Wf("leading combining mark");for(let S=1;S<u;S++){let x=a[S];if(!x.is_emoji&&Ca.has(x[0]))throw Wf(`emoji + combining mark: "${Rl(a[S-1])} + ${pg([x[0]])}"`)}kse(h);let w=tp(new Set(b)),[I]=Bse(w);Mse(I,b),Cse(I,w),l=I.N}}o.type=l}catch(a){o.error=a}return o})}function Cse(r,e){let t,n=[];for(let i of e){let s=Yc.get(i);if(s===TC)return;if(s){let o=s.M.get(i);if(t=t?t.filter(a=>o.has(a)):tp(o),!t.length)return}else n.push(i)}if(t){for(let i of t)if(n.every(s=>kh(i,s)))throw new Error(`whole-script confusable: ${r.N}/${i.N}`)}}function Bse(r){let e=mu;for(let t of r){let n=e.filter(i=>kh(i,t));if(!n.length)throw mu.some(i=>kh(i,t))?PC(e[0],t):BC(t);if(e=n,n.length==1)break}return e}function Pse(r){return r.map(({input:e,error:t,output:n})=>{if(t){let i=t.message;throw new Error(r.length==1?i:`Invalid label ${N_(pg(e,63))}: ${i}`)}return Rl(n)}).join(SC)}function BC(r){return new Error(`disallowed character: ${O_(r)}`)}function PC(r,e){let t=O_(e),n=mu.find(i=>i.P.has(e));return n&&(t=`${n.N} ${t}`),new Error(`illegal mixture: ${r.N} + ${t}`)}function Wf(r){return new Error(`illegal placement: ${r}`)}function Mse(r,e){for(let t of e)if(!kh(r,t))throw PC(r,t);if(r.M){let t=IC(e);for(let n=1,i=t.length;n<i;n++)if(Tw.has(t[n])){let s=n+1;for(let o;s<i&&Tw.has(o=t[s]);s++)for(let a=n;a<s;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${O_(o)}`);if(s-n>Qx)throw new Error(`excessive non-spacing marks: ${N_(pg(t.slice(n-1,s)))} (${s-n}/${Qx})`);n=s}}}function Lse(r,e,t){let n=[],i=[];for(r=r.slice().reverse();r.length;){let s=Dse(r);if(s)i.length&&(n.push(e(i)),i=[]),n.push(t(s));else{let o=r.pop();if(ya.has(o))i.push(o);else{let a=kw.get(o);if(a)i.push(...a);else if(!OC.has(o))throw BC(o)}}}return i.length&&n.push(e(i)),n}function Use(r){return r.filter(e=>e!=kC)}function Dse(r,e){let t=Ow,n,i=r.length;for(;i&&(t=t.get(r[--i]),!!t);){let{V:s}=t;s&&(n=s,r.length=i)}return n}const MC=new Uint8Array(32);MC.fill(0);function eR(r){return q(r.length!==0,"invalid ENS name; empty component","comp",r),r}function LC(r){const e=Js($se(r)),t=[];if(r.length===0)return t;let n=0;for(let i=0;i<e.length;i++)e[i]===46&&(t.push(eR(e.slice(n,i))),n=i+1);return q(n<e.length,"invalid ENS name; empty component","name",r),t.push(eR(e.slice(n))),t}function $se(r){try{if(r.length===0)throw new Error("empty label");return Ose(r)}catch(e){q(!1,`invalid ENS name (${e.message})`,"name",r)}}function Nw(r){q(typeof r=="string","invalid ENS name; not a string","name",r),q(r.length,"invalid ENS name (empty label)","name",r);let e=MC;const t=LC(r);for(;t.length;)e=Tr(Ir([e,Tr(t.pop())]));return Ce(e)}function Fse(r,e){const t=e;return q(t<=255,"DNS encoded label cannot exceed 255","length",t),Ce(Ir(LC(r).map(n=>{q(n.length<=t,`label ${JSON.stringify(r)} exceeds ${t} bytes`,"name",r);const i=new Uint8Array(n.length+1);return i.set(n,1),i[0]=i.length-1,i})))+"00"}function m1(r,e){return{address:Pt(r),storageKeys:e.map((t,n)=>(q(zt(t,32),"invalid slot",`storageKeys[${n}]`,t),t.toLowerCase()))}}function Bc(r){if(Array.isArray(r))return r.map((t,n)=>Array.isArray(t)?(q(t.length===2,"invalid slot set",`value[${n}]`,t),m1(t[0],t[1])):(q(t!=null&&typeof t=="object","invalid address-slot set","value",r),m1(t.address,t.storageKeys)));q(r!=null&&typeof r=="object","invalid access list","value",r);const e=Object.keys(r).map(t=>{const n=r[t].reduce((i,s)=>(i[s]=!0,i),{});return m1(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function Hse(r){let e;return typeof r=="string"?e=xh.computePublicKey(r,!1):e=r.publicKey,Pt(Tr("0x"+e.substring(4)).substring(26))}function zse(r,e){return Hse(xh.recoverPublicKey(r,e))}const $r=BigInt(0),Gse=BigInt(2),Kse=BigInt(27),jse=BigInt(28),Wse=BigInt(35),Vse=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),w1=4096*32;function tR(r,e){let t=r.toString(16);for(;t.length<2;)t="0"+t;return t+=jl(e).substring(4),"0x"+t}function gg(r){return r==="0x"?null:Pt(r)}function C_(r,e){try{return Bc(r)}catch(t){q(!1,t.message,e,r)}}function md(r,e){return r==="0x"?0:ct(r,e)}function Rr(r,e){if(r==="0x")return $r;const t=Me(r,e);return q(t<=Vse,"value exceeds uint size",e,t),t}function jt(r,e){const t=Me(r,"value"),n=mn(t);return q(n.length<=32,"value too large",`tx.${e}`,t),n}function B_(r){return Bc(r).map(e=>[e.address,e.storageKeys])}function qse(r,e){q(Array.isArray(r),`invalid ${e}`,"value",r);for(let t=0;t<r.length;t++)q(zt(r[t],32),"invalid ${ param } hash",`value[${t}]`,r[t]);return r}function Zse(r){const e=lg(r);q(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",r);const t={type:0,nonce:md(e[0],"nonce"),gasPrice:Rr(e[1],"gasPrice"),gasLimit:Rr(e[2],"gasLimit"),to:gg(e[3]),value:Rr(e[4],"value"),data:Ce(e[5]),chainId:$r};if(e.length===6)return t;const n=Rr(e[6],"v"),i=Rr(e[7],"r"),s=Rr(e[8],"s");if(i===$r&&s===$r)t.chainId=n;else{let o=(n-Wse)/Gse;o<$r&&(o=$r),t.chainId=o,q(o!==$r||n===Kse||n===jse,"non-canonical legacy v","v",e[6]),t.signature=Ni.from({r:wc(e[7],32),s:wc(e[8],32),v:n})}return t}function Qse(r,e){const t=[jt(r.nonce,"nonce"),jt(r.gasPrice||0,"gasPrice"),jt(r.gasLimit,"gasLimit"),r.to||"0x",jt(r.value,"value"),r.data];let n=$r;if(r.chainId!=$r)n=Me(r.chainId,"tx.chainId"),q(!e||e.networkV==null||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(r.signature){const s=r.signature.legacyChainId;s!=null&&(n=s)}if(!e)return n!==$r&&(t.push(mn(n)),t.push("0x"),t.push("0x")),bc(t);let i=BigInt(27+e.yParity);return n!==$r?i=Ni.getChainIdV(n,e.v):BigInt(e.v)!==i&&q(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(mn(i)),t.push(mn(e.r)),t.push(mn(e.s)),bc(t)}function P_(r,e){let t;try{if(t=md(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{q(!1,"invalid yParity","yParity",e[0])}const n=wc(e[1],32),i=wc(e[2],32),s=Ni.from({r:n,s:i,yParity:t});r.signature=s}function Jse(r){const e=lg(wt(r).slice(1));q(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",Ce(r));const t={type:2,chainId:Rr(e[0],"chainId"),nonce:md(e[1],"nonce"),maxPriorityFeePerGas:Rr(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Rr(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Rr(e[4],"gasLimit"),to:gg(e[5]),value:Rr(e[6],"value"),data:Ce(e[7]),accessList:C_(e[8],"accessList")};return e.length===9||P_(t,e.slice(9)),t}function Yse(r,e){const t=[jt(r.chainId,"chainId"),jt(r.nonce,"nonce"),jt(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),jt(r.maxFeePerGas||0,"maxFeePerGas"),jt(r.gasLimit,"gasLimit"),r.to||"0x",jt(r.value,"value"),r.data,B_(r.accessList||[])];return e&&(t.push(jt(e.yParity,"yParity")),t.push(mn(e.r)),t.push(mn(e.s))),Ir(["0x02",bc(t)])}function Xse(r){const e=lg(wt(r).slice(1));q(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",Ce(r));const t={type:1,chainId:Rr(e[0],"chainId"),nonce:md(e[1],"nonce"),gasPrice:Rr(e[2],"gasPrice"),gasLimit:Rr(e[3],"gasLimit"),to:gg(e[4]),value:Rr(e[5],"value"),data:Ce(e[6]),accessList:C_(e[7],"accessList")};return e.length===8||P_(t,e.slice(8)),t}function eoe(r,e){const t=[jt(r.chainId,"chainId"),jt(r.nonce,"nonce"),jt(r.gasPrice||0,"gasPrice"),jt(r.gasLimit,"gasLimit"),r.to||"0x",jt(r.value,"value"),r.data,B_(r.accessList||[])];return e&&(t.push(jt(e.yParity,"recoveryParam")),t.push(mn(e.r)),t.push(mn(e.s))),Ir(["0x01",bc(t)])}function toe(r){let e=lg(wt(r).slice(1)),t="3",n=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const s=e[1],o=e[2],a=e[3];q(Array.isArray(s),"invalid network format: blobs not an array","fields[1]",s),q(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),q(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),q(s.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),q(s.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let u=0;u<e[1].length;u++)n.push({data:s[u],commitment:o[u],proof:a[u]});e=e[0]}q(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",Ce(r));const i={type:3,chainId:Rr(e[0],"chainId"),nonce:md(e[1],"nonce"),maxPriorityFeePerGas:Rr(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Rr(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Rr(e[4],"gasLimit"),to:gg(e[5]),value:Rr(e[6],"value"),data:Ce(e[7]),accessList:C_(e[8],"accessList"),maxFeePerBlobGas:Rr(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),q(i.to!=null,`invalid address for transaction type: ${t}`,"data",r),q(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",r);for(let s=0;s<i.blobVersionedHashes.length;s++)q(zt(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",r);return e.length===11||P_(i,e.slice(11)),i}function roe(r,e,t){const n=[jt(r.chainId,"chainId"),jt(r.nonce,"nonce"),jt(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),jt(r.maxFeePerGas||0,"maxFeePerGas"),jt(r.gasLimit,"gasLimit"),r.to||Eh,jt(r.value,"value"),r.data,B_(r.accessList||[]),jt(r.maxFeePerBlobGas||0,"maxFeePerBlobGas"),qse(r.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(jt(e.yParity,"yParity")),n.push(mn(e.r)),n.push(mn(e.s)),t)?Ir(["0x03",bc([n,t.map(i=>i.data),t.map(i=>i.commitment),t.map(i=>i.proof)])]):Ir(["0x03",bc(n)])}var Hi,Nu,Cu,Bu,Pu,Mu,Lu,Uu,Du,$u,Fu,Hu,ja,Io,Ms,So,zu,d0;const Rs=class Rs{constructor(){se(this,zu);se(this,Hi);se(this,Nu);se(this,Cu);se(this,Bu);se(this,Pu);se(this,Mu);se(this,Lu);se(this,Uu);se(this,Du);se(this,$u);se(this,Fu);se(this,Hu);se(this,ja);se(this,Io);se(this,Ms);se(this,So);F(this,Hi,null),F(this,Nu,null),F(this,Bu,0),F(this,Pu,$r),F(this,Mu,null),F(this,Lu,null),F(this,Uu,null),F(this,Cu,"0x"),F(this,Du,$r),F(this,$u,$r),F(this,Fu,null),F(this,Hu,null),F(this,ja,null),F(this,Io,null),F(this,So,null),F(this,Ms,null)}get type(){return T(this,Hi)}set type(e){switch(e){case null:F(this,Hi,null);break;case 0:case"legacy":F(this,Hi,0);break;case 1:case"berlin":case"eip-2930":F(this,Hi,1);break;case 2:case"london":case"eip-1559":F(this,Hi,2);break;case 3:case"cancun":case"eip-4844":F(this,Hi,3);break;default:q(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=T(this,Nu);return e==null&&this.type===3?Eh:e}set to(e){F(this,Nu,e==null?null:Pt(e))}get nonce(){return T(this,Bu)}set nonce(e){F(this,Bu,ct(e,"value"))}get gasLimit(){return T(this,Pu)}set gasLimit(e){F(this,Pu,Me(e))}get gasPrice(){const e=T(this,Mu);return e==null&&(this.type===0||this.type===1)?$r:e}set gasPrice(e){F(this,Mu,e==null?null:Me(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=T(this,Lu);return e??(this.type===2||this.type===3?$r:null)}set maxPriorityFeePerGas(e){F(this,Lu,e==null?null:Me(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=T(this,Uu);return e??(this.type===2||this.type===3?$r:null)}set maxFeePerGas(e){F(this,Uu,e==null?null:Me(e,"maxFeePerGas"))}get data(){return T(this,Cu)}set data(e){F(this,Cu,Ce(e))}get value(){return T(this,Du)}set value(e){F(this,Du,Me(e,"value"))}get chainId(){return T(this,$u)}set chainId(e){F(this,$u,Me(e))}get signature(){return T(this,Fu)||null}set signature(e){F(this,Fu,e==null?null:Ni.from(e))}get accessList(){const e=T(this,Hu)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){F(this,Hu,e==null?null:Bc(e))}get maxFeePerBlobGas(){const e=T(this,ja);return e==null&&this.type===3?$r:e}set maxFeePerBlobGas(e){F(this,ja,e==null?null:Me(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=T(this,Io);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){q(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)q(zt(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}F(this,Io,e)}get blobs(){return T(this,So)==null?null:T(this,So).map(e=>Object.assign({},e))}set blobs(e){if(e==null){F(this,So,null);return}const t=[],n=[];for(let i=0;i<e.length;i++){const s=e[i];if(w_(s)){pe(T(this,Ms),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=wt(s);if(q(o.length<=w1,"blob is too large",`blobs[${i}]`,s),o.length!==w1){const l=new Uint8Array(w1);l.set(o),o=l}const a=T(this,Ms).blobToKzgCommitment(o),u=Ce(T(this,Ms).computeBlobKzgProof(o,a));t.push({data:Ce(o),commitment:Ce(a),proof:u}),n.push(tR(1,a))}else{const o=Ce(s.commitment);t.push({data:Ce(s.data),commitment:o,proof:Ce(s.proof)}),n.push(tR(1,o))}}F(this,So,t),F(this,Io,n)}get kzg(){return T(this,Ms)}set kzg(e){F(this,Ms,e)}get hash(){return this.signature==null?null:Tr(Ee(this,zu,d0).call(this,!0,!1))}get unsignedHash(){return Tr(this.unsignedSerialized)}get from(){return this.signature==null?null:zse(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:xh.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return Ee(this,zu,d0).call(this,!0,!0)}get unsignedSerialized(){return Ee(this,zu,d0).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,i=T(this,ja)!=null||T(this,Io);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&pe(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),pe(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),pe(this.type!==0||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const s=[];return this.type!=null?s.push(this.type):t?s.push(2):e?(s.push(1),n||s.push(0)):n?(s.push(1),s.push(2)):(i&&this.to||(s.push(0),s.push(1),s.push(2)),s.push(3)),s.sort(),s}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Rs.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new Rs;if(typeof e=="string"){const n=wt(e);if(n[0]>=127)return Rs.from(Zse(n));switch(n[0]){case 1:return Rs.from(Xse(n));case 2:return Rs.from(Jse(n));case 3:return Rs.from(toe(n))}pe(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Rs;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=Ni.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(q(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),q(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(q(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),q(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Hi=new WeakMap,Nu=new WeakMap,Cu=new WeakMap,Bu=new WeakMap,Pu=new WeakMap,Mu=new WeakMap,Lu=new WeakMap,Uu=new WeakMap,Du=new WeakMap,$u=new WeakMap,Fu=new WeakMap,Hu=new WeakMap,ja=new WeakMap,Io=new WeakMap,Ms=new WeakMap,So=new WeakMap,zu=new WeakSet,d0=function(e,t){pe(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=e?this.signature:null;switch(this.inferType()){case 0:return Qse(this,n);case 1:return eoe(this,n);case 2:return Yse(this,n);case 3:return roe(this,n,t?this.blobs:null)}pe(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let rp=Rs;const UC=new Uint8Array(32);UC.fill(0);const noe=BigInt(-1),DC=BigInt(0),$C=BigInt(1),ioe=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function soe(r){const e=wt(r),t=e.length%32;return t?Ir([e,UC.slice(t)]):Ce(e)}const ooe=sa($C,32),aoe=sa(DC,32),rR={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},b1=["name","version","chainId","verifyingContract","salt"];function nR(r){return function(e){return q(typeof e=="string",`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,e),e}}const coe={name:nR("name"),version:nR("version"),chainId:function(r){const e=Me(r,"domain.chainId");return q(e>=0,"invalid chain ID","domain.chainId",r),Number.isSafeInteger(e)?Number(e):au(e)},verifyingContract:function(r){try{return Pt(r).toLowerCase()}catch{}q(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",r)},salt:function(r){const e=wt(r,"domain.salt");return q(e.length===32,'invalid domain value "salt"',"domain.salt",r),Ce(e)}};function _1(r){{const e=r.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",n=parseInt(e[2]);q(n%8===0&&n!==0&&n<=256&&e[2]===String(n),"invalid numeric width","type",r);const i=Pf(ioe,t?n-1:n),s=t?(i+$C)*noe:DC;return function(o){const a=Me(o,"value");return q(a>=s&&a<=i,`value out-of-bounds for ${r}`,"value",a),sa(t?IN(a,256):a,32)}}}{const e=r.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return q(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",r),function(n){const i=wt(n);return q(i.length===t,`invalid length for ${r}`,"value",n),soe(n)}}}switch(r){case"address":return function(e){return wc(Pt(e),32)};case"bool":return function(e){return e?ooe:aoe};case"bytes":return function(e){return Tr(e)};case"string":return function(e){return _c(e)}}return null}function iR(r,e){return`${r}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}function r0(r){const e=r.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:r}}var Mh,Ls,Gu,up,FC;const Xn=class Xn{constructor(e){se(this,up);Q(this,"primaryType");se(this,Mh);se(this,Ls);se(this,Gu);F(this,Ls,new Map),F(this,Gu,new Map);const t=new Map,n=new Map,i=new Map,s={};Object.keys(e).forEach(u=>{s[u]=e[u].map(({name:l,type:h})=>{let{base:g,index:b}=r0(h);return g==="int"&&!e.int&&(g="int256"),g==="uint"&&!e.uint&&(g="uint256"),{name:l,type:g+(b||"")}}),t.set(u,new Set),n.set(u,[]),i.set(u,new Set)}),F(this,Mh,JSON.stringify(s));for(const u in s){const l=new Set;for(const h of s[u]){q(!l.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(u)}`,"types",e),l.add(h.name);const g=r0(h.type).base;q(g!==u,`circular type reference to ${JSON.stringify(g)}`,"types",e),!_1(g)&&(q(n.has(g),`unknown type ${JSON.stringify(g)}`,"types",e),n.get(g).push(u),t.get(u).add(g))}}const o=Array.from(n.keys()).filter(u=>n.get(u).length===0);q(o.length!==0,"missing primary type","types",e),q(o.length===1,`ambiguous primary types or unused types: ${o.map(u=>JSON.stringify(u)).join(", ")}`,"types",e),ze(this,{primaryType:o[0]});function a(u,l){q(!l.has(u),`circular type reference to ${JSON.stringify(u)}`,"types",e),l.add(u);for(const h of t.get(u))if(n.has(h)){a(h,l);for(const g of l)i.get(g).add(h)}l.delete(u)}a(this.primaryType,new Set);for(const[u,l]of i){const h=Array.from(l);h.sort(),T(this,Ls).set(u,iR(u,s[u])+h.map(g=>iR(g,s[g])).join(""))}}get types(){return JSON.parse(T(this,Mh))}getEncoder(e){let t=T(this,Gu).get(e);return t||(t=Ee(this,up,FC).call(this,e),T(this,Gu).set(e,t)),t}encodeType(e){const t=T(this,Ls).get(e);return q(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Tr(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(_1(e))return n(e,t);const i=r0(e).array;if(i)return q(i.count===-1||i.count===t.length,`array length mismatch; expected length ${i.count}`,"value",t),t.map(o=>this._visit(i.prefix,o,n));const s=this.types[e];if(s)return s.reduce((o,{name:a,type:u})=>(o[a]=this._visit(u,t[a],n),o),{});q(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Xn(e)}static getPrimaryType(e){return Xn.from(e).primaryType}static hashStruct(e,t,n){return Xn.from(t).hashStruct(e,n)}static hashDomain(e){const t=[];for(const n in e){if(e[n]==null)continue;const i=rR[n];q(i,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:i})}return t.sort((n,i)=>b1.indexOf(n.name)-b1.indexOf(i.name)),Xn.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,n){return Ir(["0x1901",Xn.hashDomain(e),Xn.from(t).hash(n)])}static hash(e,t,n){return Tr(Xn.encode(e,t,n))}static async resolveNames(e,t,n,i){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const s={};e.verifyingContract&&!zt(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=Xn.from(t);o.visit(n,(a,u)=>(a==="address"&&!zt(u,20)&&(s[u]="0x"),u));for(const a in s)s[a]=await i(a);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),n=o.visit(n,(a,u)=>a==="address"&&s[u]?s[u]:u),{domain:e,value:n}}static getPayload(e,t,n){Xn.hashDomain(e);const i={},s=[];b1.forEach(u=>{const l=e[u];l!=null&&(i[u]=coe[u](l),s.push({name:u,type:rR[u]}))});const o=Xn.from(t);t=o.types;const a=Object.assign({},t);return q(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=s,o.encode(n),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(n,(u,l)=>{if(u.match(/^bytes(\d*)/))return Ce(wt(l));if(u.match(/^u?int/))return Me(l).toString();switch(u){case"address":return l.toLowerCase();case"bool":return!!l;case"string":return q(typeof l=="string","invalid string","value",l),l}q(!1,"unsupported type","type",u)})}}};Mh=new WeakMap,Ls=new WeakMap,Gu=new WeakMap,up=new WeakSet,FC=function(e){{const i=_1(e);if(i)return i}const t=r0(e).array;if(t){const i=t.prefix,s=this.getEncoder(i);return o=>{q(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(s);return T(this,Ls).has(i)&&(a=a.map(Tr)),Tr(Ir(a))}}const n=this.types[e];if(n){const i=_c(T(this,Ls).get(e));return s=>{const o=n.map(({name:a,type:u})=>{const l=this.getEncoder(u)(s[a]);return T(this,Ls).has(u)?Tr(l):l});return o.unshift(i),Ir(o)}}q(!1,`unknown type: ${e}`,"type",e)};let np=Xn;function _n(r){const e=new Set;return r.forEach(t=>e.add(t)),Object.freeze(e)}const uoe="external public payable override",loe=_n(uoe.split(" ")),HC="constant external internal payable private public pure view override",foe=_n(HC.split(" ")),zC="constructor error event fallback function receive struct",GC=_n(zC.split(" ")),KC="calldata memory storage payable indexed",hoe=_n(KC.split(" ")),doe="tuple returns",poe=[zC,KC,doe,HC].join(" "),goe=_n(poe.split(" ")),yoe={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},moe=new RegExp("^(\\s*)"),woe=new RegExp("^([0-9]+)"),boe=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),jC=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),WC=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var jr,_i,Lh,Cw;const lp=class lp{constructor(e){se(this,Lh);se(this,jr);se(this,_i);F(this,jr,0),F(this,_i,e.slice())}get offset(){return T(this,jr)}get length(){return T(this,_i).length-T(this,jr)}clone(){return new lp(T(this,_i))}reset(){F(this,jr,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=Ee(this,Lh,Cw).call(this,T(this,jr)+1,e.match+1);return F(this,jr,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;T(this,jr)<e.match-1;){const n=this.peek().linkNext;t.push(Ee(this,Lh,Cw).call(this,T(this,jr)+1,n)),F(this,jr,n)}return F(this,jr,e.match+1),t}peek(){if(T(this,jr)>=T(this,_i).length)throw new Error("out-of-bounds");return T(this,_i)[T(this,jr)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return _f(this,jr)._++,e}toString(){const e=[];for(let t=T(this,jr);t<T(this,_i).length;t++){const n=T(this,_i)[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(" ")}>`}};jr=new WeakMap,_i=new WeakMap,Lh=new WeakSet,Cw=function(e=0,t=0){return new lp(T(this,_i).slice(e,t).map(n=>Object.freeze(Object.assign({},n,{match:n.match-e,linkBack:n.linkBack-e,linkNext:n.linkNext-e}))))};let Ci=lp;function ca(r){const e=[],t=o=>{const a=s<r.length?JSON.stringify(r[s]):"$EOI";throw new Error(`invalid token ${a} at ${s}: ${o}`)};let n=[],i=[],s=0;for(;s<r.length;){let o=r.substring(s),a=o.match(moe);a&&(s+=a[1].length,o=r.substring(s));const u={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(u);let l=yoe[o[0]]||"";if(l){if(u.type=l,u.text=o[0],s++,l==="OPEN_PAREN")n.push(e.length-1),i.push(e.length-1);else if(l=="CLOSE_PAREN")n.length===0&&t("no matching open bracket"),u.match=n.pop(),e[u.match].match=e.length-1,u.depth--,u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1;else if(l==="COMMA")u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1,i.push(e.length-1);else if(l==="OPEN_BRACKET")u.type="BRACKET";else if(l==="CLOSE_BRACKET"){let h=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const g=e.pop().text;h=g+h,e[e.length-1].value=ct(g)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=h}continue}if(a=o.match(boe),a){if(u.text=a[1],s+=u.text.length,goe.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(WC)){u.type="TYPE";continue}u.type="ID";continue}if(a=o.match(woe),a){u.text=a[1],u.type="NUMBER",s+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`)}return new Ci(e.map(o=>Object.freeze(o)))}function sR(r,e){let t=[];for(const n in e.keys())r.has(n)&&t.push(n);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function yg(r,e){if(e.peekKeyword(GC)){const t=e.pop().text;if(t!==r)throw new Error(`expected ${r}, got ${t}`)}return e.popType("ID")}function ro(r,e){const t=new Set;for(;;){const n=r.peekType("KEYWORD");if(n==null||e&&!e.has(n))break;if(r.pop(),t.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);t.add(n)}return Object.freeze(t)}function VC(r){let e=ro(r,foe);return sR(e,_n("constant payable nonpayable".split(" "))),sR(e,_n("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function Ys(r,e){return r.popParams().map(t=>Yr.from(t,e))}function qC(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return Me(r.pop().text);throw new Error("invalid gas")}return null}function Ac(r){if(r.length)throw new Error(`unexpected tokens at offset ${r.offset}: ${r.toString()}`)}const _oe=new RegExp(/^(.*)\[([0-9]*)\]$/);function oR(r){const e=r.match(WC);if(q(e,"invalid type","type",r),r==="uint")return"uint256";if(r==="int")return"int256";if(e[2]){const t=parseInt(e[2]);q(t!==0&&t<=32,"invalid bytes length","type",r)}else if(e[3]){const t=parseInt(e[3]);q(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",r)}return r}const sr={},Pn=Symbol.for("_ethers_internal"),aR="_ParamTypeInternal",cR="_ErrorInternal",uR="_EventInternal",lR="_ConstructorInternal",fR="_FallbackInternal",hR="_FunctionInternal",dR="_StructInternal";var Ku,p0;const ei=class ei{constructor(e,t,n,i,s,o,a,u){se(this,Ku);Q(this,"name");Q(this,"type");Q(this,"baseType");Q(this,"indexed");Q(this,"components");Q(this,"arrayLength");Q(this,"arrayChildren");if(ag(e,sr,"ParamType"),Object.defineProperty(this,Pn,{value:aR}),o&&(o=Object.freeze(o.slice())),i==="array"){if(a==null||u==null)throw new Error("")}else if(a!=null||u!=null)throw new Error("");if(i==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");ze(this,{name:t,type:n,baseType:i,indexed:s,components:o,arrayLength:a,arrayChildren:u})}format(e){if(e==null&&(e="sighash"),e==="json"){const n=this.name||"";if(this.isArray()){const s=JSON.parse(this.arrayChildren.format("json"));return s.name=n,s.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(s)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(s=>JSON.parse(s.format(e)))),JSON.stringify(i)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(n=>n.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return e.map(i=>n.arrayChildren.walk(i,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const n=this;return e.map((i,s)=>n.components[s].walk(i,t))}return t(this.type,e)}async walkAsync(e,t){const n=[],i=[e];return Ee(this,Ku,p0).call(this,n,e,t,s=>{i[0]=s}),n.length&&await Promise.all(n),i[0]}static from(e,t){if(ei.isParamType(e))return e;if(typeof e=="string")try{return ei.from(ca(e),t)}catch{q(!1,"invalid param type","obj",e)}else if(e instanceof Ci){let a="",u="",l=null;ro(e,_n(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(u="tuple",l=e.popParams().map(S=>ei.from(S)),a=`tuple(${l.map(S=>S.format()).join(",")})`):(a=oR(e.popType("TYPE")),u=a);let h=null,g=null;for(;e.length&&e.peekType("BRACKET");){const S=e.pop();h=new ei(sr,"",a,u,null,l,g,h),g=S.value,a+=S.text,u="array",l=null}let b=null;if(ro(e,hoe).has("indexed")){if(!t)throw new Error("");b=!0}const I=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new ei(sr,I,a,u,b,l,g,h)}const n=e.name;q(!n||typeof n=="string"&&n.match(jC),"invalid name","obj.name",n);let i=e.indexed;i!=null&&(q(t,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,o=s.match(_oe);if(o){const a=parseInt(o[2]||"-1"),u=ei.from({type:o[1],components:e.components});return new ei(sr,n||"",s,"array",i,null,a,u)}if(s==="tuple"||s.startsWith("tuple(")||s.startsWith("(")){const a=e.components!=null?e.components.map(l=>ei.from(l)):null;return new ei(sr,n||"",s,"tuple",i,a,null,null)}return s=oR(e.type),new ei(sr,n||"",s,s,i,null,null,null)}static isParamType(e){return e&&e[Pn]===aR}};Ku=new WeakSet,p0=function(e,t,n,i){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((u,l)=>{var h;Ee(h=o,Ku,p0).call(h,e,u,n,g=>{a[l]=g})}),i(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in t))throw new Error(`missing value for component ${u.name}`);return t[u.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((u,l)=>{var h;Ee(h=o[l],Ku,p0).call(h,e,u,n,g=>{a[l]=g})}),i(a);return}const s=n(this.type,t);s.then?e.push(async function(){i(await s)}()):i(s)};let Yr=ei;class vc{constructor(e,t,n){Q(this,"type");Q(this,"inputs");ag(e,sr,"Fragment"),n=Object.freeze(n.slice()),ze(this,{type:t,inputs:n})}static from(e){if(typeof e=="string"){try{vc.from(JSON.parse(e))}catch{}return vc.from(ca(e))}if(e instanceof Ci)switch(e.peekKeyword(GC)){case"constructor":return Zs.from(e);case"error":return Tn.from(e);case"event":return ts.from(e);case"fallback":case"receive":return Os.from(e);case"function":return rs.from(e);case"struct":return ac.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return Zs.from(e);case"error":return Tn.from(e);case"event":return ts.from(e);case"fallback":case"receive":return Os.from(e);case"function":return rs.from(e);case"struct":return ac.from(e)}pe(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}q(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return Zs.isFragment(e)}static isError(e){return Tn.isFragment(e)}static isEvent(e){return ts.isFragment(e)}static isFunction(e){return rs.isFragment(e)}static isStruct(e){return ac.isFragment(e)}}class mg extends vc{constructor(t,n,i,s){super(t,n,s);Q(this,"name");q(typeof i=="string"&&i.match(jC),"invalid identifier","name",i),s=Object.freeze(s.slice()),ze(this,{name:i})}}function Th(r,e){return"("+e.map(t=>t.format(r)).join(r==="full"?", ":",")+")"}class Tn extends mg{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,Pn,{value:cR})}get selector(){return _c(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Th(e,this.inputs)),t.join(" ")}static from(e){if(Tn.isFragment(e))return e;if(typeof e=="string")return Tn.from(ca(e));if(e instanceof Ci){const t=yg("error",e),n=Ys(e);return Ac(e),new Tn(sr,t,n)}return new Tn(sr,e.name,e.inputs?e.inputs.map(Yr.from):[])}static isFragment(e){return e&&e[Pn]===cR}}class ts extends mg{constructor(t,n,i,s){super(t,"event",n,i);Q(this,"anonymous");Object.defineProperty(this,Pn,{value:uR}),ze(this,{anonymous:s})}get topicHash(){return _c(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(t)))});const n=[];return t!=="sighash"&&n.push("event"),n.push(this.name+Th(t,this.inputs)),t!=="sighash"&&this.anonymous&&n.push("anonymous"),n.join(" ")}static getTopicHash(t,n){return n=(n||[]).map(s=>Yr.from(s)),new ts(sr,t,n,!1).topicHash}static from(t){if(ts.isFragment(t))return t;if(typeof t=="string")try{return ts.from(ca(t))}catch{q(!1,"invalid event fragment","obj",t)}else if(t instanceof Ci){const n=yg("event",t),i=Ys(t,!0),s=!!ro(t,_n(["anonymous"])).has("anonymous");return Ac(t),new ts(sr,n,i,s)}return new ts(sr,t.name,t.inputs?t.inputs.map(n=>Yr.from(n,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Pn]===uR}}class Zs extends vc{constructor(t,n,i,s,o){super(t,n,i);Q(this,"payable");Q(this,"gas");Object.defineProperty(this,Pn,{value:lR}),ze(this,{payable:s,gas:o})}format(t){if(pe(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(t)))});const n=[`constructor${Th(t,this.inputs)}`];return this.payable&&n.push("payable"),this.gas!=null&&n.push(`@${this.gas.toString()}`),n.join(" ")}static from(t){if(Zs.isFragment(t))return t;if(typeof t=="string")try{return Zs.from(ca(t))}catch{q(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Ci){ro(t,_n(["constructor"]));const n=Ys(t),i=!!ro(t,loe).has("payable"),s=qC(t);return Ac(t),new Zs(sr,"constructor",n,i,s)}return new Zs(sr,"constructor",t.inputs?t.inputs.map(Yr.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Pn]===lR}}class Os extends vc{constructor(t,n,i){super(t,"fallback",n);Q(this,"payable");Object.defineProperty(this,Pn,{value:fR}),ze(this,{payable:i})}format(t){const n=this.inputs.length===0?"receive":"fallback";if(t==="json"){const i=this.payable?"payable":"nonpayable";return JSON.stringify({type:n,stateMutability:i})}return`${n}()${this.payable?" payable":""}`}static from(t){if(Os.isFragment(t))return t;if(typeof t=="string")try{return Os.from(ca(t))}catch{q(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Ci){const n=t.toString(),i=t.peekKeyword(_n(["fallback","receive"]));if(q(i,"type must be fallback or receive","obj",n),t.popKeyword(_n(["fallback","receive"]))==="receive"){const u=Ys(t);return q(u.length===0,"receive cannot have arguments","obj.inputs",u),ro(t,_n(["payable"])),Ac(t),new Os(sr,[],!0)}let o=Ys(t);o.length?q(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(u=>u.format("minimal")).join(", ")):o=[Yr.from("bytes")];const a=VC(t);if(q(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),ro(t,_n(["returns"])).has("returns")){const u=Ys(t);q(u.length===1&&u[0].type==="bytes","invalid fallback outputs","obj.outputs",u.map(l=>l.format("minimal")).join(", "))}return Ac(t),new Os(sr,o,a==="payable")}if(t.type==="receive")return new Os(sr,[],!0);if(t.type==="fallback"){const n=[Yr.from("bytes")],i=t.stateMutability==="payable";return new Os(sr,n,i)}q(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Pn]===fR}}class rs extends mg{constructor(t,n,i,s,o,a){super(t,"function",n,s);Q(this,"constant");Q(this,"outputs");Q(this,"stateMutability");Q(this,"payable");Q(this,"gas");Object.defineProperty(this,Pn,{value:hR}),o=Object.freeze(o.slice()),ze(this,{constant:i==="view"||i==="pure",gas:a,outputs:o,payable:i==="payable",stateMutability:i})}get selector(){return _c(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(t))),outputs:this.outputs.map(i=>JSON.parse(i.format(t)))});const n=[];return t!=="sighash"&&n.push("function"),n.push(this.name+Th(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&n.push(this.stateMutability),this.outputs&&this.outputs.length&&(n.push("returns"),n.push(Th(t,this.outputs))),this.gas!=null&&n.push(`@${this.gas.toString()}`)),n.join(" ")}static getSelector(t,n){return n=(n||[]).map(s=>Yr.from(s)),new rs(sr,t,"view",n,[],null).selector}static from(t){if(rs.isFragment(t))return t;if(typeof t=="string")try{return rs.from(ca(t))}catch{q(!1,"invalid function fragment","obj",t)}else if(t instanceof Ci){const i=yg("function",t),s=Ys(t),o=VC(t);let a=[];ro(t,_n(["returns"])).has("returns")&&(a=Ys(t));const u=qC(t);return Ac(t),new rs(sr,i,o,s,a,u)}let n=t.stateMutability;return n==null&&(n="payable",typeof t.constant=="boolean"?(n="view",t.constant||(n="payable",typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable")),new rs(sr,t.name,n,t.inputs?t.inputs.map(Yr.from):[],t.outputs?t.outputs.map(Yr.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Pn]===hR}}class ac extends mg{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,Pn,{value:dR})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return ac.from(ca(e))}catch{q(!1,"invalid struct fragment","obj",e)}else if(e instanceof Ci){const t=yg("struct",e),n=Ys(e);return Ac(e),new ac(sr,t,n)}return new ac(sr,e.name,e.inputs?e.inputs.map(Yr.from):[])}static isFragment(e){return e&&e[Pn]===dR}}const Pi=new Map;Pi.set(0,"GENERIC_PANIC");Pi.set(1,"ASSERT_FALSE");Pi.set(17,"OVERFLOW");Pi.set(18,"DIVIDE_BY_ZERO");Pi.set(33,"ENUM_RANGE_ERROR");Pi.set(34,"BAD_STORAGE_DATA");Pi.set(49,"STACK_UNDERFLOW");Pi.set(50,"ARRAY_RANGE_ERROR");Pi.set(65,"OUT_OF_MEMORY");Pi.set(81,"UNINITIALIZED_FUNCTION_CALL");const Aoe=new RegExp(/^bytes([0-9]*)$/),voe=new RegExp(/^(u?int)([0-9]*)$/);let A1=null,pR=1024;function Eoe(r,e,t,n){let i="missing revert data",s=null;const o=null;let a=null;if(t){i="execution reverted";const l=wt(t);if(t=Ce(t),l.length===0)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(l.length%32!==4)i+=" (could not decode reason; invalid data length)";else if(Ce(l.slice(0,4))==="0x08c379a0")try{s=n.decode(["string"],l.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch{i+=" (could not decode reason; invalid string data)"}else if(Ce(l.slice(0,4))==="0x4e487b71")try{const h=Number(n.decode(["uint256"],l.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[h]},s=`Panic due to ${Pi.get(h)||"UNKNOWN"}(${h})`,i+=`: ${s}`}catch{i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const u={to:e.to?Pt(e.to):null,data:e.data||"0x"};return e.from&&(u.from=Pt(e.from)),Zt(i,"CALL_EXCEPTION",{action:r,data:t,reason:s,transaction:u,invocation:o,revert:a})}var ko,Xc;const fp=class fp{constructor(){se(this,ko)}getDefaultValue(e){const t=e.map(i=>Ee(this,ko,Xc).call(this,Yr.from(i)));return new t0(t,"_").defaultValue()}encode(e,t){EN(t.length,e.length,"types/values length mismatch");const n=e.map(o=>Ee(this,ko,Xc).call(this,Yr.from(o))),i=new t0(n,"_"),s=new ww;return i.encode(s,t),s.data}decode(e,t,n){const i=e.map(o=>Ee(this,ko,Xc).call(this,Yr.from(o)));return new t0(i,"_").decode(new bw(t,n,pR))}static _setDefaultMaxInflation(e){q(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),pR=e}static defaultAbiCoder(){return A1==null&&(A1=new fp),A1}static getBuiltinCallException(e,t,n){return Eoe(e,t,n,fp.defaultAbiCoder())}};ko=new WeakSet,Xc=function(e){if(e.isArray())return new Wie(Ee(this,ko,Xc).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new t0(e.components.map(n=>Ee(this,ko,Xc).call(this,n)),e.name);switch(e.baseType){case"address":return new Kie(e.name);case"bool":return new Vie(e.name);case"string":return new rse(e.name);case"bytes":return new qie(e.name);case"":return new Jie(e.name)}let t=e.type.match(voe);if(t){let n=parseInt(t[2]||"256");return q(n!==0&&n<=256&&n%8===0,"invalid "+t[1]+" bit length","param",e),new tse(n/8,t[1]==="int",e.name)}if(t=e.type.match(Aoe),t){let n=parseInt(t[1]);return q(n!==0&&n<=32,"invalid bytes length","param",e),new Zie(n,e.name)}q(!1,"invalid type","type",e.type)};let Oh=fp;class xoe{constructor(e,t,n){Q(this,"fragment");Q(this,"name");Q(this,"signature");Q(this,"topic");Q(this,"args");const i=e.name,s=e.format();ze(this,{fragment:e,name:i,signature:s,topic:t,args:n})}}class Roe{constructor(e,t,n,i){Q(this,"fragment");Q(this,"name");Q(this,"args");Q(this,"signature");Q(this,"selector");Q(this,"value");const s=e.name,o=e.format();ze(this,{fragment:e,name:s,args:n,signature:o,selector:t,value:i})}}class Ioe{constructor(e,t,n){Q(this,"fragment");Q(this,"name");Q(this,"args");Q(this,"signature");Q(this,"selector");const i=e.name,s=e.format();ze(this,{fragment:e,name:i,args:n,signature:s,selector:t})}}class gR{constructor(e){Q(this,"hash");Q(this,"_isIndexed");ze(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const yR={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},mR={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:r=>`reverted with reason string ${JSON.stringify(r)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:r=>{let e="unknown panic code";return r>=0&&r<=255&&yR[r.toString()]&&(e=yR[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${e})`}}};var zi,Gi,Ki,on,us,g0,y0;const xa=class xa{constructor(e){se(this,us);Q(this,"fragments");Q(this,"deploy");Q(this,"fallback");Q(this,"receive");se(this,zi);se(this,Gi);se(this,Ki);se(this,on);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,F(this,Ki,new Map),F(this,zi,new Map),F(this,Gi,new Map);const n=[];for(const o of t)try{n.push(vc.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}ze(this,{fragments:Object.freeze(n)});let i=null,s=!1;F(this,on,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let u;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}ze(this,{deploy:o});return;case"fallback":o.inputs.length===0?s=!0:(q(!i||o.payable!==i.payable,"conflicting fallback fragments",`fragments[${a}]`,o),i=o,s=i.payable);return;case"function":u=T(this,Ki);break;case"event":u=T(this,Gi);break;case"error":u=T(this,zi);break;default:return}const l=o.format();u.has(l)||u.set(l,o)}),this.deploy||ze(this,{deploy:Zs.from("constructor()")}),ze(this,{fallback:i,receive:s})}format(e){const t=e?"minimal":"full";return this.fragments.map(i=>i.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Oh.defaultAbiCoder()}getFunctionName(e){const t=Ee(this,us,g0).call(this,e,null,!1);return q(t,"no matching function","key",e),t.name}hasFunction(e){return!!Ee(this,us,g0).call(this,e,null,!1)}getFunction(e,t){return Ee(this,us,g0).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(T(this,Ki).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,Ki).get(i),n)}}getEventName(e){const t=Ee(this,us,y0).call(this,e,null,!1);return q(t,"no matching event","key",e),t.name}hasEvent(e){return!!Ee(this,us,y0).call(this,e,null,!1)}getEvent(e,t){return Ee(this,us,y0).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(T(this,Gi).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,Gi).get(i),n)}}getError(e,t){if(zt(e)){const i=e.toLowerCase();if(mR[i])return Tn.from(mR[i].signature);for(const s of T(this,zi).values())if(i===s.selector)return s;return null}if(e.indexOf("(")===-1){const i=[];for(const[s,o]of T(this,zi))s.split("(")[0]===e&&i.push(o);if(i.length===0)return e==="Error"?Tn.from("error Error(string)"):e==="Panic"?Tn.from("error Panic(uint256)"):null;if(i.length>1){const s=i.map(o=>JSON.stringify(o.format())).join(", ");q(!1,`ambiguous error description (i.e. ${s})`,"name",e)}return i[0]}if(e=Tn.from(e).format(),e==="Error(string)")return Tn.from("error Error(string)");if(e==="Panic(uint256)")return Tn.from("error Panic(uint256)");const n=T(this,zi).get(e);return n||null}forEachError(e){const t=Array.from(T(this,zi).keys());t.sort((n,i)=>n.localeCompare(i));for(let n=0;n<t.length;n++){const i=t[n];e(T(this,zi).get(i),n)}}_decodeParams(e,t){return T(this,on).decode(e,t)}_encodeParams(e,t){return T(this,on).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);q(n,"unknown error","fragment",e),e=n}return q(_r(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,_r(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);q(n,"unknown error","fragment",e),e=n}return Ir([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return q(_r(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,_r(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return Ir([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const s=this.getFunction(e);q(s,"unknown function","fragment",e),e=s}let n="invalid length for result data";const i=pn(t);if(i.length%32===0)try{return T(this,on).decode(e.outputs,i)}catch{n="could not decode result data"}pe(!1,n,"BAD_DATA",{value:Ce(i),info:{method:e.name,signature:e.format()}})}makeError(e,t){const n=wt(e,"data"),i=Oh.getBuiltinCallException("call",t,n);if(i.message.startsWith("execution reverted (unknown custom error)")){const a=Ce(n.slice(0,4)),u=this.getError(a);if(u)try{const l=T(this,on).decode(u.inputs,n.slice(4));i.revert={name:u.name,signature:u.format(),args:l},i.reason=i.revert.signature,i.message=`execution reverted: ${i.reason}`}catch{i.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(i.invocation={method:o.name,signature:o.signature,args:o.args}),i}encodeFunctionResult(e,t){if(typeof e=="string"){const n=this.getFunction(e);q(n,"unknown function","fragment",e),e=n}return Ce(T(this,on).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const s=this.getEvent(e);q(s,"unknown event","eventFragment",e),e=s}pe(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const n=[];e.anonymous||n.push(e.topicHash);const i=(s,o)=>s.type==="string"?_c(o):s.type==="bytes"?Tr(Ce(o)):(s.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":s.type.match(/^u?int/)?o=sa(o):s.type.match(/^bytes/)?o=Jre(o,32):s.type==="address"&&T(this,on).encode(["address"],[o]),wc(Ce(o),32));for(t.forEach((s,o)=>{const a=e.inputs[o];if(!a.indexed){q(s==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,s);return}s==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?q(!1,"filtering with tuples or arrays not supported","contract."+a.name,s):Array.isArray(s)?n.push(s.map(u=>i(a,u))):n.push(i(a,s))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);q(o,"unknown event","eventFragment",e),e=o}const n=[],i=[],s=[];return e.anonymous||n.push(e.topicHash),q(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const u=t[a];if(o.indexed)if(o.type==="string")n.push(_c(u));else if(o.type==="bytes")n.push(Tr(u));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(T(this,on).encode([o.type],[u]))}else i.push(o),s.push(u)}),{data:T(this,on).encode(i,s),topics:n}}decodeEventLog(e,t,n){if(typeof e=="string"){const w=this.getEvent(e);q(w,"unknown event","eventFragment",e),e=w}if(n!=null&&!e.anonymous){const w=e.topicHash;q(zt(n[0],32)&&n[0].toLowerCase()===w,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const i=[],s=[],o=[];e.inputs.forEach((w,I)=>{w.indexed?w.type==="string"||w.type==="bytes"||w.baseType==="tuple"||w.baseType==="array"?(i.push(Yr.from({type:"bytes32",name:w.name})),o.push(!0)):(i.push(w),o.push(!1)):(s.push(w),o.push(!1))});const a=n!=null?T(this,on).decode(i,Ir(n)):null,u=T(this,on).decode(s,t,!0),l=[],h=[];let g=0,b=0;return e.inputs.forEach((w,I)=>{let S=null;if(w.indexed)if(a==null)S=new gR(null);else if(o[I])S=new gR(a[b++]);else try{S=a[b++]}catch(x){S=x}else try{S=u[g++]}catch(x){S=x}l.push(S),h.push(w.name||null)}),_l.fromItems(l,h)}parseTransaction(e){const t=wt(e.data,"tx.data"),n=Me(e.value!=null?e.value:0,"tx.value"),i=this.getFunction(Ce(t.slice(0,4)));if(!i)return null;const s=T(this,on).decode(i.inputs,t.slice(4));return new Roe(i,i.selector,s,n)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new xoe(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=Ce(e),n=this.getError(_r(t,0,4));if(!n)return null;const i=T(this,on).decode(n.inputs,_r(t,4));return new Ioe(n,n.selector,i)}static from(e){return e instanceof xa?e:typeof e=="string"?new xa(JSON.parse(e)):typeof e.formatJson=="function"?new xa(e.formatJson()):typeof e.format=="function"?new xa(e.format("json")):new xa(e)}};zi=new WeakMap,Gi=new WeakMap,Ki=new WeakMap,on=new WeakMap,us=new WeakSet,g0=function(e,t,n){if(zt(e)){const s=e.toLowerCase();for(const o of T(this,Ki).values())if(s===o.selector)return o;return null}if(e.indexOf("(")===-1){const s=[];for(const[o,a]of T(this,Ki))o.split("(")[0]===e&&s.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,u=!0;ln.isTyped(o)&&o.type==="overrides"&&(u=!1,a--);for(let l=s.length-1;l>=0;l--){const h=s[l].inputs.length;h!==a&&(!u||h!==a-1)&&s.splice(l,1)}for(let l=s.length-1;l>=0;l--){const h=s[l].inputs;for(let g=0;g<t.length;g++)if(ln.isTyped(t[g])){if(g>=h.length){if(t[g].type==="overrides")continue;s.splice(l,1);break}if(t[g].type!==h[g].baseType){s.splice(l,1);break}}}}if(s.length===1&&t&&t.length!==s[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&s.splice(0,1)}if(s.length===0)return null;if(s.length>1&&n){const o=s.map(a=>JSON.stringify(a.format())).join(", ");q(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return s[0]}const i=T(this,Ki).get(rs.from(e).format());return i||null},y0=function(e,t,n){if(zt(e)){const s=e.toLowerCase();for(const o of T(this,Gi).values())if(s===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const s=[];for(const[o,a]of T(this,Gi))o.split("(")[0]===e&&s.push(a);if(t){for(let o=s.length-1;o>=0;o--)s[o].inputs.length<t.length&&s.splice(o,1);for(let o=s.length-1;o>=0;o--){const a=s[o].inputs;for(let u=0;u<t.length;u++)if(ln.isTyped(t[u])&&t[u].type!==a[u].baseType){s.splice(o,1);break}}}if(s.length===0)return null;if(s.length>1&&n){const o=s.map(a=>JSON.stringify(a.format())).join(", ");q(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return s[0]}const i=T(this,Gi).get(ts.from(e).format());return i||null};let Bw=xa;const ZC=BigInt(0);function wu(r){return r??null}function Er(r){return r==null?null:r.toString()}class wR{constructor(e,t,n){Q(this,"gasPrice");Q(this,"maxFeePerGas");Q(this,"maxPriorityFeePerGas");ze(this,{gasPrice:wu(e),maxFeePerGas:wu(t),maxPriorityFeePerGas:wu(n)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:Er(e),maxFeePerGas:Er(t),maxPriorityFeePerGas:Er(n)}}}function ip(r){const e={};r.to&&(e.to=r.to),r.from&&(e.from=r.from),r.data&&(e.data=Ce(r.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of t)!(i in r)||r[i]==null||(e[i]=Me(r[i],`request.${i}`));const n="type,nonce".split(/,/);for(const i of n)!(i in r)||r[i]==null||(e[i]=ct(r[i],`request.${i}`));return r.accessList&&(e.accessList=Bc(r.accessList)),"blockTag"in r&&(e.blockTag=r.blockTag),"enableCcipRead"in r&&(e.enableCcipRead=!!r.enableCcipRead),"customData"in r&&(e.customData=r.customData),"blobVersionedHashes"in r&&r.blobVersionedHashes&&(e.blobVersionedHashes=r.blobVersionedHashes.slice()),"kzg"in r&&(e.kzg=r.kzg),"blobs"in r&&r.blobs&&(e.blobs=r.blobs.map(i=>w_(i)?Ce(i):Object.assign({},i))),e}var Us;class Soe{constructor(e,t){Q(this,"provider");Q(this,"number");Q(this,"hash");Q(this,"timestamp");Q(this,"parentHash");Q(this,"parentBeaconBlockRoot");Q(this,"nonce");Q(this,"difficulty");Q(this,"gasLimit");Q(this,"gasUsed");Q(this,"stateRoot");Q(this,"receiptsRoot");Q(this,"blobGasUsed");Q(this,"excessBlobGas");Q(this,"miner");Q(this,"prevRandao");Q(this,"extraData");Q(this,"baseFeePerGas");se(this,Us);F(this,Us,e.transactions.map(n=>typeof n!="string"?new Nh(n,t):n)),ze(this,{provider:t,hash:wu(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:wu(e.prevRandao),extraData:e.extraData,baseFeePerGas:wu(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return T(this,Us).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=T(this,Us).slice();return e.length===0?[]:(pe(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:i,gasUsed:s,hash:o,miner:a,prevRandao:u,nonce:l,number:h,parentHash:g,parentBeaconBlockRoot:b,stateRoot:w,receiptsRoot:I,timestamp:S,transactions:x}=this;return{_type:"Block",baseFeePerGas:Er(e),difficulty:Er(t),extraData:n,gasLimit:Er(i),gasUsed:Er(s),blobGasUsed:Er(this.blobGasUsed),excessBlobGas:Er(this.excessBlobGas),hash:o,miner:a,prevRandao:u,nonce:l,number:h,parentHash:g,timestamp:S,parentBeaconBlockRoot:b,stateRoot:w,receiptsRoot:I,transactions:x}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Us).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=T(this,Us)[e];else{const n=e.toLowerCase();for(const i of T(this,Us))if(typeof i=="string"){if(i!==n)continue;t=i;break}else{if(i.hash!==n)continue;t=i;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const n of t)if(n.hash===e)return n;q(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return koe(this)}}Us=new WeakMap;class wd{constructor(e,t){Q(this,"provider");Q(this,"transactionHash");Q(this,"blockHash");Q(this,"blockNumber");Q(this,"removed");Q(this,"address");Q(this,"data");Q(this,"topics");Q(this,"index");Q(this,"transactionIndex");this.provider=t;const n=Object.freeze(e.topics.slice());ze(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:n,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:n,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:l}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return pe(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return pe(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return pe(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return Toe(this)}}var Uh;class QC{constructor(e,t){Q(this,"provider");Q(this,"to");Q(this,"from");Q(this,"contractAddress");Q(this,"hash");Q(this,"index");Q(this,"blockHash");Q(this,"blockNumber");Q(this,"logsBloom");Q(this,"gasUsed");Q(this,"blobGasUsed");Q(this,"cumulativeGasUsed");Q(this,"gasPrice");Q(this,"blobGasPrice");Q(this,"type");Q(this,"status");Q(this,"root");se(this,Uh);F(this,Uh,Object.freeze(e.logs.map(i=>new wd(i,t))));let n=ZC;e.effectiveGasPrice!=null?n=e.effectiveGasPrice:e.gasPrice!=null&&(n=e.gasPrice),ze(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return T(this,Uh)}toJSON(){const{to:e,from:t,contractAddress:n,hash:i,index:s,blockHash:o,blockNumber:a,logsBloom:u,logs:l,status:h,root:g}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:n,cumulativeGasUsed:Er(this.cumulativeGasUsed),from:t,gasPrice:Er(this.gasPrice),blobGasUsed:Er(this.blobGasUsed),blobGasPrice:Er(this.blobGasPrice),gasUsed:Er(this.gasUsed),hash:i,index:s,logs:l,logsBloom:u,root:g,status:h,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return YC(this)}reorderedEvent(e){return pe(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),JC(this,e)}}Uh=new WeakMap;var To;const G_=class G_{constructor(e,t){Q(this,"provider");Q(this,"blockNumber");Q(this,"blockHash");Q(this,"index");Q(this,"hash");Q(this,"type");Q(this,"to");Q(this,"from");Q(this,"nonce");Q(this,"gasLimit");Q(this,"gasPrice");Q(this,"maxPriorityFeePerGas");Q(this,"maxFeePerGas");Q(this,"maxFeePerBlobGas");Q(this,"data");Q(this,"value");Q(this,"chainId");Q(this,"signature");Q(this,"accessList");Q(this,"blobVersionedHashes");se(this,To);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,F(this,To,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:n,hash:i,type:s,to:o,from:a,nonce:u,data:l,signature:h,accessList:g,blobVersionedHashes:b}=this;return{_type:"TransactionResponse",accessList:g,blockNumber:e,blockHash:t,blobVersionedHashes:b,chainId:Er(this.chainId),data:l,from:a,gasLimit:Er(this.gasLimit),gasPrice:Er(this.gasPrice),hash:i,maxFeePerGas:Er(this.maxFeePerGas),maxPriorityFeePerGas:Er(this.maxPriorityFeePerGas),maxFeePerBlobGas:Er(this.maxFeePerBlobGas),nonce:u,signature:h,to:o,index:n,type:s,value:Er(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const n=await this.getTransaction();n&&(e=n.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:n}=await dn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:n-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const n=e??1,i=t??0;let s=T(this,To),o=-1,a=s===-1;const u=async()=>{if(a)return null;const{blockNumber:b,nonce:w}=await dn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(w<this.nonce){s=b;return}if(a)return null;const I=await this.getTransaction();if(!(I&&I.blockNumber!=null))for(o===-1&&(o=s-3,o<T(this,To)&&(o=T(this,To)));o<=b;){if(a)return null;const S=await this.provider.getBlock(o,!0);if(S==null)return;for(const x of S)if(x===this.hash)return;for(let x=0;x<S.length;x++){const C=await S.getTransaction(x);if(C.from===this.from&&C.nonce===this.nonce){if(a)return null;const H=await this.provider.getTransactionReceipt(C.hash);if(H==null||b-H.blockNumber+1<n)return;let D="replaced";C.data===this.data&&C.to===this.to&&C.value===this.value?D="repriced":C.data==="0x"&&C.from===C.to&&C.value===ZC&&(D="cancelled"),pe(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:D==="replaced"||D==="cancelled",reason:D,replacement:C.replaceableTransaction(s),hash:C.hash,receipt:H})}}o++}},l=b=>{if(b==null||b.status!==0)return b;pe(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:b.to,from:b.from,data:""},receipt:b})},h=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(h);if(h){if(await h.confirmations()>=n)return l(h)}else if(await u(),n===0)return null;return await new Promise((b,w)=>{const I=[],S=()=>{I.forEach(C=>C())};if(I.push(()=>{a=!0}),i>0){const C=setTimeout(()=>{S(),w(Zt("wait for transaction timeout","TIMEOUT"))},i);I.push(()=>{clearTimeout(C)})}const x=async C=>{if(await C.confirmations()>=n){S();try{b(l(C))}catch(H){w(H)}}};if(I.push(()=>{this.provider.off(this.hash,x)}),this.provider.on(this.hash,x),s>=0){const C=async()=>{try{await u()}catch(H){if(Zr(H,"TRANSACTION_REPLACED")){S(),w(H);return}}a||this.provider.once("block",C)};I.push(()=>{this.provider.off("block",C)}),this.provider.once("block",C)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return pe(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),YC(this)}reorderedEvent(e){return pe(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),pe(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),JC(this,e)}replaceableTransaction(e){q(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new G_(this,this.provider);return F(t,To,e),t}};To=new WeakMap;let Nh=G_;function koe(r){return{orphan:"drop-block",hash:r.hash,number:r.number}}function JC(r,e){return{orphan:"reorder-transaction",tx:r,other:e}}function YC(r){return{orphan:"drop-transaction",tx:r}}function Toe(r){return{orphan:"drop-log",log:{transactionHash:r.transactionHash,blockHash:r.blockHash,blockNumber:r.blockNumber,address:r.address,data:r.data,topics:Object.freeze(r.topics.slice()),index:r.index}}}class M_ extends wd{constructor(t,n,i){super(t,t.provider);Q(this,"interface");Q(this,"fragment");Q(this,"args");const s=n.decodeEventLog(i,t.data,t.topics);ze(this,{args:s,fragment:i,interface:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class XC extends wd{constructor(t,n){super(t,t.provider);Q(this,"error");ze(this,{error:n})}}var ju;class Ooe extends QC{constructor(t,n,i){super(i,n);se(this,ju);F(this,ju,t)}get logs(){return super.logs.map(t=>{const n=t.topics.length?T(this,ju).getEvent(t.topics[0]):null;if(n)try{return new M_(t,T(this,ju),n)}catch(i){return new XC(t,i)}return t})}}ju=new WeakMap;var Dh;class L_ extends Nh{constructor(t,n,i){super(i,n);se(this,Dh);F(this,Dh,t)}async wait(t,n){const i=await super.wait(t,n);return i==null?null:new Ooe(T(this,Dh),this.provider,i)}}Dh=new WeakMap;class e6 extends SN{constructor(t,n,i,s){super(t,n,i);Q(this,"log");ze(this,{log:s})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class Noe extends e6{constructor(e,t,n,i,s){super(e,t,n,new M_(s,e.interface,i));const o=e.interface.decodeEventLog(i,this.log.data,this.log.topics);ze(this,{args:o,fragment:i})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const bR=BigInt(0);function t6(r){return r&&typeof r.call=="function"}function r6(r){return r&&typeof r.estimateGas=="function"}function wg(r){return r&&typeof r.resolveName=="function"}function n6(r){return r&&typeof r.sendTransaction=="function"}function i6(r){if(r!=null){if(wg(r))return r;if(r.provider)return r.provider}}var $h;class Coe{constructor(e,t,n){se(this,$h);Q(this,"fragment");if(ze(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const i=Ec(e.runner,"resolveName"),s=wg(i)?i:null;F(this,$h,async function(){const o=await Promise.all(t.inputs.map((a,u)=>n[u]==null?null:a.walkAsync(n[u],(h,g)=>h==="address"?Array.isArray(g)?Promise.all(g.map(b=>bn(b,s))):bn(g,s):g)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return T(this,$h)}}$h=new WeakMap;function Ec(r,e){return r==null?null:typeof r[e]=="function"?r:r.provider&&typeof r.provider[e]=="function"?r.provider:null}function Ba(r){return r==null?null:r.provider||null}async function s6(r,e){const t=ln.dereference(r,"overrides");q(typeof t=="object","invalid overrides parameter","overrides",r);const n=ip(t);return q(n.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),q(n.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function Boe(r,e,t){const n=Ec(r,"resolveName"),i=wg(n)?n:null;return await Promise.all(e.map((s,o)=>s.walkAsync(t[o],(a,u)=>(u=ln.dereference(u,a),a==="address"?bn(u,i):u))))}function Poe(r){const e=async function(o){const a=await s6(o,["data"]);a.to=await r.getAddress(),a.from&&(a.from=await bn(a.from,i6(r.runner)));const u=r.interface,l=Me(a.value||bR,"overrides.value")===bR,h=(a.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!h&&!l&&q(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),q(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data);const g=u.receive||u.fallback&&u.fallback.payable;return q(g||l,"cannot send value to non-payable fallback","overrides.value",a.value),q(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=Ec(r.runner,"call");pe(t6(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await e(o);try{return await a.call(u)}catch(l){throw m_(l)&&l.data?r.interface.makeError(l.data,u):l}},n=async function(o){const a=r.runner;pe(n6(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await a.sendTransaction(await e(o)),l=Ba(r.runner);return new L_(r.interface,l,u)},i=async function(o){const a=Ec(r.runner,"estimateGas");return pe(r6(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},s=async o=>await n(o);return ze(s,{_contract:r,estimateGas:i,populateTransaction:e,send:n,staticCall:t}),s}function Moe(r,e){const t=function(...l){const h=r.interface.getFunction(e,l);return pe(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:l}}),h},n=async function(...l){const h=t(...l);let g={};if(h.inputs.length+1===l.length&&(g=await s6(l.pop()),g.from&&(g.from=await bn(g.from,i6(r.runner)))),h.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const b=await Boe(r.runner,h.inputs,l);return Object.assign({},g,await dn({to:r.getAddress(),data:r.interface.encodeFunctionData(h,b)}))},i=async function(...l){const h=await a(...l);return h.length===1?h[0]:h},s=async function(...l){const h=r.runner;pe(n6(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const g=await h.sendTransaction(await n(...l)),b=Ba(r.runner);return new L_(r.interface,b,g)},o=async function(...l){const h=Ec(r.runner,"estimateGas");return pe(r6(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await n(...l))},a=async function(...l){const h=Ec(r.runner,"call");pe(t6(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const g=await n(...l);let b="0x";try{b=await h.call(g)}catch(I){throw m_(I)&&I.data?r.interface.makeError(I.data,g):I}const w=t(...l);return r.interface.decodeFunctionResult(w,b)},u=async(...l)=>t(...l).constant?await i(...l):await s(...l);return ze(u,{name:r.interface.getFunctionName(e),_contract:r,_key:e,getFragment:t,estimateGas:o,populateTransaction:n,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=r.interface.getFunction(e);return pe(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),l}}),u}function Loe(r,e){const t=function(...i){const s=r.interface.getEvent(e,i);return pe(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:i}}),s},n=function(...i){return new Coe(r,t(...i),i)};return ze(n,{name:r.interface.getEventName(e),_contract:r,_key:e,getFragment:t}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const i=r.interface.getEvent(e);return pe(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),i}}),n}const sp=Symbol.for("_ethersInternal_contract"),o6=new WeakMap;function Uoe(r,e){o6.set(r[sp],e)}function Fn(r){return o6.get(r[sp])}function Doe(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function U_(r,e){let t,n=null;if(Array.isArray(e)){const s=function(o){if(zt(o,32))return o;const a=r.interface.getEvent(o);return q(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(s):s(o))}else e==="*"?t=[null]:typeof e=="string"?zt(e,32)?t=[e]:(n=r.interface.getEvent(e),q(n,"unknown fragment","event",e),t=[n.topicHash]):Doe(e)?t=await e.getTopicFilter():"fragment"in e?(n=e.fragment,t=[n.topicHash]):q(!1,"unknown event name","event",e);t=t.map(s=>{if(s==null)return null;if(Array.isArray(s)){const o=Array.from(new Set(s.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return s.toLowerCase()});const i=t.map(s=>s==null?"null":Array.isArray(s)?s.join("|"):s).join("&");return{fragment:n,tag:i,topics:t}}async function Uf(r,e){const{subs:t}=Fn(r);return t.get((await U_(r,e)).tag)||null}async function _R(r,e,t){const n=Ba(r.runner);pe(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:o}=await U_(r,t),{addr:a,subs:u}=Fn(r);let l=u.get(s);if(!l){const g={address:a||r,topics:o},b=x=>{let C=i;if(C==null)try{C=r.interface.getEvent(x.topics[0])}catch{}if(C){const H=C,D=i?r.interface.decodeEventLog(i,x.data,x.topics):[];Mw(r,t,D,z=>new Noe(r,z,t,H,x))}else Mw(r,t,[],H=>new e6(r,H,t,x))};let w=[];l={tag:s,listeners:[],start:()=>{w.length||w.push(n.on(g,b))},stop:async()=>{if(w.length==0)return;let x=w;w=[],await Promise.all(x),n.off(g,b)}},u.set(s,l)}return l}let Pw=Promise.resolve();async function $oe(r,e,t,n){await Pw;const i=await Uf(r,e);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter(({listener:o,once:a})=>{const u=Array.from(t);n&&u.push(n(a?null:o));try{o.call(r,...u)}catch{}return!a}),i.listeners.length===0&&(i.stop(),Fn(r).subs.delete(i.tag)),s>0}async function Mw(r,e,t,n){try{await Pw}catch{}const i=$oe(r,e,t,n);return Pw=i,await i}const n0=["then"];var PR;PR=sp;const Vf=class Vf{constructor(e,t,n,i){Q(this,"target");Q(this,"interface");Q(this,"runner");Q(this,"filters");Q(this,PR);Q(this,"fallback");q(typeof e=="string"||hC(e),"invalid value for Contract target","target",e),n==null&&(n=null);const s=Bw.from(t);ze(this,{target:e,runner:n,interface:s}),Object.defineProperty(this,sp,{value:{}});let o,a=null,u=null;if(i){const g=Ba(n);u=new L_(this.interface,g,i)}let l=new Map;if(typeof e=="string")if(zt(e))a=e,o=Promise.resolve(e);else{const g=Ec(n,"resolveName");if(!wg(g))throw Zt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=g.resolveName(e).then(b=>{if(b==null)throw Zt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return Fn(this).addr=b,b})}else o=e.getAddress().then(g=>{if(g==null)throw new Error("TODO");return Fn(this).addr=g,g});Uoe(this,{addrPromise:o,addr:a,deployTx:u,subs:l});const h=new Proxy({},{get:(g,b,w)=>{if(typeof b=="symbol"||n0.indexOf(b)>=0)return Reflect.get(g,b,w);try{return this.getEvent(b)}catch(I){if(!Zr(I,"INVALID_ARGUMENT")||I.argument!=="key")throw I}},has:(g,b)=>n0.indexOf(b)>=0?Reflect.has(g,b):Reflect.has(g,b)||this.interface.hasEvent(String(b))});return ze(this,{filters:h}),ze(this,{fallback:s.receive||s.fallback?Poe(this):null}),new Proxy(this,{get:(g,b,w)=>{if(typeof b=="symbol"||b in g||n0.indexOf(b)>=0)return Reflect.get(g,b,w);try{return g.getFunction(b)}catch(I){if(!Zr(I,"INVALID_ARGUMENT")||I.argument!=="key")throw I}},has:(g,b)=>typeof b=="symbol"||b in g||n0.indexOf(b)>=0?Reflect.has(g,b):g.interface.hasFunction(b)})}connect(e){return new Vf(this.target,this.interface,e)}attach(e){return new Vf(e,this.interface,this.runner)}async getAddress(){return await Fn(this).addrPromise}async getDeployedCode(){const e=Ba(this.runner);pe(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=Ba(this.runner);return pe(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((i,s)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return i(this);n.once("block",o)}catch(a){s(a)}};o()})}deploymentTransaction(){return Fn(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),Moe(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),Loe(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,n){t==null&&(t=0),n==null&&(n="latest");const{addr:i,addrPromise:s}=Fn(this),o=i||await s,{fragment:a,topics:u}=await U_(this,e),l={address:o,topics:u,fromBlock:t,toBlock:n},h=Ba(this.runner);return pe(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(l)).map(g=>{let b=a;if(b==null)try{b=this.interface.getEvent(g.topics[0])}catch{}if(b)try{return new M_(g,this.interface,b)}catch(w){return new XC(g,w)}return new wd(g,h)})}async on(e,t){const n=await _R(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){const n=await _R(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await Mw(this,e,t,null)}async listenerCount(e){if(e){const i=await Uf(this,e);return i?i.listeners.length:0}const{subs:t}=Fn(this);let n=0;for(const{listeners:i}of t.values())n+=i.length;return n}async listeners(e){if(e){const i=await Uf(this,e);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:t}=Fn(this);let n=[];for(const{listeners:i}of t.values())n=n.concat(i.map(({listener:s})=>s));return n}async off(e,t){const n=await Uf(this,e);if(!n)return this;if(t){const i=n.listeners.map(({listener:s})=>s).indexOf(t);i>=0&&n.listeners.splice(i,1)}return(t==null||n.listeners.length===0)&&(n.stop(),Fn(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){const t=await Uf(this,e);if(!t)return this;t.stop(),Fn(this).subs.delete(t.tag)}else{const{subs:t}=Fn(this);for(const{tag:n,stop:i}of t.values())i(),t.delete(n)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Vf{constructor(i,s=null){super(i,e,s)}}return t}static from(e,t,n){return n==null&&(n=null),new this(e,t,n)}};let Lw=Vf;function Foe(){return Lw}class bu extends Foe(){}function v1(r){return r.match(/^ipfs:\/\/ipfs\//i)?r=r.substring(12):r.match(/^ipfs:\/\//i)?r=r.substring(7):q(!1,"unsupported IPFS format","link",r),`https://gateway.ipfs.io/ipfs/${r}`}class Hoe{constructor(e){Q(this,"name");ze(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const a6=new RegExp("^(ipfs)://(.*)$","i"),AR=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),a6,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];var Oo,Wa,No,eu,hp,c6;const uu=class uu{constructor(e,t,n){se(this,No);Q(this,"provider");Q(this,"address");Q(this,"name");se(this,Oo);se(this,Wa);ze(this,{provider:e,address:t,name:n}),F(this,Oo,null),F(this,Wa,new bu(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return T(this,Oo)==null&&F(this,Oo,(async()=>{try{return await T(this,Wa).supportsInterface("0x9061b923")}catch(e){if(Zr(e,"CALL_EXCEPTION"))return!1;throw F(this,Oo,null),e}})()),await T(this,Oo)}async getAddress(e){if(e==null&&(e=60),e===60)try{const s=await Ee(this,No,eu).call(this,"addr(bytes32)");return s==null||s===Eh?null:s}catch(s){if(Zr(s,"CALL_EXCEPTION"))return null;throw s}if(e>=0&&e<2147483648){let s=e+2147483648;const o=await Ee(this,No,eu).call(this,"addr(bytes32,uint)",[s]);if(zt(o,20))return Pt(o)}let t=null;for(const s of this.provider.plugins)if(s instanceof Hoe&&s.supportsCoinType(e)){t=s;break}if(t==null)return null;const n=await Ee(this,No,eu).call(this,"addr(bytes32,uint)",[e]);if(n==null||n==="0x")return null;const i=await t.decodeAddress(e,n);if(i!=null)return i;pe(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){const t=await Ee(this,No,eu).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await Ee(this,No,eu).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const i=t[1]==="e3010170"?"ipfs":"ipns",s=parseInt(t[4],16);if(t[5].length===s*2)return`${i}://${ene("0x"+t[2])}`}const n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz://${n[1]}`;pe(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let n=0;n<AR.length;n++){const i=t.match(AR[n]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=v1(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=s==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:s,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const u=(i[2]||"").split("/");if(u.length!==2)return e.push({type:`!${s}caip`,value:i[2]||""}),{url:null,linkage:e};const l=u[1],h=new bu(u[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(s==="erc721"){const S=await h.ownerOf(l);if(a!==S)return e.push({type:"!owner",value:S}),{url:null,linkage:e};e.push({type:"owner",value:S})}else if(s==="erc1155"){const S=await h.balanceOf(a,l);if(!S)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:S.toString()})}let g=await h[o](l);if(g==null||g==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:g}),s==="erc1155"&&(g=g.replace("{id}",sa(l,32).substring(2)),e.push({type:"metadata-url-expanded",value:g})),g.match(/^ipfs:/i)&&(g=v1(g)),e.push({type:"metadata-url",value:g});let b={};const w=await new to(g).send();w.assertOk();try{b=w.bodyJson}catch{try{e.push({type:"!metadata",value:w.bodyText})}catch{const C=w.body;return C&&e.push({type:"!metadata",value:Ce(C)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!b)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(b)});let I=b.image;if(typeof I!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!I.match(/^(https:\/\/|data:)/i)){if(I.match(a6)==null)return e.push({type:"!imageUrl-ipfs",value:I}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:I}),I=v1(I)}return e.push({type:"url",value:I}),{linkage:e,url:I}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),n=t.getPlugin("org.ethers.plugins.network.Ens");return pe(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),n.address}static async fromName(e,t){var i;let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const s=await Ee(i=uu,hp,c6).call(i,e,n);if(s!=null){const o=new uu(e,s,t);return n!==t&&!await o.supportsWildcard()?null:o}n=n.split(".").slice(1).join(".")}}};Oo=new WeakMap,Wa=new WeakMap,No=new WeakSet,eu=async function(e,t){t=(t||[]).slice();const n=T(this,Wa).interface;t.unshift(Nw(this.name));let i=null;await this.supportsWildcard()&&(i=n.getFunction(e),pe(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[Fse(this.name,255),n.encodeFunctionData(i,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const s=await T(this,Wa)[e](...t);return i?n.decodeFunctionResult(i,s)[0]:s}catch(s){if(!Zr(s,"CALL_EXCEPTION"))throw s}return null},hp=new WeakSet,c6=async function(e,t){const n=await uu.getEnsAddress(e);try{const s=await new bu(n,["function resolver(bytes32) view returns (address)"],e).resolver(Nw(t),{enableCcipRead:!0});return s===Eh?null:s}catch(i){throw i}return null},se(uu,hp);let op=uu;const vR=BigInt(0);function pt(r,e){return function(t){return t==null?e:r(t)}}function bg(r,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(n=>r(n))}}function bd(r,e){return t=>{const n={};for(const i in r){let s=i;if(e&&i in e&&!(s in t)){for(const o of e[i])if(o in t){s=o;break}}try{const o=r[i](t[s]);o!==void 0&&(n[i]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";pe(!1,`invalid value for value.${i} (${a})`,"BAD_DATA",{value:t})}}return n}}function zoe(r){switch(r){case!0:case"true":return!0;case!1:case"false":return!1}q(!1,`invalid boolean; ${JSON.stringify(r)}`,"value",r)}function Sl(r){return q(zt(r,!0),"invalid data","value",r),r}function qr(r){return q(zt(r,32),"invalid hash","value",r),r}const Goe=bd({address:Pt,blockHash:qr,blockNumber:ct,data:Sl,index:ct,removed:pt(zoe,!1),topics:bg(qr),transactionHash:qr,transactionIndex:ct},{index:["logIndex"]});function Koe(r){return Goe(r)}const joe=bd({hash:pt(qr),parentHash:qr,parentBeaconBlockRoot:pt(qr,null),number:ct,timestamp:ct,nonce:pt(Sl),difficulty:Me,gasLimit:Me,gasUsed:Me,stateRoot:pt(qr,null),receiptsRoot:pt(qr,null),blobGasUsed:pt(Me,null),excessBlobGas:pt(Me,null),miner:pt(Pt),prevRandao:pt(qr,null),extraData:Sl,baseFeePerGas:pt(Me)},{prevRandao:["mixHash"]});function Woe(r){const e=joe(r);return e.transactions=r.transactions.map(t=>typeof t=="string"?t:u6(t)),e}const Voe=bd({transactionIndex:ct,blockNumber:ct,transactionHash:qr,address:Pt,topics:bg(qr),data:Sl,index:ct,blockHash:qr},{index:["logIndex"]});function qoe(r){return Voe(r)}const Zoe=bd({to:pt(Pt,null),from:pt(Pt,null),contractAddress:pt(Pt,null),index:ct,root:pt(Ce),gasUsed:Me,blobGasUsed:pt(Me,null),logsBloom:pt(Sl),blockHash:qr,hash:qr,logs:bg(qoe),blockNumber:ct,cumulativeGasUsed:Me,effectiveGasPrice:pt(Me),blobGasPrice:pt(Me,null),status:pt(ct),type:pt(ct,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function Qoe(r){return Zoe(r)}function u6(r){r.to&&Me(r.to)===vR&&(r.to="0x0000000000000000000000000000000000000000");const e=bd({hash:qr,index:pt(ct,void 0),type:t=>t==="0x"||t==null?0:ct(t),accessList:pt(Bc,null),blobVersionedHashes:pt(bg(qr,!0),null),blockHash:pt(qr,null),blockNumber:pt(ct,null),transactionIndex:pt(ct,null),from:Pt,gasPrice:pt(Me),maxPriorityFeePerGas:pt(Me),maxFeePerGas:pt(Me),maxFeePerBlobGas:pt(Me,null),gasLimit:Me,to:pt(Pt,null),value:Me,nonce:ct,data:Sl,creates:pt(Pt,null),chainId:pt(Me,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(r);if(e.to==null&&e.creates==null&&(e.creates=Gie(e)),(r.type===1||r.type===2)&&r.accessList==null&&(e.accessList=[]),r.signature?e.signature=Ni.from(r.signature):e.signature=Ni.from(r),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Me(e.blockHash)===vR&&(e.blockHash=null),e}const Joe="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class _d{constructor(e){Q(this,"name");ze(this,{name:e})}clone(){return new _d(this.name)}}class _g extends _d{constructor(t,n){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);Q(this,"effectiveBlock");Q(this,"txBase");Q(this,"txCreate");Q(this,"txDataZero");Q(this,"txDataNonzero");Q(this,"txAccessListStorageKey");Q(this,"txAccessListAddress");const i={effectiveBlock:t};function s(o,a){let u=(n||{})[o];u==null&&(u=a),q(typeof u=="number",`invalud value for ${o}`,"costs",n),i[o]=u}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),ze(this,i)}clone(){return new _g(this.effectiveBlock,this)}}class Ag extends _d{constructor(t,n){super("org.ethers.plugins.network.Ens");Q(this,"address");Q(this,"targetNetwork");ze(this,{address:t||Joe,targetNetwork:n??1})}clone(){return new Ag(this.address,this.targetNetwork)}}var Fh,Hh;class Yoe extends _d{constructor(t,n){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");se(this,Fh);se(this,Hh);F(this,Fh,t),F(this,Hh,n)}get url(){return T(this,Fh)}get processFunc(){return T(this,Hh)}clone(){return this}}Fh=new WeakMap,Hh=new WeakMap;const E1=new Map;var Wu,Vu,Co;const lu=class lu{constructor(e,t){se(this,Wu);se(this,Vu);se(this,Co);F(this,Wu,e),F(this,Vu,Me(t)),F(this,Co,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,Wu)}set name(e){F(this,Wu,e)}get chainId(){return T(this,Vu)}set chainId(e){F(this,Vu,Me(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Me(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Me(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Me(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(T(this,Co).values())}attachPlugin(e){if(T(this,Co).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,Co).set(e.name,e.clone()),this}getPlugin(e){return T(this,Co).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new lu(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new _g;let n=t.txBase;if(e.to==null&&(n+=t.txCreate),e.data)for(let i=2;i<e.data.length;i+=2)e.data.substring(i,i+2)==="00"?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){const i=Bc(e.accessList);for(const s in i)n+=t.txAccessListAddress+t.txAccessListStorageKey*i[s].storageKeys.length}return n}static from(e){if(Xoe(),e==null)return lu.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=E1.get(e);if(t)return t();if(typeof e=="bigint")return new lu("unknown",e);q(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){q(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new lu(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Ag(e.ensAddress,e.ensNetwork)),t}q(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const n=E1.get(e);n&&q(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",e),E1.set(e,t)}};Wu=new WeakMap,Vu=new WeakMap,Co=new WeakMap;let is=lu;function ER(r,e){const t=String(r);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${r}`);const n=t.split(".");if(n.length===1&&n.push(""),n.length!==2)throw new Error(`invalid gwei value: ${r}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let i=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||i++,n[1]=i.toString()}return BigInt(n[0]+n[1])}function xR(r){return new Yoe(r,async(e,t,n)=>{n.setHeader("User-Agent","ethers");let i;try{const[s,o]=await Promise.all([n.send(),e()]);i=s;const a=i.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:ER(a.maxFee,9),maxPriorityFeePerGas:ER(a.maxPriorityFee,9)}}catch(s){pe(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:i,error:s})}})}let RR=!1;function Xoe(){if(RR)return;RR=!0;function r(e,t,n){const i=function(){const s=new is(e,t);return n.ensNetwork!=null&&s.attachPlugin(new Ag(null,n.ensNetwork)),s.attachPlugin(new _g),(n.plugins||[]).forEach(o=>{s.attachPlugin(o)}),s};is.register(e,i),is.register(t,i),n.altNames&&n.altNames.forEach(s=>{is.register(s,i)})}r("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),r("ropsten",3,{ensNetwork:3}),r("rinkeby",4,{ensNetwork:4}),r("goerli",5,{ensNetwork:5}),r("kovan",42,{ensNetwork:42}),r("sepolia",11155111,{ensNetwork:11155111}),r("holesky",17e3,{ensNetwork:17e3}),r("classic",61,{}),r("classicKotti",6,{}),r("arbitrum",42161,{ensNetwork:1}),r("arbitrum-goerli",421613,{}),r("arbitrum-sepolia",421614,{}),r("base",8453,{ensNetwork:1}),r("base-goerli",84531,{}),r("base-sepolia",84532,{}),r("bnb",56,{ensNetwork:1}),r("bnbt",97,{}),r("linea",59144,{ensNetwork:1}),r("linea-goerli",59140,{}),r("linea-sepolia",59141,{}),r("matic",137,{ensNetwork:1,plugins:[xR("https://gasstation.polygon.technology/v2")]}),r("matic-amoy",80002,{}),r("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[xR("https://gasstation-testnet.polygon.technology/v2")]}),r("optimism",10,{ensNetwork:1,plugins:[]}),r("optimism-goerli",420,{}),r("optimism-sepolia",11155420,{}),r("xdai",100,{ensNetwork:1})}function Uw(r){return JSON.parse(JSON.stringify(r))}var Ds,ri,Bo,ji,qu,m0;class eae{constructor(e){se(this,qu);se(this,Ds);se(this,ri);se(this,Bo);se(this,ji);F(this,Ds,e),F(this,ri,null),F(this,Bo,4e3),F(this,ji,-2)}get pollingInterval(){return T(this,Bo)}set pollingInterval(e){F(this,Bo,e)}start(){T(this,ri)||(F(this,ri,T(this,Ds)._setTimeout(Ee(this,qu,m0).bind(this),T(this,Bo))),Ee(this,qu,m0).call(this))}stop(){T(this,ri)&&(T(this,Ds)._clearTimeout(T(this,ri)),F(this,ri,null))}pause(e){this.stop(),e&&F(this,ji,-2)}resume(){this.start()}}Ds=new WeakMap,ri=new WeakMap,Bo=new WeakMap,ji=new WeakMap,qu=new WeakSet,m0=async function(){try{const e=await T(this,Ds).getBlockNumber();if(T(this,ji)===-2){F(this,ji,e);return}if(e!==T(this,ji)){for(let t=T(this,ji)+1;t<=e;t++){if(T(this,ri)==null)return;await T(this,Ds).emit("block",t)}F(this,ji,e)}}catch{}T(this,ri)!=null&&F(this,ri,T(this,Ds)._setTimeout(Ee(this,qu,m0).bind(this),T(this,Bo)))};var Va,qa,Po;class D_{constructor(e){se(this,Va);se(this,qa);se(this,Po);F(this,Va,e),F(this,Po,!1),F(this,qa,t=>{this._poll(t,T(this,Va))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){T(this,Po)||(F(this,Po,!0),T(this,qa).call(this,-2),T(this,Va).on("block",T(this,qa)))}stop(){T(this,Po)&&(F(this,Po,!1),T(this,Va).off("block",T(this,qa)))}pause(e){this.stop()}resume(){this.start()}}Va=new WeakMap,qa=new WeakMap,Po=new WeakMap;var Zu,$s;class tae extends D_{constructor(t,n){super(t);se(this,Zu);se(this,$s);F(this,Zu,n),F(this,$s,-2)}pause(t){t&&F(this,$s,-2),super.pause(t)}async _poll(t,n){const i=await n.getBlock(T(this,Zu));i!=null&&(T(this,$s)===-2?F(this,$s,i.number):i.number>T(this,$s)&&(n.emit(T(this,Zu),i.number),F(this,$s,i.number)))}}Zu=new WeakMap,$s=new WeakMap;var dp;class rae extends D_{constructor(t,n){super(t);se(this,dp);F(this,dp,Uw(n))}async _poll(t,n){throw new Error("@TODO")}}dp=new WeakMap;var Qu;class nae extends D_{constructor(t,n){super(t);se(this,Qu);F(this,Qu,n)}async _poll(t,n){const i=await n.getTransactionReceipt(T(this,Qu));i&&n.emit(T(this,Qu),i)}}Qu=new WeakMap;var Fs,Ju,Yu,Mo,ni,pp,l6;class $_{constructor(e,t){se(this,pp);se(this,Fs);se(this,Ju);se(this,Yu);se(this,Mo);se(this,ni);F(this,Fs,e),F(this,Ju,Uw(t)),F(this,Yu,Ee(this,pp,l6).bind(this)),F(this,Mo,!1),F(this,ni,-2)}start(){T(this,Mo)||(F(this,Mo,!0),T(this,ni)===-2&&T(this,Fs).getBlockNumber().then(e=>{F(this,ni,e)}),T(this,Fs).on("block",T(this,Yu)))}stop(){T(this,Mo)&&(F(this,Mo,!1),T(this,Fs).off("block",T(this,Yu)))}pause(e){this.stop(),e&&F(this,ni,-2)}resume(){this.start()}}Fs=new WeakMap,Ju=new WeakMap,Yu=new WeakMap,Mo=new WeakMap,ni=new WeakMap,pp=new WeakSet,l6=async function(e){if(T(this,ni)===-2)return;const t=Uw(T(this,Ju));t.fromBlock=T(this,ni)+1,t.toBlock=e;const n=await T(this,Fs).getLogs(t);if(n.length===0){T(this,ni)<e-60&&F(this,ni,e-60);return}for(const i of n)T(this,Fs).emit(T(this,Ju),i),F(this,ni,i.blockNumber)};const iae=BigInt(2),sae=10;function i0(r){return r&&typeof r.then=="function"}function w0(r,e){return r+":"+JSON.stringify(e,(t,n)=>{if(n==null)return"null";if(typeof n=="bigint")return`bigint:${n.toString()}`;if(typeof n=="string")return n.toLowerCase();if(typeof n=="object"&&!Array.isArray(n)){const i=Object.keys(n);return i.sort(),i.reduce((s,o)=>(s[o]=n[o],s),{})}return n})}class ap{constructor(e){Q(this,"name");ze(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function oae(r){return JSON.parse(JSON.stringify(r))}function Dw(r){return r=Array.from(new Set(r).values()),r.sort(),r}async function x1(r,e){if(r==null)throw new Error("invalid event");if(Array.isArray(r)&&(r={topics:r}),typeof r=="string")switch(r){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:r,tag:r}}if(zt(r,32)){const t=r.toLowerCase();return{type:"transaction",tag:w0("tx",{hash:t}),hash:t}}if(r.orphan){const t=r;return{type:"orphan",tag:w0("orphan",t),filter:oae(t)}}if(r.address||r.topics){const t=r,n={topics:(t.topics||[]).map(i=>i==null?null:Array.isArray(i)?Dw(i.map(s=>s.toLowerCase())):i.toLowerCase())};if(t.address){const i=[],s=[],o=a=>{zt(a)?i.push(a):s.push((async()=>{i.push(await bn(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),s.length&&await Promise.all(s),n.address=Dw(i.map(a=>a.toLowerCase()))}return{filter:n,tag:w0("event",n),type:"event"}}q(!1,"unknown ProviderEvent","event",r)}function R1(){return new Date().getTime()}const aae={cacheTimeout:250,pollingInterval:4e3};var an,Lo,cn,Xu,Kn,Za,Uo,Hs,zh,ii,el,tl,at,Un,$w,Fw,Df,Hw,$f,b0;class cae{constructor(e,t){se(this,at);se(this,an);se(this,Lo);se(this,cn);se(this,Xu);se(this,Kn);se(this,Za);se(this,Uo);se(this,Hs);se(this,zh);se(this,ii);se(this,el);se(this,tl);if(F(this,tl,Object.assign({},aae,t||{})),e==="any")F(this,Za,!0),F(this,Kn,null);else if(e){const n=is.from(e);F(this,Za,!1),F(this,Kn,Promise.resolve(n)),setTimeout(()=>{this.emit("network",n,null)},0)}else F(this,Za,!1),F(this,Kn,null);F(this,Hs,-1),F(this,Uo,new Map),F(this,an,new Map),F(this,Lo,new Map),F(this,cn,null),F(this,Xu,!1),F(this,zh,1),F(this,ii,new Map),F(this,el,!1)}get pollingInterval(){return T(this,tl).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Lo).values())}attachPlugin(e){if(T(this,Lo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,Lo).set(e.name,e.connect(this)),this}getPlugin(e){return T(this,Lo).get(e)||null}get disableCcipRead(){return T(this,el)}set disableCcipRead(e){F(this,el,!!e)}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;const i=e.to.toLowerCase(),s=t.toLowerCase(),o=[];for(let a=0;a<n.length;a++){const u=n[a],l=u.replace("{sender}",i).replace("{data}",s),h=new to(l);u.indexOf("{data}")===-1&&(h.body={data:s,sender:i}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:a,urls:n});let g="unknown error",b;try{b=await h.send()}catch(w){o.push(w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:w}});continue}try{const w=b.bodyJson;if(w.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:w}),w.data;w.message&&(g=w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:w})}catch{}pe(b.statusCode<400||b.statusCode>=500,`response not found during CCIP fetch: ${g}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:u,errorMessage:g}}),o.push(g)}pe(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:n,errorMessages:o}})}_wrapBlock(e,t){return new Soe(Woe(e),this)}_wrapLog(e,t){return new wd(Koe(e),this)}_wrapTransactionReceipt(e,t){return new QC(Qoe(e),this)}_wrapTransactionResponse(e,t){return new Nh(u6(e),this)}_detectNetwork(){pe(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){pe(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=ct(await Ee(this,at,Un).call(this,{method:"getBlockNumber"}),"%response");return T(this,Hs)>=0&&F(this,Hs,e),e}_getAddress(e){return bn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(zt(e))return zt(e,32)?e:au(e);if(typeof e=="bigint"&&(e=ct(e,"blockTag")),typeof e=="number")return e>=0?au(e):T(this,Hs)>=0?au(T(this,Hs)+e):this.getBlockNumber().then(t=>au(t+e));q(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(u=>u==null?null:Array.isArray(u)?Dw(u.map(l=>l.toLowerCase())):u.toLowerCase()),n="blockHash"in e?e.blockHash:void 0,i=(u,l,h)=>{let g;switch(u.length){case 0:break;case 1:g=u[0];break;default:u.sort(),g=u}if(n&&(l!=null||h!=null))throw new Error("invalid filter");const b={};return g&&(b.address=g),t.length&&(b.topics=t),l&&(b.fromBlock=l),h&&(b.toBlock=h),n&&(b.blockHash=n),b};let s=[];if(e.address)if(Array.isArray(e.address))for(const u of e.address)s.push(this._getAddress(u));else s.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),s.filter(u=>typeof u!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(s),o,a]).then(u=>i(u[0],u[1],u[2])):i(s,o,a)}_getTransactionRequest(e){const t=ip(e),n=[];if(["to","from"].forEach(i=>{if(t[i]==null)return;const s=bn(t[i],this);i0(s)?n.push(async function(){t[i]=await s}()):t[i]=s}),t.blockTag!=null){const i=this._getBlockTag(t.blockTag);i0(i)?n.push(async function(){t.blockTag=await i}()):t.blockTag=i}return n.length?async function(){return await Promise.all(n),t}():t}async getNetwork(){if(T(this,Kn)==null){const i=(async()=>{try{const s=await this._detectNetwork();return this.emit("network",s,null),s}catch(s){throw T(this,Kn)===i&&F(this,Kn,null),s}})();return F(this,Kn,i),(await i).clone()}const e=T(this,Kn),[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(T(this,Za)?(this.emit("network",n,t),T(this,Kn)===e&&F(this,Kn,Promise.resolve(n))):pe(!1,`network changed: ${t.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:i,gasPrice:s,priorityFee:o}=await dn({_block:Ee(this,at,Hw).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await Ee(this,at,Un).call(this,{method:"getGasPrice"});return Me(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await Ee(this,at,Un).call(this,{method:"getPriorityFee"});return Me(h,"%response")}catch{}return null})()});let a=null,u=null;const l=this._wrapBlock(i,e);return l&&l.baseFeePerGas&&(u=o??BigInt("1000000000"),a=l.baseFeePerGas*iae+u),new wR(s,a,u)},n=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const i=new to(n.url),s=await n.processFunc(t,this,i);return new wR(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return i0(t)&&(t=await t),Me(await Ee(this,at,Un).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:n}=await dn({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await Ee(this,at,Fw).call(this,Ee(this,at,$w).call(this,t,n,e.enableCcipRead?0:-1))}async getBalance(e,t){return Me(await Ee(this,at,Df).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return ct(await Ee(this,at,Df).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return Ce(await Ee(this,at,Df).call(this,{method:"getCode"},e,t))}async getStorage(e,t,n){const i=Me(t,"position");return Ce(await Ee(this,at,Df).call(this,{method:"getStorage",position:i},e,n))}async broadcastTransaction(e){const{blockNumber:t,hash:n,network:i}=await dn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),s=rp.from(e);if(s.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(s,i).replaceableTransaction(t)}async getBlock(e,t){const{network:n,params:i}=await dn({network:this.getNetwork(),params:Ee(this,at,Hw).call(this,e,!!t)});return i==null?null:this._wrapBlock(i,n)}async getTransaction(e){const{network:t,params:n}=await dn({network:this.getNetwork(),params:Ee(this,at,Un).call(this,{method:"getTransaction",hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){const{network:t,params:n}=await dn({network:this.getNetwork(),params:Ee(this,at,Un).call(this,{method:"getTransactionReceipt",hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const i=await Ee(this,at,Un).call(this,{method:"getTransaction",hash:e});if(i==null)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=i.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){const{result:t}=await dn({network:this.getNetwork(),result:Ee(this,at,Un).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:Ce(t)}async getLogs(e){let t=this._getFilter(e);i0(t)&&(t=await t);const{network:n,params:i}=await dn({network:this.getNetwork(),params:Ee(this,at,Un).call(this,{method:"getLogs",filter:t})});return i.map(s=>this._wrapLog(s,n))}_getProvider(e){pe(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await op.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=Pt(e);const t=Nw(e.substring(2).toLowerCase()+".addr.reverse");try{const n=await op.getEnsAddress(this),s=await new bu(n,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(s==null||s===Eh)return null;const a=await new bu(s,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(n){if(Zr(n,"BAD_DATA")&&n.value==="0x"||Zr(n,"CALL_EXCEPTION"))return null;throw n}return null}async waitForTransaction(e,t,n){const i=t??1;return i===0?this.getTransactionReceipt(e):new Promise(async(s,o)=>{let a=null;const u=async l=>{try{const h=await this.getTransactionReceipt(e);if(h!=null&&l-h.blockNumber+1>=i){s(h),a&&(clearTimeout(a),a=null);return}}catch(h){console.log("EEE",h)}this.once("block",u)};n!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",u),o(Zt("timeout","TIMEOUT",{reason:"timeout"})))},n)),u(await this.getBlockNumber())})}async waitForBlock(e){pe(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=T(this,ii).get(e);t&&(t.timer&&clearTimeout(t.timer),T(this,ii).delete(e))}_setTimeout(e,t){t==null&&(t=0);const n=_f(this,zh)._++,i=()=>{T(this,ii).delete(n),e()};if(this.paused)T(this,ii).set(n,{timer:null,func:i,time:t});else{const s=setTimeout(i,t);T(this,ii).set(n,{timer:s,func:i,time:R1()})}return n}_forEachSubscriber(e){for(const t of T(this,an).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new ap(e.type);case"block":{const t=new eae(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new tae(this,e.type);case"event":return new $_(this,e.filter);case"transaction":return new nae(this,e.hash);case"orphan":return new rae(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const n of T(this,an).values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),T(this,cn)!=null&&t.pause(T(this,cn));break}}async on(e,t){const n=await Ee(this,at,b0).call(this,e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,T(this,cn)!=null&&n.subscriber.pause(T(this,cn))),this}async once(e,t){const n=await Ee(this,at,b0).call(this,e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,T(this,cn)!=null&&n.subscriber.pause(T(this,cn))),this}async emit(e,...t){const n=await Ee(this,at,$f).call(this,e,t);if(!n||n.listeners.length===0)return!1;const i=n.listeners.length;return n.listeners=n.listeners.filter(({listener:s,once:o})=>{const a=new SN(this,o?null:s,e);try{s.call(this,...t,a)}catch{}return!o}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),T(this,an).delete(n.tag)),i>0}async listenerCount(e){if(e){const n=await Ee(this,at,$f).call(this,e);return n?n.listeners.length:0}let t=0;for(const{listeners:n}of T(this,an).values())t+=n.length;return t}async listeners(e){if(e){const n=await Ee(this,at,$f).call(this,e);return n?n.listeners.map(({listener:i})=>i):[]}let t=[];for(const{listeners:n}of T(this,an).values())t=t.concat(n.map(({listener:i})=>i));return t}async off(e,t){const n=await Ee(this,at,$f).call(this,e);if(!n)return this;if(t){const i=n.listeners.map(({listener:s})=>s).indexOf(t);i>=0&&n.listeners.splice(i,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),T(this,an).delete(n.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:n,subscriber:i}=await Ee(this,at,b0).call(this,e);n&&i.stop(),T(this,an).delete(t)}else for(const[t,{started:n,subscriber:i}]of T(this,an))n&&i.stop(),T(this,an).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return T(this,Xu)}destroy(){this.removeAllListeners();for(const e of T(this,ii).keys())this._clearTimeout(e);F(this,Xu,!0)}get paused(){return T(this,cn)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(F(this,Hs,-1),T(this,cn)!=null){if(T(this,cn)==!!e)return;pe(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),F(this,cn,!!e);for(const t of T(this,ii).values())t.timer&&clearTimeout(t.timer),t.time=R1()-t.time}resume(){if(T(this,cn)!=null){this._forEachSubscriber(e=>e.resume()),F(this,cn,null);for(const e of T(this,ii).values()){let t=e.time;t<0&&(t=0),e.time=R1(),setTimeout(e.func,t)}}}}an=new WeakMap,Lo=new WeakMap,cn=new WeakMap,Xu=new WeakMap,Kn=new WeakMap,Za=new WeakMap,Uo=new WeakMap,Hs=new WeakMap,zh=new WeakMap,ii=new WeakMap,el=new WeakMap,tl=new WeakMap,at=new WeakSet,Un=async function(e){const t=T(this,tl).cacheTimeout;if(t<0)return await this._perform(e);const n=w0(e.method,e);let i=T(this,Uo).get(n);return i||(i=this._perform(e),T(this,Uo).set(n,i),setTimeout(()=>{T(this,Uo).get(n)===i&&T(this,Uo).delete(n)},t)),await i},$w=async function(e,t,n){pe(n<sae,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const i=ip(e);try{return Ce(await this._perform({method:"call",transaction:i,blockTag:t}))}catch(s){if(!this.disableCcipRead&&m_(s)&&s.data&&n>=0&&t==="latest"&&i.to!=null&&_r(s.data,0,4)==="0x556f1830"){const o=s.data,a=await bn(i.to,this);let u;try{u=dae(_r(s.data,4))}catch(g){pe(!1,g.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:i,info:{data:o}})}pe(u.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:i,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:u.errorArgs}});const l=await this.ccipReadFetch(i,u.calldata,u.urls);pe(l!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:i,info:{data:s.data,errorArgs:u.errorArgs}});const h={to:a,data:Ir([u.selector,hae([l,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const g=await Ee(this,at,$w).call(this,h,t,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:g}),g}catch(g){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:g}),g}}throw s}},Fw=async function(e){const{value:t}=await dn({network:this.getNetwork(),value:e});return t},Df=async function(e,t,n){let i=this._getAddress(t),s=this._getBlockTag(n);return(typeof i!="string"||typeof s!="string")&&([i,s]=await Promise.all([i,s])),await Ee(this,at,Fw).call(this,Ee(this,at,Un).call(this,Object.assign(e,{address:i,blockTag:s})))},Hw=async function(e,t){if(zt(e,32))return await Ee(this,at,Un).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!="string"&&(n=await n),await Ee(this,at,Un).call(this,{method:"getBlock",blockTag:n,includeTransactions:t})},$f=async function(e,t){let n=await x1(e,this);return n.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(n=await x1({orphan:"drop-log",log:t[0]},this)),T(this,an).get(n.tag)||null},b0=async function(e){const t=await x1(e,this),n=t.tag;let i=T(this,an).get(n);return i||(i={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,an).set(n,i)),i};function uae(r,e){try{const t=zw(r,e);if(t)return Z0(t)}catch{}return null}function zw(r,e){if(r==="0x")return null;try{const t=ct(_r(r,e,e+32)),n=ct(_r(r,t,t+32));return _r(r,t+32,t+32+n)}catch{}return null}function IR(r){const e=mn(r);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function lae(r){if(r.length%32===0)return r;const e=new Uint8Array(Math.ceil(r.length/32)*32);return e.set(r),e}const fae=new Uint8Array([]);function hae(r){const e=[];let t=0;for(let n=0;n<r.length;n++)e.push(fae),t+=32;for(let n=0;n<r.length;n++){const i=wt(r[n]);e[n]=IR(t),e.push(IR(i.length)),e.push(lae(i)),t+=32+Math.ceil(i.length/32)*32}return Ir(e)}const SR="0x0000000000000000000000000000000000000000000000000000000000000000";function dae(r){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};pe(yu(r)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=_r(r,0,32);pe(_r(t,0,12)===_r(SR,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=_r(t,12);try{const n=[],i=ct(_r(r,32,64)),s=ct(_r(r,i,i+32)),o=_r(r,i+32);for(let a=0;a<s;a++){const u=uae(o,a*32);if(u==null)throw new Error("abort");n.push(u)}e.urls=n}catch{pe(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=zw(r,64);if(n==null)throw new Error("abort");e.calldata=n}catch{pe(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}pe(_r(r,100,128)===_r(SR,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=_r(r,96,100);try{const n=zw(r,128);if(n==null)throw new Error("abort");e.extraData=n}catch{pe(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(n=>e[n]),e}function Vc(r,e){if(r.provider)return r.provider;pe(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function kR(r,e){let t=ip(e);if(t.to!=null&&(t.to=bn(t.to,r)),t.from!=null){const n=t.from;t.from=Promise.all([r.getAddress(),bn(n,r)]).then(([i,s])=>(q(i.toLowerCase()===s.toLowerCase(),"transaction from mismatch","tx.from",s),i))}else t.from=r.getAddress();return await dn(t)}class pae{constructor(e){Q(this,"provider");ze(this,{provider:e||null})}async getNonce(e){return Vc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await kR(this,e)}async populateTransaction(e){const t=Vc(this,"populateTransaction"),n=await kR(this,e);n.nonce==null&&(n.nonce=await this.getNonce("pending")),n.gasLimit==null&&(n.gasLimit=await this.estimateGas(n));const i=await this.provider.getNetwork();if(n.chainId!=null){const o=Me(n.chainId);q(o===i.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else n.chainId=i.chainId;const s=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||s)?q(!1,"eip-1559 transaction do not support gasPrice","tx",e):(n.type===0||n.type===1)&&s&&q(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){const o=await t.getFeeData();pe(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(n.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(n.type=2,n.gasPrice!=null){const a=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=a,n.maxPriorityFeePerGas=a}else n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(pe(!s,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice),n.type=0):pe(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(n.type===2||n.type===3)&&(n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await dn(n)}async estimateGas(e){return Vc(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Vc(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Vc(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Vc(this,"sendTransaction"),n=await this.populateTransaction(e);delete n.from;const i=rp.from(n);return await t.broadcastTransaction(await this.signTransaction(i))}}function gae(r){return JSON.parse(JSON.stringify(r))}var hn,Wi,Qa,Do,Ja,rl,oa,Gw,Kw;class f6{constructor(e){se(this,oa);se(this,hn);se(this,Wi);se(this,Qa);se(this,Do);se(this,Ja);se(this,rl);F(this,hn,e),F(this,Wi,null),F(this,Qa,Ee(this,oa,Gw).bind(this)),F(this,Do,!1),F(this,Ja,null),F(this,rl,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){T(this,Do)||(F(this,Do,!0),Ee(this,oa,Gw).call(this,-2))}stop(){T(this,Do)&&(F(this,Do,!1),F(this,rl,!0),Ee(this,oa,Kw).call(this),T(this,hn).off("block",T(this,Qa)))}pause(e){e&&Ee(this,oa,Kw).call(this),T(this,hn).off("block",T(this,Qa))}resume(){this.start()}}hn=new WeakMap,Wi=new WeakMap,Qa=new WeakMap,Do=new WeakMap,Ja=new WeakMap,rl=new WeakMap,oa=new WeakSet,Gw=async function(e){try{T(this,Wi)==null&&F(this,Wi,this._subscribe(T(this,hn)));let t=null;try{t=await T(this,Wi)}catch(s){if(!Zr(s,"UNSUPPORTED_OPERATION")||s.operation!=="eth_newFilter")throw s}if(t==null){F(this,Wi,null),T(this,hn)._recoverSubscriber(this,this._recover(T(this,hn)));return}const n=await T(this,hn).getNetwork();if(T(this,Ja)||F(this,Ja,n),T(this,Ja).chainId!==n.chainId)throw new Error("chaid changed");if(T(this,rl))return;const i=await T(this,hn).send("eth_getFilterChanges",[t]);await this._emitResults(T(this,hn),i)}catch(t){console.log("@TODO",t)}T(this,hn).once("block",T(this,Qa))},Kw=function(){const e=T(this,Wi);e&&(F(this,Wi,null),e.then(t=>{T(this,hn).destroyed||T(this,hn).send("eth_uninstallFilter",[t])}))};var Ya;class yae extends f6{constructor(t,n){super(t);se(this,Ya);F(this,Ya,gae(n))}_recover(t){return new $_(t,T(this,Ya))}async _subscribe(t){return await t.send("eth_newFilter",[T(this,Ya)])}async _emitResults(t,n){for(const i of n)t.emit(T(this,Ya),t._wrapLog(i,t._network))}}Ya=new WeakMap;class mae extends f6{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const n of t)e.emit("pending",n)}}const wae="bigint,boolean,function,number,string,symbol".split(/,/g);function _0(r){if(r==null||wae.indexOf(typeof r)>=0||typeof r.getAddress=="function")return r;if(Array.isArray(r))return r.map(_0);if(typeof r=="object")return Object.keys(r).reduce((e,t)=>(e[t]=r[t],e),{});throw new Error(`should not happen: ${r} (${typeof r})`)}function bae(r){return new Promise(e=>{setTimeout(e,r)})}function qc(r){return r&&r.toLowerCase()}function TR(r){return r&&typeof r.pollingInterval=="number"}const h6={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class I1 extends pae{constructor(t,n){super(t);Q(this,"address");n=Pt(n),ze(this,{address:n})}connect(t){pe(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const n=_0(t),i=[];if(n.from){const o=n.from;i.push((async()=>{const a=await bn(o,this.provider);q(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=a})())}else n.from=this.address;if(n.gasLimit==null&&i.push((async()=>{n.gasLimit=await this.provider.estimateGas({...n,from:this.address})})()),n.to!=null){const o=n.to;i.push((async()=>{n.to=await bn(o,this.provider)})())}i.length&&await Promise.all(i);const s=this.provider.getRpcTransaction(n);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(t){const n=await this.provider.getBlockNumber(),i=await this.sendUncheckedTransaction(t);return await new Promise((s,o)=>{const a=[1e3,100];let u=0;const l=async()=>{try{const h=await this.provider.getTransaction(i);if(h!=null){s(h.replaceableTransaction(n));return}}catch(h){if(Zr(h,"CANCELLED")||Zr(h,"BAD_DATA")||Zr(h,"NETWORK_ERROR")||Zr(h,"UNSUPPORTED_OPERATION")){h.info==null&&(h.info={}),h.info.sendTransactionHash=i,o(h);return}if(Zr(h,"INVALID_ARGUMENT")&&(u++,h.info==null&&(h.info={}),h.info.sendTransactionHash=i,u>10)){o(h);return}this.provider.emit("error",Zt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{l()},a.pop()||4e3)};l()})}async signTransaction(t){const n=_0(t);if(n.from){const s=await bn(n.from,this.provider);q(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=s}else n.from=this.address;const i=this.provider.getRpcTransaction(n);return await this.provider.send("eth_signTransaction",[i])}async signMessage(t){const n=typeof t=="string"?Js(t):t;return await this.provider.send("personal_sign",[Ce(n),this.address.toLowerCase()])}async signTypedData(t,n,i){const s=_0(i),o=await np.resolveNames(t,n,s,async a=>{const u=await bn(a);return q(u!=null,"TypedData does not support null address","value",a),u});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(np.getPayload(o.domain,n,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const n=typeof t=="string"?Js(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),Ce(n)])}}var Xa,nl,zs,Vi,Ai,si,Rn,Gh,jw;class d6 extends cae{constructor(t,n){super(t,n);se(this,Gh);se(this,Xa);se(this,nl);se(this,zs);se(this,Vi);se(this,Ai);se(this,si);se(this,Rn);F(this,nl,1),F(this,Xa,Object.assign({},h6,n||{})),F(this,zs,[]),F(this,Vi,null),F(this,si,null),F(this,Rn,null);{let s=null;const o=new Promise(a=>{s=a});F(this,Ai,{promise:o,resolve:s})}const i=this._getOption("staticNetwork");typeof i=="boolean"?(q(!i||t!=="any","staticNetwork cannot be used on special network 'any'","options",n),i&&t!=null&&F(this,si,is.from(t))):i&&(q(t==null||i.matches(t),"staticNetwork MUST match network object","options",n),F(this,si,i))}_getOption(t){return T(this,Xa)[t]}get _network(){return pe(T(this,si),"network is not available yet","NETWORK_ERROR"),T(this,si)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let i=t.transaction;if(i&&i.type!=null&&Me(i.type)&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},i,{type:void 0})}))}}const n=this.getRpcRequest(t);return n!=null?await this.send(n.method,n.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(T(this,si))return T(this,si)}else return t;return T(this,Rn)?await T(this,Rn):this.ready?(F(this,Rn,(async()=>{try{const n=is.from(Me(await this.send("eth_chainId",[])));return F(this,Rn,null),n}catch(n){throw F(this,Rn,null),n}})()),await T(this,Rn)):(F(this,Rn,(async()=>{const n={id:_f(this,nl)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:n});let i;try{i=(await this._send(n))[0],F(this,Rn,null)}catch(s){throw F(this,Rn,null),this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:i}),"result"in i)return is.from(Me(i.result));throw this.getRpcError(n,i)})()),await T(this,Rn))}_start(){T(this,Ai)==null||T(this,Ai).resolve==null||(T(this,Ai).resolve(),F(this,Ai,null),(async()=>{for(;T(this,si)==null&&!this.destroyed;)try{F(this,si,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Zt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await bae(1e3)}Ee(this,Gh,jw).call(this)})())}async _waitUntilReady(){if(T(this,Ai)!=null)return await T(this,Ai).promise}_getSubscriber(t){return t.type==="pending"?new mae(this):t.type==="event"?this._getOption("polling")?new $_(this,t.filter):new yae(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new ap("orphan"):super._getSubscriber(t)}get ready(){return T(this,Ai)==null}getRpcTransaction(t){const n={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(i=>{if(t[i]==null)return;let s=i;i==="gasLimit"&&(s="gas"),n[s]=au(Me(t[i],`tx.${i}`))}),["from","to","data"].forEach(i=>{t[i]!=null&&(n[i]=Ce(t[i]))}),t.accessList&&(n.accessList=Bc(t.accessList)),t.blobVersionedHashes&&(n.blobVersionedHashes=t.blobVersionedHashes.map(i=>i.toLowerCase())),n}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[qc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[qc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[qc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[qc(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(qc):t.filter.address=qc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,n){const{method:i}=t,{error:s}=n;if(i==="eth_estimateGas"&&s.message){const u=s.message;if(!u.match(/revert/i)&&u.match(/insufficient funds/i))return Zt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:s}})}if(i==="eth_call"||i==="eth_estimateGas"){const u=Ww(s),l=Oh.getBuiltinCallException(i==="eth_call"?"call":"estimateGas",t.params[0],u?u.data:null);return l.info={error:s,payload:t},l}const o=JSON.stringify(vae(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Zt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[i]||"unknown",reason:"rejected",info:{payload:t,error:s}});if(i==="eth_sendRawTransaction"||i==="eth_sendTransaction"){const u=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Zt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:u,info:{error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Zt("nonce has already been used","NONCE_EXPIRED",{transaction:u,info:{error:s}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Zt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:u,info:{error:s}});if(o.match(/only replay-protected/i))return Zt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:i,info:{transaction:u,info:{error:s}}})}let a=!!o.match(/the method .* does not exist/i);return a||s&&s.details&&s.details.startsWith("Unauthorized method:")&&(a=!0),a?Zt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:s,payload:t}}):Zt("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:t})}send(t,n){if(this.destroyed)return Promise.reject(Zt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const i=_f(this,nl)._++,s=new Promise((o,a)=>{T(this,zs).push({resolve:o,reject:a,payload:{method:t,params:n,id:i,jsonrpc:"2.0"}})});return Ee(this,Gh,jw).call(this),s}async getSigner(t){t==null&&(t=0);const n=this.send("eth_accounts",[]);if(typeof t=="number"){const s=await n;if(t>=s.length)throw new Error("no such account");return new I1(this,s[t])}const{accounts:i}=await dn({network:this.getNetwork(),accounts:n});t=Pt(t);for(const s of i)if(Pt(s)===t)return new I1(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(n=>new I1(this,n))}destroy(){T(this,Vi)&&(clearTimeout(T(this,Vi)),F(this,Vi,null));for(const{payload:t,reject:n}of T(this,zs))n(Zt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));F(this,zs,[]),super.destroy()}}Xa=new WeakMap,nl=new WeakMap,zs=new WeakMap,Vi=new WeakMap,Ai=new WeakMap,si=new WeakMap,Rn=new WeakMap,Gh=new WeakSet,jw=function(){if(T(this,Vi))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");F(this,Vi,setTimeout(()=>{F(this,Vi,null);const n=T(this,zs);for(F(this,zs,[]);n.length;){const i=[n.shift()];for(;n.length&&i.length!==T(this,Xa).batchMaxCount;)if(i.push(n.shift()),JSON.stringify(i.map(o=>o.payload)).length>T(this,Xa).batchMaxSize){n.unshift(i.pop());break}(async()=>{const s=i.length===1?i[0].payload:i.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:s});try{const o=await this._send(s);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:u,payload:l}of i){if(this.destroyed){u(Zt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:l.method}));continue}const h=o.filter(g=>g.id===l.id)[0];if(h==null){const g=Zt("missing response for request","BAD_DATA",{value:o,info:{payload:l}});this.emit("error",g),u(g);continue}if("error"in h){u(this.getRpcError(l,h));continue}a(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of i)a(o)}})()}},t))};var $o;class _ae extends d6{constructor(t,n){super(t,n);se(this,$o);let i=this._getOption("pollingInterval");i==null&&(i=h6.pollingInterval),F(this,$o,i)}_getSubscriber(t){const n=super._getSubscriber(t);return TR(n)&&(n.pollingInterval=T(this,$o)),n}get pollingInterval(){return T(this,$o)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");F(this,$o,t),this._forEachSubscriber(n=>{TR(n)&&(n.pollingInterval=T(this,$o))})}}$o=new WeakMap;var il;class Aae extends _ae{constructor(t,n,i){t==null&&(t="http://localhost:8545");super(n,i);se(this,il);typeof t=="string"?F(this,il,new to(t)):F(this,il,t.clone())}_getConnection(){return T(this,il).clone()}async send(t,n){return await this._start(),await super.send(t,n)}async _send(t){const n=this._getConnection();n.body=JSON.stringify(t),n.setHeader("content-type","application/json");const i=await n.send();i.assertOk();let s=i.bodyJson;return Array.isArray(s)||(s=[s]),s}}il=new WeakMap;function Ww(r){if(r==null)return null;if(typeof r.message=="string"&&r.message.match(/revert/i)&&zt(r.data))return{message:r.message,data:r.data};if(typeof r=="object"){for(const e in r){const t=Ww(r[e]);if(t)return t}return null}if(typeof r=="string")try{return Ww(JSON.parse(r))}catch{}return null}function Vw(r,e){if(r!=null){if(typeof r.message=="string"&&e.push(r.message),typeof r=="object")for(const t in r)Vw(r[t],e);if(typeof r=="string")try{return Vw(JSON.parse(r),e)}catch{}}}function vae(r){const e=[];return Vw(r,e),e}function Eae(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof ul<"u")return ul;throw new Error("unable to locate global object")}const xae=Eae().WebSocket;var qi,Kh,Fo,ec,Ho;class F_{constructor(e,t){se(this,qi);se(this,Kh);se(this,Fo);se(this,ec);se(this,Ho);F(this,qi,e),F(this,Kh,JSON.stringify(t)),F(this,Fo,null),F(this,ec,null),F(this,Ho,null)}get filter(){return JSON.parse(T(this,Kh))}start(){F(this,Fo,T(this,qi).send("eth_subscribe",this.filter).then(e=>(T(this,qi)._register(e,this),e)))}stop(){T(this,Fo).then(e=>{T(this,qi).destroyed||T(this,qi).send("eth_unsubscribe",[e])}),F(this,Fo,null)}pause(e){pe(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),F(this,ec,!!e)}resume(){F(this,ec,null)}_handleMessage(e){if(T(this,Fo)!=null&&T(this,ec)===null){let t=T(this,Ho);t==null?t=this._emit(T(this,qi),e):t=t.then(async()=>{await this._emit(T(this,qi),e)}),F(this,Ho,t.then(()=>{T(this,Ho)===t&&F(this,Ho,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}qi=new WeakMap,Kh=new WeakMap,Fo=new WeakMap,ec=new WeakMap,Ho=new WeakMap;class Rae extends F_{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class Iae extends F_{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}var jh;class Sae extends F_{constructor(t,n){super(t,["logs",n]);se(this,jh);F(this,jh,JSON.stringify(n))}get logFilter(){return JSON.parse(T(this,jh))}async _emit(t,n){t.emit(this.logFilter,t._wrapLog(n,t._network))}}jh=new WeakMap;var tc,sl,zo;class kae extends d6{constructor(t,n){const i=Object.assign({},n??{});q(i.batchMaxCount==null||i.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",n),i.batchMaxCount=1,i.staticNetwork==null&&(i.staticNetwork=!0);super(t,i);se(this,tc);se(this,sl);se(this,zo);F(this,tc,new Map),F(this,sl,new Map),F(this,zo,new Map)}_getSubscriber(t){switch(t.type){case"close":return new ap("close");case"block":return new Rae(this);case"pending":return new Iae(this);case"event":return new Sae(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new ap("drop-log")}return super._getSubscriber(t)}_register(t,n){T(this,sl).set(t,n);const i=T(this,zo).get(t);if(i){for(const s of i)n._handleMessage(s);T(this,zo).delete(t)}}async _send(t){q(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const n=new Promise((i,s)=>{T(this,tc).set(t.id,{payload:t,resolve:i,reject:s})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await n]}async _processMessage(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&"id"in n){const i=T(this,tc).get(n.id);if(i==null){this.emit("error",Zt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:n}));return}T(this,tc).delete(n.id),i.resolve(n)}else if(n&&n.method==="eth_subscription"){const i=n.params.subscription,s=T(this,sl).get(i);if(s)s._handleMessage(n.params.result);else{let o=T(this,zo).get(i);o==null&&(o=[],T(this,zo).set(i,o)),o.push(n.params.result)}}else{this.emit("error",Zt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:n}));return}}async _write(t){throw new Error("sub-classes must override this")}}tc=new WeakMap,sl=new WeakMap,zo=new WeakMap;var rc,vi;class Tae extends kae{constructor(t,n,i){super(n,i);se(this,rc);se(this,vi);typeof t=="string"?(F(this,rc,()=>new xae(t)),F(this,vi,T(this,rc).call(this))):typeof t=="function"?(F(this,rc,t),F(this,vi,t())):(F(this,rc,null),F(this,vi,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(s){console.log("failed to start WebsocketProvider",s)}},this.websocket.onmessage=s=>{this._processMessage(s.data)}}get websocket(){if(T(this,vi)==null)throw new Error("websocket closed");return T(this,vi)}async _write(t){this.websocket.send(t)}async destroy(){T(this,vi)!=null&&(T(this,vi).close(),F(this,vi,null)),super.destroy()}}rc=new WeakMap,vi=new WeakMap;const Oae="hh-sol-artifact-1",Nae="SwarmEventEmitter",Cae="contracts/SwarmEventEmitter.sol",Bae=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"string",name:"message",type:"string"}],name:"MessageLogged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"RemovedFromWhitelist",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"Whitelisted",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"addToWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"admin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"string",name:"message",type:"string"}],name:"emitMessage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"removeFromWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"whitelisted",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}],Pae="0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a26107b08061013b6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",Mae="0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",Lae={},Uae={},Dae={_format:Oae,contractName:Nae,sourceName:Cae,abi:Bae,bytecode:Pae,deployedBytecode:Mae,linkReferences:Lae,deployedLinkReferences:Uae},$ae="Eai8D93JKad51sYmft1r74fzLkBSwRGPQVAmwZoLoWDf",Fae={name:"swarm_event_emitter",version:"0.1.0",spec:"0.1.0",description:"Created with Anchor"},Hae=[{name:"add_to_whitelist",discriminator:[157,211,52,54,144,81,5,55],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]},{name:"emit_message",discriminator:[118,99,20,87,25,132,207,62],accounts:[{name:"state",writable:!0},{name:"user",signer:!0}],args:[{name:"message",type:"string"}]},{name:"initialize",discriminator:[175,175,109,31,13,152,155,237],accounts:[{name:"state",writable:!0,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"admin",writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"remove_from_whitelist",discriminator:[7,144,216,239,243,236,193,235],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]}],zae=[{name:"State",discriminator:[216,146,107,94,104,75,182,177]}],Gae=[{name:"MessageLogged",discriminator:[24,236,247,207,227,70,101,210]},{name:"RemovedFromWhitelist",discriminator:[107,247,94,185,182,200,82,172]},{name:"Whitelisted",discriminator:[235,202,86,232,226,75,139,182]}],Kae=[{code:6e3,name:"NotAdmin",msg:"Only the admin can perform this action."},{code:6001,name:"NotWhitelisted",msg:"You are not whitelisted."}],jae=[{name:"MessageLogged",type:{kind:"struct",fields:[{name:"sender",type:"pubkey"},{name:"message",type:"string"}]}},{name:"RemovedFromWhitelist",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}},{name:"State",type:{kind:"struct",fields:[{name:"admin",type:"pubkey"},{name:"whitelisted",type:{vec:"pubkey"}}]}},{name:"Whitelisted",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}}],Wae={address:$ae,metadata:Fae,instructions:Hae,accounts:zae,events:Gae,errors:Kae,types:jae};class Vae{constructor(e){this.settings=e,this.evm=null,this.svm=null,this.init()}init(){this.settings.chainType==="EVM"?this.initEvm():this.settings.chainType==="SVM"&&this.initSvm()}initEvm(){const{rpcUrl:e,contractAddress:t}=this.settings;if(!t)throw new Error("Contract address is required for EVM chain type");const n=e.startsWith("ws")?new Tae(e):new Aae(e),i=new bu(t,Dae.abi,n);this.evm={provider:n,contract:i}}initSvm(){const e=new Tk(this.settings.rpcUrl,"confirmed"),t=sc.generate(),n={signTransaction:async o=>o,signAllTransactions:async o=>o,publicKey:t.publicKey},i=new Ah(e,n,{}),s=new bl(Wae,i);this.svm={provider:e,program:s}}async onMessageFrom(e){this.settings.chainType==="EVM"?this.listenToEvm(e):this.settings.chainType==="SVM"&&await this.listenToSvm(e)}listenToEvm(e){var t;(t=this.evm)==null||t.contract.on("MessageLogged",(n,i)=>{n.toLowerCase()===this.settings.swarmEmitterAddress.toLowerCase()&&e(n,i)})}async listenToSvm(e){var n;const t=(n=this.svm)==null?void 0:n.program.addEventListener("messageLogged",i=>{const{sender:s,message:o}=i;s.toBase58()===this.settings.swarmEmitterAddress&&e(s.toBase58(),o)});this.svm&&t!==void 0&&(this.svm.listenerId=t)}async removeAllListeners(){var e,t;this.settings.chainType==="EVM"&&((e=this.evm)==null||e.contract.removeAllListeners("MessageLogged")),this.settings.chainType==="SVM"&&((t=this.svm)==null?void 0:t.listenerId)!==void 0&&(await this.svm.program.removeEventListener(this.svm.listenerId),this.svm.listenerId=void 0)}}const qae=new TextEncoder,OR=1,NR=4096,S1=4096,Zae=32;function Qae(r,e){return e=typeof e=="number"?nt.FeedIndex.fromBigInt(BigInt(e)):e,new nt.Identifier(un.keccak256(un.concatBytes(r.toUint8Array(),e.toUint8Array())))}function Jae(r){const e=r.slice(0,nt.Span.LENGTH),t=r.slice(nt.Span.LENGTH),n=Yae(t),i=un.keccak256(un.concatBytes(e,n));return new nt.Reference(i)}function Yae(r){if(r.length>S1)throw new nt.BeeArgumentError(`payload size ${r.length} exceeds maximum chunk payload size ${S1}`,r);const e=new Uint8Array(S1);return e.set(r),un.log2Reduce(un.partition(e,Zae),(t,n)=>un.keccak256(un.concatBytes(t,n)))}function CR(r){if(r instanceof Uint8Array||(r=qae.encode(r)),r.length<OR||r.length>NR)throw new RangeError(`payload size ${r.length} exceeds limits [${OR}, ${NR}]`);const e=nt.Span.fromBigInt(BigInt(r.length)),t=un.concatBytes(e.toUint8Array(),r);return{data:t,span:e,payload:nt.Bytes.fromSlice(t,nt.Span.LENGTH),address:Jae(t)}}function Xae(r,e){return new nt.Reference(un.keccak256(un.concatBytes(r.toUint8Array(),e.toUint8Array())))}function BR(r,e,t){e=new nt.Identifier(e),t=new nt.PrivateKey(t);const n=Xae(e,t.publicKey().address()),i=t.sign(un.concatBytes(e.toUint8Array(),r.address.toUint8Array())),s=un.concatBytes(e.toUint8Array(),i.toUint8Array(),r.data),o=nt.Span.fromSlice(r.data,0),a=nt.Bytes.fromSlice(r.data,nt.Span.LENGTH);return{data:s,identifier:e,signature:i,span:o,payload:a,address:n,owner:t.publicKey().address()}}class ece{constructor(e,t){this.userDetails=e,this.swarmSettings=t,this.depth=24,this.logger=ns.getInstance(),this.errorHandler=new Sp,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(e,t){const{enveloped:n,stamp:i}=this.swarmSettings;if(!n)await this.writeOwnFeedDataByIndexOwned(e,t);else if(i)await this.writeOwnFeedDataByIndexEnvelope(e,t);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async writeOwnFeedDataByIndexOwned(e,t){const{bee:n,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=this.generateUserOwnedFeedId(s,a),l=nt.Topic.fromString(u);console.log("DEBUG: feedID write",l.toString(),a,e,u),await n.makeFeedWriter(l,new nt.PrivateKey(o)).uploadPayload(i,JSON.stringify(t),{index:e})}async writeOwnFeedDataByIndexEnvelope(e,t){const{bee:n,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=new nt.PrivateKey(o),l=nt.Stamper.fromBlank(o,i,this.depth),h=this.generateUserOwnedFeedId(s,a),g=nt.Topic.fromString(h),b=Qae(g,e),w=CR(t),I=BR(w,b,u),S={hash:()=>I.address.toUint8Array()},x=l.stamp(S),{upload:C}=n.makeSOCWriter(u),H=nt.Bytes.fromUtf8(t);return(await C(x,b,H.toUint8Array())).reference.toHex()}async fetchUserFeedDataByIndex(e,t,n){const{bee:i,chatTopic:s}=this.swarmSettings,o=(n==null?void 0:n.timeout)??1500,a=this.generateUserOwnedFeedId(s,e),u=nt.Topic.fromString(a);console.log("DEBUG: feedID read",u.toString(),e,t,a);const h=await i.makeFeedReader(u,e,{timeout:o}).downloadPayload({index:t});return console.log(h.payload.toHex()),console.log(h.payload.toUtf8()),h.payload.toJSON()}orderMessages(e){return e.sort((t,n)=>t.timestamp-n.timestamp)}async retryAwaitableAsync(e,t=3,n=250){return new Promise((i,s)=>{e().then(i).catch(o=>{t>0?(this.logger.info(`Retrying... Attempts left: ${t}. Error: ${o.message}`),setTimeout(()=>{this.retryAwaitableAsync(e,t-1,n).then(i).catch(s)},n)):(this.errorHandler.handleError(o,"Utils.retryAwaitableAsync"),s(o))})})}async uploadObjectToBee(e){const{enveloped:t,stamp:n}=this.swarmSettings;if(t){if(n)return this.uploadObjectToBeeEnvelope(e);throw new Error("Enveloped mode is enabled, but stamp is not provided")}else return this.uploadObjectToBeeOwn(e)}async uploadObjectToBeeOwn(e){try{const{bee:t,stamp:n}=this.swarmSettings,i=await t.uploadData(n,JSON.stringify(e),{redundancyLevel:4});return console.log("DEBUG: result",i.reference.toString()),i.reference.toString()}catch(t){return this.errorHandler.handleError(t,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeEnvelope(e){try{const{bee:t,stamp:n}=this.swarmSettings,{privateKey:i}=this.userDetails,s=nt.Stamper.fromBlank(i,n,this.depth),o=nt.Bytes.fromUtf8(JSON.stringify(e)),a=new CD(async l=>{await t.uploadChunk(s.stamp(l),l.build())});await a.append(o.toUint8Array());const u=await a.finalize();return un.uint8ArrayToHex(u.hash())}catch(t){return this.errorHandler.handleError(t,"Utils.uploadObjectToBee"),null}}async downloadObjectFromBee(e){try{const{bee:t}=this.swarmSettings;return(await t.downloadData(e)).toJSON()}catch(t){return this.errorHandler.handleError(t,"Utils.beeDownloadObject"),null}}async getOwnLatestFeedIndex(){try{const{bee:e,chatTopic:t}=this.swarmSettings,{ownAddress:n}=this.userDetails,i=this.generateUserOwnedFeedId(t,n),s=nt.Topic.fromString(i),a=await e.makeFeedReader(s,n).downloadPayload(),u=Number(a.feedIndex.toBigInt()),l=u+1;return console.log("DEBUG: getLatestFeedIndex",u,l),{latestIndex:u,nextIndex:l}}catch(e){if(this.isNotFoundError(e))return{latestIndex:-1,nextIndex:0};throw e}}async fetchLatestChatMessage(){const{bee:e,chatTopic:t,chatAddress:n}=this.swarmSettings;return(await e.makeFeedReader(nt.Topic.fromString(t),P1(n)).downloadPayload()).payload.toJSON()}async fetchChatMessage(e){const{bee:t,chatTopic:n,chatAddress:i}=this.swarmSettings;return(await t.makeFeedReader(nt.Topic.fromString(n),P1(i)).downloadPayload({index:nt.FeedIndex.fromBigInt(BigInt(`0x${e}`))})).payload.toJSON()}async sendMessageToGsoc(e){const{enveloped:t,stamp:n}=this.swarmSettings;if(!t)await this.sendMessageToGsocOwn(e);else if(n)await this.sendMessageToGsocEnvelope(e);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async sendMessageToGsocOwn(e){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:t,stamp:n,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,o=new nt.PrivateKey(s),a=nt.Identifier.fromString(i),u=nt.Bytes.fromUtf8(e),{upload:l}=t.makeSOCWriter(o,{timeout:this.UPLOAD_GSOC_TIMEOUT});await l(n,a,u.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}async sendMessageToGsocEnvelope(e){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:t,stamp:n,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,{privateKey:o}=this.userDetails,a=nt.Stamper.fromBlank(o,n,this.depth),u=new nt.PrivateKey(s),l=nt.Identifier.fromString(i),h=nt.Bytes.fromUtf8(e),g=CR(h.toUint8Array()),b=BR(g,l,u),w={hash:()=>b.address.toUint8Array()},I=a.stamp(w),{upload:S}=t.makeSOCWriter(u,{timeout:this.UPLOAD_GSOC_TIMEOUT});await S(I,l,h.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}generateUserOwnedFeedId(e,t){return`${e}_EthercastChat_${t}`}isNotFoundError(e){return e.stack.includes("404")||e.message.includes("Not Found")||e.message.includes("404")}}class tce{constructor(e){var n,i,s;this.logger=ns.getInstance(),this.errorHandler=new Sp,this.messagesQueue=new M1({clearWaitTime:200}),this.gsocListenerQueue=new M1({clearWaitTime:200}),this.activeUsers={},this.latestMessage=null,this.userIndexCache={};const t=new nt.PrivateKey(P1(e.user.privateKey));this.userDetails={privateKey:e.user.privateKey,ownAddress:t.publicKey().address().toString(),nickname:e.user.nickname,ownIndex:-1},this.swarmSettings={bee:new nt.Bee(e.infra.swarm.beeUrl),stamp:e.infra.swarm.stamp||"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",enveloped:e.infra.swarm.enveloped,gsocTopic:e.infra.swarm.gsocTopic,gsocResourceId:e.infra.swarm.gsocResourceId,chatTopic:e.infra.swarm.chatTopic,chatAddress:e.infra.swarm.chatAddress},this.options={fetchMessageTimer:null,idleUserCleanupInterval:null,FETCH_MESSAGE_INTERVAL_TIME:((n=e.options)==null?void 0:n.fetchMessageIntervalTime)||1e3,IDLE_USER_CLEANUP_INTERVAL_TIME:((i=e.options)==null?void 0:i.idleUserCleanupIntervalTime)||5e3,READ_MESSAGE_TIMEOUT:((s=e.options)==null?void 0:s.readMessageTimeout)||1500},this.emitter=new ND,this.utils=new ece(this.userDetails,this.swarmSettings),this.history=new NV(this.userDetails,this.utils,this.emitter),this.swarmEventEmitterReader=new Vae(e.infra.chain)}start(){this.init(),this.subscribeToGSOCEvent(),this.startMessagesFetchProcess(),this.startIdleUserCleanup(),this.history.startHistoryUpdateProcess()}stop(){this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.unsubFromGSOCEvent(),this.history.stopHistoryUpdateProcess(),this.emitter.cleanAll()}getEmitter(){return this.emitter}orderMessages(e){return this.utils.orderMessages(e)}async sendMessage(e,t){const n=this.userDetails.ownIndex===-1?0:this.userDetails.ownIndex+1,i={id:t||OD(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,timestamp:Date.now(),index:n,message:e};try{this.emitter.emit(Yn.MESSAGE_REQUEST_INITIATED,i),await this.utils.writeOwnFeedDataByIndex(n,JSON.stringify(i)),this.userDetails.ownIndex=n,this.emitter.emit(Yn.MESSAGE_REQUEST_UPLOADED,i),await this.waitForMessageBroadcast(n)}catch(s){this.emitter.emit(Yn.MESSAGE_REQUEST_ERROR,i),this.errorHandler.handleError(s,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(Yn.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages({preDownloadHistory:!0})}finally{this.emitter.emit(Yn.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(e){this.sendMessage(e.message,e.id)}async retryBroadcastUserMessage(e){this.waitForMessageBroadcast(e.index)}async init(){try{this.emitter.emit(Yn.LOADING_INIT,!0);const[e,t]=await Promise.allSettled([this.initOwnIndex(),this.history.init()]);if(e.status==="rejected")throw e.reason;t.status==="rejected"&&this.logger.warn(`historyInitResult failed: ${t.reason}`),this.emitter.emit(Yn.LOADING_INIT,!1)}catch(e){this.errorHandler.handleError(e,"Chat.initSelfState"),this.emitter.emit(Yn.CRITICAL_ERROR,e)}}async initOwnIndex(){const{latestIndex:n}=await this.utils.retryAwaitableAsync(()=>this.utils.getOwnLatestFeedIndex(),10,1e3);this.userDetails.ownIndex=n}subscribeToGSOCEvent(){try{this.swarmEventEmitterReader.onMessageFrom((e,t)=>this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(t)))}catch(e){this.errorHandler.handleError(e,"Chat.listenToNewSubscribers"),this.emitter.emit(Yn.CRITICAL_ERROR,e)}}async processGsocEvent(e){try{console.log("processGsocMessage CALLED",e);const[t,n]=e.split("_"),i=await this.utils.fetchChatMessage(n);if(console.log("DEBUG processGsocMessage",i),!uI(i)){this.logger.warn("Invalid GSOC message during processing");return}if(this.logger.debug("New GSOC message:",i),RD(this.latestMessage,i))return;i.messageSender?(this.updateActiveUsers(i.messageSender),this.history.processHistoryUpdaterEntry(this.activeUsers,i.historyEntry)):this.history.setHistoryEntry(i.historyEntry),this.latestMessage=i}catch(t){this.errorHandler.handleError(t,"Chat.processGsocMessage")}}async waitForMessageBroadcast(e){return lI({condition:()=>Object.values(this.activeUsers).some(t=>t.index===e),broadcast:()=>this.broadcastUserMessage()})}async broadcastUserMessage(){try{this.logger.debug("broadcastUserMessage entry CALLED");const e=await this.makeMessageSender();console.log("DEBUG broadcastUserMessage",e),await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({messageSender:e,historyEntry:this.history.getHistoryEntryWithNewUpdater(this.activeUsers)})))}catch(e){this.errorHandler.handleError(e,"Chat.broadcastUserMessage")}}async makeMessageSender(){const{ownAddress:e,privateKey:t,nickname:n}=this.userDetails,i=new nt.EthAddress(e).toString(),s=new nt.PrivateKey(t);if(s.publicKey().address().toString()!==i)throw new Error("The provided address does not match the address derived from the private key");const a=Date.now(),u=s.sign(JSON.stringify({username:n,address:i,timestamp:a}));return{address:i,timestamp:a,signature:u.toHex(),index:this.getOwnIndex(),username:n}}async readAllActiveUserMessage(){if(!await this.messagesQueue.waitForProcessing())for(const t of Object.values(this.activeUsers))this.messagesQueue.enqueue(()=>this.readMessage(t))}async readMessage(e){try{let t;const n=this.isUserIndexRead(e.address,e.index);if(n.isIndexRead)return;t=n.cachedIndex?n.cachedIndex+1:e.index;const i=await this.utils.fetchUserFeedDataByIndex(e.address,t);this.setUserIndexCache(e.address,t),this.emitter.emit(Yn.MESSAGE_RECEIVED,i)}catch(t){this.errorHandler.handleError(t,"readMessage")}}unsubFromGSOCEvent(){this.swarmEventEmitterReader.removeAllListeners()}startMessagesFetchProcess(){const{fetchMessageTimer:e,FETCH_MESSAGE_INTERVAL_TIME:t}=this.options;if(e){this.logger.warn("Messages fetch process is already running.");return}this.options.fetchMessageTimer=setInterval(this.readAllActiveUserMessage.bind(this),t)}stopMessagesFetchProcess(){const{fetchMessageTimer:e}=this.options;e&&(clearInterval(e),this.options.fetchMessageTimer=null)}startIdleUserCleanup(){const{idleUserCleanupInterval:e,IDLE_USER_CLEANUP_INTERVAL_TIME:t}=this.options;if(e){this.logger.warn("Idle user cleanup is already running.");return}this.options.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),t)}stopIdleUserCleanup(){const{idleUserCleanupInterval:e}=this.options;e&&(clearInterval(e),this.options.idleUserCleanupInterval=null)}isUserIndexRead(e,t){const n=this.userIndexCache[e];return{cachedIndex:n,isIndexRead:n===t}}setUserIndexCache(e,t){this.userIndexCache[e]=t}getOwnIndex(){return this.userDetails.ownIndex}removeIdleUsers(){const e=Date.now();for(const t of Object.values(this.activeUsers))e-t.timestamp>300*q$&&delete this.activeUsers[t.address]}updateActiveUsers(e){this.activeUsers[e.address]=e}}exports.EVENTS=Yn;exports.SwarmChat=tce;